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

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

Merge "Refactored hotseat translation X logic" into main

parents 4eaf3df1 1d4e75c7
Loading
Loading
Loading
Loading
+7 −11
Original line number Diff line number Diff line
@@ -151,30 +151,26 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas
                DisplayController.showLockedTaskbarOnHome(context)
        ) {
            // adding the taskbar touch region
            val touchableHeight: Int
            var left = 0
            var right = context.deviceProfile.widthPx
            var bubbleBarAdjustment = 0
            val touchableHeight: Int
            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)
                    val navBarOffset =
                        bubbleControllers?.bubbleBarViewController?.let {
                        if (dp.shouldAdjustHotseatOnBubblesLocationUpdate(context)) {
                            val isBubblesOnLeft = it.bubbleBarLocation.isOnLeft(isRtl)
                            bubbleBarAdjustment =
                                dp.getHotseatTranslationXForBubbleBar(isBubblesOnLeft, isRtl)
                        }
                    }
                            dp.getHotseatTranslationXForNavBar(context, isBubblesOnLeft)
                        } ?: 0
                    val hotseatPadding: Rect = dp.getHotseatLayoutPadding(context)
                    val borderSpacing: Int = dp.hotseatBorderSpace
                    if (isRtl) {
                        right =
                            dp.widthPx - hotseatPadding.right + borderSpacing + bubbleBarAdjustment
                        right = dp.widthPx - hotseatPadding.right + borderSpacing + navBarOffset
                    } else {
                        left = hotseatPadding.left - borderSpacing + bubbleBarAdjustment
                        left = hotseatPadding.left - borderSpacing + navBarOffset
                    }
                }
            } else {
+4 −5
Original line number Diff line number Diff line
@@ -886,19 +886,18 @@ public class TaskbarLauncherStateController {
        mBubbleBarLocation = location;
        if (location == null) {
            // bubble bar is not present, hence no location, resetting the hotseat
            updateHotseatAndQsbTranslationX(0, animate);
            updateHotseatAndQsbTranslationX(/* targetValue = */ 0, animate);
            mBubbleBarLocation = null;
            return;
        }
        DeviceProfile deviceProfile = mLauncher.getDeviceProfile();
        if (!deviceProfile.shouldAdjustHotseatOnBubblesLocationUpdate(
        if (!deviceProfile.shouldAdjustHotseatOnNavBarLocationUpdate(
                mControllers.taskbarActivityContext)) {
            return;
        }
        boolean isRtl = isRtl(mLauncher.getResources());
        boolean isBubblesOnLeft = location.isOnLeft(isRtl);
        boolean isBubblesOnLeft = location.isOnLeft(isRtl(mLauncher.getResources()));
        int targetX = deviceProfile
                .getHotseatTranslationXForBubbleBar(isBubblesOnLeft, isRtl);
                .getHotseatTranslationXForNavBar(mLauncher, isBubblesOnLeft);
        updateHotseatAndQsbTranslationX(targetX, animate);
    }

+4 −5
Original line number Diff line number Diff line
@@ -837,12 +837,11 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar

        int firstRecentTaskIndex = -1;
        int hotseatNavBarTranslationX = 0;
        if (mCurrentBubbleBarLocation != null
                && taskbarDp.shouldAdjustHotseatOnBubblesLocationUpdate(mActivity)) {
            boolean isRtl = mTaskbarView.isLayoutRtl();
            boolean isBubblesOnLeft = mCurrentBubbleBarLocation.isOnLeft(isRtl);
        if (mCurrentBubbleBarLocation != null) {
            boolean isBubblesOnLeft = mCurrentBubbleBarLocation
                    .isOnLeft(mTaskbarView.isLayoutRtl());
            hotseatNavBarTranslationX = taskbarDp
                    .getHotseatTranslationXForBubbleBar(isBubblesOnLeft, isRtl);
                    .getHotseatTranslationXForNavBar(mActivity, isBubblesOnLeft);
        }
        for (int i = 0; i < mTaskbarView.getChildCount(); i++) {
            View child = mTaskbarView.getChildAt(i);
+2 −3
Original line number Diff line number Diff line
@@ -1101,10 +1101,9 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer,
        if (isBubbleBarEnabled()
                && enableBubbleBarInPersistentTaskBar()
                && mBubbleBarLocation != null) {
            boolean isRtl = isRtl(getResources());
            boolean isBubblesOnLeft = mBubbleBarLocation.isOnLeft(isRtl);
            boolean isBubblesOnLeft = mBubbleBarLocation.isOnLeft(isRtl(getResources()));
            translationX += mDeviceProfile
                    .getHotseatTranslationXForBubbleBar(isBubblesOnLeft, isRtl);
                    .getHotseatTranslationXForNavBar(this, isBubblesOnLeft);
        }
        if (isBubbleBarEnabled()
                && mDeviceProfile.shouldAdjustHotseatForBubbleBar(getContext(), hasBubbles())) {
+10 −5
Original line number Diff line number Diff line
@@ -2355,19 +2355,24 @@ public class DeviceProfile {
    /**
     * Returns whether Taskbar and Hotseat should adjust horizontally on bubble bar location update.
     */
    public boolean shouldAdjustHotseatOnBubblesLocationUpdate(Context context) {
    public boolean shouldAdjustHotseatOnNavBarLocationUpdate(Context context) {
        return enableBubbleBar()
                && enableBubbleBarInPersistentTaskBar()
                && !DisplayController.getNavigationMode(context).hasGestures;
    }

    /** Returns hotseat translation X for the bubble bar position. */
    public int getHotseatTranslationXForBubbleBar(boolean isNavbarOnRight, boolean isRtl) {
        if (isNavbarOnRight) {
    public int getHotseatTranslationXForNavBar(Context context, boolean isBubblesOnLeft) {
        if (shouldAdjustHotseatOnNavBarLocationUpdate(context)) {
            boolean isRtl = Utilities.isRtl(context.getResources());
            if (isBubblesOnLeft) {
                return isRtl ? -navButtonsLayoutWidthPx : 0;
            } else {
                return isRtl ? 0 : navButtonsLayoutWidthPx;
            }
        } else {
            return 0;
        }
    }

    /**