From d4ac98ad3d6a1d8a17dd1ac835f5f669a53d2f41 Mon Sep 17 00:00:00 2001 From: camsim99 Date: Tue, 2 Nov 2021 15:22:10 -0700 Subject: [PATCH 01/39] Add usage of updated window, system bar appearance APIs --- .../plugin/platform/PlatformPlugin.java | 126 ++++++++++++++---- 1 file changed, 100 insertions(+), 26 deletions(-) diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java index 46d0aecf0b46d..a045ce284cd6a 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java @@ -15,6 +15,7 @@ import android.view.SoundEffectConstants; import android.view.View; import android.view.Window; +import android.view.WindowInsets; import android.view.WindowManager; import androidx.activity.OnBackPressedDispatcherOwner; import androidx.annotation.NonNull; @@ -244,21 +245,35 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; - if (systemUiMode == PlatformChannel.SystemUiMode.LEAN_BACK - && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { - // LEAN BACK - // Available starting at SDK 16 - // Should not show overlays, tap to reveal overlays, needs onChange callback - // When the overlays come in on tap, the app does not recieve the gesture and does not know - // the system overlay has changed. The overlays cannot be dismissed, so adding the callback - // support will allow users to restore the system ui and dismiss the overlays. - // Not compatible with top/bottom overlays enabled. - enabledOverlays = - 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; + Window window = activity.getWindow(); + View view = window.getDecorView(); + WindowInsetsControllerCompat windowInsetsControllerCompat = new WindowInsetsControllerCompat(window, view); + + if (systemUiMode == PlatformChannel.SystemUiMode.LEAN_BACK + && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + // LEAN BACK + // Available starting at SDK 16 + // Should not show overlays, tap to reveal overlays, needs onChange callback + // When the overlays come in on tap, the app does not recieve the gesture and does not know + // the system overlay has changed. The overlays cannot be dismissed, so adding the callback + // support will allow users to restore the system ui and dismiss the overlays. + // Not compatible with top/bottom overlays enabled. + if (Build.VERSION.SDK_INT >= 30) { + windowInsetsControllerCompat.setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_TOUCH); + window.setDecorFitsSystemWindows(false); + windowInsetsControllerCompat.hide(WindowInsets.Type.statusBars()); + windowInsetsControllerCompat.hide(WindowInsets.Type.navigationBars()); + + return; + } + else { + enabledOverlays = + 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; + } } else if (systemUiMode == PlatformChannel.SystemUiMode.IMMERSIVE && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { // IMMERSIVE @@ -268,13 +283,23 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys // the system overlay has changed. The overlays cannot be dismissed, so adding callback // support will allow users to restore the system ui and dismiss the overlays. // Not compatible with top/bottom overlays enabled. - enabledOverlays = + if (Build.VERSION.SDK_INT >= 30) { + windowInsetsControllerCompat.setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_SWIPE); + window.setDecorFitsSystemWindows(false); + windowInsetsControllerCompat.hide(WindowInsets.Type.statusBars()); + windowInsetsControllerCompat.hide(WindowInsets.Type.navigationBars()); + + return; + } + else { + enabledOverlays = View.SYSTEM_UI_FLAG_IMMERSIVE | 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; + } } else if (systemUiMode == PlatformChannel.SystemUiMode.IMMERSIVE_STICKY && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { // STICKY IMMERSIVE @@ -283,13 +308,24 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys // the swipe gesture. The overlays cannot be dismissed, so adding callback support will // allow users to restore the system ui and dismiss the overlays. // Not compatible with top/bottom overlays enabled. - enabledOverlays = + if (Build.VERSION.SDK_INT >= 30) { + windowInsetsControllerCompat.setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); + window.setDecorFitsSystemWindows(false); + windowInsetsControllerCompat.hide(WindowInsets.Type.statusBars()); + windowInsetsControllerCompat.hide(WindowInsets.Type.navigationBars()); + return; + } + else { + enabledOverlays = View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | 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; + mEnabledOverlays = enabledOverlays; + updateSystemUiOverlays(); + } } else if (systemUiMode == PlatformChannel.SystemUiMode.EDGE_TO_EDGE && Build.VERSION.SDK_INT >= 29) { // EDGE TO EDGE @@ -297,14 +333,26 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys // SDK 29 and up will apply a translucent body scrim behind 2/3 button navigation bars // to ensure contrast with buttons on the nav and status bars, unless the contrast is not // enforced in the overlay styling. - enabledOverlays = + if (Build.VERSION.SDK_INT >= 30) { + window.setDecorFitsSystemWindows(false); + return; + } + else { + enabledOverlays = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN; + } } - mEnabledOverlays = enabledOverlays; - updateSystemUiOverlays(); + if (Build.VERSION.SDK_INT >= 30) { + windowInsetsControllerCompat.hide(WindowInsets.Type.statusBars()); + windowInsetsControllerCompat.hide(WindowInsets.Type.navigationBars()); + window.setDecorFitsSystemWindows(false); + } else { + mEnabledOverlays = enabledOverlays; + updateSystemUiOverlays(); + } } private void setSystemChromeEnabledSystemUIOverlays( @@ -316,12 +364,27 @@ private void setSystemChromeEnabledSystemUIOverlays( | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; + + Window window = activity.getWindow(); + View view = window.getDecorView(); + WindowInsetsControllerCompat windowInsetsControllerCompat = new WindowInsetsControllerCompat(window, view); + + if (Build.VERSION.SDK_INT >= 30) { + windowInsetsControllerCompat.hide(WindowInsets.Type.statusBars()); + window.setDecorFitsSystemWindows(false); + windowInsetsControllerCompat.hide(WindowInsets.Type.navigationBars()); + } //todo move this // The SYSTEM_UI_FLAG_IMMERSIVE_STICKY flag was introduced in API 19, so we // apply it // if desired, and if the current Android version is 19 or greater. if (overlaysToShow.size() == 0 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - enabledOverlays |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; + if (Build.VERSION.SDK_INT >= 30) { + windowInsetsControllerCompat.setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); + } + else { + enabledOverlays |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; + } } // Re-add any desired system overlays. @@ -329,17 +392,28 @@ private void setSystemChromeEnabledSystemUIOverlays( PlatformChannel.SystemUiOverlay overlayToShow = overlaysToShow.get(i); switch (overlayToShow) { case TOP_OVERLAYS: - enabledOverlays &= ~View.SYSTEM_UI_FLAG_FULLSCREEN; + if (Build.VERSION.SDK_INT >= 30) { + windowInsetsControllerCompat.show(WindowInsets.Type.statusBars()); + } else { + enabledOverlays &= ~View.SYSTEM_UI_FLAG_FULLSCREEN; + } break; case BOTTOM_OVERLAYS: - enabledOverlays &= ~View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION; - enabledOverlays &= ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; + if (Build.VERSION.SDK_INT >= 30) { + window.setDecorFitsSystemWindows(true); + windowInsetsControllerCompat.show(WindowInsets.Type.navigationBars()); + } else { + enabledOverlays &= ~View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION; + enabledOverlays &= ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; + } break; } } - mEnabledOverlays = enabledOverlays; - updateSystemUiOverlays(); + if (Build.VERSION.SDK_INT < 30) { + mEnabledOverlays = enabledOverlays; + updateSystemUiOverlays(); + } } /** From a3fc96ccd43179ebd2f534c7b5515b168d03b501 Mon Sep 17 00:00:00 2001 From: camsim99 Date: Tue, 2 Nov 2021 15:29:21 -0700 Subject: [PATCH 02/39] Format java file: --- .../android/io/flutter/plugin/platform/PlatformPlugin.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java index a045ce284cd6a..169c8e3a6fa24 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java @@ -248,7 +248,6 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys Window window = activity.getWindow(); View view = window.getDecorView(); WindowInsetsControllerCompat windowInsetsControllerCompat = new WindowInsetsControllerCompat(window, view); - if (systemUiMode == PlatformChannel.SystemUiMode.LEAN_BACK && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { // LEAN BACK @@ -364,7 +363,6 @@ private void setSystemChromeEnabledSystemUIOverlays( | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; - Window window = activity.getWindow(); View view = window.getDecorView(); WindowInsetsControllerCompat windowInsetsControllerCompat = new WindowInsetsControllerCompat(window, view); From ef971cf0b1fea3a81f3276c84cfd5b55fe4b7a73 Mon Sep 17 00:00:00 2001 From: camsim99 Date: Tue, 2 Nov 2021 15:47:09 -0700 Subject: [PATCH 03/39] Format file --- .../io/flutter/plugin/platform/PlatformPlugin.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java index 169c8e3a6fa24..e5a4a2fe1ed02 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java @@ -258,7 +258,8 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys // support will allow users to restore the system ui and dismiss the overlays. // Not compatible with top/bottom overlays enabled. if (Build.VERSION.SDK_INT >= 30) { - windowInsetsControllerCompat.setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_TOUCH); + windowInsetsControllerCompat + .setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_TOUCH); window.setDecorFitsSystemWindows(false); windowInsetsControllerCompat.hide(WindowInsets.Type.statusBars()); windowInsetsControllerCompat.hide(WindowInsets.Type.navigationBars()); @@ -283,7 +284,8 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys // support will allow users to restore the system ui and dismiss the overlays. // Not compatible with top/bottom overlays enabled. if (Build.VERSION.SDK_INT >= 30) { - windowInsetsControllerCompat.setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_SWIPE); + windowInsetsControllerCompat + .setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_SWIPE); window.setDecorFitsSystemWindows(false); windowInsetsControllerCompat.hide(WindowInsets.Type.statusBars()); windowInsetsControllerCompat.hide(WindowInsets.Type.navigationBars()); @@ -308,7 +310,8 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys // allow users to restore the system ui and dismiss the overlays. // Not compatible with top/bottom overlays enabled. if (Build.VERSION.SDK_INT >= 30) { - windowInsetsControllerCompat.setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); + windowInsetsControllerCompat + .setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); window.setDecorFitsSystemWindows(false); windowInsetsControllerCompat.hide(WindowInsets.Type.statusBars()); windowInsetsControllerCompat.hide(WindowInsets.Type.navigationBars()); @@ -371,7 +374,7 @@ private void setSystemChromeEnabledSystemUIOverlays( windowInsetsControllerCompat.hide(WindowInsets.Type.statusBars()); window.setDecorFitsSystemWindows(false); windowInsetsControllerCompat.hide(WindowInsets.Type.navigationBars()); - } //todo move this + } // The SYSTEM_UI_FLAG_IMMERSIVE_STICKY flag was introduced in API 19, so we // apply it From 136b0a5eb94ee6a8284bee1589eec30fdf8eeb93 Mon Sep 17 00:00:00 2001 From: camsim99 Date: Tue, 2 Nov 2021 17:32:31 -0700 Subject: [PATCH 04/39] Format file --- .../plugin/platform/PlatformPlugin.java | 102 +++++++++--------- 1 file changed, 50 insertions(+), 52 deletions(-) diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java index e5a4a2fe1ed02..be4f775b5c288 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java @@ -247,33 +247,33 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys Window window = activity.getWindow(); View view = window.getDecorView(); - WindowInsetsControllerCompat windowInsetsControllerCompat = new WindowInsetsControllerCompat(window, view); - if (systemUiMode == PlatformChannel.SystemUiMode.LEAN_BACK - && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { - // LEAN BACK - // Available starting at SDK 16 - // Should not show overlays, tap to reveal overlays, needs onChange callback - // When the overlays come in on tap, the app does not recieve the gesture and does not know - // the system overlay has changed. The overlays cannot be dismissed, so adding the callback - // support will allow users to restore the system ui and dismiss the overlays. - // Not compatible with top/bottom overlays enabled. - if (Build.VERSION.SDK_INT >= 30) { - windowInsetsControllerCompat - .setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_TOUCH); - window.setDecorFitsSystemWindows(false); - windowInsetsControllerCompat.hide(WindowInsets.Type.statusBars()); - windowInsetsControllerCompat.hide(WindowInsets.Type.navigationBars()); - - return; - } - else { - enabledOverlays = + WindowInsetsControllerCompat windowInsetsControllerCompat = + new WindowInsetsControllerCompat(window, view); + if (systemUiMode == PlatformChannel.SystemUiMode.LEAN_BACK + && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + // LEAN BACK + // Available starting at SDK 16 + // Should not show overlays, tap to reveal overlays, needs onChange callback + // When the overlays come in on tap, the app does not recieve the gesture and does not know + // the system overlay has changed. The overlays cannot be dismissed, so adding the callback + // support will allow users to restore the system ui and dismiss the overlays. + // Not compatible with top/bottom overlays enabled. + if (Build.VERSION.SDK_INT >= 30) { + windowInsetsControllerCompat.setSystemBarsBehavior( + WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_TOUCH); + window.setDecorFitsSystemWindows(false); + windowInsetsControllerCompat.hide(WindowInsets.Type.statusBars()); + windowInsetsControllerCompat.hide(WindowInsets.Type.navigationBars()); + + return; + } else { + enabledOverlays = 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; - } + } } else if (systemUiMode == PlatformChannel.SystemUiMode.IMMERSIVE && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { // IMMERSIVE @@ -284,23 +284,22 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys // support will allow users to restore the system ui and dismiss the overlays. // Not compatible with top/bottom overlays enabled. if (Build.VERSION.SDK_INT >= 30) { - windowInsetsControllerCompat - .setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_SWIPE); + windowInsetsControllerCompat.setSystemBarsBehavior( + WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_SWIPE); window.setDecorFitsSystemWindows(false); windowInsetsControllerCompat.hide(WindowInsets.Type.statusBars()); windowInsetsControllerCompat.hide(WindowInsets.Type.navigationBars()); return; - } - else { + } else { enabledOverlays = - View.SYSTEM_UI_FLAG_IMMERSIVE - | 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; - } + View.SYSTEM_UI_FLAG_IMMERSIVE + | 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; + } } else if (systemUiMode == PlatformChannel.SystemUiMode.IMMERSIVE_STICKY && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { // STICKY IMMERSIVE @@ -310,21 +309,20 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys // allow users to restore the system ui and dismiss the overlays. // Not compatible with top/bottom overlays enabled. if (Build.VERSION.SDK_INT >= 30) { - windowInsetsControllerCompat - .setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); + windowInsetsControllerCompat.setSystemBarsBehavior( + WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); window.setDecorFitsSystemWindows(false); windowInsetsControllerCompat.hide(WindowInsets.Type.statusBars()); windowInsetsControllerCompat.hide(WindowInsets.Type.navigationBars()); return; - } - else { + } else { enabledOverlays = - View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY - | 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; + View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY + | 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; mEnabledOverlays = enabledOverlays; updateSystemUiOverlays(); } @@ -338,12 +336,11 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys if (Build.VERSION.SDK_INT >= 30) { window.setDecorFitsSystemWindows(false); return; - } - else { + } else { enabledOverlays = - View.SYSTEM_UI_FLAG_LAYOUT_STABLE - | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN; + View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN; } } @@ -368,7 +365,8 @@ private void setSystemChromeEnabledSystemUIOverlays( | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; Window window = activity.getWindow(); View view = window.getDecorView(); - WindowInsetsControllerCompat windowInsetsControllerCompat = new WindowInsetsControllerCompat(window, view); + WindowInsetsControllerCompat windowInsetsControllerCompat = + new WindowInsetsControllerCompat(window, view); if (Build.VERSION.SDK_INT >= 30) { windowInsetsControllerCompat.hide(WindowInsets.Type.statusBars()); @@ -381,9 +379,9 @@ private void setSystemChromeEnabledSystemUIOverlays( // if desired, and if the current Android version is 19 or greater. if (overlaysToShow.size() == 0 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { if (Build.VERSION.SDK_INT >= 30) { - windowInsetsControllerCompat.setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); - } - else { + windowInsetsControllerCompat.setSystemBarsBehavior( + WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); + } else { enabledOverlays |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; } } From 6b0acd3f04f7e7e2042161d0c47e21dcdd12d3ef Mon Sep 17 00:00:00 2001 From: camsim99 Date: Wed, 3 Nov 2021 16:11:07 -0700 Subject: [PATCH 05/39] add fix for flutter activitiy delegate --- .../android/io/flutter/app/FlutterActivityDelegate.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java b/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java index 0fe692c49c6c7..b9074449c2d87 100644 --- a/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java +++ b/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java @@ -141,7 +141,12 @@ public void onCreate(Bundle savedInstanceState) { Window window = activity.getWindow(); window.addFlags(LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(0x40000000); - window.getDecorView().setSystemUiVisibility(PlatformPlugin.DEFAULT_SYSTEM_UI); + if (Build.VERSION.SDK_INT >= 30) { + window.setDecorFitsSystemWindows(false); + } + else { + window.getDecorView().setSystemUiVisibility(PlatformPlugin.DEFAULT_SYSTEM_UI); + } } String[] args = getArgsFromIntent(activity.getIntent()); From f34f87674255aaa752c3e695e6440c8da4286cc4 Mon Sep 17 00:00:00 2001 From: camsim99 Date: Wed, 3 Nov 2021 16:11:54 -0700 Subject: [PATCH 06/39] format file --- .../android/io/flutter/app/FlutterActivityDelegate.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java b/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java index b9074449c2d87..9bec235b3b175 100644 --- a/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java +++ b/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java @@ -143,8 +143,7 @@ public void onCreate(Bundle savedInstanceState) { window.setStatusBarColor(0x40000000); if (Build.VERSION.SDK_INT >= 30) { window.setDecorFitsSystemWindows(false); - } - else { + } else { window.getDecorView().setSystemUiVisibility(PlatformPlugin.DEFAULT_SYSTEM_UI); } } From 15959f614347810b7720524623be6217e2bc9e4e Mon Sep 17 00:00:00 2001 From: camsim99 Date: Fri, 5 Nov 2021 10:10:51 -0700 Subject: [PATCH 07/39] Add changes for flutter activity and fragment activity --- .../io/flutter/embedding/android/FlutterActivity.java | 6 +++++- .../flutter/embedding/android/FlutterFragmentActivity.java | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/shell/platform/android/io/flutter/embedding/android/FlutterActivity.java b/shell/platform/android/io/flutter/embedding/android/FlutterActivity.java index 8ace803e5db0f..8eca8ae359634 100644 --- a/shell/platform/android/io/flutter/embedding/android/FlutterActivity.java +++ b/shell/platform/android/io/flutter/embedding/android/FlutterActivity.java @@ -580,7 +580,11 @@ private void configureStatusBarForFullscreenFlutterExperience() { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(0x40000000); - window.getDecorView().setSystemUiVisibility(PlatformPlugin.DEFAULT_SYSTEM_UI); + if (Build.VERSION.SDK_INT >= 30) { + window.setDecorFitsSystemWindows(false); + } else { + window.getDecorView().setSystemUiVisibility(PlatformPlugin.DEFAULT_SYSTEM_UI); + } } } diff --git a/shell/platform/android/io/flutter/embedding/android/FlutterFragmentActivity.java b/shell/platform/android/io/flutter/embedding/android/FlutterFragmentActivity.java index 52c65ca855d45..487513930d398 100644 --- a/shell/platform/android/io/flutter/embedding/android/FlutterFragmentActivity.java +++ b/shell/platform/android/io/flutter/embedding/android/FlutterFragmentActivity.java @@ -488,7 +488,11 @@ private void configureStatusBarForFullscreenFlutterExperience() { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(0x40000000); - window.getDecorView().setSystemUiVisibility(PlatformPlugin.DEFAULT_SYSTEM_UI); + if (Build.VERSION.SDK_INT >= 30) { + window.setDecorFitsSystemWindows(false); + } else { + window.getDecorView().setSystemUiVisibility(PlatformPlugin.DEFAULT_SYSTEM_UI); + } } } From 2dab8381f9c74a11963df108fc053511862f3646 Mon Sep 17 00:00:00 2001 From: camsim99 Date: Tue, 9 Nov 2021 10:37:49 -0800 Subject: [PATCH 08/39] Make fixes based on manual testing --- .../android/io/flutter/plugin/platform/PlatformPlugin.java | 1 - 1 file changed, 1 deletion(-) diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java index be4f775b5c288..9a347b63e2a9e 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java @@ -399,7 +399,6 @@ private void setSystemChromeEnabledSystemUIOverlays( break; case BOTTOM_OVERLAYS: if (Build.VERSION.SDK_INT >= 30) { - window.setDecorFitsSystemWindows(true); windowInsetsControllerCompat.show(WindowInsets.Type.navigationBars()); } else { enabledOverlays &= ~View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION; From 66e12760f590faacea1173a1ea4cc66bb772445c Mon Sep 17 00:00:00 2001 From: camsim99 Date: Tue, 9 Nov 2021 10:42:05 -0800 Subject: [PATCH 09/39] replace setdecorfitssystemwindows methods --- .../io/flutter/plugin/platform/PlatformPlugin.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java index 9a347b63e2a9e..51fbd5f3d6cb8 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java @@ -261,8 +261,8 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys if (Build.VERSION.SDK_INT >= 30) { windowInsetsControllerCompat.setSystemBarsBehavior( WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_TOUCH); - window.setDecorFitsSystemWindows(false); - windowInsetsControllerCompat.hide(WindowInsets.Type.statusBars()); + WindowCompat.setDecorFitsSystemWindows(window, false); + windowInsetsControllerCompat.hide(WindowInsets.Type.statusBars()); windowInsetsControllerCompat.hide(WindowInsets.Type.navigationBars()); return; @@ -286,7 +286,7 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys if (Build.VERSION.SDK_INT >= 30) { windowInsetsControllerCompat.setSystemBarsBehavior( WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_SWIPE); - window.setDecorFitsSystemWindows(false); + WindowCompat.setDecorFitsSystemWindows(window, false); windowInsetsControllerCompat.hide(WindowInsets.Type.statusBars()); windowInsetsControllerCompat.hide(WindowInsets.Type.navigationBars()); @@ -311,7 +311,7 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys if (Build.VERSION.SDK_INT >= 30) { windowInsetsControllerCompat.setSystemBarsBehavior( WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); - window.setDecorFitsSystemWindows(false); + WindowCompat.setDecorFitsSystemWindows(window, false); windowInsetsControllerCompat.hide(WindowInsets.Type.statusBars()); windowInsetsControllerCompat.hide(WindowInsets.Type.navigationBars()); return; @@ -334,7 +334,7 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys // to ensure contrast with buttons on the nav and status bars, unless the contrast is not // enforced in the overlay styling. if (Build.VERSION.SDK_INT >= 30) { - window.setDecorFitsSystemWindows(false); + WindowCompat.setDecorFitsSystemWindows(window, false); return; } else { enabledOverlays = @@ -347,7 +347,7 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys if (Build.VERSION.SDK_INT >= 30) { windowInsetsControllerCompat.hide(WindowInsets.Type.statusBars()); windowInsetsControllerCompat.hide(WindowInsets.Type.navigationBars()); - window.setDecorFitsSystemWindows(false); + WindowCompat.setDecorFitsSystemWindows(window, false); } else { mEnabledOverlays = enabledOverlays; updateSystemUiOverlays(); @@ -370,7 +370,7 @@ private void setSystemChromeEnabledSystemUIOverlays( if (Build.VERSION.SDK_INT >= 30) { windowInsetsControllerCompat.hide(WindowInsets.Type.statusBars()); - window.setDecorFitsSystemWindows(false); + WindowCompat.setDecorFitsSystemWindows(window, false); windowInsetsControllerCompat.hide(WindowInsets.Type.navigationBars()); } From 5d70fd6c3f3c814580073708805493fd5ebe67f5 Mon Sep 17 00:00:00 2001 From: camsim99 Date: Tue, 9 Nov 2021 10:42:32 -0800 Subject: [PATCH 10/39] Format platform plugin --- .../android/io/flutter/plugin/platform/PlatformPlugin.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java index 51fbd5f3d6cb8..ad69b3cb51ece 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java @@ -261,8 +261,8 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys if (Build.VERSION.SDK_INT >= 30) { windowInsetsControllerCompat.setSystemBarsBehavior( WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_TOUCH); - WindowCompat.setDecorFitsSystemWindows(window, false); - windowInsetsControllerCompat.hide(WindowInsets.Type.statusBars()); + WindowCompat.setDecorFitsSystemWindows(window, false); + windowInsetsControllerCompat.hide(WindowInsets.Type.statusBars()); windowInsetsControllerCompat.hide(WindowInsets.Type.navigationBars()); return; From 6377d18b87c2f5fee8dade42d8aa90ca62bf8c16 Mon Sep 17 00:00:00 2001 From: camsim99 Date: Tue, 9 Nov 2021 12:05:04 -0800 Subject: [PATCH 11/39] add one liners --- .../plugin/platform/PlatformPlugin.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java index ad69b3cb51ece..dc27227778598 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java @@ -262,8 +262,8 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys windowInsetsControllerCompat.setSystemBarsBehavior( WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_TOUCH); WindowCompat.setDecorFitsSystemWindows(window, false); - windowInsetsControllerCompat.hide(WindowInsets.Type.statusBars()); - windowInsetsControllerCompat.hide(WindowInsets.Type.navigationBars()); + windowInsetsControllerCompat.hide( + WindowInsets.Type.statusBars() | WindowInsets.Type.navigationBars()); return; } else { @@ -287,8 +287,8 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys windowInsetsControllerCompat.setSystemBarsBehavior( WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_SWIPE); WindowCompat.setDecorFitsSystemWindows(window, false); - windowInsetsControllerCompat.hide(WindowInsets.Type.statusBars()); - windowInsetsControllerCompat.hide(WindowInsets.Type.navigationBars()); + windowInsetsControllerCompat.hide( + WindowInsets.Type.statusBars() | WindowInsets.Type.navigationBars()); return; } else { @@ -312,8 +312,8 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys windowInsetsControllerCompat.setSystemBarsBehavior( WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); WindowCompat.setDecorFitsSystemWindows(window, false); - windowInsetsControllerCompat.hide(WindowInsets.Type.statusBars()); - windowInsetsControllerCompat.hide(WindowInsets.Type.navigationBars()); + windowInsetsControllerCompat.hide( + WindowInsets.Type.statusBars() | WindowInsets.Type.navigationBars()); return; } else { enabledOverlays = @@ -345,8 +345,8 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys } if (Build.VERSION.SDK_INT >= 30) { - windowInsetsControllerCompat.hide(WindowInsets.Type.statusBars()); - windowInsetsControllerCompat.hide(WindowInsets.Type.navigationBars()); + windowInsetsControllerCompat.hide( + WindowInsets.Type.statusBars() | WindowInsets.Type.navigationBars()); WindowCompat.setDecorFitsSystemWindows(window, false); } else { mEnabledOverlays = enabledOverlays; @@ -369,9 +369,9 @@ private void setSystemChromeEnabledSystemUIOverlays( new WindowInsetsControllerCompat(window, view); if (Build.VERSION.SDK_INT >= 30) { - windowInsetsControllerCompat.hide(WindowInsets.Type.statusBars()); + windowInsetsControllerCompat.hide( + WindowInsets.Type.statusBars() | WindowInsets.Type.navigationBars()); WindowCompat.setDecorFitsSystemWindows(window, false); - windowInsetsControllerCompat.hide(WindowInsets.Type.navigationBars()); } // The SYSTEM_UI_FLAG_IMMERSIVE_STICKY flag was introduced in API 19, so we From 6c7c9634a9a3cd094447d43e5b87971e412fc728 Mon Sep 17 00:00:00 2001 From: camsim99 Date: Tue, 9 Nov 2021 12:58:11 -0800 Subject: [PATCH 12/39] format file --- .../android/io/flutter/plugin/platform/PlatformPlugin.java | 1 + 1 file changed, 1 insertion(+) diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java index dc27227778598..cde1d040cf5dc 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java @@ -21,6 +21,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; +import androidx.core.view.WindowCompat; import androidx.core.view.WindowInsetsControllerCompat; import io.flutter.Log; import io.flutter.embedding.engine.systemchannels.PlatformChannel; From 452151761a98e1ed99453eed72275c4d09387b95 Mon Sep 17 00:00:00 2001 From: camsim99 Date: Wed, 10 Nov 2021 08:57:18 -0800 Subject: [PATCH 13/39] change setdecorfitssystem methods --- .../android/io/flutter/app/FlutterActivityDelegate.java | 6 +----- .../io/flutter/embedding/android/FlutterActivity.java | 3 ++- .../flutter/embedding/android/FlutterFragmentActivity.java | 3 ++- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java b/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java index 9bec235b3b175..0fe692c49c6c7 100644 --- a/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java +++ b/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java @@ -141,11 +141,7 @@ public void onCreate(Bundle savedInstanceState) { Window window = activity.getWindow(); window.addFlags(LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(0x40000000); - if (Build.VERSION.SDK_INT >= 30) { - window.setDecorFitsSystemWindows(false); - } else { - window.getDecorView().setSystemUiVisibility(PlatformPlugin.DEFAULT_SYSTEM_UI); - } + window.getDecorView().setSystemUiVisibility(PlatformPlugin.DEFAULT_SYSTEM_UI); } String[] args = getArgsFromIntent(activity.getIntent()); diff --git a/shell/platform/android/io/flutter/embedding/android/FlutterActivity.java b/shell/platform/android/io/flutter/embedding/android/FlutterActivity.java index 8eca8ae359634..c859582463509 100644 --- a/shell/platform/android/io/flutter/embedding/android/FlutterActivity.java +++ b/shell/platform/android/io/flutter/embedding/android/FlutterActivity.java @@ -37,6 +37,7 @@ import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import androidx.core.content.res.ResourcesCompat; +import androidx.core.view.WindowCompat; import androidx.lifecycle.Lifecycle; import androidx.lifecycle.LifecycleOwner; import androidx.lifecycle.LifecycleRegistry; @@ -581,7 +582,7 @@ private void configureStatusBarForFullscreenFlutterExperience() { window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(0x40000000); if (Build.VERSION.SDK_INT >= 30) { - window.setDecorFitsSystemWindows(false); + WindowCompat.setDecorFitsSystemWindows(window, false); } else { window.getDecorView().setSystemUiVisibility(PlatformPlugin.DEFAULT_SYSTEM_UI); } diff --git a/shell/platform/android/io/flutter/embedding/android/FlutterFragmentActivity.java b/shell/platform/android/io/flutter/embedding/android/FlutterFragmentActivity.java index 487513930d398..f37b4157cec2f 100644 --- a/shell/platform/android/io/flutter/embedding/android/FlutterFragmentActivity.java +++ b/shell/platform/android/io/flutter/embedding/android/FlutterFragmentActivity.java @@ -37,6 +37,7 @@ import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import androidx.core.content.res.ResourcesCompat; +import androidx.core.view.WindowCompat; import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentManager; import io.flutter.Log; @@ -489,7 +490,7 @@ private void configureStatusBarForFullscreenFlutterExperience() { window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(0x40000000); if (Build.VERSION.SDK_INT >= 30) { - window.setDecorFitsSystemWindows(false); + WindowCompat.setDecorFitsSystemWindows(window, false); } else { window.getDecorView().setSystemUiVisibility(PlatformPlugin.DEFAULT_SYSTEM_UI); } From 8de6247dcdcadf3e9219129d15919dcf72aa51a1 Mon Sep 17 00:00:00 2001 From: camsim99 Date: Thu, 2 Dec 2021 17:02:13 -0500 Subject: [PATCH 14/39] Remove old code --- .../plugin/platform/PlatformPlugin.java | 53 +------------------ 1 file changed, 1 insertion(+), 52 deletions(-) diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java index bcaee3ff10044..2653044785abb 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java @@ -246,6 +246,7 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys View view = window.getDecorView(); WindowInsetsControllerCompat windowInsetsControllerCompat = new WindowInsetsControllerCompat(window, view); + if (systemUiMode == PlatformChannel.SystemUiMode.LEAN_BACK && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { // LEAN BACK @@ -255,22 +256,11 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys // the system overlay has changed. The overlays cannot be dismissed, so adding the callback // support will allow users to restore the system ui and dismiss the overlays. // Not compatible with top/bottom overlays enabled. - if (Build.VERSION.SDK_INT >= 30) { windowInsetsControllerCompat.setSystemBarsBehavior( WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_TOUCH); WindowCompat.setDecorFitsSystemWindows(window, false); windowInsetsControllerCompat.hide( WindowInsets.Type.statusBars() | WindowInsets.Type.navigationBars()); - - return; - } else { - enabledOverlays = - 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; - } } else if (systemUiMode == PlatformChannel.SystemUiMode.IMMERSIVE && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { // IMMERSIVE @@ -280,23 +270,12 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys // the system overlay has changed. The overlays cannot be dismissed, so adding callback // support will allow users to restore the system ui and dismiss the overlays. // Not compatible with top/bottom overlays enabled. - if (Build.VERSION.SDK_INT >= 30) { windowInsetsControllerCompat.setSystemBarsBehavior( WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_SWIPE); WindowCompat.setDecorFitsSystemWindows(window, false); windowInsetsControllerCompat.hide( WindowInsets.Type.statusBars() | WindowInsets.Type.navigationBars()); - return; - } else { - enabledOverlays = - View.SYSTEM_UI_FLAG_IMMERSIVE - | 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; - } } else if (systemUiMode == PlatformChannel.SystemUiMode.IMMERSIVE_STICKY && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { // STICKY IMMERSIVE @@ -305,24 +284,11 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys // the swipe gesture. The overlays cannot be dismissed, so adding callback support will // allow users to restore the system ui and dismiss the overlays. // Not compatible with top/bottom overlays enabled. - if (Build.VERSION.SDK_INT >= 30) { windowInsetsControllerCompat.setSystemBarsBehavior( WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); WindowCompat.setDecorFitsSystemWindows(window, false); windowInsetsControllerCompat.hide( WindowInsets.Type.statusBars() | WindowInsets.Type.navigationBars()); - return; - } else { - enabledOverlays = - View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY - | 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; - mEnabledOverlays = enabledOverlays; - updateSystemUiOverlays(); - } } else if (systemUiMode == PlatformChannel.SystemUiMode.EDGE_TO_EDGE && Build.VERSION.SDK_INT >= 29) { // EDGE TO EDGE @@ -330,28 +296,11 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys // SDK 29 and up will apply a translucent body scrim behind 2/3 button navigation bars // to ensure contrast with buttons on the nav and status bars, unless the contrast is not // enforced in the overlay styling. - if (Build.VERSION.SDK_INT >= 30) { WindowCompat.setDecorFitsSystemWindows(window, false); - return; - } else { - enabledOverlays = - View.SYSTEM_UI_FLAG_LAYOUT_STABLE - | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN; - } } else { // When none of the conditions are matched, return without updating the system UI overlays. return; } - - if (Build.VERSION.SDK_INT >= 30) { - windowInsetsControllerCompat.hide( - WindowInsets.Type.statusBars() | WindowInsets.Type.navigationBars()); - WindowCompat.setDecorFitsSystemWindows(window, false); - } else { - mEnabledOverlays = enabledOverlays; - updateSystemUiOverlays(); - } } private void setSystemChromeEnabledSystemUIOverlays( From 42419c5b3b96390e630a45e0b333b1c905d7a43d Mon Sep 17 00:00:00 2001 From: camsim99 Date: Thu, 2 Dec 2021 17:16:30 -0500 Subject: [PATCH 15/39] Remove changes from deprecated method --- .../plugin/platform/PlatformPlugin.java | 31 +++---------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java index 2653044785abb..c555bfd8e376e 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java @@ -303,6 +303,8 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys } } + /** @deprecated This feature was deprecated after v2.3.0-17.0.pre. Use setEnabledSystemUIMode instead. */ + @Deprecated private void setSystemChromeEnabledSystemUIOverlays( List overlaysToShow) { // Start by assuming we want to hide all system overlays (like an immersive @@ -312,27 +314,12 @@ private void setSystemChromeEnabledSystemUIOverlays( | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; - Window window = activity.getWindow(); - View view = window.getDecorView(); - WindowInsetsControllerCompat windowInsetsControllerCompat = - new WindowInsetsControllerCompat(window, view); - - if (Build.VERSION.SDK_INT >= 30) { - windowInsetsControllerCompat.hide( - WindowInsets.Type.statusBars() | WindowInsets.Type.navigationBars()); - WindowCompat.setDecorFitsSystemWindows(window, false); - } // The SYSTEM_UI_FLAG_IMMERSIVE_STICKY flag was introduced in API 19, so we // apply it // if desired, and if the current Android version is 19 or greater. if (overlaysToShow.size() == 0 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - if (Build.VERSION.SDK_INT >= 30) { - windowInsetsControllerCompat.setSystemBarsBehavior( - WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); - } else { enabledOverlays |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; - } } // Re-add any desired system overlays. @@ -340,27 +327,17 @@ private void setSystemChromeEnabledSystemUIOverlays( PlatformChannel.SystemUiOverlay overlayToShow = overlaysToShow.get(i); switch (overlayToShow) { case TOP_OVERLAYS: - if (Build.VERSION.SDK_INT >= 30) { - windowInsetsControllerCompat.show(WindowInsets.Type.statusBars()); - } else { enabledOverlays &= ~View.SYSTEM_UI_FLAG_FULLSCREEN; - } break; case BOTTOM_OVERLAYS: - if (Build.VERSION.SDK_INT >= 30) { - windowInsetsControllerCompat.show(WindowInsets.Type.navigationBars()); - } else { enabledOverlays &= ~View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION; enabledOverlays &= ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; - } break; } } - if (Build.VERSION.SDK_INT < 30) { - mEnabledOverlays = enabledOverlays; - updateSystemUiOverlays(); - } + mEnabledOverlays = enabledOverlays; + updateSystemUiOverlays(); } /** From 968a33c2ee92f1011e178fc4dfeb88630ed41707 Mon Sep 17 00:00:00 2001 From: camsim99 Date: Thu, 2 Dec 2021 17:37:38 -0500 Subject: [PATCH 16/39] Update window inset type --- .../io/flutter/plugin/platform/PlatformPlugin.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java index c555bfd8e376e..f768950d49c6c 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java @@ -15,13 +15,13 @@ import android.view.SoundEffectConstants; import android.view.View; import android.view.Window; -import android.view.WindowInsets; import android.view.WindowManager; import androidx.activity.OnBackPressedDispatcherOwner; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import androidx.core.view.WindowCompat; +import androidx.core.view.WindowInsetsCompat; import androidx.core.view.WindowInsetsControllerCompat; import io.flutter.Log; import io.flutter.embedding.engine.systemchannels.PlatformChannel; @@ -260,7 +260,7 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_TOUCH); WindowCompat.setDecorFitsSystemWindows(window, false); windowInsetsControllerCompat.hide( - WindowInsets.Type.statusBars() | WindowInsets.Type.navigationBars()); + WindowInsetsCompat.Type.systemBars()); } else if (systemUiMode == PlatformChannel.SystemUiMode.IMMERSIVE && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { // IMMERSIVE @@ -274,7 +274,7 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_SWIPE); WindowCompat.setDecorFitsSystemWindows(window, false); windowInsetsControllerCompat.hide( - WindowInsets.Type.statusBars() | WindowInsets.Type.navigationBars()); + WindowInsetsCompat.Type.systemBars()); } else if (systemUiMode == PlatformChannel.SystemUiMode.IMMERSIVE_STICKY && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { @@ -288,7 +288,7 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); WindowCompat.setDecorFitsSystemWindows(window, false); windowInsetsControllerCompat.hide( - WindowInsets.Type.statusBars() | WindowInsets.Type.navigationBars()); + WindowInsetsCompat.Type.systemBars()); } else if (systemUiMode == PlatformChannel.SystemUiMode.EDGE_TO_EDGE && Build.VERSION.SDK_INT >= 29) { // EDGE TO EDGE From f3e07243cac9955a5e619d26ec98919d2eeb8018 Mon Sep 17 00:00:00 2001 From: camsim99 Date: Thu, 2 Dec 2021 18:14:57 -0500 Subject: [PATCH 17/39] Remove old code --- .../android/io/flutter/app/FlutterActivityDelegate.java | 3 ++- .../io/flutter/embedding/android/FlutterActivity.java | 6 +----- .../flutter/embedding/android/FlutterFragmentActivity.java | 6 +----- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java b/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java index 0fe692c49c6c7..af00d09510fed 100644 --- a/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java +++ b/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java @@ -24,6 +24,7 @@ import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager.LayoutParams; +import androidx.core.view.WindowCompat; import io.flutter.Log; import io.flutter.plugin.common.PluginRegistry; import io.flutter.plugin.platform.PlatformPlugin; @@ -141,7 +142,7 @@ public void onCreate(Bundle savedInstanceState) { Window window = activity.getWindow(); window.addFlags(LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(0x40000000); - window.getDecorView().setSystemUiVisibility(PlatformPlugin.DEFAULT_SYSTEM_UI); + WindowCompat.setDecorFitsSystemWindows(window, false); } String[] args = getArgsFromIntent(activity.getIntent()); diff --git a/shell/platform/android/io/flutter/embedding/android/FlutterActivity.java b/shell/platform/android/io/flutter/embedding/android/FlutterActivity.java index c859582463509..acb4669a11da9 100644 --- a/shell/platform/android/io/flutter/embedding/android/FlutterActivity.java +++ b/shell/platform/android/io/flutter/embedding/android/FlutterActivity.java @@ -581,11 +581,7 @@ private void configureStatusBarForFullscreenFlutterExperience() { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(0x40000000); - if (Build.VERSION.SDK_INT >= 30) { - WindowCompat.setDecorFitsSystemWindows(window, false); - } else { - window.getDecorView().setSystemUiVisibility(PlatformPlugin.DEFAULT_SYSTEM_UI); - } + WindowCompat.setDecorFitsSystemWindows(window, false); } } diff --git a/shell/platform/android/io/flutter/embedding/android/FlutterFragmentActivity.java b/shell/platform/android/io/flutter/embedding/android/FlutterFragmentActivity.java index f37b4157cec2f..16f4ba41d006e 100644 --- a/shell/platform/android/io/flutter/embedding/android/FlutterFragmentActivity.java +++ b/shell/platform/android/io/flutter/embedding/android/FlutterFragmentActivity.java @@ -489,11 +489,7 @@ private void configureStatusBarForFullscreenFlutterExperience() { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(0x40000000); - if (Build.VERSION.SDK_INT >= 30) { - WindowCompat.setDecorFitsSystemWindows(window, false); - } else { - window.getDecorView().setSystemUiVisibility(PlatformPlugin.DEFAULT_SYSTEM_UI); - } + WindowCompat.setDecorFitsSystemWindows(window, false); } } From 1e6065639d890abc6411a57ba95c8708032d06c4 Mon Sep 17 00:00:00 2001 From: camsim99 Date: Thu, 2 Dec 2021 18:17:01 -0500 Subject: [PATCH 18/39] Format files --- .../flutter/app/FlutterActivityDelegate.java | 1 - .../android/FlutterFragmentActivity.java | 1 - .../plugin/platform/PlatformPlugin.java | 42 +++++++++---------- 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java b/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java index af00d09510fed..afc3ac9ae640d 100644 --- a/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java +++ b/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java @@ -27,7 +27,6 @@ import androidx.core.view.WindowCompat; import io.flutter.Log; import io.flutter.plugin.common.PluginRegistry; -import io.flutter.plugin.platform.PlatformPlugin; import io.flutter.util.Preconditions; import io.flutter.view.FlutterMain; import io.flutter.view.FlutterNativeView; diff --git a/shell/platform/android/io/flutter/embedding/android/FlutterFragmentActivity.java b/shell/platform/android/io/flutter/embedding/android/FlutterFragmentActivity.java index 16f4ba41d006e..af5df2c687cdc 100644 --- a/shell/platform/android/io/flutter/embedding/android/FlutterFragmentActivity.java +++ b/shell/platform/android/io/flutter/embedding/android/FlutterFragmentActivity.java @@ -45,7 +45,6 @@ import io.flutter.embedding.engine.FlutterEngine; import io.flutter.embedding.engine.FlutterShellArgs; import io.flutter.embedding.engine.plugins.util.GeneratedPluginRegister; -import io.flutter.plugin.platform.PlatformPlugin; /** * A Flutter {@code Activity} that is based upon {@link FragmentActivity}. diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java index f768950d49c6c..3eb460fef644f 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java @@ -256,11 +256,10 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys // the system overlay has changed. The overlays cannot be dismissed, so adding the callback // support will allow users to restore the system ui and dismiss the overlays. // Not compatible with top/bottom overlays enabled. - windowInsetsControllerCompat.setSystemBarsBehavior( - WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_TOUCH); - WindowCompat.setDecorFitsSystemWindows(window, false); - windowInsetsControllerCompat.hide( - WindowInsetsCompat.Type.systemBars()); + windowInsetsControllerCompat.setSystemBarsBehavior( + WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_TOUCH); + WindowCompat.setDecorFitsSystemWindows(window, false); + windowInsetsControllerCompat.hide(WindowInsetsCompat.Type.systemBars()); } else if (systemUiMode == PlatformChannel.SystemUiMode.IMMERSIVE && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { // IMMERSIVE @@ -270,11 +269,10 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys // the system overlay has changed. The overlays cannot be dismissed, so adding callback // support will allow users to restore the system ui and dismiss the overlays. // Not compatible with top/bottom overlays enabled. - windowInsetsControllerCompat.setSystemBarsBehavior( - WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_SWIPE); - WindowCompat.setDecorFitsSystemWindows(window, false); - windowInsetsControllerCompat.hide( - WindowInsetsCompat.Type.systemBars()); + windowInsetsControllerCompat.setSystemBarsBehavior( + WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_SWIPE); + WindowCompat.setDecorFitsSystemWindows(window, false); + windowInsetsControllerCompat.hide(WindowInsetsCompat.Type.systemBars()); } else if (systemUiMode == PlatformChannel.SystemUiMode.IMMERSIVE_STICKY && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { @@ -284,11 +282,10 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys // the swipe gesture. The overlays cannot be dismissed, so adding callback support will // allow users to restore the system ui and dismiss the overlays. // Not compatible with top/bottom overlays enabled. - windowInsetsControllerCompat.setSystemBarsBehavior( - WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); - WindowCompat.setDecorFitsSystemWindows(window, false); - windowInsetsControllerCompat.hide( - WindowInsetsCompat.Type.systemBars()); + windowInsetsControllerCompat.setSystemBarsBehavior( + WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); + WindowCompat.setDecorFitsSystemWindows(window, false); + windowInsetsControllerCompat.hide(WindowInsetsCompat.Type.systemBars()); } else if (systemUiMode == PlatformChannel.SystemUiMode.EDGE_TO_EDGE && Build.VERSION.SDK_INT >= 29) { // EDGE TO EDGE @@ -296,14 +293,17 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys // SDK 29 and up will apply a translucent body scrim behind 2/3 button navigation bars // to ensure contrast with buttons on the nav and status bars, unless the contrast is not // enforced in the overlay styling. - WindowCompat.setDecorFitsSystemWindows(window, false); + WindowCompat.setDecorFitsSystemWindows(window, false); } else { // When none of the conditions are matched, return without updating the system UI overlays. return; } } - /** @deprecated This feature was deprecated after v2.3.0-17.0.pre. Use setEnabledSystemUIMode instead. */ + /** + * @deprecated This feature was deprecated after v2.3.0-17.0.pre. Use setEnabledSystemUIMode + * instead. + */ @Deprecated private void setSystemChromeEnabledSystemUIOverlays( List overlaysToShow) { @@ -319,7 +319,7 @@ private void setSystemChromeEnabledSystemUIOverlays( // apply it // if desired, and if the current Android version is 19 or greater. if (overlaysToShow.size() == 0 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - enabledOverlays |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; + enabledOverlays |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; } // Re-add any desired system overlays. @@ -327,11 +327,11 @@ private void setSystemChromeEnabledSystemUIOverlays( PlatformChannel.SystemUiOverlay overlayToShow = overlaysToShow.get(i); switch (overlayToShow) { case TOP_OVERLAYS: - enabledOverlays &= ~View.SYSTEM_UI_FLAG_FULLSCREEN; + enabledOverlays &= ~View.SYSTEM_UI_FLAG_FULLSCREEN; break; case BOTTOM_OVERLAYS: - enabledOverlays &= ~View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION; - enabledOverlays &= ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; + enabledOverlays &= ~View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION; + enabledOverlays &= ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; break; } } From c27341303a9dd67f729cf99ae1999327c8b25642 Mon Sep 17 00:00:00 2001 From: camsim99 Date: Fri, 3 Dec 2021 12:48:56 -0500 Subject: [PATCH 19/39] Reformat file --- .../android/io/flutter/plugin/platform/PlatformPlugin.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java index 3eb460fef644f..0bddfb1d5089f 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java @@ -258,8 +258,8 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys // Not compatible with top/bottom overlays enabled. windowInsetsControllerCompat.setSystemBarsBehavior( WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_TOUCH); - WindowCompat.setDecorFitsSystemWindows(window, false); windowInsetsControllerCompat.hide(WindowInsetsCompat.Type.systemBars()); + WindowCompat.setDecorFitsSystemWindows(window, false); } else if (systemUiMode == PlatformChannel.SystemUiMode.IMMERSIVE && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { // IMMERSIVE @@ -271,9 +271,8 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys // Not compatible with top/bottom overlays enabled. windowInsetsControllerCompat.setSystemBarsBehavior( WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_SWIPE); - WindowCompat.setDecorFitsSystemWindows(window, false); windowInsetsControllerCompat.hide(WindowInsetsCompat.Type.systemBars()); - + WindowCompat.setDecorFitsSystemWindows(window, false); } else if (systemUiMode == PlatformChannel.SystemUiMode.IMMERSIVE_STICKY && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { // STICKY IMMERSIVE @@ -284,8 +283,8 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys // Not compatible with top/bottom overlays enabled. windowInsetsControllerCompat.setSystemBarsBehavior( WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); - WindowCompat.setDecorFitsSystemWindows(window, false); windowInsetsControllerCompat.hide(WindowInsetsCompat.Type.systemBars()); + WindowCompat.setDecorFitsSystemWindows(window, false); } else if (systemUiMode == PlatformChannel.SystemUiMode.EDGE_TO_EDGE && Build.VERSION.SDK_INT >= 29) { // EDGE TO EDGE From 19629c889c40c756a08fadeebf744c65165f52ad Mon Sep 17 00:00:00 2001 From: camsim99 Date: Mon, 6 Dec 2021 13:44:52 -0800 Subject: [PATCH 20/39] WIP fixing tests --- .../plugin/platform/PlatformPluginTest.java | 90 ++++++++++++------- .../platform/android/test_runner/build.gradle | 3 +- 2 files changed, 59 insertions(+), 34 deletions(-) diff --git a/shell/platform/android/test/io/flutter/plugin/platform/PlatformPluginTest.java b/shell/platform/android/test/io/flutter/plugin/platform/PlatformPluginTest.java index 3800ddfbff98e..28f20d59abea7 100644 --- a/shell/platform/android/test/io/flutter/plugin/platform/PlatformPluginTest.java +++ b/shell/platform/android/test/io/flutter/plugin/platform/PlatformPluginTest.java @@ -24,6 +24,8 @@ import android.view.Window; import android.view.WindowInsetsController; import androidx.activity.OnBackPressedCallback; +import androidx.core.view.WindowInsetsCompat; +import androidx.core.view.WindowInsetsControllerCompat; import androidx.fragment.app.FragmentActivity; import io.flutter.embedding.engine.systemchannels.PlatformChannel; import io.flutter.embedding.engine.systemchannels.PlatformChannel.Brightness; @@ -321,49 +323,71 @@ public void setSystemUiMode() { when(fakeActivity.getWindow()).thenReturn(fakeWindow); PlatformChannel fakePlatformChannel = mock(PlatformChannel.class); PlatformPlugin platformPlugin = new PlatformPlugin(fakeActivity, fakePlatformChannel); + // WindowInsetsControllerCompat windowInsetsControllerCompat = spy(new + // WindowInsetsControllerCompat(fakeWindow, fakeDecorView)); + WindowInsetsControllerCompat windowInsetsControllerCompat = + mock(WindowInsetsControllerCompat.class); if (Build.VERSION.SDK_INT >= 28) { platformPlugin.mPlatformMessageHandler.showSystemUiMode( PlatformChannel.SystemUiMode.LEAN_BACK); - verify(fakeDecorView) - .setSystemUiVisibility( - 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); + // verify(fakeDecorView) + // .setSystemUiVisibility( + // 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); + verify(windowInsetsControllerCompat) + .setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_TOUCH); + verify(windowInsetsControllerCompat).hide(WindowInsetsCompat.Type.systemBars()); + + // TODO: WindowCompat.setDecorFitsSystemWindows(window, false); + + // platformPlugin.mPlatformMessageHandler.showSystemUiMode( + // PlatformChannel.SystemUiMode.IMMERSIVE); + // verify(fakeDecorView) + // .setSystemUiVisibility( + // View.SYSTEM_UI_FLAG_IMMERSIVE + // | 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); + verify(windowInsetsControllerCompat) + .setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_SWIPE); + verify(windowInsetsControllerCompat).hide(WindowInsetsCompat.Type.systemBars()); + + // TODO: WindowCompat.setDecorFitsSystemWindows(window, false); + + // platformPlugin.mPlatformMessageHandler.showSystemUiMode( + // PlatformChannel.SystemUiMode.IMMERSIVE_STICKY); + // verify(fakeDecorView) + // .setSystemUiVisibility( + // View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY + // | 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); + verify(windowInsetsControllerCompat) + .setSystemBarsBehavior( + WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); + verify(windowInsetsControllerCompat).hide(WindowInsetsCompat.Type.systemBars()); + + // TODO: WindowCompat.setDecorFitsSystemWindows(window, false); - platformPlugin.mPlatformMessageHandler.showSystemUiMode( - PlatformChannel.SystemUiMode.IMMERSIVE); - verify(fakeDecorView) - .setSystemUiVisibility( - View.SYSTEM_UI_FLAG_IMMERSIVE - | 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); - - platformPlugin.mPlatformMessageHandler.showSystemUiMode( - PlatformChannel.SystemUiMode.IMMERSIVE_STICKY); - verify(fakeDecorView) - .setSystemUiVisibility( - View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY - | 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); } if (Build.VERSION.SDK_INT >= 29) { platformPlugin.mPlatformMessageHandler.showSystemUiMode( PlatformChannel.SystemUiMode.EDGE_TO_EDGE); - verify(fakeDecorView) - .setSystemUiVisibility( - View.SYSTEM_UI_FLAG_LAYOUT_STABLE - | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); + // verify(fakeDecorView) + // .setSystemUiVisibility( + // View.SYSTEM_UI_FLAG_LAYOUT_STABLE + // | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + // | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); + // TODO: WindowCompat.setDecorFitsSystemWindows(window, false); } } diff --git a/shell/platform/android/test_runner/build.gradle b/shell/platform/android/test_runner/build.gradle index 10945a98a489d..f83ab0e716e3e 100644 --- a/shell/platform/android/test_runner/build.gradle +++ b/shell/platform/android/test_runner/build.gradle @@ -46,7 +46,8 @@ android { testImplementation "androidx.window:window-java:1.0.0-beta04" testImplementation "com.google.android.play:core:1.8.0" testImplementation "com.ibm.icu:icu4j:69.1" - testImplementation "org.mockito:mockito-core:3.11.2" + testImplementation "org.mockito:mockito-core:3.12.4" + testImplementation "org.mockito:mockito-inline:3.12.4" testImplementation "org.robolectric:robolectric:4.6.1" testImplementation "junit:junit:4.13" } From e9b106a23bc66548bc62197f38d4a5acc7abe77c Mon Sep 17 00:00:00 2001 From: camsim99 Date: Tue, 7 Dec 2021 09:55:35 -0800 Subject: [PATCH 21/39] Undo mockito version bump --- shell/platform/android/test_runner/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shell/platform/android/test_runner/build.gradle b/shell/platform/android/test_runner/build.gradle index f83ab0e716e3e..3615cab3e0859 100644 --- a/shell/platform/android/test_runner/build.gradle +++ b/shell/platform/android/test_runner/build.gradle @@ -46,8 +46,8 @@ android { testImplementation "androidx.window:window-java:1.0.0-beta04" testImplementation "com.google.android.play:core:1.8.0" testImplementation "com.ibm.icu:icu4j:69.1" - testImplementation "org.mockito:mockito-core:3.12.4" - testImplementation "org.mockito:mockito-inline:3.12.4" + testImplementation "org.mockito:mockito-core:3.11.2" + testImplementation "org.mockito:mockito-inline:3.11.2" testImplementation "org.robolectric:robolectric:4.6.1" testImplementation "junit:junit:4.13" } From 7c6c8f3c204e1a64dc9953c0eafc6998c707020c Mon Sep 17 00:00:00 2001 From: camsim99 Date: Mon, 13 Dec 2021 12:47:54 -0800 Subject: [PATCH 22/39] Fix test --- .../plugin/platform/PlatformPluginTest.java | 120 ++++++++++-------- 1 file changed, 64 insertions(+), 56 deletions(-) diff --git a/shell/platform/android/test/io/flutter/plugin/platform/PlatformPluginTest.java b/shell/platform/android/test/io/flutter/plugin/platform/PlatformPluginTest.java index 28f20d59abea7..7559a21aba534 100644 --- a/shell/platform/android/test/io/flutter/plugin/platform/PlatformPluginTest.java +++ b/shell/platform/android/test/io/flutter/plugin/platform/PlatformPluginTest.java @@ -313,7 +313,7 @@ public void setStatusBarIconBrightness() { } } - @Config(sdk = 29) + @Config(minSdk = 29) @Test public void setSystemUiMode() { View fakeDecorView = mock(View.class); @@ -323,71 +323,79 @@ public void setSystemUiMode() { when(fakeActivity.getWindow()).thenReturn(fakeWindow); PlatformChannel fakePlatformChannel = mock(PlatformChannel.class); PlatformPlugin platformPlugin = new PlatformPlugin(fakeActivity, fakePlatformChannel); - // WindowInsetsControllerCompat windowInsetsControllerCompat = spy(new - // WindowInsetsControllerCompat(fakeWindow, fakeDecorView)); - WindowInsetsControllerCompat windowInsetsControllerCompat = - mock(WindowInsetsControllerCompat.class); + WindowInsetsController fakeWindowInsetsController = mock(WindowInsetsController.class); + when(fakeWindow.getInsetsController()).thenReturn(fakeWindowInsetsController); if (Build.VERSION.SDK_INT >= 28) { platformPlugin.mPlatformMessageHandler.showSystemUiMode( PlatformChannel.SystemUiMode.LEAN_BACK); - // verify(fakeDecorView) - // .setSystemUiVisibility( - // 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); - verify(windowInsetsControllerCompat) - .setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_TOUCH); - verify(windowInsetsControllerCompat).hide(WindowInsetsCompat.Type.systemBars()); - - // TODO: WindowCompat.setDecorFitsSystemWindows(window, false); - - // platformPlugin.mPlatformMessageHandler.showSystemUiMode( - // PlatformChannel.SystemUiMode.IMMERSIVE); - // verify(fakeDecorView) - // .setSystemUiVisibility( - // View.SYSTEM_UI_FLAG_IMMERSIVE - // | 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); - verify(windowInsetsControllerCompat) - .setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_SWIPE); - verify(windowInsetsControllerCompat).hide(WindowInsetsCompat.Type.systemBars()); - - // TODO: WindowCompat.setDecorFitsSystemWindows(window, false); - - // platformPlugin.mPlatformMessageHandler.showSystemUiMode( - // PlatformChannel.SystemUiMode.IMMERSIVE_STICKY); - // verify(fakeDecorView) - // .setSystemUiVisibility( - // View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY - // | 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); - verify(windowInsetsControllerCompat) - .setSystemBarsBehavior( - WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); - verify(windowInsetsControllerCompat).hide(WindowInsetsCompat.Type.systemBars()); - - // TODO: WindowCompat.setDecorFitsSystemWindows(window, false); + if (Build.VERSION.SDK_INT < 30) { + verify(fakeDecorView).setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN); + verify(fakeDecorView).setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); + verify(fakeDecorView) + .setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); + } else { + verify(fakeWindowInsetsController) + .setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_TOUCH); + verify(fakeWindowInsetsController).hide(WindowInsetsCompat.Type.systemBars()); + verify(fakeWindow).setDecorFitsSystemWindows(false); + } + + platformPlugin.mPlatformMessageHandler.showSystemUiMode( + PlatformChannel.SystemUiMode.IMMERSIVE); + if (Build.VERSION.SDK_INT < 30) { + verify(fakeDecorView).setSystemUiVisibility(View.SYSTEM_UI_FLAG_IMMERSIVE); + verify(fakeDecorView, times(2)).setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN); + verify(fakeDecorView, times(2)).setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); + verify(fakeDecorView, times(2)) + .setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); + } else { + verify(fakeWindowInsetsController) + .setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_SWIPE); + verify(fakeWindowInsetsController, times(2)).hide(WindowInsetsCompat.Type.systemBars()); + verify(fakeWindow, times(2)).setDecorFitsSystemWindows(false); + } + + platformPlugin.mPlatformMessageHandler.showSystemUiMode( + PlatformChannel.SystemUiMode.IMMERSIVE_STICKY); + if (Build.VERSION.SDK_INT < 30) { + verify(fakeDecorView).setSystemUiVisibility(View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); + verify(fakeDecorView, times(3)).setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN); + verify(fakeDecorView, times(3)).setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); + verify(fakeDecorView, times(3)) + .setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); + } else { + verify(fakeWindowInsetsController) + .setSystemBarsBehavior( + WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); + verify(fakeWindowInsetsController, times(3)).hide(WindowInsetsCompat.Type.systemBars()); + verify(fakeWindow, times(3)).setDecorFitsSystemWindows(false); + } } if (Build.VERSION.SDK_INT >= 29) { platformPlugin.mPlatformMessageHandler.showSystemUiMode( PlatformChannel.SystemUiMode.EDGE_TO_EDGE); - // verify(fakeDecorView) - // .setSystemUiVisibility( - // View.SYSTEM_UI_FLAG_LAYOUT_STABLE - // | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION - // | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); - // TODO: WindowCompat.setDecorFitsSystemWindows(window, false); + + if (Build.VERSION.SDK_INT < 30) { + verify(fakeDecorView, times(4)) + .setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); + } else { + verify(fakeWindow, times(4)).setDecorFitsSystemWindows(false); + } } } From 73b030d6885b6ec62f372b5a9067da600385407d Mon Sep 17 00:00:00 2001 From: camsim99 Date: Mon, 13 Dec 2021 12:57:57 -0800 Subject: [PATCH 23/39] Change signs for consistency --- .../plugin/platform/PlatformPluginTest.java | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/shell/platform/android/test/io/flutter/plugin/platform/PlatformPluginTest.java b/shell/platform/android/test/io/flutter/plugin/platform/PlatformPluginTest.java index 7559a21aba534..af299eabfa08f 100644 --- a/shell/platform/android/test/io/flutter/plugin/platform/PlatformPluginTest.java +++ b/shell/platform/android/test/io/flutter/plugin/platform/PlatformPluginTest.java @@ -330,7 +330,13 @@ public void setSystemUiMode() { platformPlugin.mPlatformMessageHandler.showSystemUiMode( PlatformChannel.SystemUiMode.LEAN_BACK); - if (Build.VERSION.SDK_INT < 30) { + if (Build.VERSION.SDK_INT >= 30) { + verify(fakeWindowInsetsController) + .setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_TOUCH); + verify(fakeWindowInsetsController).hide(WindowInsetsCompat.Type.systemBars()); + verify(fakeWindow).setDecorFitsSystemWindows(false); + + } else { verify(fakeDecorView).setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN); verify(fakeDecorView).setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); verify(fakeDecorView) @@ -338,16 +344,16 @@ public void setSystemUiMode() { View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); - } else { - verify(fakeWindowInsetsController) - .setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_TOUCH); - verify(fakeWindowInsetsController).hide(WindowInsetsCompat.Type.systemBars()); - verify(fakeWindow).setDecorFitsSystemWindows(false); } platformPlugin.mPlatformMessageHandler.showSystemUiMode( PlatformChannel.SystemUiMode.IMMERSIVE); - if (Build.VERSION.SDK_INT < 30) { + if (Build.VERSION.SDK_INT >= 30) { + verify(fakeWindowInsetsController) + .setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_SWIPE); + verify(fakeWindowInsetsController, times(2)).hide(WindowInsetsCompat.Type.systemBars()); + verify(fakeWindow, times(2)).setDecorFitsSystemWindows(false); + } else { verify(fakeDecorView).setSystemUiVisibility(View.SYSTEM_UI_FLAG_IMMERSIVE); verify(fakeDecorView, times(2)).setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN); verify(fakeDecorView, times(2)).setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); @@ -356,16 +362,17 @@ public void setSystemUiMode() { View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); - } else { - verify(fakeWindowInsetsController) - .setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_SWIPE); - verify(fakeWindowInsetsController, times(2)).hide(WindowInsetsCompat.Type.systemBars()); - verify(fakeWindow, times(2)).setDecorFitsSystemWindows(false); } platformPlugin.mPlatformMessageHandler.showSystemUiMode( PlatformChannel.SystemUiMode.IMMERSIVE_STICKY); - if (Build.VERSION.SDK_INT < 30) { + if (Build.VERSION.SDK_INT >= 30) { + verify(fakeWindowInsetsController) + .setSystemBarsBehavior( + WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); + verify(fakeWindowInsetsController, times(3)).hide(WindowInsetsCompat.Type.systemBars()); + verify(fakeWindow, times(3)).setDecorFitsSystemWindows(false); + } else { verify(fakeDecorView).setSystemUiVisibility(View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); verify(fakeDecorView, times(3)).setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN); verify(fakeDecorView, times(3)).setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); @@ -374,12 +381,6 @@ public void setSystemUiMode() { View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); - } else { - verify(fakeWindowInsetsController) - .setSystemBarsBehavior( - WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); - verify(fakeWindowInsetsController, times(3)).hide(WindowInsetsCompat.Type.systemBars()); - verify(fakeWindow, times(3)).setDecorFitsSystemWindows(false); } } @@ -387,14 +388,14 @@ public void setSystemUiMode() { platformPlugin.mPlatformMessageHandler.showSystemUiMode( PlatformChannel.SystemUiMode.EDGE_TO_EDGE); - if (Build.VERSION.SDK_INT < 30) { + if (Build.VERSION.SDK_INT >= 30) { + verify(fakeWindow, times(4)).setDecorFitsSystemWindows(false); + } else { verify(fakeDecorView, times(4)) .setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); - } else { - verify(fakeWindow, times(4)).setDecorFitsSystemWindows(false); } } } From 03f8d3bde14162a3624ecd4c13b35877326211cc Mon Sep 17 00:00:00 2001 From: camsim99 Date: Mon, 13 Dec 2021 14:12:16 -0800 Subject: [PATCH 24/39] Fix Linux Unopt errors --- .../plugin/platform/PlatformPlugin.java | 3 +- .../plugin/platform/PlatformPluginTest.java | 136 ++++++++++-------- 2 files changed, 80 insertions(+), 59 deletions(-) diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java index 0bddfb1d5089f..4328ff8cb306d 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java @@ -247,8 +247,7 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys WindowInsetsControllerCompat windowInsetsControllerCompat = new WindowInsetsControllerCompat(window, view); - if (systemUiMode == PlatformChannel.SystemUiMode.LEAN_BACK - && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + if (systemUiMode == PlatformChannel.SystemUiMode.LEAN_BACK) { // LEAN BACK // Available starting at SDK 16 // Should not show overlays, tap to reveal overlays, needs onChange callback diff --git a/shell/platform/android/test/io/flutter/plugin/platform/PlatformPluginTest.java b/shell/platform/android/test/io/flutter/plugin/platform/PlatformPluginTest.java index af299eabfa08f..2b83bd3b8c788 100644 --- a/shell/platform/android/test/io/flutter/plugin/platform/PlatformPluginTest.java +++ b/shell/platform/android/test/io/flutter/plugin/platform/PlatformPluginTest.java @@ -313,7 +313,67 @@ public void setStatusBarIconBrightness() { } } - @Config(minSdk = 29) + @Config(sdk = 29) + @Test + public void setSystemUiModeLegacy() { + View fakeDecorView = mock(View.class); + Window fakeWindow = mock(Window.class); + when(fakeWindow.getDecorView()).thenReturn(fakeDecorView); + Activity fakeActivity = mock(Activity.class); + when(fakeActivity.getWindow()).thenReturn(fakeWindow); + PlatformChannel fakePlatformChannel = mock(PlatformChannel.class); + PlatformPlugin platformPlugin = new PlatformPlugin(fakeActivity, fakePlatformChannel); + + if (Build.VERSION.SDK_INT >= 28) { + platformPlugin.mPlatformMessageHandler.showSystemUiMode( + PlatformChannel.SystemUiMode.LEAN_BACK); + + verify(fakeDecorView).setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN); + verify(fakeDecorView).setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); + verify(fakeDecorView) + .setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); + + platformPlugin.mPlatformMessageHandler.showSystemUiMode( + PlatformChannel.SystemUiMode.IMMERSIVE); + + verify(fakeDecorView).setSystemUiVisibility(View.SYSTEM_UI_FLAG_IMMERSIVE); + verify(fakeDecorView, times(2)).setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN); + verify(fakeDecorView, times(2)).setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); + verify(fakeDecorView, times(2)) + .setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); + + platformPlugin.mPlatformMessageHandler.showSystemUiMode( + PlatformChannel.SystemUiMode.IMMERSIVE_STICKY); + + verify(fakeDecorView).setSystemUiVisibility(View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); + verify(fakeDecorView, times(3)).setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN); + verify(fakeDecorView, times(3)).setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); + verify(fakeDecorView, times(3)) + .setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); + } + + if (Build.VERSION.SDK_INT >= 29) { + platformPlugin.mPlatformMessageHandler.showSystemUiMode( + PlatformChannel.SystemUiMode.EDGE_TO_EDGE); + + verify(fakeDecorView, times(4)) + .setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); + } + } + + @Config(minSdk = 30) @Test public void setSystemUiMode() { View fakeDecorView = mock(View.class); @@ -323,80 +383,42 @@ public void setSystemUiMode() { when(fakeActivity.getWindow()).thenReturn(fakeWindow); PlatformChannel fakePlatformChannel = mock(PlatformChannel.class); PlatformPlugin platformPlugin = new PlatformPlugin(fakeActivity, fakePlatformChannel); - WindowInsetsController fakeWindowInsetsController = mock(WindowInsetsController.class); + WindowInsetsController fakeWindowInsetsController; + fakeWindowInsetsController = mock(WindowInsetsController.class); when(fakeWindow.getInsetsController()).thenReturn(fakeWindowInsetsController); if (Build.VERSION.SDK_INT >= 28) { platformPlugin.mPlatformMessageHandler.showSystemUiMode( PlatformChannel.SystemUiMode.LEAN_BACK); - if (Build.VERSION.SDK_INT >= 30) { - verify(fakeWindowInsetsController) - .setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_TOUCH); - verify(fakeWindowInsetsController).hide(WindowInsetsCompat.Type.systemBars()); - verify(fakeWindow).setDecorFitsSystemWindows(false); - - } else { - verify(fakeDecorView).setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN); - verify(fakeDecorView).setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); - verify(fakeDecorView) - .setSystemUiVisibility( - View.SYSTEM_UI_FLAG_LAYOUT_STABLE - | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); - } + verify(fakeWindowInsetsController) + .setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_TOUCH); + verify(fakeWindowInsetsController).hide(WindowInsetsCompat.Type.systemBars()); + verify(fakeWindow).setDecorFitsSystemWindows(false); platformPlugin.mPlatformMessageHandler.showSystemUiMode( PlatformChannel.SystemUiMode.IMMERSIVE); - if (Build.VERSION.SDK_INT >= 30) { - verify(fakeWindowInsetsController) - .setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_SWIPE); - verify(fakeWindowInsetsController, times(2)).hide(WindowInsetsCompat.Type.systemBars()); - verify(fakeWindow, times(2)).setDecorFitsSystemWindows(false); - } else { - verify(fakeDecorView).setSystemUiVisibility(View.SYSTEM_UI_FLAG_IMMERSIVE); - verify(fakeDecorView, times(2)).setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN); - verify(fakeDecorView, times(2)).setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); - verify(fakeDecorView, times(2)) - .setSystemUiVisibility( - View.SYSTEM_UI_FLAG_LAYOUT_STABLE - | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); - } + + verify(fakeWindowInsetsController) + .setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_SWIPE); + verify(fakeWindowInsetsController, times(2)).hide(WindowInsetsCompat.Type.systemBars()); + verify(fakeWindow, times(2)).setDecorFitsSystemWindows(false); platformPlugin.mPlatformMessageHandler.showSystemUiMode( PlatformChannel.SystemUiMode.IMMERSIVE_STICKY); - if (Build.VERSION.SDK_INT >= 30) { - verify(fakeWindowInsetsController) - .setSystemBarsBehavior( - WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); - verify(fakeWindowInsetsController, times(3)).hide(WindowInsetsCompat.Type.systemBars()); - verify(fakeWindow, times(3)).setDecorFitsSystemWindows(false); - } else { - verify(fakeDecorView).setSystemUiVisibility(View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); - verify(fakeDecorView, times(3)).setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN); - verify(fakeDecorView, times(3)).setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); - verify(fakeDecorView, times(3)) - .setSystemUiVisibility( - View.SYSTEM_UI_FLAG_LAYOUT_STABLE - | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); - } + + verify(fakeWindowInsetsController) + .setSystemBarsBehavior( + WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); + verify(fakeWindowInsetsController, times(3)).hide(WindowInsetsCompat.Type.systemBars()); + verify(fakeWindow, times(3)).setDecorFitsSystemWindows(false); } if (Build.VERSION.SDK_INT >= 29) { platformPlugin.mPlatformMessageHandler.showSystemUiMode( PlatformChannel.SystemUiMode.EDGE_TO_EDGE); - if (Build.VERSION.SDK_INT >= 30) { - verify(fakeWindow, times(4)).setDecorFitsSystemWindows(false); - } else { - verify(fakeDecorView, times(4)) - .setSystemUiVisibility( - View.SYSTEM_UI_FLAG_LAYOUT_STABLE - | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); - } + verify(fakeWindow, times(4)).setDecorFitsSystemWindows(false); } } From 091cd5cb6fae4a36ca9dea94de5607504b919a14 Mon Sep 17 00:00:00 2001 From: camsim99 Date: Mon, 13 Dec 2021 15:29:35 -0800 Subject: [PATCH 25/39] Add version check --- .../plugin/platform/PlatformPluginTest.java | 72 ++++++++++--------- 1 file changed, 37 insertions(+), 35 deletions(-) diff --git a/shell/platform/android/test/io/flutter/plugin/platform/PlatformPluginTest.java b/shell/platform/android/test/io/flutter/plugin/platform/PlatformPluginTest.java index 2b83bd3b8c788..b5193f01c5f06 100644 --- a/shell/platform/android/test/io/flutter/plugin/platform/PlatformPluginTest.java +++ b/shell/platform/android/test/io/flutter/plugin/platform/PlatformPluginTest.java @@ -376,49 +376,51 @@ public void setSystemUiModeLegacy() { @Config(minSdk = 30) @Test public void setSystemUiMode() { - View fakeDecorView = mock(View.class); - Window fakeWindow = mock(Window.class); - when(fakeWindow.getDecorView()).thenReturn(fakeDecorView); - Activity fakeActivity = mock(Activity.class); - when(fakeActivity.getWindow()).thenReturn(fakeWindow); - PlatformChannel fakePlatformChannel = mock(PlatformChannel.class); - PlatformPlugin platformPlugin = new PlatformPlugin(fakeActivity, fakePlatformChannel); - WindowInsetsController fakeWindowInsetsController; - fakeWindowInsetsController = mock(WindowInsetsController.class); - when(fakeWindow.getInsetsController()).thenReturn(fakeWindowInsetsController); + if (Build.VERSION.SDK_INT >= 30) { + View fakeDecorView = mock(View.class); + Window fakeWindow = mock(Window.class); + when(fakeWindow.getDecorView()).thenReturn(fakeDecorView); + Activity fakeActivity = mock(Activity.class); + when(fakeActivity.getWindow()).thenReturn(fakeWindow); + PlatformChannel fakePlatformChannel = mock(PlatformChannel.class); + PlatformPlugin platformPlugin = new PlatformPlugin(fakeActivity, fakePlatformChannel); + WindowInsetsController fakeWindowInsetsController; + fakeWindowInsetsController = mock(WindowInsetsController.class); + when(fakeWindow.getInsetsController()).thenReturn(fakeWindowInsetsController); - if (Build.VERSION.SDK_INT >= 28) { - platformPlugin.mPlatformMessageHandler.showSystemUiMode( - PlatformChannel.SystemUiMode.LEAN_BACK); + if (Build.VERSION.SDK_INT >= 28) { + platformPlugin.mPlatformMessageHandler.showSystemUiMode( + PlatformChannel.SystemUiMode.LEAN_BACK); - verify(fakeWindowInsetsController) - .setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_TOUCH); - verify(fakeWindowInsetsController).hide(WindowInsetsCompat.Type.systemBars()); - verify(fakeWindow).setDecorFitsSystemWindows(false); + verify(fakeWindowInsetsController) + .setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_TOUCH); + verify(fakeWindowInsetsController).hide(WindowInsetsCompat.Type.systemBars()); + verify(fakeWindow).setDecorFitsSystemWindows(false); - platformPlugin.mPlatformMessageHandler.showSystemUiMode( - PlatformChannel.SystemUiMode.IMMERSIVE); + platformPlugin.mPlatformMessageHandler.showSystemUiMode( + PlatformChannel.SystemUiMode.IMMERSIVE); - verify(fakeWindowInsetsController) - .setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_SWIPE); - verify(fakeWindowInsetsController, times(2)).hide(WindowInsetsCompat.Type.systemBars()); - verify(fakeWindow, times(2)).setDecorFitsSystemWindows(false); + verify(fakeWindowInsetsController) + .setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_SWIPE); + verify(fakeWindowInsetsController, times(2)).hide(WindowInsetsCompat.Type.systemBars()); + verify(fakeWindow, times(2)).setDecorFitsSystemWindows(false); - platformPlugin.mPlatformMessageHandler.showSystemUiMode( - PlatformChannel.SystemUiMode.IMMERSIVE_STICKY); + platformPlugin.mPlatformMessageHandler.showSystemUiMode( + PlatformChannel.SystemUiMode.IMMERSIVE_STICKY); - verify(fakeWindowInsetsController) - .setSystemBarsBehavior( - WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); - verify(fakeWindowInsetsController, times(3)).hide(WindowInsetsCompat.Type.systemBars()); - verify(fakeWindow, times(3)).setDecorFitsSystemWindows(false); - } + verify(fakeWindowInsetsController) + .setSystemBarsBehavior( + WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); + verify(fakeWindowInsetsController, times(3)).hide(WindowInsetsCompat.Type.systemBars()); + verify(fakeWindow, times(3)).setDecorFitsSystemWindows(false); + } - if (Build.VERSION.SDK_INT >= 29) { - platformPlugin.mPlatformMessageHandler.showSystemUiMode( - PlatformChannel.SystemUiMode.EDGE_TO_EDGE); + if (Build.VERSION.SDK_INT >= 29) { + platformPlugin.mPlatformMessageHandler.showSystemUiMode( + PlatformChannel.SystemUiMode.EDGE_TO_EDGE); - verify(fakeWindow, times(4)).setDecorFitsSystemWindows(false); + verify(fakeWindow, times(4)).setDecorFitsSystemWindows(false); + } } } From 0f0fc71f8abbd4fd957047d945b117706d059636 Mon Sep 17 00:00:00 2001 From: camsim99 Date: Mon, 13 Dec 2021 15:36:01 -0800 Subject: [PATCH 26/39] Remove unecessary checks --- .../plugin/platform/PlatformPluginTest.java | 62 +++++++++---------- 1 file changed, 29 insertions(+), 33 deletions(-) diff --git a/shell/platform/android/test/io/flutter/plugin/platform/PlatformPluginTest.java b/shell/platform/android/test/io/flutter/plugin/platform/PlatformPluginTest.java index b5193f01c5f06..0fed4b3d239f1 100644 --- a/shell/platform/android/test/io/flutter/plugin/platform/PlatformPluginTest.java +++ b/shell/platform/android/test/io/flutter/plugin/platform/PlatformPluginTest.java @@ -388,39 +388,35 @@ public void setSystemUiMode() { fakeWindowInsetsController = mock(WindowInsetsController.class); when(fakeWindow.getInsetsController()).thenReturn(fakeWindowInsetsController); - if (Build.VERSION.SDK_INT >= 28) { - platformPlugin.mPlatformMessageHandler.showSystemUiMode( - PlatformChannel.SystemUiMode.LEAN_BACK); - - verify(fakeWindowInsetsController) - .setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_TOUCH); - verify(fakeWindowInsetsController).hide(WindowInsetsCompat.Type.systemBars()); - verify(fakeWindow).setDecorFitsSystemWindows(false); - - platformPlugin.mPlatformMessageHandler.showSystemUiMode( - PlatformChannel.SystemUiMode.IMMERSIVE); - - verify(fakeWindowInsetsController) - .setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_SWIPE); - verify(fakeWindowInsetsController, times(2)).hide(WindowInsetsCompat.Type.systemBars()); - verify(fakeWindow, times(2)).setDecorFitsSystemWindows(false); - - platformPlugin.mPlatformMessageHandler.showSystemUiMode( - PlatformChannel.SystemUiMode.IMMERSIVE_STICKY); - - verify(fakeWindowInsetsController) - .setSystemBarsBehavior( - WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); - verify(fakeWindowInsetsController, times(3)).hide(WindowInsetsCompat.Type.systemBars()); - verify(fakeWindow, times(3)).setDecorFitsSystemWindows(false); - } - - if (Build.VERSION.SDK_INT >= 29) { - platformPlugin.mPlatformMessageHandler.showSystemUiMode( - PlatformChannel.SystemUiMode.EDGE_TO_EDGE); - - verify(fakeWindow, times(4)).setDecorFitsSystemWindows(false); - } + platformPlugin.mPlatformMessageHandler.showSystemUiMode( + PlatformChannel.SystemUiMode.LEAN_BACK); + + verify(fakeWindowInsetsController) + .setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_TOUCH); + verify(fakeWindowInsetsController).hide(WindowInsetsCompat.Type.systemBars()); + verify(fakeWindow).setDecorFitsSystemWindows(false); + + platformPlugin.mPlatformMessageHandler.showSystemUiMode( + PlatformChannel.SystemUiMode.IMMERSIVE); + + verify(fakeWindowInsetsController) + .setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_SWIPE); + verify(fakeWindowInsetsController, times(2)).hide(WindowInsetsCompat.Type.systemBars()); + verify(fakeWindow, times(2)).setDecorFitsSystemWindows(false); + + platformPlugin.mPlatformMessageHandler.showSystemUiMode( + PlatformChannel.SystemUiMode.IMMERSIVE_STICKY); + + verify(fakeWindowInsetsController) + .setSystemBarsBehavior( + WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); + verify(fakeWindowInsetsController, times(3)).hide(WindowInsetsCompat.Type.systemBars()); + verify(fakeWindow, times(3)).setDecorFitsSystemWindows(false); + + platformPlugin.mPlatformMessageHandler.showSystemUiMode( + PlatformChannel.SystemUiMode.EDGE_TO_EDGE); + + verify(fakeWindow, times(4)).setDecorFitsSystemWindows(false); } } From ea9c1ea96b0e7230c0fe908eab6b1a7fc107511a Mon Sep 17 00:00:00 2001 From: camsim99 Date: Tue, 14 Dec 2021 09:02:58 -0800 Subject: [PATCH 27/39] Undo deprecation --- .../android/io/flutter/plugin/platform/PlatformPlugin.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java index 4328ff8cb306d..e824ed60e7956 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java @@ -298,11 +298,6 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys } } - /** - * @deprecated This feature was deprecated after v2.3.0-17.0.pre. Use setEnabledSystemUIMode - * instead. - */ - @Deprecated private void setSystemChromeEnabledSystemUIOverlays( List overlaysToShow) { // Start by assuming we want to hide all system overlays (like an immersive From 2e009097106361f50d67b1fd147b50088eb08be9 Mon Sep 17 00:00:00 2001 From: camsim99 Date: Tue, 14 Dec 2021 09:54:29 -0800 Subject: [PATCH 28/39] Update method, leave todo --- .../plugin/platform/PlatformPlugin.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java index e824ed60e7956..1834189e67a76 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java @@ -300,19 +300,22 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys private void setSystemChromeEnabledSystemUIOverlays( List overlaysToShow) { + Window window = activity.getWindow(); + View view = window.getDecorView(); + WindowInsetsControllerCompat windowInsetsControllerCompat = + new WindowInsetsControllerCompat(window, view); + // Start by assuming we want to hide all system overlays (like an immersive // game). - int enabledOverlays = - DEFAULT_SYSTEM_UI - | View.SYSTEM_UI_FLAG_FULLSCREEN - | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; + windowInsetsControllerCompat.hide(WindowInsetsCompat.Type.systemBars()); + WindowCompat.setDecorFitsSystemWindows(window, false); // The SYSTEM_UI_FLAG_IMMERSIVE_STICKY flag was introduced in API 19, so we // apply it // if desired, and if the current Android version is 19 or greater. if (overlaysToShow.size() == 0 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - enabledOverlays |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; + windowInsetsControllerCompat.setSystemBarsBehavior( + WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); } // Re-add any desired system overlays. @@ -320,17 +323,13 @@ private void setSystemChromeEnabledSystemUIOverlays( PlatformChannel.SystemUiOverlay overlayToShow = overlaysToShow.get(i); switch (overlayToShow) { case TOP_OVERLAYS: - enabledOverlays &= ~View.SYSTEM_UI_FLAG_FULLSCREEN; + windowInsetsControllerCompat.show(WindowInsetsCompat.Type.statusBars()); break; case BOTTOM_OVERLAYS: - enabledOverlays &= ~View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION; - enabledOverlays &= ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; + windowInsetsControllerCompat.show(WindowInsetsCompat.Type.navigationBars()); break; } } - - mEnabledOverlays = enabledOverlays; - updateSystemUiOverlays(); } /** @@ -342,6 +341,7 @@ private void setSystemChromeEnabledSystemUIOverlays( * PlatformPlugin}. */ public void updateSystemUiOverlays() { + //TODO: remove this call activity.getWindow().getDecorView().setSystemUiVisibility(mEnabledOverlays); if (currentTheme != null) { setSystemChromeSystemUIOverlayStyle(currentTheme); From 2a5215807c146089f95a276e93578dc0a041973d Mon Sep 17 00:00:00 2001 From: camsim99 Date: Tue, 14 Dec 2021 09:57:47 -0800 Subject: [PATCH 29/39] format --- .../android/io/flutter/plugin/platform/PlatformPlugin.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java index 1834189e67a76..eee883ddaffc2 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java @@ -315,7 +315,7 @@ private void setSystemChromeEnabledSystemUIOverlays( // if desired, and if the current Android version is 19 or greater. if (overlaysToShow.size() == 0 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { windowInsetsControllerCompat.setSystemBarsBehavior( - WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); + WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); } // Re-add any desired system overlays. @@ -341,7 +341,7 @@ private void setSystemChromeEnabledSystemUIOverlays( * PlatformPlugin}. */ public void updateSystemUiOverlays() { - //TODO: remove this call + // TODO: remove this call activity.getWindow().getDecorView().setSystemUiVisibility(mEnabledOverlays); if (currentTheme != null) { setSystemChromeSystemUIOverlayStyle(currentTheme); From 95dba21ed1f150d8c986c3b8d796dbc87b33a6a5 Mon Sep 17 00:00:00 2001 From: camsim99 Date: Tue, 14 Dec 2021 09:59:13 -0800 Subject: [PATCH 30/39] Update comment --- .../android/io/flutter/plugin/platform/PlatformPlugin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java index eee883ddaffc2..9e6ad32440186 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java @@ -310,7 +310,7 @@ private void setSystemChromeEnabledSystemUIOverlays( windowInsetsControllerCompat.hide(WindowInsetsCompat.Type.systemBars()); WindowCompat.setDecorFitsSystemWindows(window, false); - // The SYSTEM_UI_FLAG_IMMERSIVE_STICKY flag was introduced in API 19, so we + // The sticky immersive mode was introduced in API 19, so we // apply it // if desired, and if the current Android version is 19 or greater. if (overlaysToShow.size() == 0 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { From fd56253ea3563f18eb1bf706fc7e8e4e070aac9b Mon Sep 17 00:00:00 2001 From: camsim99 Date: Tue, 14 Dec 2021 14:42:50 -0800 Subject: [PATCH 31/39] Fix remainder of references --- .../systemchannels/PlatformChannel.java | 5 ++- .../plugin/platform/PlatformPlugin.java | 45 +++++++++++++++---- 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/shell/platform/android/io/flutter/embedding/engine/systemchannels/PlatformChannel.java b/shell/platform/android/io/flutter/embedding/engine/systemchannels/PlatformChannel.java index da08e499f1bb6..ee13dc0ce138d 100644 --- a/shell/platform/android/io/flutter/embedding/engine/systemchannels/PlatformChannel.java +++ b/shell/platform/android/io/flutter/embedding/engine/systemchannels/PlatformChannel.java @@ -640,7 +640,10 @@ public enum SystemUiMode { LEAN_BACK("SystemUiMode.leanBack"), IMMERSIVE("SystemUiMode.immersive"), IMMERSIVE_STICKY("SystemUiMode.immersiveSticky"), - EDGE_TO_EDGE("SystemUiMode.edgeToEdge"); + EDGE_TO_EDGE("SystemUiMode.edgeToEdge"), + MANUAL_TOP("SystemUiMode.manualTop"), + MANUAL_BOTTOM("SystemUiMode.manualBottom"), + MANUAL_BOTH("SystemUiMode.manualBoth"); /** * Returns the SystemUiMode for the provied encoded value. @throws NoSuchFieldException if any diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java index 9e6ad32440186..63b1927a246d4 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java @@ -30,14 +30,12 @@ /** Android implementation of the platform plugin. */ public class PlatformPlugin { - public static final int DEFAULT_SYSTEM_UI = - View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN; private final Activity activity; private final PlatformChannel platformChannel; private final PlatformPluginDelegate platformPluginDelegate; private PlatformChannel.SystemChromeStyle currentTheme; - private int mEnabledOverlays; + private PlatformChannel.SystemUiMode currentSystemUiMode; private static final String TAG = "PlatformPlugin"; /** @@ -143,7 +141,7 @@ public PlatformPlugin( this.platformChannel.setPlatformMessageHandler(mPlatformMessageHandler); this.platformPluginDelegate = delegate; - mEnabledOverlays = DEFAULT_SYSTEM_UI; + currentSystemUiMode = PlatformChannel.SystemUiMode.EDGE_TO_EDGE; } /** @@ -255,6 +253,7 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys // the system overlay has changed. The overlays cannot be dismissed, so adding the callback // support will allow users to restore the system ui and dismiss the overlays. // Not compatible with top/bottom overlays enabled. + currentSystemUiMode = PlatformChannel.SystemUiMode.LEAN_BACK; windowInsetsControllerCompat.setSystemBarsBehavior( WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_TOUCH); windowInsetsControllerCompat.hide(WindowInsetsCompat.Type.systemBars()); @@ -268,6 +267,7 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys // the system overlay has changed. The overlays cannot be dismissed, so adding callback // support will allow users to restore the system ui and dismiss the overlays. // Not compatible with top/bottom overlays enabled. + currentSystemUiMode = PlatformChannel.SystemUiMode.IMMERSIVE; windowInsetsControllerCompat.setSystemBarsBehavior( WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_SWIPE); windowInsetsControllerCompat.hide(WindowInsetsCompat.Type.systemBars()); @@ -280,6 +280,7 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys // the swipe gesture. The overlays cannot be dismissed, so adding callback support will // allow users to restore the system ui and dismiss the overlays. // Not compatible with top/bottom overlays enabled. + currentSystemUiMode = PlatformChannel.SystemUiMode.IMMERSIVE_STICKY; windowInsetsControllerCompat.setSystemBarsBehavior( WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); windowInsetsControllerCompat.hide(WindowInsetsCompat.Type.systemBars()); @@ -291,6 +292,7 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys // SDK 29 and up will apply a translucent body scrim behind 2/3 button navigation bars // to ensure contrast with buttons on the nav and status bars, unless the contrast is not // enforced in the overlay styling. + currentSystemUiMode = PlatformChannel.SystemUiMode.EDGE_TO_EDGE; WindowCompat.setDecorFitsSystemWindows(window, false); } else { // When none of the conditions are matched, return without updating the system UI overlays. @@ -311,9 +313,11 @@ private void setSystemChromeEnabledSystemUIOverlays( WindowCompat.setDecorFitsSystemWindows(window, false); // The sticky immersive mode was introduced in API 19, so we - // apply it - // if desired, and if the current Android version is 19 or greater. + // apply it if desired, and if the current Android version is + // 19 or greater. if (overlaysToShow.size() == 0 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + currentSystemUiMode = PlatformChannel.SystemUiMode.IMMERSIVE_STICKY; + windowInsetsControllerCompat.setSystemBarsBehavior( WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); } @@ -323,9 +327,17 @@ private void setSystemChromeEnabledSystemUIOverlays( PlatformChannel.SystemUiOverlay overlayToShow = overlaysToShow.get(i); switch (overlayToShow) { case TOP_OVERLAYS: + currentSystemUiMode = + i == 0 + ? PlatformChannel.SystemUiMode.MANUAL_TOP + : PlatformChannel.SystemUiMode.MANUAL_BOTH; windowInsetsControllerCompat.show(WindowInsetsCompat.Type.statusBars()); break; case BOTTOM_OVERLAYS: + currentSystemUiMode = + i == 0 + ? PlatformChannel.SystemUiMode.MANUAL_BOTTOM + : PlatformChannel.SystemUiMode.MANUAL_BOTH; windowInsetsControllerCompat.show(WindowInsetsCompat.Type.navigationBars()); break; } @@ -341,8 +353,25 @@ private void setSystemChromeEnabledSystemUIOverlays( * PlatformPlugin}. */ public void updateSystemUiOverlays() { - // TODO: remove this call - activity.getWindow().getDecorView().setSystemUiVisibility(mEnabledOverlays); + switch (currentSystemUiMode) { + case MANUAL_TOP: + setSystemChromeEnabledSystemUIOverlays( + new ArrayList( + Arrays.asList(PlatformChannel.SystemUiOverlay.TOP_OVERLAYS))); + case MANUAL_BOTTOM: + setSystemChromeEnabledSystemUIOverlays( + new ArrayList( + Arrays.asList(PlatformChannel.SystemUiOverlay.BOTTOM_OVERLAYS))); + case MANUAL_BOTH: + setSystemChromeEnabledSystemUIOverlays( + new ArrayList( + Arrays.asList( + PlatformChannel.SystemUiOverlay.TOP_OVERLAYS, + PlatformChannel.SystemUiOverlay.TOP_OVERLAYS))); + default: + setSystemChromeEnabledSystemUIMode(currentSystemUiMode); + } + if (currentTheme != null) { setSystemChromeSystemUIOverlayStyle(currentTheme); } From b44129bf8e72350f22cd7caaa221f10a9d638753 Mon Sep 17 00:00:00 2001 From: camsim99 Date: Tue, 14 Dec 2021 16:12:36 -0800 Subject: [PATCH 32/39] Update tests --- .../plugin/platform/PlatformPlugin.java | 4 +- .../plugin/platform/PlatformPluginTest.java | 151 ++++++++++++++---- 2 files changed, 120 insertions(+), 35 deletions(-) diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java index 63b1927a246d4..a8668d0f6b1ae 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java @@ -26,6 +26,8 @@ import io.flutter.Log; import io.flutter.embedding.engine.systemchannels.PlatformChannel; import java.io.FileNotFoundException; +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; /** Android implementation of the platform plugin. */ @@ -367,7 +369,7 @@ public void updateSystemUiOverlays() { new ArrayList( Arrays.asList( PlatformChannel.SystemUiOverlay.TOP_OVERLAYS, - PlatformChannel.SystemUiOverlay.TOP_OVERLAYS))); + PlatformChannel.SystemUiOverlay.BOTTOM_OVERLAYS))); default: setSystemChromeEnabledSystemUIMode(currentSystemUiMode); } diff --git a/shell/platform/android/test/io/flutter/plugin/platform/PlatformPluginTest.java b/shell/platform/android/test/io/flutter/plugin/platform/PlatformPluginTest.java index 0fed4b3d239f1..f3866e760b4fd 100644 --- a/shell/platform/android/test/io/flutter/plugin/platform/PlatformPluginTest.java +++ b/shell/platform/android/test/io/flutter/plugin/platform/PlatformPluginTest.java @@ -33,6 +33,8 @@ import io.flutter.embedding.engine.systemchannels.PlatformChannel.SystemChromeStyle; import io.flutter.plugin.platform.PlatformPlugin.PlatformPluginDelegate; import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; import java.util.concurrent.atomic.AtomicBoolean; import org.junit.Test; import org.junit.runner.RunWith; @@ -376,48 +378,129 @@ public void setSystemUiModeLegacy() { @Config(minSdk = 30) @Test public void setSystemUiMode() { - if (Build.VERSION.SDK_INT >= 30) { - View fakeDecorView = mock(View.class); - Window fakeWindow = mock(Window.class); - when(fakeWindow.getDecorView()).thenReturn(fakeDecorView); - Activity fakeActivity = mock(Activity.class); - when(fakeActivity.getWindow()).thenReturn(fakeWindow); - PlatformChannel fakePlatformChannel = mock(PlatformChannel.class); - PlatformPlugin platformPlugin = new PlatformPlugin(fakeActivity, fakePlatformChannel); - WindowInsetsController fakeWindowInsetsController; - fakeWindowInsetsController = mock(WindowInsetsController.class); - when(fakeWindow.getInsetsController()).thenReturn(fakeWindowInsetsController); + View fakeDecorView = mock(View.class); + Window fakeWindow = mock(Window.class); + when(fakeWindow.getDecorView()).thenReturn(fakeDecorView); + Activity fakeActivity = mock(Activity.class); + when(fakeActivity.getWindow()).thenReturn(fakeWindow); + PlatformChannel fakePlatformChannel = mock(PlatformChannel.class); + PlatformPlugin platformPlugin = new PlatformPlugin(fakeActivity, fakePlatformChannel); + WindowInsetsController fakeWindowInsetsController = mock(WindowInsetsController.class); + when(fakeWindow.getInsetsController()).thenReturn(fakeWindowInsetsController); - platformPlugin.mPlatformMessageHandler.showSystemUiMode( - PlatformChannel.SystemUiMode.LEAN_BACK); + platformPlugin.mPlatformMessageHandler.showSystemUiMode(PlatformChannel.SystemUiMode.LEAN_BACK); - verify(fakeWindowInsetsController) - .setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_TOUCH); - verify(fakeWindowInsetsController).hide(WindowInsetsCompat.Type.systemBars()); - verify(fakeWindow).setDecorFitsSystemWindows(false); + verify(fakeWindowInsetsController) + .setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_TOUCH); + verify(fakeWindowInsetsController).hide(WindowInsetsCompat.Type.systemBars()); + verify(fakeWindow).setDecorFitsSystemWindows(false); - platformPlugin.mPlatformMessageHandler.showSystemUiMode( - PlatformChannel.SystemUiMode.IMMERSIVE); + platformPlugin.mPlatformMessageHandler.showSystemUiMode(PlatformChannel.SystemUiMode.IMMERSIVE); - verify(fakeWindowInsetsController) - .setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_SWIPE); - verify(fakeWindowInsetsController, times(2)).hide(WindowInsetsCompat.Type.systemBars()); - verify(fakeWindow, times(2)).setDecorFitsSystemWindows(false); + verify(fakeWindowInsetsController) + .setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_SWIPE); + verify(fakeWindowInsetsController, times(2)).hide(WindowInsetsCompat.Type.systemBars()); + verify(fakeWindow, times(2)).setDecorFitsSystemWindows(false); - platformPlugin.mPlatformMessageHandler.showSystemUiMode( - PlatformChannel.SystemUiMode.IMMERSIVE_STICKY); + platformPlugin.mPlatformMessageHandler.showSystemUiMode( + PlatformChannel.SystemUiMode.IMMERSIVE_STICKY); - verify(fakeWindowInsetsController) - .setSystemBarsBehavior( - WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); - verify(fakeWindowInsetsController, times(3)).hide(WindowInsetsCompat.Type.systemBars()); - verify(fakeWindow, times(3)).setDecorFitsSystemWindows(false); + verify(fakeWindowInsetsController) + .setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); + verify(fakeWindowInsetsController, times(3)).hide(WindowInsetsCompat.Type.systemBars()); + verify(fakeWindow, times(3)).setDecorFitsSystemWindows(false); - platformPlugin.mPlatformMessageHandler.showSystemUiMode( - PlatformChannel.SystemUiMode.EDGE_TO_EDGE); + platformPlugin.mPlatformMessageHandler.showSystemUiMode( + PlatformChannel.SystemUiMode.EDGE_TO_EDGE); - verify(fakeWindow, times(4)).setDecorFitsSystemWindows(false); - } + verify(fakeWindow, times(4)).setDecorFitsSystemWindows(false); + } + + @Config(sdk = 29) + @Test + public void showSystemOverlaysLegacy() { + View fakeDecorView = mock(View.class); + Window fakeWindow = mock(Window.class); + when(fakeWindow.getDecorView()).thenReturn(fakeDecorView); + int fakeSetFlags = + View.SYSTEM_UI_FLAG_FULLSCREEN + | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN; + Activity fakeActivity = mock(Activity.class); + when(fakeActivity.getWindow()).thenReturn(fakeWindow); + PlatformChannel fakePlatformChannel = mock(PlatformChannel.class); + PlatformPlugin platformPlugin = new PlatformPlugin(fakeActivity, fakePlatformChannel); + + platformPlugin.mPlatformMessageHandler.showSystemOverlays( + new ArrayList()); + + verify(fakeDecorView).setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN); + verify(fakeDecorView).setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); + verify(fakeDecorView) + .setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); + + verify(fakeDecorView).setSystemUiVisibility(View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); + verify(fakeDecorView).setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN); + verify(fakeDecorView).setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); + verify(fakeDecorView) + .setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); + + when(fakeDecorView.getSystemUiVisibility()).thenReturn(fakeSetFlags); + platformPlugin.mPlatformMessageHandler.showSystemOverlays( + new ArrayList( + Arrays.asList( + PlatformChannel.SystemUiOverlay.TOP_OVERLAYS, + PlatformChannel.SystemUiOverlay.BOTTOM_OVERLAYS))); + + verify(fakeDecorView).setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN); + verify(fakeDecorView).setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); + verify(fakeDecorView) + .setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); + + verify(fakeDecorView).setSystemUiVisibility(fakeSetFlags &= ~View.SYSTEM_UI_FLAG_FULLSCREEN); + verify(fakeDecorView) + .setSystemUiVisibility(fakeSetFlags &= ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); + } + + @Config(minSdk = 30) + @Test + public void showSystemOverlays() { + View fakeDecorView = mock(View.class); + Window fakeWindow = mock(Window.class); + when(fakeWindow.getDecorView()).thenReturn(fakeDecorView); + Activity fakeActivity = mock(Activity.class); + when(fakeActivity.getWindow()).thenReturn(fakeWindow); + PlatformChannel fakePlatformChannel = mock(PlatformChannel.class); + PlatformPlugin platformPlugin = new PlatformPlugin(fakeActivity, fakePlatformChannel); + WindowInsetsController fakeWindowInsetsController = mock(WindowInsetsController.class); + when(fakeWindow.getInsetsController()).thenReturn(fakeWindowInsetsController); + + platformPlugin.mPlatformMessageHandler.showSystemOverlays( + new ArrayList()); + + verify(fakeWindowInsetsController) + .setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); + verify(fakeWindowInsetsController).hide(WindowInsetsCompat.Type.systemBars()); + + platformPlugin.mPlatformMessageHandler.showSystemOverlays( + new ArrayList( + Arrays.asList( + PlatformChannel.SystemUiOverlay.TOP_OVERLAYS, + PlatformChannel.SystemUiOverlay.BOTTOM_OVERLAYS))); + + verify(fakeWindowInsetsController).show(WindowInsetsCompat.Type.statusBars()); + verify(fakeWindowInsetsController).show(WindowInsetsCompat.Type.navigationBars()); } @Config(sdk = 28) From 85a0f78624344cf5e81748c79c6c5ccfe9eb861e Mon Sep 17 00:00:00 2001 From: camsim99 Date: Mon, 10 Jan 2022 16:03:44 -0800 Subject: [PATCH 33/39] Address comments --- .../io/flutter/plugin/platform/PlatformPlugin.java | 8 ++++---- .../io/flutter/plugin/platform/PlatformPluginTest.java | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java index a8668d0f6b1ae..4cb08ee7b4250 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java @@ -255,7 +255,6 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys // the system overlay has changed. The overlays cannot be dismissed, so adding the callback // support will allow users to restore the system ui and dismiss the overlays. // Not compatible with top/bottom overlays enabled. - currentSystemUiMode = PlatformChannel.SystemUiMode.LEAN_BACK; windowInsetsControllerCompat.setSystemBarsBehavior( WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_TOUCH); windowInsetsControllerCompat.hide(WindowInsetsCompat.Type.systemBars()); @@ -269,7 +268,6 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys // the system overlay has changed. The overlays cannot be dismissed, so adding callback // support will allow users to restore the system ui and dismiss the overlays. // Not compatible with top/bottom overlays enabled. - currentSystemUiMode = PlatformChannel.SystemUiMode.IMMERSIVE; windowInsetsControllerCompat.setSystemBarsBehavior( WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_SWIPE); windowInsetsControllerCompat.hide(WindowInsetsCompat.Type.systemBars()); @@ -282,7 +280,6 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys // the swipe gesture. The overlays cannot be dismissed, so adding callback support will // allow users to restore the system ui and dismiss the overlays. // Not compatible with top/bottom overlays enabled. - currentSystemUiMode = PlatformChannel.SystemUiMode.IMMERSIVE_STICKY; windowInsetsControllerCompat.setSystemBarsBehavior( WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); windowInsetsControllerCompat.hide(WindowInsetsCompat.Type.systemBars()); @@ -294,12 +291,12 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys // SDK 29 and up will apply a translucent body scrim behind 2/3 button navigation bars // to ensure contrast with buttons on the nav and status bars, unless the contrast is not // enforced in the overlay styling. - currentSystemUiMode = PlatformChannel.SystemUiMode.EDGE_TO_EDGE; WindowCompat.setDecorFitsSystemWindows(window, false); } else { // When none of the conditions are matched, return without updating the system UI overlays. return; } + currentSystemUiMode = systemUiMode; } private void setSystemChromeEnabledSystemUIOverlays( @@ -360,16 +357,19 @@ public void updateSystemUiOverlays() { setSystemChromeEnabledSystemUIOverlays( new ArrayList( Arrays.asList(PlatformChannel.SystemUiOverlay.TOP_OVERLAYS))); + break; case MANUAL_BOTTOM: setSystemChromeEnabledSystemUIOverlays( new ArrayList( Arrays.asList(PlatformChannel.SystemUiOverlay.BOTTOM_OVERLAYS))); + break; case MANUAL_BOTH: setSystemChromeEnabledSystemUIOverlays( new ArrayList( Arrays.asList( PlatformChannel.SystemUiOverlay.TOP_OVERLAYS, PlatformChannel.SystemUiOverlay.BOTTOM_OVERLAYS))); + break; default: setSystemChromeEnabledSystemUIMode(currentSystemUiMode); } diff --git a/shell/platform/android/test/io/flutter/plugin/platform/PlatformPluginTest.java b/shell/platform/android/test/io/flutter/plugin/platform/PlatformPluginTest.java index f3866e760b4fd..c94eaa262712a 100644 --- a/shell/platform/android/test/io/flutter/plugin/platform/PlatformPluginTest.java +++ b/shell/platform/android/test/io/flutter/plugin/platform/PlatformPluginTest.java @@ -13,6 +13,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import android.annotation.TargetApi; import android.app.Activity; import android.content.ClipData; import android.content.ClipboardManager; @@ -375,7 +376,7 @@ public void setSystemUiModeLegacy() { } } - @Config(minSdk = 30) + @TargetApi(30) @Test public void setSystemUiMode() { View fakeDecorView = mock(View.class); @@ -473,7 +474,7 @@ public void showSystemOverlaysLegacy() { .setSystemUiVisibility(fakeSetFlags &= ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); } - @Config(minSdk = 30) + @TargetApi(30) @Test public void showSystemOverlays() { View fakeDecorView = mock(View.class); From cfbef5b3c8edb4bdd42f44ad4a6dad025c43345e Mon Sep 17 00:00:00 2001 From: camsim99 Date: Tue, 11 Jan 2022 18:06:33 -0800 Subject: [PATCH 34/39] Undo modification of enum --- .../systemchannels/PlatformChannel.java | 5 +-- .../plugin/platform/PlatformPlugin.java | 36 ++++--------------- 2 files changed, 7 insertions(+), 34 deletions(-) diff --git a/shell/platform/android/io/flutter/embedding/engine/systemchannels/PlatformChannel.java b/shell/platform/android/io/flutter/embedding/engine/systemchannels/PlatformChannel.java index ee13dc0ce138d..da08e499f1bb6 100644 --- a/shell/platform/android/io/flutter/embedding/engine/systemchannels/PlatformChannel.java +++ b/shell/platform/android/io/flutter/embedding/engine/systemchannels/PlatformChannel.java @@ -640,10 +640,7 @@ public enum SystemUiMode { LEAN_BACK("SystemUiMode.leanBack"), IMMERSIVE("SystemUiMode.immersive"), IMMERSIVE_STICKY("SystemUiMode.immersiveSticky"), - EDGE_TO_EDGE("SystemUiMode.edgeToEdge"), - MANUAL_TOP("SystemUiMode.manualTop"), - MANUAL_BOTTOM("SystemUiMode.manualBottom"), - MANUAL_BOTH("SystemUiMode.manualBoth"); + EDGE_TO_EDGE("SystemUiMode.edgeToEdge"); /** * Returns the SystemUiMode for the provied encoded value. @throws NoSuchFieldException if any diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java index 4cb08ee7b4250..474deac989099 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java @@ -26,8 +26,6 @@ import io.flutter.Log; import io.flutter.embedding.engine.systemchannels.PlatformChannel; import java.io.FileNotFoundException; -import java.util.ArrayList; -import java.util.Arrays; import java.util.List; /** Android implementation of the platform plugin. */ @@ -38,6 +36,7 @@ public class PlatformPlugin { private final PlatformPluginDelegate platformPluginDelegate; private PlatformChannel.SystemChromeStyle currentTheme; private PlatformChannel.SystemUiMode currentSystemUiMode; + private List currentOverlays; private static final String TAG = "PlatformPlugin"; /** @@ -326,21 +325,14 @@ private void setSystemChromeEnabledSystemUIOverlays( PlatformChannel.SystemUiOverlay overlayToShow = overlaysToShow.get(i); switch (overlayToShow) { case TOP_OVERLAYS: - currentSystemUiMode = - i == 0 - ? PlatformChannel.SystemUiMode.MANUAL_TOP - : PlatformChannel.SystemUiMode.MANUAL_BOTH; windowInsetsControllerCompat.show(WindowInsetsCompat.Type.statusBars()); break; case BOTTOM_OVERLAYS: - currentSystemUiMode = - i == 0 - ? PlatformChannel.SystemUiMode.MANUAL_BOTTOM - : PlatformChannel.SystemUiMode.MANUAL_BOTH; windowInsetsControllerCompat.show(WindowInsetsCompat.Type.navigationBars()); break; } } + currentOverlays = overlaysToShow; } /** @@ -352,26 +344,10 @@ private void setSystemChromeEnabledSystemUIOverlays( * PlatformPlugin}. */ public void updateSystemUiOverlays() { - switch (currentSystemUiMode) { - case MANUAL_TOP: - setSystemChromeEnabledSystemUIOverlays( - new ArrayList( - Arrays.asList(PlatformChannel.SystemUiOverlay.TOP_OVERLAYS))); - break; - case MANUAL_BOTTOM: - setSystemChromeEnabledSystemUIOverlays( - new ArrayList( - Arrays.asList(PlatformChannel.SystemUiOverlay.BOTTOM_OVERLAYS))); - break; - case MANUAL_BOTH: - setSystemChromeEnabledSystemUIOverlays( - new ArrayList( - Arrays.asList( - PlatformChannel.SystemUiOverlay.TOP_OVERLAYS, - PlatformChannel.SystemUiOverlay.BOTTOM_OVERLAYS))); - break; - default: - setSystemChromeEnabledSystemUIMode(currentSystemUiMode); + setSystemChromeEnabledSystemUIMode(currentSystemUiMode); + + if (currentOverlays != null) { + setSystemChromeEnabledSystemUIOverlays(currentOverlays); } if (currentTheme != null) { From 94ee3f6c20e840acaf2f79ddac761efc4333afae Mon Sep 17 00:00:00 2001 From: camsim99 Date: Wed, 12 Jan 2022 10:44:24 -0800 Subject: [PATCH 35/39] Remove version checks --- .../plugin/platform/PlatformPlugin.java | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java index 474deac989099..a6b487b80b024 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java @@ -248,7 +248,7 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys if (systemUiMode == PlatformChannel.SystemUiMode.LEAN_BACK) { // LEAN BACK - // Available starting at SDK 16 + // Available starting at SDK 20 // Should not show overlays, tap to reveal overlays, needs onChange callback // When the overlays come in on tap, the app does not receive the gesture and does not know // the system overlay has changed. The overlays cannot be dismissed, so adding the callback @@ -258,10 +258,9 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_TOUCH); windowInsetsControllerCompat.hide(WindowInsetsCompat.Type.systemBars()); WindowCompat.setDecorFitsSystemWindows(window, false); - } else if (systemUiMode == PlatformChannel.SystemUiMode.IMMERSIVE - && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + } else if (systemUiMode == PlatformChannel.SystemUiMode.IMMERSIVE) { // IMMERSIVE - // Available starting at 19 + // Available starting at SDK 20 // Should not show overlays, swipe from edges to reveal overlays, needs onChange callback // When the overlays come in on swipe, the app does not receive the gesture and does not know // the system overlay has changed. The overlays cannot be dismissed, so adding callback @@ -274,7 +273,7 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys } else if (systemUiMode == PlatformChannel.SystemUiMode.IMMERSIVE_STICKY && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { // STICKY IMMERSIVE - // Available starting at 19 + // Available starting at SDK 20 // Should not show overlays, swipe from edges to reveal overlays. The app will also receive // the swipe gesture. The overlays cannot be dismissed, so adding callback support will // allow users to restore the system ui and dismiss the overlays. @@ -283,11 +282,10 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); windowInsetsControllerCompat.hide(WindowInsetsCompat.Type.systemBars()); WindowCompat.setDecorFitsSystemWindows(window, false); - } else if (systemUiMode == PlatformChannel.SystemUiMode.EDGE_TO_EDGE - && Build.VERSION.SDK_INT >= 29) { + } else if (systemUiMode == PlatformChannel.SystemUiMode.EDGE_TO_EDGE) { // EDGE TO EDGE - // Available starting at 29 - // SDK 29 and up will apply a translucent body scrim behind 2/3 button navigation bars + // Available starting at SDK 16 + // Will apply a translucent body scrim behind 2/3 button navigation bars // to ensure contrast with buttons on the nav and status bars, unless the contrast is not // enforced in the overlay styling. WindowCompat.setDecorFitsSystemWindows(window, false); @@ -310,10 +308,8 @@ private void setSystemChromeEnabledSystemUIOverlays( windowInsetsControllerCompat.hide(WindowInsetsCompat.Type.systemBars()); WindowCompat.setDecorFitsSystemWindows(window, false); - // The sticky immersive mode was introduced in API 19, so we - // apply it if desired, and if the current Android version is - // 19 or greater. - if (overlaysToShow.size() == 0 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + // We apply sticky immersive mode if desired. Available starting at SDK 20. + if (overlaysToShow.size() == 0) { currentSystemUiMode = PlatformChannel.SystemUiMode.IMMERSIVE_STICKY; windowInsetsControllerCompat.setSystemBarsBehavior( From 2e2747d05c91261ec2d69081263f350d397c5d70 Mon Sep 17 00:00:00 2001 From: camsim99 Date: Wed, 12 Jan 2022 11:35:37 -0800 Subject: [PATCH 36/39] Remove check --- .../android/io/flutter/plugin/platform/PlatformPlugin.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java index a6b487b80b024..92fcbea578743 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java @@ -270,8 +270,7 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_SWIPE); windowInsetsControllerCompat.hide(WindowInsetsCompat.Type.systemBars()); WindowCompat.setDecorFitsSystemWindows(window, false); - } else if (systemUiMode == PlatformChannel.SystemUiMode.IMMERSIVE_STICKY - && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + } else if (systemUiMode == PlatformChannel.SystemUiMode.IMMERSIVE_STICKY) { // STICKY IMMERSIVE // Available starting at SDK 20 // Should not show overlays, swipe from edges to reveal overlays. The app will also receive From 881a2db9deaf8e8735a3cbb23900981fd7dbf688 Mon Sep 17 00:00:00 2001 From: camsim99 Date: Wed, 12 Jan 2022 14:29:57 -0800 Subject: [PATCH 37/39] Add comments, add back version check --- .../flutter/plugin/platform/PlatformPlugin.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java index 92fcbea578743..5299d73ad4ab3 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java @@ -248,7 +248,8 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys if (systemUiMode == PlatformChannel.SystemUiMode.LEAN_BACK) { // LEAN BACK - // Available starting at SDK 20 + // Available starting at SDK 20, due to the backwards compatibility provided by the + // WindowInsetsControllerCompat class for setting the behavior of system bars. // Should not show overlays, tap to reveal overlays, needs onChange callback // When the overlays come in on tap, the app does not receive the gesture and does not know // the system overlay has changed. The overlays cannot be dismissed, so adding the callback @@ -260,7 +261,8 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys WindowCompat.setDecorFitsSystemWindows(window, false); } else if (systemUiMode == PlatformChannel.SystemUiMode.IMMERSIVE) { // IMMERSIVE - // Available starting at SDK 20 + // Available starting at SDK 20, due to the backwards compatibility provided by the + // WindowInsetsControllerCompat class for setting the behavior of system bars. // Should not show overlays, swipe from edges to reveal overlays, needs onChange callback // When the overlays come in on swipe, the app does not receive the gesture and does not know // the system overlay has changed. The overlays cannot be dismissed, so adding callback @@ -272,7 +274,8 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys WindowCompat.setDecorFitsSystemWindows(window, false); } else if (systemUiMode == PlatformChannel.SystemUiMode.IMMERSIVE_STICKY) { // STICKY IMMERSIVE - // Available starting at SDK 20 + // Available starting at SDK 20, due to the backwards compatibility provided by the + // WindowInsetsControllerCompat class for setting the behavior of system bars. // Should not show overlays, swipe from edges to reveal overlays. The app will also receive // the swipe gesture. The overlays cannot be dismissed, so adding callback support will // allow users to restore the system ui and dismiss the overlays. @@ -281,9 +284,11 @@ private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode sys WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); windowInsetsControllerCompat.hide(WindowInsetsCompat.Type.systemBars()); WindowCompat.setDecorFitsSystemWindows(window, false); - } else if (systemUiMode == PlatformChannel.SystemUiMode.EDGE_TO_EDGE) { + } else if (systemUiMode == PlatformChannel.SystemUiMode.EDGE_TO_EDGE + && Build.VERSION.SDK_INT >= 29) { // EDGE TO EDGE - // Available starting at SDK 16 + // Available starting at SDK 29. See issue for context: + // https://github.com/flutter/flutter/issues/89774. // Will apply a translucent body scrim behind 2/3 button navigation bars // to ensure contrast with buttons on the nav and status bars, unless the contrast is not // enforced in the overlay styling. From 8db28bc75ebe01edbc1c3a5f097faa5012da25db Mon Sep 17 00:00:00 2001 From: camsim99 Date: Thu, 13 Jan 2022 11:03:01 -0800 Subject: [PATCH 38/39] Move conditional --- .../io/flutter/plugin/platform/PlatformPlugin.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java index 5299d73ad4ab3..03f862aa13837 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java @@ -348,10 +348,10 @@ public void updateSystemUiOverlays() { if (currentOverlays != null) { setSystemChromeEnabledSystemUIOverlays(currentOverlays); - } - - if (currentTheme != null) { - setSystemChromeSystemUIOverlayStyle(currentTheme); + } else { + if (currentTheme != null) { + setSystemChromeSystemUIOverlayStyle(currentTheme); + } } } From cf6159f0864953a715e814586f89016cda0e8f97 Mon Sep 17 00:00:00 2001 From: camsim99 Date: Thu, 13 Jan 2022 11:13:04 -0800 Subject: [PATCH 39/39] Nit --- .../android/io/flutter/plugin/platform/PlatformPlugin.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java index 03f862aa13837..586d8de4e50a0 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java @@ -348,10 +348,8 @@ public void updateSystemUiOverlays() { if (currentOverlays != null) { setSystemChromeEnabledSystemUIOverlays(currentOverlays); - } else { - if (currentTheme != null) { - setSystemChromeSystemUIOverlayStyle(currentTheme); - } + } else if (currentTheme != null) { + setSystemChromeSystemUIOverlayStyle(currentTheme); } }