-
Notifications
You must be signed in to change notification settings - Fork 6k
Remove usages of deprecated setSystemUiVisibility() #29493
Conversation
shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java
Outdated
Show resolved
Hide resolved
| window.setStatusBarColor(0x40000000); | ||
| window.getDecorView().setSystemUiVisibility(PlatformPlugin.DEFAULT_SYSTEM_UI); | ||
| if (Build.VERSION.SDK_INT >= 30) { | ||
| window.setDecorFitsSystemWindows(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use https://developer.android.com/reference/androidx/core/view/WindowCompat instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there an advantage of using this? The window.setDecorFitsSystemWindows(boolean) behavior seems to mirror that of the windowCompat.setDecorFitsSystemWindows(window, boolean) behavior.
Edit: I do see that the windowCompat version is not compatible with the deprecated flags so I will try to use that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ClassName}Compat is part of the AndroidX library. It provides a compatibility layer that handles all the inconsistencies between each version behind-the-scene.
Since the implementation details are abstracted from us, we can worry less about adding if statements for specific versions on our side and focus more on the feature work. In this case, we should try to migrate the deprecated code to use WindowCompat and WindowInsetsControllerCompat instead.
b1a8771 to
2962099
Compare
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE | ||
| | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | ||
| | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | ||
| | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | ||
| | View.SYSTEM_UI_FLAG_FULLSCREEN; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These flags are also deprecated aren't they? Or are these going to be migrated in a separate change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new API is backwards compatible, so I will take care of these in this PR as well!
| setSystemChromeEnabledSystemUIMode(currentSystemUiMode); | ||
|
|
||
| if (currentOverlays != null) { | ||
| setSystemChromeEnabledSystemUIOverlays(currentOverlays); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setSystemChromeEnabledSystemUIOverlays sets currentOverlays.
Is what situation updateSystemUiOverlays needs to call setSystemChromeEnabledSystemUIOverlays again with the same value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If someone decides to make a call to setSystemChromeEnabledSystemUIMode after updateSystemUiOverlays is called to change the systemUiMode, this could possibly hide some of the system bars, so then calling updateSystemUiOverlays would show those system bars again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, but wouldn't an external call to setSystemChromeEnabledSystemUIMode set a new currentSystemUiMode , thus making updateSystemUiOverlays() call setSystemChromeEnabledSystemUIMode(currentSystemUiMode) with the same value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see what you mean. In that case, if currentOverlays isn't null, then there's no need to make the call to setSystemChromeEnabledSystemUIMode.
blasten
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! - I will defer to @Piinks for final review :)
Piinks
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| } else { | ||
| if (currentTheme != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit else/if -> else if (currentTheme != null)) {
| window.addFlags(LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); | ||
| window.setStatusBarColor(0x40000000); | ||
| window.getDecorView().setSystemUiVisibility(PlatformPlugin.DEFAULT_SYSTEM_UI); | ||
| WindowCompat.setDecorFitsSystemWindows(window, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line means edge-to-edge mode will become the default mode (related to flutter/flutter#86248 ?). It would be great if we can eventually land this, but do note that it will be a breaking change for apps that don't handle paddings/safe area properly. My team had to manually apply non-trivial fixes (e.g. cl/397106186 and cl/397283284) before enabling this.
| if (systemUiMode == PlatformChannel.SystemUiMode.LEAN_BACK) { | ||
| // LEAN BACK | ||
| // Available starting at SDK 16 | ||
| // Available starting at SDK 20, due to the backwards compatibility provided by the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be great if we can eventually migrate from the deprecated APIs to use AndroidX's compat libraries, but according to https://docs.flutter.dev/development/tools/sdk/release-notes/supported-platforms we are also supporting API 19. Seems like everything here and below will require API 20+. We might need to rethink a bit on the supported modes and the default mode (especially if edge-to-edge, which works best on API 29+, is going to be the new default).
flutter/engine@fab1982...83d99a5 2022-01-14 [email protected] Roll Fuchsia Linux SDK from 35I2K_Bou... to V541xkYVr... (flutter/engine#30879) 2022-01-14 [email protected] Roll Dart SDK from dcab0d0b2f6c to d0d4dbfc6e69 (1 revision) (flutter/engine#30878) 2022-01-14 [email protected] Roll Skia from 1f0e64acd621 to f260a297c68d (1 revision) (flutter/engine#30877) 2022-01-14 [email protected] [fuchsia] stamp package with target api level (flutter/engine#30857) 2022-01-14 [email protected] Roll Skia from dd9e165ef7d0 to 1f0e64acd621 (1 revision) (flutter/engine#30876) 2022-01-14 [email protected] Roll Fuchsia Mac SDK from BQ2l2096A... to bGW3xlB1D... (flutter/engine#30875) 2022-01-14 [email protected] Roll Skia from 7aec4b164e79 to dd9e165ef7d0 (1 revision) (flutter/engine#30874) 2022-01-14 [email protected] Roll Dart SDK from 68ccd13498be to dcab0d0b2f6c (1 revision) (flutter/engine#30872) 2022-01-14 [email protected] Roll Dart SDK from aa6fbac07951 to 68ccd13498be (1 revision) (flutter/engine#30870) 2022-01-14 [email protected] Roll Skia from 76e62d32d979 to 7aec4b164e79 (1 revision) (flutter/engine#30869) 2022-01-14 [email protected] Roll Skia from a6f2ebf30fea to 76e62d32d979 (1 revision) (flutter/engine#30868) 2022-01-14 [email protected] Roll Dart SDK from ba044d5e9c03 to aa6fbac07951 (1 revision) (flutter/engine#30867) 2022-01-14 [email protected] Roll Skia from 7c80b2f08ead to a6f2ebf30fea (1 revision) (flutter/engine#30863) 2022-01-14 [email protected] [Windows, Keyboard] Lift key event redispatching to KeyboardManagerWin32 (flutter/engine#30702) 2022-01-14 [email protected] Ensure that PlatformViewIOS does not call into Shell semantics APIs during destruction (flutter/engine#30835) 2022-01-14 [email protected] Roll Skia from 119fb6bb2568 to 7c80b2f08ead (1 revision) (flutter/engine#30862) 2022-01-14 [email protected] Roll Dart SDK from b36d861d5487 to ba044d5e9c03 (1 revision) (flutter/engine#30861) 2022-01-14 [email protected] Roll Skia from 62b32180c192 to 119fb6bb2568 (1 revision) (flutter/engine#30860) 2022-01-14 [email protected] Roll Fuchsia Mac SDK from Uvw9UoGSm... to BQ2l2096A... (flutter/engine#30859) 2022-01-13 [email protected] Move SoftwareCanvasProvider into its own source file (flutter/engine#30856) 2022-01-13 [email protected] Roll Skia from c505bdca9d60 to 62b32180c192 (1 revision) (flutter/engine#30855) 2022-01-13 [email protected] Create a DisplayList benchmarks dylib on iOS (flutter/engine#30833) 2022-01-13 [email protected] Don't retain the MTLTexture or MTLDevice in TestMetalContext (flutter/engine#30832) 2022-01-13 [email protected] Roll Skia from 455e580b9c78 to c505bdca9d60 (1 revision) (flutter/engine#30852) 2022-01-13 [email protected] Roll buildroot to 7effd69. (flutter/engine#30851) 2022-01-13 [email protected] Remove unused field initializing formal parameters. (flutter/engine#30822) 2022-01-13 [email protected] Roll Dart SDK from f1c98a571d1a to b36d861d5487 (1 revision) (flutter/engine#30850) 2022-01-13 [email protected] Roll Skia from 759bc62a06d2 to 455e580b9c78 (2 revisions) (flutter/engine#30849) 2022-01-13 [email protected] Remove usages of deprecated setSystemUiVisibility() (flutter/engine#29493) 2022-01-13 [email protected] Roll Skia from b21c4af0f670 to 759bc62a06d2 (3 revisions) (flutter/engine#30848) 2022-01-13 [email protected] [fuchsia] Switch from core-jit to core snapshots. (flutter/engine#30744) Also rolling transitive DEPS: fuchsia/sdk/core/linux-amd64 from 35I2K_BouXUN to V541xkYVrdUC fuchsia/sdk/core/mac-amd64 from Uvw9UoGSmIjy to bGW3xlB1DoAm
* a193f08 [fuchsia] Switch from core-jit to core snapshots. (flutter/engine#30744) * 7e50462 Roll Skia from b21c4af0f670 to 759bc62a06d2 (3 revisions) (flutter/engine#30848) * 8db5038 Remove usages of deprecated setSystemUiVisibility() (flutter/engine#29493) * c05d0df Roll Skia from 759bc62a06d2 to 455e580b9c78 (2 revisions) (flutter/engine#30849) * 1fab2fb Roll Dart SDK from f1c98a571d1a to b36d861d5487 (1 revision) (flutter/engine#30850) * f9385e7 Remove unused field initializing formal parameters. (flutter/engine#30822) * b6e5d99 Roll buildroot to 7effd69. (flutter/engine#30851) * 742eaf8 Roll Skia from 455e580b9c78 to c505bdca9d60 (1 revision) (flutter/engine#30852) * d0f2beb Don't retain the MTLTexture or MTLDevice in TestMetalContext (flutter/engine#30832) * f121c1f Create a DisplayList benchmarks dylib on iOS (flutter/engine#30833) * 4499797 Roll Skia from c505bdca9d60 to 62b32180c192 (1 revision) (flutter/engine#30855) * fcf7458 Move SoftwareCanvasProvider into its own source file (flutter/engine#30856) * 794a833 Roll Fuchsia Mac SDK from Uvw9UoGSm... to BQ2l2096A... (flutter/engine#30859) * 4b32e1c Roll Skia from 62b32180c192 to 119fb6bb2568 (1 revision) (flutter/engine#30860) * facfa74 Roll Dart SDK from b36d861d5487 to ba044d5e9c03 (1 revision) (flutter/engine#30861) * f6613c9 Roll Skia from 119fb6bb2568 to 7c80b2f08ead (1 revision) (flutter/engine#30862) * fb3ee7f Ensure that PlatformViewIOS does not call into Shell semantics APIs during destruction (flutter/engine#30835) * 073e6c5 [Windows, Keyboard] Lift key event redispatching to KeyboardManagerWin32 (flutter/engine#30702) * 88e67a2 Roll Skia from 7c80b2f08ead to a6f2ebf30fea (1 revision) (flutter/engine#30863) * 1f4e7fa Roll Dart SDK from ba044d5e9c03 to aa6fbac07951 (1 revision) (flutter/engine#30867) * 3fbd427 Roll Skia from a6f2ebf30fea to 76e62d32d979 (1 revision) (flutter/engine#30868) * b6db081 Roll Skia from 76e62d32d979 to 7aec4b164e79 (1 revision) (flutter/engine#30869) * b92fd27 Roll Dart SDK from aa6fbac07951 to 68ccd13498be (1 revision) (flutter/engine#30870) * 8961366 Roll Dart SDK from 68ccd13498be to dcab0d0b2f6c (1 revision) (flutter/engine#30872) * 18ea2ce Roll Skia from 7aec4b164e79 to dd9e165ef7d0 (1 revision) (flutter/engine#30874) * 9d660d9 Roll Fuchsia Mac SDK from BQ2l2096A... to bGW3xlB1D... (flutter/engine#30875) * ad68b1b Roll Skia from dd9e165ef7d0 to 1f0e64acd621 (1 revision) (flutter/engine#30876) * b61a6f5 [fuchsia] stamp package with target api level (flutter/engine#30857) * 5787489 Roll Skia from 1f0e64acd621 to f260a297c68d (1 revision) (flutter/engine#30877) * 87ba2d8 Roll Dart SDK from dcab0d0b2f6c to d0d4dbfc6e69 (1 revision) (flutter/engine#30878) * 83d99a5 Roll Fuchsia Linux SDK from 35I2K_Bou... to V541xkYVr... (flutter/engine#30879) * 50adf4c Revert "Remove usages of deprecated setSystemUiVisibility()" (flutter/engine#30880)
* a193f08 [fuchsia] Switch from core-jit to core snapshots. (flutter/engine#30744) * 7e50462 Roll Skia from b21c4af0f670 to 759bc62a06d2 (3 revisions) (flutter/engine#30848) * 8db5038 Remove usages of deprecated setSystemUiVisibility() (flutter/engine#29493) * c05d0df Roll Skia from 759bc62a06d2 to 455e580b9c78 (2 revisions) (flutter/engine#30849) * 1fab2fb Roll Dart SDK from f1c98a571d1a to b36d861d5487 (1 revision) (flutter/engine#30850) * f9385e7 Remove unused field initializing formal parameters. (flutter/engine#30822) * b6e5d99 Roll buildroot to 7effd69. (flutter/engine#30851) * 742eaf8 Roll Skia from 455e580b9c78 to c505bdca9d60 (1 revision) (flutter/engine#30852) * d0f2beb Don't retain the MTLTexture or MTLDevice in TestMetalContext (flutter/engine#30832) * f121c1f Create a DisplayList benchmarks dylib on iOS (flutter/engine#30833) * 4499797 Roll Skia from c505bdca9d60 to 62b32180c192 (1 revision) (flutter/engine#30855) * fcf7458 Move SoftwareCanvasProvider into its own source file (flutter/engine#30856) * 794a833 Roll Fuchsia Mac SDK from Uvw9UoGSm... to BQ2l2096A... (flutter/engine#30859) * 4b32e1c Roll Skia from 62b32180c192 to 119fb6bb2568 (1 revision) (flutter/engine#30860) * facfa74 Roll Dart SDK from b36d861d5487 to ba044d5e9c03 (1 revision) (flutter/engine#30861) * f6613c9 Roll Skia from 119fb6bb2568 to 7c80b2f08ead (1 revision) (flutter/engine#30862) * fb3ee7f Ensure that PlatformViewIOS does not call into Shell semantics APIs during destruction (flutter/engine#30835) * 073e6c5 [Windows, Keyboard] Lift key event redispatching to KeyboardManagerWin32 (flutter/engine#30702) * 88e67a2 Roll Skia from 7c80b2f08ead to a6f2ebf30fea (1 revision) (flutter/engine#30863) * 1f4e7fa Roll Dart SDK from ba044d5e9c03 to aa6fbac07951 (1 revision) (flutter/engine#30867) * 3fbd427 Roll Skia from a6f2ebf30fea to 76e62d32d979 (1 revision) (flutter/engine#30868) * b6db081 Roll Skia from 76e62d32d979 to 7aec4b164e79 (1 revision) (flutter/engine#30869) * b92fd27 Roll Dart SDK from aa6fbac07951 to 68ccd13498be (1 revision) (flutter/engine#30870) * 8961366 Roll Dart SDK from 68ccd13498be to dcab0d0b2f6c (1 revision) (flutter/engine#30872) * 18ea2ce Roll Skia from 7aec4b164e79 to dd9e165ef7d0 (1 revision) (flutter/engine#30874) * 9d660d9 Roll Fuchsia Mac SDK from BQ2l2096A... to bGW3xlB1D... (flutter/engine#30875) * ad68b1b Roll Skia from dd9e165ef7d0 to 1f0e64acd621 (1 revision) (flutter/engine#30876) * b61a6f5 [fuchsia] stamp package with target api level (flutter/engine#30857) * 5787489 Roll Skia from 1f0e64acd621 to f260a297c68d (1 revision) (flutter/engine#30877) * 87ba2d8 Roll Dart SDK from dcab0d0b2f6c to d0d4dbfc6e69 (1 revision) (flutter/engine#30878) * 83d99a5 Roll Fuchsia Linux SDK from 35I2K_Bou... to V541xkYVr... (flutter/engine#30879) * 50adf4c Revert "Remove usages of deprecated setSystemUiVisibility()" (flutter/engine#30880)

Removes uses of setSystemUiVisibility() in the engine.
Addresses Issue 91128.
Pre-launch Checklist
writing and running engine tests.
///).