Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
933f811d
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,发现更多精彩内容 >>
未验证
提交
933f811d
编写于
9月 16, 2020
作者:
G
Gary Qian
提交者:
GitHub
9月 16, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove extraneous window inset call on IME animation (#21213)
上级
6a66d63f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
35 addition
and
13 deletion
+35
-13
shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java
...rm/android/io/flutter/plugin/editing/TextInputPlugin.java
+26
-12
shell/platform/android/test/io/flutter/plugin/editing/TextInputPluginTest.java
...d/test/io/flutter/plugin/editing/TextInputPluginTest.java
+9
-1
未找到文件。
shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java
浏览文件 @
933f811d
...
...
@@ -199,7 +199,17 @@ public class TextInputPlugin {
private
View
view
;
private
WindowInsets
lastWindowInsets
;
private
boolean
started
=
false
;
// True when an animation that matches deferredInsetTypes is active.
//
// While this is active, this class will capture the initial window inset
// sent into lastWindowInsets by flagging needsSave to true, and will hold
// onto the intitial inset until the animation is completed, when it will
// re-dispatch the inset change.
private
boolean
animating
=
false
;
// When an animation begins, android sends a WindowInset with the final
// state of the animation. When needsSave is true, we know to capture this
// initial WindowInset.
private
boolean
needsSave
=
false
;
ImeSyncDeferringInsetsCallback
(
@NonNull
View
view
,
int
overlayInsetTypes
,
int
deferredInsetTypes
)
{
...
...
@@ -212,34 +222,38 @@ public class TextInputPlugin {
@Override
public
WindowInsets
onApplyWindowInsets
(
View
view
,
WindowInsets
windowInsets
)
{
this
.
view
=
view
;
if
(
started
)
{
if
(
needsSave
)
{
// Store the view and insets for us in onEnd() below. This captured inset
// is not part of the animation and instead, represents the final state
// of the inset after the animation is completed. Thus, we defer the processing
// of this WindowInset until the animation completes.
lastWindowInsets
=
windowInsets
;
needsSave
=
false
;
}
if
(
animating
)
{
// While animation is running, we consume the insets to prevent disrupting
// the animation, which skips this implementation and calls the view's
// onApplyWindowInsets directly to avoid being consumed here.
return
WindowInsets
.
CONSUMED
;
}
// Store the view and insets for us in onEnd() below
lastWindowInsets
=
windowInsets
;
// If no animation is happening, pass the insets on to the view's own
// inset handling.
return
view
.
onApplyWindowInsets
(
windowInsets
);
}
@Override
public
WindowInsetsAnimation
.
Bounds
onStart
(
WindowInsetsAnimation
animation
,
WindowInsetsAnimation
.
Bounds
bounds
)
{
public
void
onPrepare
(
WindowInsetsAnimation
animation
)
{
if
((
animation
.
getTypeMask
()
&
deferredInsetTypes
)
!=
0
)
{
started
=
true
;
animating
=
true
;
needsSave
=
true
;
}
return
bounds
;
}
@Override
public
WindowInsets
onProgress
(
WindowInsets
insets
,
List
<
WindowInsetsAnimation
>
runningAnimations
)
{
if
(!
started
)
{
if
(!
animating
||
needsSave
)
{
return
insets
;
}
boolean
matching
=
false
;
...
...
@@ -280,10 +294,10 @@ public class TextInputPlugin {
@Override
public
void
onEnd
(
WindowInsetsAnimation
animation
)
{
if
(
started
&&
(
animation
.
getTypeMask
()
&
deferredInsetTypes
)
!=
0
)
{
if
(
animating
&&
(
animation
.
getTypeMask
()
&
deferredInsetTypes
)
!=
0
)
{
// If we deferred the IME insets and an IME animation has finished, we need to reset
// the flags
started
=
false
;
animating
=
false
;
// And finally dispatch the deferred insets to the view now.
// Ideally we would just call view.requestApplyInsets() and let the normal dispatch
...
...
shell/platform/android/test/io/flutter/plugin/editing/TextInputPluginTest.java
浏览文件 @
933f811d
...
...
@@ -669,6 +669,8 @@ public class TextInputPluginTest {
WindowInsets
.
Builder
builder
=
new
WindowInsets
.
Builder
();
WindowInsets
noneInsets
=
builder
.
build
();
// imeInsets0, 1, and 2 contain unique IME bottom insets, and are used
// to distinguish which insets were sent at each stage.
builder
.
setInsets
(
WindowInsets
.
Type
.
ime
(),
Insets
.
of
(
0
,
0
,
0
,
100
));
builder
.
setInsets
(
WindowInsets
.
Type
.
navigationBars
(),
Insets
.
of
(
10
,
10
,
10
,
40
));
WindowInsets
imeInsets0
=
builder
.
build
();
...
...
@@ -677,6 +679,10 @@ public class TextInputPluginTest {
builder
.
setInsets
(
WindowInsets
.
Type
.
navigationBars
(),
Insets
.
of
(
10
,
10
,
10
,
40
));
WindowInsets
imeInsets1
=
builder
.
build
();
builder
.
setInsets
(
WindowInsets
.
Type
.
ime
(),
Insets
.
of
(
0
,
0
,
0
,
50
));
builder
.
setInsets
(
WindowInsets
.
Type
.
navigationBars
(),
Insets
.
of
(
10
,
10
,
10
,
40
));
WindowInsets
imeInsets2
=
builder
.
build
();
builder
.
setInsets
(
WindowInsets
.
Type
.
ime
(),
Insets
.
of
(
0
,
0
,
0
,
200
));
builder
.
setInsets
(
WindowInsets
.
Type
.
navigationBars
(),
Insets
.
of
(
10
,
10
,
10
,
0
));
WindowInsets
deferredInsets
=
builder
.
build
();
...
...
@@ -696,6 +702,8 @@ public class TextInputPluginTest {
imeSyncCallback
.
onPrepare
(
animation
);
imeSyncCallback
.
onApplyWindowInsets
(
testView
,
deferredInsets
);
imeSyncCallback
.
onStart
(
animation
,
null
);
// Only the final state call is saved, extra calls are passed on.
imeSyncCallback
.
onApplyWindowInsets
(
testView
,
imeInsets2
);
verify
(
flutterRenderer
).
setViewportMetrics
(
viewportMetricsCaptor
.
capture
());
// No change, as deferredInset is stored to be passed in onEnd()
...
...
@@ -723,7 +731,7 @@ public class TextInputPluginTest {
imeSyncCallback
.
onEnd
(
animation
);
verify
(
flutterRenderer
).
setViewportMetrics
(
viewportMetricsCaptor
.
capture
());
// Values should be of deferredInsets
// Values should be of deferredInsets
, not imeInsets2
assertEquals
(
0
,
viewportMetricsCaptor
.
getValue
().
paddingBottom
);
assertEquals
(
10
,
viewportMetricsCaptor
.
getValue
().
paddingTop
);
assertEquals
(
200
,
viewportMetricsCaptor
.
getValue
().
viewInsetBottom
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录