Revert "Remove usages of deprecated setSystemUiVisibility()" (flutter/engine#30880)

This commit is contained in:
Emmanuel Garcia
2022-01-14 11:05:09 -08:00
committed by GitHub
parent 8142bd74c6
commit 470d1581e9
5 changed files with 82 additions and 217 deletions

View File

@@ -24,9 +24,9 @@ import android.view.View;
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;
import io.flutter.util.Preconditions;
import io.flutter.view.FlutterMain;
import io.flutter.view.FlutterNativeView;
@@ -141,7 +141,7 @@ public final class FlutterActivityDelegate
Window window = activity.getWindow();
window.addFlags(LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(0x40000000);
WindowCompat.setDecorFitsSystemWindows(window, false);
window.getDecorView().setSystemUiVisibility(PlatformPlugin.DEFAULT_SYSTEM_UI);
}
String[] args = getArgsFromIntent(activity.getIntent());

View File

@@ -38,7 +38,6 @@ import androidx.annotation.NonNull;
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;
@@ -582,7 +581,7 @@ public class FlutterActivity extends Activity
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(0x40000000);
WindowCompat.setDecorFitsSystemWindows(window, false);
window.getDecorView().setSystemUiVisibility(PlatformPlugin.DEFAULT_SYSTEM_UI);
}
}

View File

@@ -38,7 +38,6 @@ import androidx.annotation.NonNull;
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;
@@ -46,6 +45,7 @@ import io.flutter.embedding.android.FlutterActivityLaunchConfigs.BackgroundMode;
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}.
@@ -493,7 +493,7 @@ public class FlutterFragmentActivity extends FragmentActivity
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(0x40000000);
WindowCompat.setDecorFitsSystemWindows(window, false);
window.getDecorView().setSystemUiVisibility(PlatformPlugin.DEFAULT_SYSTEM_UI);
}
}

View File

