Skip to content

Commit

Permalink
Display Features support (Foldable and Cutout) (flutter#24756)
Browse files Browse the repository at this point in the history
* Add DisplayFeatures and DisplayCutout to viewport metrics

* WindowManager alpha03 and better documentation

* Fixed formatting

* Fixed failing tests

* Replaced API version code P with 28

* Unnecessary import

* Fixed display features parameters missing

* Documentation changes

* First paragraph is a sentence

* Update androidx window library to version 1.0.0-alpha05

* Improve documentation, remove deprecated display feature call

* Write tests and improve documentation

* Migrate to Window Manager alpha08

* Update androidx window to beta01

* Remove unused import

* Remove window_hook_integration_test.dart

* Fix tests

* Update android_embedding_dependencies version to include androidx.window

* Add androidx.window to test_runner build

* Add empty display features arrays to fuchsia platform view

* Fix tests using final class mocking

* Add missing license header

* Update licenses_golden
  • Loading branch information
andreidiaconu authored Sep 3, 2021
1 parent 9e1337e commit 67d114f
Show file tree
Hide file tree
Showing 29 changed files with 896 additions and 93 deletions.
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ deps = {
'packages': [
{
'package': 'flutter/android/embedding_bundle',
'version': 'last_updated:2021-08-10T22:12:57-0700'
'version': 'last_updated:2021-08-26T13:35:58-0700'
}
],
'condition': 'download_android_deps',
Expand Down
1 change: 1 addition & 0 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,7 @@ FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/android/Rende
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/android/SplashScreen.java
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/android/SplashScreenProvider.java
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/android/TransparencyMode.java
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/android/WindowInfoRepositoryCallbackAdapterWrapper.java
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/FlutterEngine.java
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/FlutterEngineCache.java
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/FlutterEngineConnectionRegistry.java
Expand Down
35 changes: 28 additions & 7 deletions lib/ui/fixtures/ui_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ void hooksTests() {
window.onMetricsChanged!();
_callHook(
'_updateWindowMetrics',
17,
20,
0, // window Id
0.1234, // device pixel ratio
0.0, // width
Expand All @@ -355,8 +355,11 @@ void hooksTests() {
0.0, // system gesture inset top
0.0, // system gesture inset right
0.0, // system gesture inset bottom
0.0, // system gesture inset left,
0.0, // system gesture inset left
22.0, // physicalTouchSlop
<double>[], // display features bounds
<int>[], // display features types
<int>[], // display features states
);

expectIdentical(originalZone, callbackZone);
Expand Down Expand Up @@ -403,7 +406,7 @@ void hooksTests() {
test('Window padding/insets/viewPadding/systemGestureInsets', () {
_callHook(
'_updateWindowMetrics',
17,
20,
0, // window Id
1.0, // devicePixelRatio
800.0, // width
Expand All @@ -421,6 +424,9 @@ void hooksTests() {
0.0, // systemGestureInsetBottom
0.0, // systemGestureInsetLeft
22.0, // physicalTouchSlop
<double>[], // display features bounds
<int>[], // display features types
<int>[], // display features states
);

expectEquals(window.viewInsets.bottom, 0.0);
Expand All @@ -430,7 +436,7 @@ void hooksTests() {

_callHook(
'_updateWindowMetrics',
17,
20,
0, // window Id
1.0, // devicePixelRatio
800.0, // width
Expand All @@ -448,6 +454,9 @@ void hooksTests() {
44.0, // systemGestureInsetBottom
0.0, // systemGestureInsetLeft
22.0, // physicalTouchSlop
<double>[], // display features bounds
<int>[], // display features types
<int>[], // display features states
);

expectEquals(window.viewInsets.bottom, 400.0);
Expand All @@ -459,7 +468,7 @@ void hooksTests() {
test('Window physical touch slop', () {
_callHook(
'_updateWindowMetrics',
17,
20,
0, // window Id
1.0, // devicePixelRatio
800.0, // width
Expand All @@ -477,14 +486,17 @@ void hooksTests() {
0.0, // systemGestureInsetBottom
0.0, // systemGestureInsetLeft
11.0, // physicalTouchSlop
<double>[], // display features bounds
<int>[], // display features types
<int>[], // display features states
);

expectEquals(window.viewConfiguration.gestureSettings,
GestureSettings(physicalTouchSlop: 11.0));

_callHook(
'_updateWindowMetrics',
17,
20,
0, // window Id
1.0, // devicePixelRatio
800.0, // width
Expand All @@ -502,14 +514,17 @@ void hooksTests() {
44.0, // systemGestureInsetBottom
0.0, // systemGestureInsetLeft
-1.0, // physicalTouchSlop
<double>[], // display features bounds
<int>[], // display features types
<int>[], // display features states
);

expectEquals(window.viewConfiguration.gestureSettings,
GestureSettings(physicalTouchSlop: null));

_callHook(
'_updateWindowMetrics',
17,
20,
0, // window Id
1.0, // devicePixelRatio
800.0, // width
Expand All @@ -527,6 +542,9 @@ void hooksTests() {
44.0, // systemGestureInsetBottom
0.0, // systemGestureInsetLeft
22.0, // physicalTouchSlop
<double>[], // display features bounds
<int>[], // display features types
<int>[], // display features states
);

expectEquals(window.viewConfiguration.gestureSettings,
Expand Down Expand Up @@ -752,4 +770,7 @@ void _callHook(
Object? arg15,
Object? arg16,
Object? arg17,
Object? arg18,
Object? arg19,
Object? arg20,
]) native 'CallHook';
6 changes: 6 additions & 0 deletions lib/ui/hooks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ void _updateWindowMetrics(
double systemGestureInsetBottom,
double systemGestureInsetLeft,
double physicalTouchSlop,
List<double> displayFeaturesBounds,
List<int> displayFeaturesType,
List<int> displayFeaturesState,
) {
PlatformDispatcher.instance._updateWindowMetrics(
id,
Expand All @@ -47,6 +50,9 @@ void _updateWindowMetrics(
systemGestureInsetBottom,
systemGestureInsetLeft,
physicalTouchSlop,
displayFeaturesBounds,
displayFeaturesType,
displayFeaturesState,
);
}

Expand Down
Loading

0 comments on commit 67d114f

Please sign in to comment.