Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 67d114f

Browse files
Display Features support (Foldable and Cutout) (#24756)
* 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
1 parent 9e1337e commit 67d114f

29 files changed

Lines changed: 896 additions & 93 deletions

DEPS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ deps = {
549549
'packages': [
550550
{
551551
'package': 'flutter/android/embedding_bundle',
552-
'version': 'last_updated:2021-08-10T22:12:57-0700'
552+
'version': 'last_updated:2021-08-26T13:35:58-0700'
553553
}
554554
],
555555
'condition': 'download_android_deps',

ci/licenses_golden/licenses_flutter

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,7 @@ FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/android/Rende
824824
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/android/SplashScreen.java
825825
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/android/SplashScreenProvider.java
826826
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/android/TransparencyMode.java
827+
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/android/WindowInfoRepositoryCallbackAdapterWrapper.java
827828
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/FlutterEngine.java
828829
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/FlutterEngineCache.java
829830
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/FlutterEngineConnectionRegistry.java

lib/ui/fixtures/ui_test.dart

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ void hooksTests() {
339339
window.onMetricsChanged!();
340340
_callHook(
341341
'_updateWindowMetrics',
342-
17,
342+
20,
343343
0, // window Id
344344
0.1234, // device pixel ratio
345345
0.0, // width
@@ -355,8 +355,11 @@ void hooksTests() {
355355
0.0, // system gesture inset top
356356
0.0, // system gesture inset right
357357
0.0, // system gesture inset bottom
358-
0.0, // system gesture inset left,
358+
0.0, // system gesture inset left
359359
22.0, // physicalTouchSlop
360+
<double>[], // display features bounds
361+
<int>[], // display features types
362+
<int>[], // display features states
360363
);
361364

362365
expectIdentical(originalZone, callbackZone);
@@ -403,7 +406,7 @@ void hooksTests() {
403406
test('Window padding/insets/viewPadding/systemGestureInsets', () {
404407
_callHook(
405408
'_updateWindowMetrics',
406-
17,
409+
20,
407410
0, // window Id
408411
1.0, // devicePixelRatio
409412
800.0, // width
@@ -421,6 +424,9 @@ void hooksTests() {
421424
0.0, // systemGestureInsetBottom
422425
0.0, // systemGestureInsetLeft
423426
22.0, // physicalTouchSlop
427+
<double>[], // display features bounds
428+
<int>[], // display features types
429+
<int>[], // display features states
424430
);
425431

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

431437
_callHook(
432438
'_updateWindowMetrics',
433-
17,
439+
20,
434440
0, // window Id
435441
1.0, // devicePixelRatio
436442
800.0, // width
@@ -448,6 +454,9 @@ void hooksTests() {
448454
44.0, // systemGestureInsetBottom
449455
0.0, // systemGestureInsetLeft
450456
22.0, // physicalTouchSlop
457+
<double>[], // display features bounds
458+
<int>[], // display features types
459+
<int>[], // display features states
451460
);
452461

453462
expectEquals(window.viewInsets.bottom, 400.0);
@@ -459,7 +468,7 @@ void hooksTests() {
459468
test('Window physical touch slop', () {
460469
_callHook(
461470
'_updateWindowMetrics',
462-
17,
471+
20,
463472
0, // window Id
464473
1.0, // devicePixelRatio
465474
800.0, // width
@@ -477,14 +486,17 @@ void hooksTests() {
477486
0.0, // systemGestureInsetBottom
478487
0.0, // systemGestureInsetLeft
479488
11.0, // physicalTouchSlop
489+
<double>[], // display features bounds
490+
<int>[], // display features types
491+
<int>[], // display features states
480492
);
481493

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

485497
_callHook(
486498
'_updateWindowMetrics',
487-
17,
499+
20,
488500
0, // window Id
489501
1.0, // devicePixelRatio
490502
800.0, // width
@@ -502,14 +514,17 @@ void hooksTests() {
502514
44.0, // systemGestureInsetBottom
503515
0.0, // systemGestureInsetLeft
504516
-1.0, // physicalTouchSlop
517+
<double>[], // display features bounds
518+
<int>[], // display features types
519+
<int>[], // display features states
505520
);
506521

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

510525
_callHook(
511526
'_updateWindowMetrics',
512-
17,
527+
20,
513528
0, // window Id
514529
1.0, // devicePixelRatio
515530
800.0, // width
@@ -527,6 +542,9 @@ void hooksTests() {
527542
44.0, // systemGestureInsetBottom
528543
0.0, // systemGestureInsetLeft
529544
22.0, // physicalTouchSlop
545+
<double>[], // display features bounds
546+
<int>[], // display features types
547+
<int>[], // display features states
530548
);
531549

532550
expectEquals(window.viewConfiguration.gestureSettings,
@@ -752,4 +770,7 @@ void _callHook(
752770
Object? arg15,
753771
Object? arg16,
754772
Object? arg17,
773+
Object? arg18,
774+
Object? arg19,
775+
Object? arg20,
755776
]) native 'CallHook';

lib/ui/hooks.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ void _updateWindowMetrics(
2828
double systemGestureInsetBottom,
2929
double systemGestureInsetLeft,
3030
double physicalTouchSlop,
31+
List<double> displayFeaturesBounds,
32+
List<int> displayFeaturesType,
33+
List<int> displayFeaturesState,
3134
) {
3235
PlatformDispatcher.instance._updateWindowMetrics(
3336
id,
@@ -47,6 +50,9 @@ void _updateWindowMetrics(
4750
systemGestureInsetBottom,
4851
systemGestureInsetLeft,
4952
physicalTouchSlop,
53+
displayFeaturesBounds,
54+
displayFeaturesType,
55+
displayFeaturesState,
5056
);
5157
}
5258

0 commit comments

Comments
 (0)