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

Commit 2eea74b6 authored by Mykola Podolian's avatar Mykola Podolian Committed by Android (Google) Code Review
Browse files

Merge "Made the taskbar touchable during animation to home." into main

parents 8915d3c3 d89732ef
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -154,12 +154,6 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
        }
    }

    @Override
    protected boolean isTaskbarTouchable() {
        return !(mTaskbarLauncherStateController.isAnimatingToLauncher()
                && mTaskbarLauncherStateController.isTaskbarAlignedWithHotseat());
    }

    public void setShouldDelayLauncherStateAnim(boolean shouldDelayLauncherStateAnim) {
        mTaskbarLauncherStateController.setShouldDelayLauncherStateAnim(
                shouldDelayLauncherStateAnim);
@@ -452,6 +446,16 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
                    .getValue() == 0;
    }

    @Override
    public boolean isHotseatVisibleForTaskBarAlignment() {
        return mTaskbarLauncherStateController.isHotseatVisibleForTaskbarAlignment();
    }

    @Override
    public boolean isAnimatingToLauncher() {
        return mTaskbarLauncherStateController.isAnimatingToLauncher();
    }

    @Override
    protected boolean isInOverviewUi() {
        return mTaskbarLauncherStateController.isInOverviewUi();
+46 −23
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import androidx.core.graphics.toRegion
import com.android.internal.policy.GestureNavigationSettingsObserver
import com.android.launcher3.DeviceProfile
import com.android.launcher3.R
import com.android.launcher3.Utilities
import com.android.launcher3.anim.AlphaUpdateListener
import com.android.launcher3.config.FeatureFlags.ENABLE_TASKBAR_NAVBAR_UNIFICATION
import com.android.launcher3.config.FeatureFlags.enableTaskbarNoRecreate
@@ -82,7 +83,7 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas
            context.mainThreadHandler,
            Executors.UI_HELPER_EXECUTOR.handler,
            context,
            this::onTaskbarOrBubblebarWindowHeightOrInsetsChanged
            this::onTaskbarOrBubblebarWindowHeightOrInsetsChanged,
        )
    private val debugTouchableRegion = DebugTouchableRegion()

@@ -120,7 +121,7 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas
            if (enableTaskbarNoRecreate() && controllers.sharedState != null) {
                getProvidedInsets(
                    controllers.sharedState!!.insetsFrameProviders,
                    insetsRoundedCornerFlag
                    insetsRoundedCornerFlag,
                )
            } else {
                getProvidedInsets(insetsRoundedCornerFlag)
@@ -133,9 +134,6 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas
        }

        val bubbleControllers = controllers.bubbleControllers.getOrNull()
        val taskbarTouchableHeight = taskbarStashController.touchableHeight
        val bubblesTouchableHeight =
            bubbleControllers?.bubbleStashController?.getTouchableHeight() ?: 0
        // reset touch bounds
        defaultTouchableRegion.setEmpty()
        if (bubbleControllers != null) {
@@ -147,16 +145,45 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas
                defaultTouchableRegion.addBoundsToRegion(bubbleBarViewController.bubbleBarBounds)
            }
        }
        val uiController = controllers.uiController
        if (
            taskbarStashController.isInApp ||
                taskbarStashController.isInOverview ||
            !uiController.isHotseatVisibleForTaskBarAlignment ||
                DisplayController.showLockedTaskbarOnHome(context)
        ) {
            // only add the taskbar touch region if not on home
            // adding the taskbar touch region
            val touchableHeight: Int
            var left = 0
            var right = context.deviceProfile.widthPx
            var bubbleBarAdjustment = 0
            if (uiController.isAnimatingToLauncher) {
                val dp = controllers.taskbarActivityContext.deviceProfile
                touchableHeight = windowLayoutParams.height
                if (dp.isQsbInline) {
                    // if Qsb is inline need to exclude search icon from touch region
                    val isRtl = Utilities.isRtl(context.resources)
                    bubbleControllers?.bubbleBarViewController?.let {
                        if (dp.shouldAdjustHotseatOnBubblesLocationUpdate(context)) {
                            val isBubblesOnLeft = it.bubbleBarLocation.isOnLeft(isRtl)
                            bubbleBarAdjustment =
                                dp.getHotseatTranslationXForBubbleBar(isBubblesOnLeft, isRtl)
                        }
                    }
                    val hotseatPadding: Rect = dp.getHotseatLayoutPadding(context)
                    val borderSpacing: Int = dp.hotseatBorderSpace
                    if (isRtl) {
                        right =
                            dp.widthPx - hotseatPadding.right + borderSpacing + bubbleBarAdjustment
                    } else {
                        left = hotseatPadding.left - borderSpacing + bubbleBarAdjustment
                    }
                }
            } else {
                // if not animating to launcher use the taskbar touchanle height
                touchableHeight = taskbarStashController.touchableHeight
            }
            val bottom = windowLayoutParams.height
            val top = bottom - taskbarTouchableHeight
            val right = context.deviceProfile.widthPx
            defaultTouchableRegion.addBoundsToRegion(Rect(/* left= */ 0, top, right, bottom))
            val top = bottom - touchableHeight
            defaultTouchableRegion.addBoundsToRegion(Rect(left, top, right, bottom))
        }

        // Pre-calculate insets for different providers across different rotations for this gravity
