Improve support for gesture nav on wallpapers only
TopLevelPickerActivity is used when there's no styles
support, ensure proper support for transparent navigation
in that case (and improve the current support in Category
page).
Bug: 138446847
Change-Id: If5ab11aad02a003c538e54964060e814e28069ae
diff --git a/src/com/android/wallpaper/picker/TopLevelPickerActivity.java b/src/com/android/wallpaper/picker/TopLevelPickerActivity.java
index ac6a13b..87358ec 100755
--- a/src/com/android/wallpaper/picker/TopLevelPickerActivity.java
+++ b/src/com/android/wallpaper/picker/TopLevelPickerActivity.java
@@ -20,6 +20,7 @@
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
+import android.graphics.Insets;
import android.graphics.Point;
import android.graphics.PorterDuff.Mode;
import android.graphics.drawable.Drawable;
@@ -32,6 +33,7 @@
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
+import android.view.WindowInsets;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
@@ -47,6 +49,7 @@
import com.android.wallpaper.R;
import com.android.wallpaper.asset.Asset;
+import com.android.wallpaper.compat.BuildCompat;
import com.android.wallpaper.compat.ButtonDrawableSetterCompat;
import com.android.wallpaper.config.Flags;
import com.android.wallpaper.model.Category;
@@ -241,6 +244,29 @@
private void initializeMobile(boolean shouldForceRefresh) {
setContentView(R.layout.activity_single_fragment);
+ getWindow().getDecorView().setSystemUiVisibility(
+ getWindow().getDecorView().getSystemUiVisibility()
+ | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
+ findViewById(R.id.fragment_container)
+ .setOnApplyWindowInsetsListener((view, windowInsets) -> {
+ view.setPadding(view.getPaddingLeft(), windowInsets.getSystemWindowInsetTop(),
+ view.getPaddingRight(), view.getBottom());
+ // Consume only the top inset (status bar), to let other content in the Activity consume
+ // the nav bar (ie, by using "fitSystemWindows")
+ if (BuildCompat.isAtLeastQ()) {
+ WindowInsets.Builder builder = new WindowInsets.Builder(windowInsets);
+ builder.setSystemWindowInsets(Insets.of(windowInsets.getSystemWindowInsetLeft(),
+ 0, windowInsets.getStableInsetRight(),
+ windowInsets.getSystemWindowInsetBottom()));
+ return builder.build();
+ } else {
+ return windowInsets.replaceSystemWindowInsets(
+ windowInsets.getSystemWindowInsetLeft(),
+ 0, windowInsets.getStableInsetRight(),
+ windowInsets.getSystemWindowInsetBottom());
+ }
+ });
// Set toolbar as the action bar.
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);