Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 27d33e29 authored by Tony Wickham's avatar Tony Wickham
Browse files

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
parent 54da6aa3
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -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;
+41 −0
Original line number Diff line number Diff line
@@ -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();
        }
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -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;
    }