Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_43355755
engine
提交
7d6180c3
E
engine
项目概览
weixin_43355755
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
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,发现更多精彩内容 >>
未验证
提交
7d6180c3
编写于
10月 30, 2020
作者:
L
Lazy Llama
提交者:
GitHub
10月 29, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix viewInset.bottom and viewPadding.bottom… (#21730)
上级
baba31e8
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
107 addition
and
18 deletion
+107
-18
shell/platform/android/io/flutter/embedding/android/FlutterView.java
...orm/android/io/flutter/embedding/android/FlutterView.java
+7
-7
shell/platform/android/io/flutter/view/FlutterView.java
shell/platform/android/io/flutter/view/FlutterView.java
+7
-7
shell/platform/android/test/io/flutter/embedding/android/FlutterViewTest.java
...id/test/io/flutter/embedding/android/FlutterViewTest.java
+93
-4
未找到文件。
shell/platform/android/io/flutter/embedding/android/FlutterView.java
浏览文件 @
7d6180c3
...
...
@@ -580,14 +580,17 @@ public class FlutterView extends FrameLayout implements MouseCursorPlugin.MouseC
zeroSides
=
calculateShouldZeroSides
();
}
// Status bar (top)
and left/right system insets should partially obscure the content
// (padding).
// Status bar (top)
, navigation bar (bottom) and left/right system insets should
//
partially obscure the content
(padding).
viewportMetrics
.
paddingTop
=
statusBarVisible
?
insets
.
getSystemWindowInsetTop
()
:
0
;
viewportMetrics
.
paddingRight
=
zeroSides
==
ZeroSides
.
RIGHT
||
zeroSides
==
ZeroSides
.
BOTH
?
0
:
insets
.
getSystemWindowInsetRight
();
viewportMetrics
.
paddingBottom
=
0
;
viewportMetrics
.
paddingBottom
=
navigationBarVisible
&&
guessBottomKeyboardInset
(
insets
)
==
0
?
insets
.
getSystemWindowInsetBottom
()
:
0
;
viewportMetrics
.
paddingLeft
=
zeroSides
==
ZeroSides
.
LEFT
||
zeroSides
==
ZeroSides
.
BOTH
?
0
...
...
@@ -596,10 +599,7 @@ public class FlutterView extends FrameLayout implements MouseCursorPlugin.MouseC
// Bottom system inset (keyboard) should adjust scrollable bottom edge (inset).
viewportMetrics
.
viewInsetTop
=
0
;
viewportMetrics
.
viewInsetRight
=
0
;
viewportMetrics
.
viewInsetBottom
=
navigationBarVisible
?
insets
.
getSystemWindowInsetBottom
()
:
guessBottomKeyboardInset
(
insets
);
viewportMetrics
.
viewInsetBottom
=
guessBottomKeyboardInset
(
insets
);
viewportMetrics
.
viewInsetLeft
=
0
;
}
...
...
shell/platform/android/io/flutter/view/FlutterView.java
浏览文件 @
7d6180c3
...
...
@@ -662,14 +662,17 @@ public class FlutterView extends SurfaceView
zeroSides
=
calculateShouldZeroSides
();
}
// Status bar (top)
and left/right system insets should partially obscure the content
// (padding).
// Status bar (top)
, navigation bar (bottom) and left/right system insets should
//
partially obscure the content
(padding).
mMetrics
.
physicalPaddingTop
=
statusBarVisible
?
insets
.
getSystemWindowInsetTop
()
:
0
;
mMetrics
.
physicalPaddingRight
=
zeroSides
==
ZeroSides
.
RIGHT
||
zeroSides
==
ZeroSides
.
BOTH
?
0
:
insets
.
getSystemWindowInsetRight
();
mMetrics
.
physicalPaddingBottom
=
0
;
mMetrics
.
physicalPaddingBottom
=
navigationBarVisible
&&
guessBottomKeyboardInset
(
insets
)
==
0
?
insets
.
getSystemWindowInsetBottom
()
:
0
;
mMetrics
.
physicalPaddingLeft
=
zeroSides
==
ZeroSides
.
LEFT
||
zeroSides
==
ZeroSides
.
BOTH
?
0
...
...
@@ -678,10 +681,7 @@ public class FlutterView extends SurfaceView
// Bottom system inset (keyboard) should adjust scrollable bottom edge (inset).
mMetrics
.
physicalViewInsetTop
=
0
;
mMetrics
.
physicalViewInsetRight
=
0
;
mMetrics
.
physicalViewInsetBottom
=
navigationBarVisible
?
insets
.
getSystemWindowInsetBottom
()
:
guessBottomKeyboardInset
(
insets
);
mMetrics
.
physicalViewInsetBottom
=
guessBottomKeyboardInset
(
insets
);
mMetrics
.
physicalViewInsetLeft
=
0
;
}
...
...
shell/platform/android/test/io/flutter/embedding/android/FlutterViewTest.java
浏览文件 @
7d6180c3
...
...
@@ -210,8 +210,12 @@ public class FlutterViewTest {
assertEquals
(
SettingsChannel
.
PlatformBrightness
.
dark
,
reportedBrightness
.
get
());
}
// This test uses the API 30+ Algorithm for window insets. The legacy algorithm is
// set to -1 values, so it is clear if the wrong algorithm is used.
@Test
@TargetApi
(
30
)
@Config
(
sdk
=
30
,
shadows
=
{
FlutterViewTest
.
ShadowFullscreenView
.
class
,
FlutterViewTest
.
ShadowFullscreenViewGroup
.
class
...
...
@@ -249,7 +253,52 @@ public class FlutterViewTest {
assertEquals
(
100
,
viewportMetricsCaptor
.
getValue
().
paddingRight
);
}
// This test uses the pre-API 30 Algorithm for window insets.
@Test
@TargetApi
(
29
)
@Config
(
sdk
=
29
,
shadows
=
{
FlutterViewTest
.
ShadowFullscreenView
.
class
,
FlutterViewTest
.
ShadowFullscreenViewGroup
.
class
})
public
void
setPaddingTopToZeroForFullscreenModeLegacy
()
{
FlutterView
flutterView
=
new
FlutterView
(
RuntimeEnvironment
.
application
);
FlutterEngine
flutterEngine
=
spy
(
new
FlutterEngine
(
RuntimeEnvironment
.
application
,
mockFlutterLoader
,
mockFlutterJni
));
FlutterRenderer
flutterRenderer
=
spy
(
new
FlutterRenderer
(
mockFlutterJni
));
when
(
flutterEngine
.
getRenderer
()).
thenReturn
(
flutterRenderer
);
// When we attach a new FlutterView to the engine without any system insets, the viewport
// metrics
// default to 0.
flutterView
.
attachToFlutterEngine
(
flutterEngine
);
ArgumentCaptor
<
FlutterRenderer
.
ViewportMetrics
>
viewportMetricsCaptor
=
ArgumentCaptor
.
forClass
(
FlutterRenderer
.
ViewportMetrics
.
class
);
verify
(
flutterRenderer
).
setViewportMetrics
(
viewportMetricsCaptor
.
capture
());
assertEquals
(
0
,
viewportMetricsCaptor
.
getValue
().
paddingTop
);
// Then we simulate the system applying a window inset.
WindowInsets
windowInsets
=
mock
(
WindowInsets
.
class
);
when
(
windowInsets
.
getSystemWindowInsetTop
()).
thenReturn
(
100
);
when
(
windowInsets
.
getSystemWindowInsetBottom
()).
thenReturn
(
100
);
when
(
windowInsets
.
getSystemWindowInsetLeft
()).
thenReturn
(
100
);
when
(
windowInsets
.
getSystemWindowInsetRight
()).
thenReturn
(
100
);
flutterView
.
onApplyWindowInsets
(
windowInsets
);
// Verify.
verify
(
flutterRenderer
,
times
(
2
)).
setViewportMetrics
(
viewportMetricsCaptor
.
capture
());
assertEquals
(
0
,
viewportMetricsCaptor
.
getValue
().
paddingTop
);
assertEquals
(
100
,
viewportMetricsCaptor
.
getValue
().
paddingBottom
);
assertEquals
(
100
,
viewportMetricsCaptor
.
getValue
().
paddingLeft
);
assertEquals
(
100
,
viewportMetricsCaptor
.
getValue
().
paddingRight
);
}
// This test uses the API 30+ Algorithm for window insets. The legacy algorithm is
// set to -1 values, so it is clear if the wrong algorithm is used.
@Test
@TargetApi
(
30
)
@Config
(
sdk
=
30
)
public
void
reportSystemInsetWhenNotFullscreen
()
{
// Without custom shadows, the default system ui visibility flags is 0.
FlutterView
flutterView
=
new
FlutterView
(
RuntimeEnvironment
.
application
);
...
...
@@ -287,6 +336,46 @@ public class FlutterViewTest {
assertEquals
(
100
,
viewportMetricsCaptor
.
getValue
().
paddingRight
);
}
// This test uses the pre-API 30 Algorithm for window insets.
@Test
@TargetApi
(
29
)
@Config
(
sdk
=
29
)
public
void
reportSystemInsetWhenNotFullscreenLegacy
()
{
// Without custom shadows, the default system ui visibility flags is 0.
FlutterView
flutterView
=
new
FlutterView
(
RuntimeEnvironment
.
application
);
assertEquals
(
0
,
flutterView
.
getSystemUiVisibility
());
FlutterEngine
flutterEngine
=
spy
(
new
FlutterEngine
(
RuntimeEnvironment
.
application
,
mockFlutterLoader
,
mockFlutterJni
));
FlutterRenderer
flutterRenderer
=
spy
(
new
FlutterRenderer
(
mockFlutterJni
));
when
(
flutterEngine
.
getRenderer
()).
thenReturn
(
flutterRenderer
);
// When we attach a new FlutterView to the engine without any system insets, the viewport
// metrics
// default to 0.
flutterView
.
attachToFlutterEngine
(
flutterEngine
);
ArgumentCaptor
<
FlutterRenderer
.
ViewportMetrics
>
viewportMetricsCaptor
=
ArgumentCaptor
.
forClass
(
FlutterRenderer
.
ViewportMetrics
.
class
);
verify
(
flutterRenderer
).
setViewportMetrics
(
viewportMetricsCaptor
.
capture
());
assertEquals
(
0
,
viewportMetricsCaptor
.
getValue
().
paddingTop
);
// Then we simulate the system applying a window inset.
WindowInsets
windowInsets
=
mock
(
WindowInsets
.
class
);
when
(
windowInsets
.
getSystemWindowInsetTop
()).
thenReturn
(
100
);
when
(
windowInsets
.
getSystemWindowInsetBottom
()).
thenReturn
(
100
);
when
(
windowInsets
.
getSystemWindowInsetLeft
()).
thenReturn
(
100
);
when
(
windowInsets
.
getSystemWindowInsetRight
()).
thenReturn
(
100
);
flutterView
.
onApplyWindowInsets
(
windowInsets
);
// Verify.
verify
(
flutterRenderer
,
times
(
2
)).
setViewportMetrics
(
viewportMetricsCaptor
.
capture
());
// Top padding is reported as-is.
assertEquals
(
100
,
viewportMetricsCaptor
.
getValue
().
paddingTop
);
assertEquals
(
0
,
viewportMetricsCaptor
.
getValue
().
paddingBottom
);
assertEquals
(
100
,
viewportMetricsCaptor
.
getValue
().
paddingLeft
);
assertEquals
(
100
,
viewportMetricsCaptor
.
getValue
().
paddingRight
);
}
@Test
public
void
systemInsetHandlesFullscreenNavbarRight
()
{
RuntimeEnvironment
.
setQualifiers
(
"+land"
);
...
...
@@ -327,10 +416,10 @@ public class FlutterViewTest {
verify
(
flutterRenderer
,
times
(
2
)).
setViewportMetrics
(
viewportMetricsCaptor
.
capture
());
// Top padding is removed due to full screen.
assertEquals
(
0
,
viewportMetricsCaptor
.
getValue
().
paddingTop
);
//
Padding bottom is always 0
.
//
Bottom padding is removed due to hide navigation
.
assertEquals
(
0
,
viewportMetricsCaptor
.
getValue
().
paddingBottom
);
assertEquals
(
100
,
viewportMetricsCaptor
.
getValue
().
paddingLeft
);
// Right padding is zero because the rotation is
27
0deg
// Right padding is zero because the rotation is
9
0deg
assertEquals
(
0
,
viewportMetricsCaptor
.
getValue
().
paddingRight
);
}
...
...
@@ -374,7 +463,7 @@ public class FlutterViewTest {
verify
(
flutterRenderer
,
times
(
2
)).
setViewportMetrics
(
viewportMetricsCaptor
.
capture
());
// Top padding is removed due to full screen.
assertEquals
(
0
,
viewportMetricsCaptor
.
getValue
().
paddingTop
);
//
Padding bottom is always 0
.
//
Bottom padding is removed due to hide navigation
.
assertEquals
(
0
,
viewportMetricsCaptor
.
getValue
().
paddingBottom
);
// Left padding is zero because the rotation is 270deg
assertEquals
(
0
,
viewportMetricsCaptor
.
getValue
().
paddingLeft
);
...
...
@@ -477,7 +566,7 @@ public class FlutterViewTest {
verify
(
flutterRenderer
,
times
(
2
)).
setViewportMetrics
(
viewportMetricsCaptor
.
capture
());
// Top padding is removed due to full screen.
assertEquals
(
0
,
viewportMetricsCaptor
.
getValue
().
paddingTop
);
//
Padding bottom is always 0
.
//
Bottom padding is removed due to hide navigation
.
assertEquals
(
0
,
viewportMetricsCaptor
.
getValue
().
paddingBottom
);
// Left padding is zero because the rotation is 270deg
assertEquals
(
0
,
viewportMetricsCaptor
.
getValue
().
paddingLeft
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录