@@ -181,7 +208,7 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas
     */
    private fun getProvidedInsets(
        providedInsets: Array<InsetsFrameProvider>,
        insetsRoundedCornerFlag: Int
        insetsRoundedCornerFlag: Int,
    ): Array<InsetsFrameProvider> {
        val navBarsFlag =
            (if (context.isGestureNav) FLAG_SUPPRESS_SCRIM else 0) or insetsRoundedCornerFlag
@@ -207,14 +234,14 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas
            InsetsFrameProvider(insetsOwner, 0, navigationBars())
                .setFlags(
                    navBarsFlag,
                    FLAG_SUPPRESS_SCRIM or FLAG_ANIMATE_RESIZING or FLAG_INSETS_ROUNDED_CORNER
                    FLAG_SUPPRESS_SCRIM or FLAG_ANIMATE_RESIZING or FLAG_INSETS_ROUNDED_CORNER,
                ),
            InsetsFrameProvider(insetsOwner, 0, tappableElement()),
            InsetsFrameProvider(insetsOwner, 0, mandatorySystemGestures()),
            InsetsFrameProvider(insetsOwner, INDEX_LEFT, systemGestures())
                .setSource(SOURCE_DISPLAY),
            InsetsFrameProvider(insetsOwner, INDEX_RIGHT, systemGestures())
                .setSource(SOURCE_DISPLAY)
                .setSource(SOURCE_DISPLAY),
        )
    }

@@ -232,7 +259,7 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas
                val gestureHeight =
                    ResourceUtils.getNavbarSize(
                        ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE,
                        context.resources
                        context.resources,
                    )
                val isPinnedTaskbar =
                    context.deviceProfile.isTaskbarPresent &&
@@ -272,8 +299,8 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas
                    // override below (insetsSizeOverrides must have the same length and
                    // types after the window is added according to
                    // WindowManagerService#relayoutWindow)
                    provider.insetsSize
                )
                    provider.insetsSize,
                ),
            )
        // Use 0 tappableElement insets for the VoiceInteractionWindow when gesture nav is enabled.
        val visInsetsSizeForTappableElement =
@@ -284,7 +311,7 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas
                InsetsFrameProvider.InsetsSizeOverride(TYPE_INPUT_METHOD, imeInsetsSize),
                InsetsFrameProvider.InsetsSizeOverride(
                    TYPE_VOICE_INTERACTION,
                    visInsetsSizeForTappableElement
                    visInsetsSizeForTappableElement,
                ),
            )
        if (
@@ -368,10 +395,6 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas
            // Let touches pass through us.
            insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION)
            debugTouchableRegion.lastSetTouchableReason = "Stashed over IME"
        } else if (!controllers.uiController.isTaskbarTouchable) {
            // Let touches pass through us.
            insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION)
            debugTouchableRegion.lastSetTouchableReason = "Taskbar is not touchable"
        } else if (controllers.taskbarDragController.isSystemDragInProgress) {
            // Let touches pass through us.
            insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION)
@@ -427,7 +450,7 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas
        // Always have nav buttons be touchable
        controllers.navbarButtonsViewController.addVisibleButtonsRegion(
            context.dragLayer,
            insetsInfo.touchableRegion
            insetsInfo.touchableRegion,
        )
        debugTouchableRegion.lastSetTouchableBounds.set(insetsInfo.touchableRegion.bounds)
        context.excludeFromMagnificationRegion(insetsIsTouchableRegion)