@@ -20,8 +20,6 @@ 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;
@@ -30,13 +28,14 @@ import java.util.List;
/** 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 PlatformChannel.SystemUiMode currentSystemUiMode;
private List<PlatformChannel.SystemUiOverlay> currentOverlays;
private int mEnabledOverlays;
private static final String TAG = "PlatformPlugin";
/**
@@ -142,7 +141,7 @@ public class PlatformPlugin {
this.platformChannel.setPlatformMessageHandler(mPlatformMessageHandler);
this.platformPluginDelegate = delegate;
currentSystemUiMode = PlatformChannel.SystemUiMode.EDGE_TO_EDGE;
mEnabledOverlays = DEFAULT_SYSTEM_UI;
}
/**
@@ -241,83 +240,87 @@ public class PlatformPlugin {
private void setSystemChromeEnabledSystemUIMode(PlatformChannel.SystemUiMode systemUiMode) {
int enabledOverlays;
Window window = activity.getWindow();
View view = window.getDecorView();
WindowInsetsControllerCompat windowInsetsControllerCompat =
new WindowInsetsControllerCompat(window, view);
if (systemUiMode == PlatformChannel.SystemUiMode.LEAN_BACK) {
if (systemUiMode == PlatformChannel.SystemUiMode.LEAN_BACK
&& Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
// LEAN BACK
// Available starting at SDK 20, due to the backwards compatibility provided by the
// WindowInsetsControllerCompat class for setting the behavior of system bars.
// 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 receive 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.
windowInsetsControllerCompat.setSystemBarsBehavior(
WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_TOUCH);
windowInsetsControllerCompat.hide(WindowInsetsCompat.Type.systemBars());
WindowCompat.setDecorFitsSystemWindows(window, false);
} else if (systemUiMode == PlatformChannel.SystemUiMode.IMMERSIVE) {
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
// Available starting at SDK 20, due to the backwards compatibility provided by the
// WindowInsetsControllerCompat class for setting the behavior of system bars.
// Available starting at 19
// 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
// 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);
windowInsetsControllerCompat.hide(WindowInsetsCompat.Type.systemBars());
WindowCompat.setDecorFitsSystemWindows(window, false);
} else if (systemUiMode == PlatformChannel.SystemUiMode.IMMERSIVE_STICKY) {
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
// Available starting at SDK 20, due to the backwards compatibility provided by the
// WindowInsetsControllerCompat class for setting the behavior of system bars.
// Available starting at 19
// 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.
// Not compatible with top/bottom overlays enabled.
windowInsetsControllerCompat.setSystemBarsBehavior(
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
windowInsetsControllerCompat.hide(WindowInsetsCompat.Type.systemBars());
WindowCompat.setDecorFitsSystemWindows(window, false);
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;
} else if (systemUiMode == PlatformChannel.SystemUiMode.EDGE_TO_EDGE
&& Build.VERSION.SDK_INT >= 29) {
// EDGE TO EDGE
// 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
// Available starting at 29
// 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);
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;
}
currentSystemUiMode = systemUiMode;
mEnabledOverlays = enabledOverlays;
updateSystemUiOverlays();
}
private void setSystemChromeEnabledSystemUIOverlays(
List<PlatformChannel.SystemUiOverlay> 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).
windowInsetsControllerCompat.hide(WindowInsetsCompat.Type.systemBars());
WindowCompat.setDecorFitsSystemWindows(window, false);
int enabledOverlays =
DEFAULT_SYSTEM_UI
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
// We apply sticky immersive mode if desired. Available starting at SDK 20.
if (overlaysToShow.size() == 0) {
currentSystemUiMode = PlatformChannel.SystemUiMode.IMMERSIVE_STICKY;
windowInsetsControllerCompat.setSystemBarsBehavior(
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
// 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;
}
// Re-add any desired system overlays.
@@ -325,14 +328,17 @@ public class PlatformPlugin {
PlatformChannel.SystemUiOverlay overlayToShow = overlaysToShow.get(i);
switch (overlayToShow) {
case TOP_OVERLAYS:
windowInsetsControllerCompat.show(WindowInsetsCompat.Type.statusBars());
enabledOverlays &= ~View.SYSTEM_UI_FLAG_FULLSCREEN;
break;
case BOTTOM_OVERLAYS:
windowInsetsControllerCompat.show(WindowInsetsCompat.Type.navigationBars());
enabledOverlays &= ~View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
enabledOverlays &= ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
break;
}
}
currentOverlays = overlaysToShow;
mEnabledOverlays = enabledOverlays;
updateSystemUiOverlays();
}
/**
@@ -344,11 +350,8 @@ public class PlatformPlugin {
* PlatformPlugin}.
*/
public void updateSystemUiOverlays() {
setSystemChromeEnabledSystemUIMode(currentSystemUiMode);
if (currentOverlays != null) {
setSystemChromeEnabledSystemUIOverlays(currentOverlays);
} else if (currentTheme != null) {
activity.getWindow().getDecorView().setSystemUiVisibility(mEnabledOverlays);
if (currentTheme != null) {
setSystemChromeSystemUIOverlayStyle(currentTheme);
}
}

View File

@@ -13,7 +13,6 @@ import static org.mockito.Mockito.times;
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;
@@ -25,8 +24,6 @@ import android.view.View;
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;
@@ -34,8 +31,6 @@ import io.flutter.embedding.engine.systemchannels.PlatformChannel.ClipboardConte
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;
@@ -318,7 +313,7 @@ public class PlatformPluginTest {
@Config(sdk = 29)
@Test
public void setSystemUiModeLegacy() {
public void setSystemUiMode() {
View fakeDecorView = mock(View.class);
Window fakeWindow = mock(Window.class);
when(fakeWindow.getDecorView()).thenReturn(fakeDecorView);
@@ -330,45 +325,41 @@ public class PlatformPluginTest {
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);
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_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))
verify(fakeDecorView)
.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
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_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);
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))
verify(fakeDecorView)
.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
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_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, times(4))
verify(fakeDecorView)
.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
@@ -376,134 +367,6 @@ public class PlatformPluginTest {
}
}
@TargetApi(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 = mock(WindowInsetsController.class);
when(fakeWindow.getInsetsController()).thenReturn(fakeWindowInsetsController);
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);
}
@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<PlatformChannel.SystemUiOverlay>());
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<PlatformChannel.SystemUiOverlay>(
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);
}
@TargetApi(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<PlatformChannel.SystemUiOverlay>());
verify(fakeWindowInsetsController)
.setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
verify(fakeWindowInsetsController).hide(WindowInsetsCompat.Type.systemBars());
platformPlugin.mPlatformMessageHandler.showSystemOverlays(
new ArrayList<PlatformChannel.SystemUiOverlay>(
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)
@Test
public void doNotEnableEdgeToEdgeOnOlderSdk() {