Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
2c0eee43
E
engine
项目概览
sxychenjing
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
2c0eee43
编写于
11月 27, 2019
作者:
G
Gary Qian
提交者:
GitHub
11月 27, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Always set mEditable values when different in TextPlugin (#13951)
上级
c139def5
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
36 addition
and
4 deletion
+36
-4
shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java
...rm/android/io/flutter/plugin/editing/TextInputPlugin.java
+14
-4
shell/platform/android/test/io/flutter/plugin/editing/TextInputPluginTest.java
...d/test/io/flutter/plugin/editing/TextInputPluginTest.java
+22
-0
未找到文件。
shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java
浏览文件 @
2c0eee43
...
@@ -102,6 +102,10 @@ public class TextInputPlugin {
...
@@ -102,6 +102,10 @@ public class TextInputPlugin {
return
mImm
;
return
mImm
;
}
}
@VisibleForTesting
Editable
getEditable
()
{
return
mEditable
;
}
/***
/***
* Use the current platform view input connection until unlockPlatformViewInputConnection is called.
* Use the current platform view input connection until unlockPlatformViewInputConnection is called.
*
*
...
@@ -306,15 +310,21 @@ public class TextInputPlugin {
...
@@ -306,15 +310,21 @@ public class TextInputPlugin {
}
}
@VisibleForTesting
void
setTextInputEditingState
(
View
view
,
TextInputChannel
.
TextEditState
state
)
{
@VisibleForTesting
void
setTextInputEditingState
(
View
view
,
TextInputChannel
.
TextEditState
state
)
{
if
(!
restartAlwaysRequired
&&
!
mRestartInputPending
&&
state
.
text
.
equals
(
mEditable
.
toString
()))
{
// Always replace the contents of mEditable if the text differs
applyStateToSelection
(
state
);
if
(!
state
.
text
.
equals
(
mEditable
.
toString
()))
{
mEditable
.
replace
(
0
,
mEditable
.
length
(),
state
.
text
);
}
// Always apply state to selection which handles updating the selection if needed.
applyStateToSelection
(
state
);
// Use updateSelection to update imm on selection if it is not neccessary to restart.
if
(!
restartAlwaysRequired
&&
!
mRestartInputPending
)
{
mImm
.
updateSelection
(
mView
,
Math
.
max
(
Selection
.
getSelectionStart
(
mEditable
),
0
),
mImm
.
updateSelection
(
mView
,
Math
.
max
(
Selection
.
getSelectionStart
(
mEditable
),
0
),
Math
.
max
(
Selection
.
getSelectionEnd
(
mEditable
),
0
),
Math
.
max
(
Selection
.
getSelectionEnd
(
mEditable
),
0
),
BaseInputConnection
.
getComposingSpanStart
(
mEditable
),
BaseInputConnection
.
getComposingSpanStart
(
mEditable
),
BaseInputConnection
.
getComposingSpanEnd
(
mEditable
));
BaseInputConnection
.
getComposingSpanEnd
(
mEditable
));
// Restart if there is a pending restart or the device requires a force restart
// (see isRestartAlwaysRequired). Restarting will also update the selection.
}
else
{
}
else
{
mEditable
.
replace
(
0
,
mEditable
.
length
(),
state
.
text
);
applyStateToSelection
(
state
);
mImm
.
restartInput
(
view
);
mImm
.
restartInput
(
view
);
mRestartInputPending
=
false
;
mRestartInputPending
=
false
;
}
}
...
...
shell/platform/android/test/io/flutter/plugin/editing/TextInputPluginTest.java
浏览文件 @
2c0eee43
...
@@ -29,6 +29,7 @@ import io.flutter.plugin.common.MethodCall;
...
@@ -29,6 +29,7 @@ import io.flutter.plugin.common.MethodCall;
import
io.flutter.plugin.platform.PlatformViewsController
;
import
io.flutter.plugin.platform.PlatformViewsController
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
spy
;
import
static
org
.
mockito
.
Mockito
.
spy
;
import
static
org
.
mockito
.
Mockito
.
times
;
import
static
org
.
mockito
.
Mockito
.
times
;
...
@@ -73,6 +74,27 @@ public class TextInputPluginTest {
...
@@ -73,6 +74,27 @@ public class TextInputPluginTest {
assertEquals
(
1
,
testImm
.
getRestartCount
(
testView
));
assertEquals
(
1
,
testImm
.
getRestartCount
(
testView
));
}
}
@Test
public
void
setTextInputEditingState_alwaysSetEditableWhenDifferent
()
{
// Initialize a general TextInputPlugin.
InputMethodSubtype
inputMethodSubtype
=
mock
(
InputMethodSubtype
.
class
);
TestImm
testImm
=
Shadow
.
extract
(
RuntimeEnvironment
.
application
.
getSystemService
(
Context
.
INPUT_METHOD_SERVICE
));
testImm
.
setCurrentInputMethodSubtype
(
inputMethodSubtype
);
View
testView
=
new
View
(
RuntimeEnvironment
.
application
);
TextInputPlugin
textInputPlugin
=
new
TextInputPlugin
(
testView
,
mock
(
DartExecutor
.
class
),
mock
(
PlatformViewsController
.
class
));
textInputPlugin
.
setTextInputClient
(
0
,
new
TextInputChannel
.
Configuration
(
false
,
false
,
true
,
TextInputChannel
.
TextCapitalization
.
NONE
,
null
,
null
,
null
));
// There's a pending restart since we initialized the text input client. Flush that now. With changed text, we should
// always set the Editable contents.
textInputPlugin
.
setTextInputEditingState
(
testView
,
new
TextInputChannel
.
TextEditState
(
"hello"
,
0
,
0
));
assertEquals
(
1
,
testImm
.
getRestartCount
(
testView
));
assertTrue
(
textInputPlugin
.
getEditable
().
toString
().
equals
(
"hello"
));
// No pending restart, set Editable contents anyways.
textInputPlugin
.
setTextInputEditingState
(
testView
,
new
TextInputChannel
.
TextEditState
(
"Shibuyawoo"
,
0
,
0
));
assertEquals
(
1
,
testImm
.
getRestartCount
(
testView
));
assertTrue
(
textInputPlugin
.
getEditable
().
toString
().
equals
(
"Shibuyawoo"
));
}
// See https://github.com/flutter/flutter/issues/29341 and https://github.com/flutter/flutter/issues/31512
// See https://github.com/flutter/flutter/issues/29341 and https://github.com/flutter/flutter/issues/31512
// All modern Samsung keybords are affected including non-korean languages and thus
// All modern Samsung keybords are affected including non-korean languages and thus
// need the restart.
// need the restart.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录