+23 −1
Original line number Diff line number Diff line
@@ -192,6 +192,8 @@ public class TaskbarLauncherStateController {

    private boolean mIsQsbInline;

    private boolean mIsHotseatVisibleForTaskbarAlignment;

    private final DeviceProfile.OnDeviceProfileChangeListener mOnDeviceProfileChangeListener =
            new DeviceProfile.OnDeviceProfileChangeListener() {
                @Override
@@ -738,6 +740,7 @@ public class TaskbarLauncherStateController {
            boolean committed) {
        boolean isInStashedState = mLauncherState.isTaskbarStashed(mLauncher);
        TaskbarStashController stashController = mControllers.taskbarStashController;
        TaskbarInsetsController insetsController = mControllers.taskbarInsetsController;
        stashController.updateStateForFlag(FLAG_IN_STASHED_LAUNCHER_STATE, isInStashedState);
        Animator stashAnimator = stashController.createApplyStateAnimator(duration);
        if (stashAnimator != null) {
@@ -746,7 +749,11 @@ public class TaskbarLauncherStateController {
                public void onAnimationEnd(Animator animation) {
                    if (isInStashedState && committed) {
                        // Reset hotseat alpha to default
                        mLauncher.getHotseat().setIconsAlpha(1, ALPHA_CHANNEL_TASKBAR_ALIGNMENT);
                        updateIconAlphaForHome(
                                /* taskbarAlpha = */ 0,
                                ALPHA_CHANNEL_TASKBAR_ALIGNMENT,
                                /* updateTaskbarAlpha = */ false
                        );
                    }
                }

@@ -871,6 +878,14 @@ public class TaskbarLauncherStateController {
        if (mIsQsbInline) {
            mLauncher.getHotseat().setQsbAlpha(targetAlpha, alphaChannel);
        }
        if (alphaChannel == ALPHA_CHANNEL_TASKBAR_ALIGNMENT) {
            boolean isHotseatVisibleForTaskbarAlignment = isHotseatVisibleForTaskbarAlignment();
            if (mIsHotseatVisibleForTaskbarAlignment != isHotseatVisibleForTaskbarAlignment) {
                mIsHotseatVisibleForTaskbarAlignment = isHotseatVisibleForTaskbarAlignment;
                mControllers.taskbarInsetsController
                        .onTaskbarOrBubblebarWindowHeightOrInsetsChanged();
            }
        }
    }

    /** Updates launcher home screen appearance accordingly to the bubble bar location. */
@@ -932,6 +947,13 @@ public class TaskbarLauncherStateController {
        translationXAnimation.start();
    }

    /** Returns true if hotseat icons visible for the taskbar alignment */
    public boolean isHotseatVisibleForTaskbarAlignment() {
        return mLauncher.getHotseat()
                .getIconsAlpha(ALPHA_CHANNEL_TASKBAR_ALIGNMENT).getValue() == 1;
    }


    private final class TaskBarRecentsAnimationListener implements
            RecentsAnimationCallbacks.RecentsAnimationListener {
        private final RecentsAnimationCallbacks mCallbacks;
+8 −2
Original line number Diff line number Diff line
@@ -75,8 +75,14 @@ public class TaskbarUIController implements BubbleBarController.BubbleBarLocatio
        mControllers = null;
    }

    protected boolean isTaskbarTouchable() {
        return true;
    /** Returns true if transition animation to launcher home is being played. */
    public boolean isAnimatingToLauncher() {
        return false;
    }

    /** Returns true if hotseat icons visible for the taskbar alignment. */
    public boolean isHotseatVisibleForTaskBarAlignment() {
        return false;
    }

    /**
+0 −1
Original line number Diff line number Diff line
@@ -185,7 +185,6 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
                    resources.getDrawable(R.drawable.taskbar_overflow_icon));
            mTaskbarOverflowView.setPadding(mItemPadding, mItemPadding, mItemPadding, mItemPadding);
        }
        // TODO: Disable touch events on QSB otherwise it can crash.
        mQsb = LayoutInflater.from(context).inflate(R.layout.search_container_hotseat, this, false);

        mMaxNumIcons = calculateMaxNumIcons();