Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
ced6c63d
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,发现更多精彩内容 >>
未验证
提交
ced6c63d
编写于
11月 01, 2019
作者:
D
Dan Field
提交者:
GitHub
11月 01, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Request a reattach when creating the text input plugin on Android (#13474)
上级
0a8bd9dd
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
38 addition
and
0 deletion
+38
-0
shell/platform/android/io/flutter/embedding/engine/systemchannels/TextInputChannel.java
...ter/embedding/engine/systemchannels/TextInputChannel.java
+11
-0
shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java
...rm/android/io/flutter/plugin/editing/TextInputPlugin.java
+2
-0
shell/platform/android/test/io/flutter/plugin/editing/TextInputPluginTest.java
...d/test/io/flutter/plugin/editing/TextInputPluginTest.java
+25
-0
未找到文件。
shell/platform/android/io/flutter/embedding/engine/systemchannels/TextInputChannel.java
浏览文件 @
ced6c63d
...
@@ -110,6 +110,17 @@ public class TextInputChannel {
...
@@ -110,6 +110,17 @@ public class TextInputChannel {
channel
.
setMethodCallHandler
(
parsingMethodHandler
);
channel
.
setMethodCallHandler
(
parsingMethodHandler
);
}
}
/**
* Instructs Flutter to reattach the last active text input client, if any.
*
* This is necessary when the view heirarchy has been detached and reattached
* to a {@link FlutterEngine}, as the engine may have kept alive a text
* editing client on the Dart side.
*/
public
void
requestExistingInputState
()
{
channel
.
invokeMethod
(
"TextInputClient.requestExistingInputState"
,
null
);
}
/**
/**
* Instructs Flutter to update its text input editing state to reflect the given configuration.
* Instructs Flutter to update its text input editing state to reflect the given configuration.
*/
*/
...
...
shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java
浏览文件 @
ced6c63d
...
@@ -90,6 +90,8 @@ public class TextInputPlugin {
...
@@ -90,6 +90,8 @@ public class TextInputPlugin {
}
}
});
});
textInputChannel
.
requestExistingInputState
();
this
.
platformViewsController
=
platformViewsController
;
this
.
platformViewsController
=
platformViewsController
;
this
.
platformViewsController
.
attachTextInputPlugin
(
this
);
this
.
platformViewsController
.
attachTextInputPlugin
(
this
);
restartAlwaysRequired
=
isRestartAlwaysRequired
();
restartAlwaysRequired
=
isRestartAlwaysRequired
();
...
...
shell/platform/android/test/io/flutter/plugin/editing/TextInputPluginTest.java
浏览文件 @
ced6c63d
package
io.flutter.plugin.editing
;
package
io.flutter.plugin.editing
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.res.AssetManager
;
import
android.provider.Settings
;
import
android.provider.Settings
;
import
android.util.SparseIntArray
;
import
android.util.SparseIntArray
;
import
android.view.View
;
import
android.view.View
;
import
android.view.inputmethod.InputMethodManager
;
import
android.view.inputmethod.InputMethodManager
;
import
android.view.inputmethod.InputMethodSubtype
;
import
android.view.inputmethod.InputMethodSubtype
;
import
java.nio.ByteBuffer
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
import
org.robolectric.RobolectricTestRunner
;
import
org.robolectric.RobolectricTestRunner
;
...
@@ -18,16 +21,38 @@ import org.robolectric.shadow.api.Shadow;
...
@@ -18,16 +21,38 @@ import org.robolectric.shadow.api.Shadow;
import
org.robolectric.shadows.ShadowBuild
;
import
org.robolectric.shadows.ShadowBuild
;
import
org.robolectric.shadows.ShadowInputMethodManager
;
import
org.robolectric.shadows.ShadowInputMethodManager
;
import
io.flutter.embedding.engine.FlutterJNI
;
import
io.flutter.embedding.engine.dart.DartExecutor
;
import
io.flutter.embedding.engine.dart.DartExecutor
;
import
io.flutter.embedding.engine.systemchannels.TextInputChannel
;
import
io.flutter.embedding.engine.systemchannels.TextInputChannel
;
import
io.flutter.plugin.common.JSONMethodCodec
;
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
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
spy
;
import
static
org
.
mockito
.
Mockito
.
times
;
import
static
org
.
mockito
.
Mockito
.
verify
;
@Config
(
manifest
=
Config
.
NONE
,
shadows
=
TextInputPluginTest
.
TestImm
.
class
,
sdk
=
27
)
@Config
(
manifest
=
Config
.
NONE
,
shadows
=
TextInputPluginTest
.
TestImm
.
class
,
sdk
=
27
)
@RunWith
(
RobolectricTestRunner
.
class
)
@RunWith
(
RobolectricTestRunner
.
class
)
public
class
TextInputPluginTest
{
public
class
TextInputPluginTest
{
@Test
public
void
textInputPlugin_RequestsReattachOnCreation
()
{
// 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
);
FlutterJNI
mockFlutterJni
=
mock
(
FlutterJNI
.
class
);
DartExecutor
dartExecutor
=
spy
(
new
DartExecutor
(
mockFlutterJni
,
mock
(
AssetManager
.
class
)));
TextInputPlugin
textInputPlugin
=
new
TextInputPlugin
(
testView
,
dartExecutor
,
mock
(
PlatformViewsController
.
class
));
ByteBuffer
message
=
JSONMethodCodec
.
INSTANCE
.
encodeMethodCall
(
new
MethodCall
(
"TextInputClient.requestExistingInputState"
,
null
));
verify
(
dartExecutor
,
times
(
1
)).
send
(
"flutter/textinput"
,
message
,
null
);
}
@Test
@Test
public
void
setTextInputEditingState_doesNotRestartWhenTextIsIdentical
()
{
public
void
setTextInputEditingState_doesNotRestartWhenTextIsIdentical
()
{
// Initialize a general TextInputPlugin.
// Initialize a general TextInputPlugin.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录