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

Commit e9056a9e authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Address some insets issues in Taskbar All Apps" into tm-dev

parents ed6d3a47 27d33e29
Loading
Loading
Loading
Loading
+5 −5
Original line number Original line 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
    // 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.
    // 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
    // Currently any flag that causes us to stash in an app is included, except for IME or All Apps
    // covers the underlying app anyway and thus the app shouldn't change insets.
    // 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
    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.
     * 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
     * Returns whether the taskbar can visually stash into a handle based on the current device
     * state.
     * state.
     */
     */
    private boolean supportsVisualStashing() {
    public boolean supportsVisualStashing() {
        return !mActivity.isThreeButtonNav();
        return !mActivity.isThreeButtonNav();
    }
    }


@@ -254,7 +254,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
     * Returns the height that taskbar will inset when inside apps.
     * Returns the height that taskbar will inset when inside apps.
     */
     */
    public int getContentHeightToReportToApps() {
    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();
            boolean isAnimating = mAnimator != null && mAnimator.isStarted();
            return mControllers.stashedHandleViewController.isStashedHandleVisible() || isAnimating
            return mControllers.stashedHandleViewController.isStashedHandleVisible() || isAnimating
                    ? mStashedHeight : 0;
                    ? mStashedHeight : 0;
+41 −0
Original line number Original line 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 static com.android.systemui.shared.system.ViewTreeObserverWrapper.InsetsInfo.TOUCHABLE_INSETS_REGION;


import android.content.Context;
import android.content.Context;
import android.graphics.Insets;
import android.view.KeyEvent;
import android.view.KeyEvent;
import android.view.View;
import android.view.View;
import android.view.WindowInsets;


import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.DeviceProfile;
@@ -59,6 +61,10 @@ class TaskbarAllAppsContext extends BaseTaskbarContext {
    private final TaskbarAllAppsDragLayer mDragLayer;
    private final TaskbarAllAppsDragLayer mDragLayer;
    private final TaskbarAllAppsContainerView mAppsView;
    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(
    TaskbarAllAppsContext(
            TaskbarActivityContext taskbarContext,
            TaskbarActivityContext taskbarContext,
            TaskbarAllAppsController windowController,
            TaskbarAllAppsController windowController,
@@ -79,6 +85,9 @@ class TaskbarAllAppsContext extends BaseTaskbarContext {
                windowController,
                windowController,
                taskbarStashController);
                taskbarStashController);
        mAppsView = slideInView.getAppsView();
        mAppsView = slideInView.getAppsView();

        mWillTaskbarBeVisuallyStashed = taskbarStashController.supportsVisualStashing();
        mStashedTaskbarHeight = taskbarStashController.getStashedHeight();
    }
    }


    TaskbarAllAppsViewController getAllAppsViewController() {
    TaskbarAllAppsViewController getAllAppsViewController() {
@@ -189,5 +198,37 @@ class TaskbarAllAppsContext extends BaseTaskbarContext {
                inoutInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION);
                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 Original line Diff line number Diff line
@@ -15,6 +15,7 @@
 */
 */
package com.android.launcher3.taskbar.allapps;
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 android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;


import static com.android.launcher3.AbstractFloatingView.TYPE_ALL;
import static com.android.launcher3.AbstractFloatingView.TYPE_ALL;
@@ -158,6 +159,7 @@ public final class TaskbarAllAppsController implements OnDeviceProfileChangeList
        layoutParams.gravity = Gravity.BOTTOM;
        layoutParams.gravity = Gravity.BOTTOM;
        layoutParams.packageName = mTaskbarContext.getPackageName();
        layoutParams.packageName = mTaskbarContext.getPackageName();
        layoutParams.setFitInsetsTypes(0); // Handled by container view.
        layoutParams.setFitInsetsTypes(0); // Handled by container view.
        layoutParams.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
        layoutParams.setSystemApplicationOverlay(true);
        layoutParams.setSystemApplicationOverlay(true);
        return layoutParams;
        return layoutParams;
    }
    }