From 27d33e299469fbc627be8c346555e91630502721 Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Thu, 3 Mar 2022 06:35:03 +0000 Subject: [PATCH] Address some insets issues in Taskbar All Apps - Don't report insets change to underlying app when stashing taskbar during all apps transition - Internally override all apps insets to take stashing into account - Don't offset all apps window by display cutouts, as we handle them internally via padding internally - Also Fix bug where "stashing" taskbar in 3 button mode (which just fades out taskbar icons but keeps nav buttons) was reporting smaller insets to apps Test: 1) open all apps in Calculator, ensure Calculator doesn't adjust insets and all apps has bottom content padding but no nav scrim 2) in 3 button mode, scroll to bottom of all apps and can read last row icon labels 3) enable display cutout in developer options, ensure no change to tests 1 and 2, and all apps scrim fills the screen (including behind cutout) Fixes: 219980805 Change-Id: Ic3c6a744bc675e4ea277d22c4c0b3b353eddd905 --- .../taskbar/TaskbarStashController.java | 10 ++--- .../allapps/TaskbarAllAppsContext.java | 41 +++++++++++++++++++ .../allapps/TaskbarAllAppsController.java | 2 + 3 files changed, 48 insertions(+), 5 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java index 1d5fa4d47b..d083602a78 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java @@ -60,10 +60,10 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba // If any of these flags are enabled, inset apps by our stashed height instead of our unstashed // height. This way the reported insets are consistent even during transitions out of the app. - // Currently any flag that causes us to stash in an app is included, except for IME since that - // covers the underlying app anyway and thus the app shouldn't change insets. + // Currently any flag that causes us to stash in an app is included, except for IME or All Apps + // since those cover the underlying app anyway and thus the app shouldn't change insets. private static final int FLAGS_REPORT_STASHED_INSETS_TO_APP = FLAGS_STASHED_IN_APP - & ~FLAG_STASHED_IN_APP_IME; + & ~FLAG_STASHED_IN_APP_IME & ~FLAG_STASHED_IN_APP_ALL_APPS; /** * How long to stash/unstash when manually invoked via long press. @@ -187,7 +187,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba * Returns whether the taskbar can visually stash into a handle based on the current device * state. */ - private boolean supportsVisualStashing() { + public boolean supportsVisualStashing() { return !mActivity.isThreeButtonNav(); } @@ -254,7 +254,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba * Returns the height that taskbar will inset when inside apps. */ public int getContentHeightToReportToApps() { - if (hasAnyFlag(FLAGS_REPORT_STASHED_INSETS_TO_APP)) { + if (supportsVisualStashing() && hasAnyFlag(FLAGS_REPORT_STASHED_INSETS_TO_APP)) { boolean isAnimating = mAnimator != null && mAnimator.isStarted(); return mControllers.stashedHandleViewController.isStashedHandleVisible() || isAnimating ? mStashedHeight : 0; diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContext.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContext.java index 7f3add3761..a67ca7089b 100644 --- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContext.java @@ -22,8 +22,10 @@ import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; import static com.android.systemui.shared.system.ViewTreeObserverWrapper.InsetsInfo.TOUCHABLE_INSETS_REGION; import android.content.Context; +import android.graphics.Insets; import android.view.KeyEvent; import android.view.View; +import android.view.WindowInsets; import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.DeviceProfile; @@ -59,6 +61,10 @@ class TaskbarAllAppsContext extends BaseTaskbarContext { private final TaskbarAllAppsDragLayer mDragLayer; private final TaskbarAllAppsContainerView mAppsView; + // We automatically stash taskbar when all apps is opened in gesture navigation mode. + private final boolean mWillTaskbarBeVisuallyStashed; + private final int mStashedTaskbarHeight; + TaskbarAllAppsContext( TaskbarActivityContext taskbarContext, TaskbarAllAppsController windowController, @@ -79,6 +85,9 @@ class TaskbarAllAppsContext extends BaseTaskbarContext { windowController, taskbarStashController); mAppsView = slideInView.getAppsView(); + + mWillTaskbarBeVisuallyStashed = taskbarStashController.supportsVisualStashing(); + mStashedTaskbarHeight = taskbarStashController.getStashedHeight(); } TaskbarAllAppsViewController getAllAppsViewController() { @@ -189,5 +198,37 @@ class TaskbarAllAppsContext extends BaseTaskbarContext { inoutInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION); } } + + @Override + public WindowInsets onApplyWindowInsets(WindowInsets insets) { + return updateInsetsDueToStashing(insets); + } + + /** + * Taskbar automatically stashes when opening all apps, but we don't report the insets as + * changing to avoid moving the underlying app. But internally, the apps view should still + * layout according to the stashed insets rather than the unstashed insets. So this method + * does two things: + * 1) Sets navigationBars bottom inset to stashedHeight. + * 2) Sets tappableInsets bottom inset to 0. + */ + private WindowInsets updateInsetsDueToStashing(WindowInsets oldInsets) { + if (!mActivity.mWillTaskbarBeVisuallyStashed) { + return oldInsets; + } + WindowInsets.Builder updatedInsetsBuilder = new WindowInsets.Builder(oldInsets); + + Insets oldNavInsets = oldInsets.getInsets(WindowInsets.Type.navigationBars()); + Insets newNavInsets = Insets.of(oldNavInsets.left, oldNavInsets.top, oldNavInsets.right, + mActivity.mStashedTaskbarHeight); + updatedInsetsBuilder.setInsets(WindowInsets.Type.navigationBars(), newNavInsets); + + Insets oldTappableInsets = oldInsets.getInsets(WindowInsets.Type.tappableElement()); + Insets newTappableInsets = Insets.of(oldTappableInsets.left, oldTappableInsets.top, + oldTappableInsets.right, 0); + updatedInsetsBuilder.setInsets(WindowInsets.Type.tappableElement(), newTappableInsets); + + return updatedInsetsBuilder.build(); + } } } diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java index 87133fcb5a..321ff79308 100644 --- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java +++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java @@ -15,6 +15,7 @@ */ package com.android.launcher3.taskbar.allapps; +import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; import static com.android.launcher3.AbstractFloatingView.TYPE_ALL; @@ -158,6 +159,7 @@ public final class TaskbarAllAppsController implements OnDeviceProfileChangeList layoutParams.gravity = Gravity.BOTTOM; layoutParams.packageName = mTaskbarContext.getPackageName(); layoutParams.setFitInsetsTypes(0); // Handled by container view. + layoutParams.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS; layoutParams.setSystemApplicationOverlay(true); return layoutParams; }