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

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

Merge "3 button nav is laid out correctly." into main

parents f36e9414 989aa8ac
Loading
Loading
Loading
Loading
+30 −6
Original line number Diff line number Diff line
@@ -406,6 +406,12 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
            }
        };
        mSeparateWindowParent.recreateControllers();
        if (BubbleBarController.isBubbleBarEnabled()) {
            mNavButtonsView.addOnLayoutChangeListener(
                    (v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) ->
                            onLayoutsUpdated()
            );
        }
    }

    private void initButtons(ViewGroup navContainer, ViewGroup endContainer,
@@ -1180,15 +1186,20 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
    /** Adjusts navigation buttons layout accordingly to the bubble bar position. */
    @Override
    public void onBubbleBarLocationUpdated(BubbleBarLocation location) {
        boolean locationUpdated = location != mBubbleBarTargetLocation;
        if (locationUpdated) {
            cancelExistingNavBarAnimation();
        mBubbleBarTargetLocation = location;
        } else {
            endExistingAnimation();
        }
        mNavButtonContainer.setTranslationX(getNavBarTranslationX(location));
        mNavButtonContainer.setAlpha(1);
        mBubbleBarTargetLocation = location;
    }

    /** Animates navigation buttons accordingly to the bubble bar position. */
    @Override
    public void onBubbleBarLocationAnimated(BubbleBarLocation location) {
        if (location == mBubbleBarTargetLocation) return;
        cancelExistingNavBarAnimation();
        mBubbleBarTargetLocation = location;
        int finalX = getNavBarTranslationX(location);
@@ -1199,6 +1210,13 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
        mNavBarLocationAnimator.start();
    }

    private void endExistingAnimation() {
        if (mNavBarLocationAnimator != null) {
            mNavBarLocationAnimator.end();
            mNavBarLocationAnimator = null;
        }
    }

    private void cancelExistingNavBarAnimation() {
        if (mNavBarLocationAnimator != null) {
            mNavBarLocationAnimator.cancel();
@@ -1240,12 +1258,18 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
    }

    /** Adjusts the navigation buttons layout position according to the bubble bar location. */
    public void onTaskbarLayoutChanged() {
        if (mControllers.taskbarViewController.getIconLayoutBounds().isEmpty()) return;
    public void onLayoutsUpdated() {
        // no need to do anything if on phone, or if taskbar or navbar views were not placed on
        // screen.
        if (mContext.getDeviceProfile().isPhone
                || mControllers.taskbarViewController.getIconLayoutBounds().isEmpty()
                || mNavButtonsView.getWidth() == 0) {
            return;
        }
        if (enableBubbleBarInPersistentTaskBar()
                && mControllers.bubbleControllers.isPresent()) {
            if (mBubbleBarTargetLocation == null) {
                // only set bubble bar location if it was not set before, e.g. at device boot
                // only set bubble bar location if it was not set before
                mBubbleBarTargetLocation = mControllers.bubbleControllers.get()
                        .bubbleBarViewController.getBubbleBarLocation();
            }
+4 −1
Original line number Diff line number Diff line
@@ -278,7 +278,10 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
        // If Bubble bar is present, TaskbarControllers depends on it so build it first.
        Optional<BubbleControllers> bubbleControllersOptional = Optional.empty();
        BubbleBarController.onTaskbarRecreated();
        if (BubbleBarController.isBubbleBarEnabled() && bubbleBarView != null) {
        if (BubbleBarController.isBubbleBarEnabled()
                && !mDeviceProfile.isPhone
                && bubbleBarView != null
        ) {
            Optional<BubbleStashedHandleViewController> bubbleHandleController = Optional.empty();
            Optional<BubbleBarSwipeController> bubbleBarSwipeController = Optional.empty();
            if (isTransientTaskbar) {
+3 −2
Original line number Diff line number Diff line
@@ -220,11 +220,12 @@ public class TaskbarControllers {
        uiController = newUiController;
        uiController.init(this);
        uiController.updateStateForSysuiFlags(mSharedState.sysuiStateFlags);
        bubbleControllers.ifPresent(bubbleControllers -> {
        // if bubble controllers are present take bubble bar location, else set it to null
        bubbleControllers.ifPresentOrElse(bubbleControllers -> {
            BubbleBarLocation location =
                    bubbleControllers.bubbleBarViewController.getBubbleBarLocation();
            uiController.onBubbleBarLocationUpdated(location);
        });
        }, () -> uiController.onBubbleBarLocationUpdated(null));
        // Notify that the ui controller has changed
        navbarButtonsViewController.onUiControllerChanged();
    }
+23 −18
Original line number Diff line number Diff line
@@ -866,43 +866,49 @@ public class TaskbarLauncherStateController {
    }

    /** Updates launcher home screen appearance accordingly to the bubble bar location. */
    public void onBubbleBarLocationChanged(BubbleBarLocation location, boolean animate) {
        DeviceProfile deviceProfile = mLauncher.getDeviceProfile();
        if (mBubbleBarLocation == location) return;
    public void onBubbleBarLocationChanged(@Nullable BubbleBarLocation location, boolean animate) {
        mBubbleBarLocation = location;
        if (location == null) {
            // bubble bar is not present, hence no location, resetting the hotseat
            updateHotseatAndQsbTranslationX(0, animate);
            mBubbleBarLocation = null;
            return;
        }
        DeviceProfile deviceProfile = mLauncher.getDeviceProfile();
        if (!deviceProfile.shouldAdjustHotseatOnBubblesLocationUpdate(
                mControllers.taskbarActivityContext)) {
            return;
        }
        int targetX = 0;
        if (mBubbleBarLocation != null) {
        boolean isBubblesOnLeft = location.isOnLeft(isRtl(mLauncher.getResources()));
            targetX = deviceProfile.getHotseatTranslationXForBubbleBar(/* isNavbarOnRight= */
                    isBubblesOnLeft);
        }
        int targetX = deviceProfile
                .getHotseatTranslationXForBubbleBar(/* isNavbarOnRight= */ isBubblesOnLeft);
        updateHotseatAndQsbTranslationX(targetX, animate);
    }

    /** Used to translate hotseat and QSB to make room for bubbles. */
    private void updateHotseatAndQsbTranslationX(float targetValue, boolean animate) {
        // cancel existing animation
        if (mHotseatTranslationXAnimation != null) {
            mHotseatTranslationXAnimation.cancel();
            mHotseatTranslationXAnimation = null;
        }
        Runnable alignTaskbar = new Runnable() {
        Runnable postAnimationAction = new Runnable() {
            @Override
            public void run() {
                mHotseatTranslationXAnimation = null;
                // We only need to align the task bar when on launcher home screen
                if (mControllers.taskbarStashController.isOnHome()) {
                    DeviceProfile dp = mLauncher.getDeviceProfile();
                    mControllers.taskbarViewController
                            .setLauncherIconAlignment(/* alignmentRatio = */ 1, dp);
                    mControllers.taskbarViewController.setLauncherIconAlignment(
                            /* alignmentRatio = */ 1,
                            mLauncher.getDeviceProfile()
                    );
                }
            }
        };
        Hotseat hotseat = mLauncher.getHotseat();
        AnimatorSet translationXAnimation = new AnimatorSet();
        MultiProperty iconsTranslationX = hotseat.getIconsTranslationX(
                Hotseat.ICONS_TRANSLATION_X_NAV_BAR_ALIGNMENT);
        MultiProperty iconsTranslationX = mLauncher.getHotseat()
                .getIconsTranslationX(Hotseat.ICONS_TRANSLATION_X_NAV_BAR_ALIGNMENT);
        if (animate) {
            translationXAnimation.playTogether(iconsTranslationX.animateToValue(targetValue));
        } else {
@@ -921,18 +927,17 @@ public class TaskbarLauncherStateController {
            }
        }
        if (!animate) {
            alignTaskbar.run();
            postAnimationAction.run();
            return;
        }
        mHotseatTranslationXAnimation = translationXAnimation;
        translationXAnimation.setStartDelay(FADE_OUT_ANIM_POSITION_DURATION_MS);
        translationXAnimation.setDuration(FADE_IN_ANIM_ALPHA_DURATION_MS);
        translationXAnimation.setInterpolator(Interpolators.EMPHASIZED);
        translationXAnimation.addListener(AnimatorListeners.forEndCallback(alignTaskbar));
        translationXAnimation.addListener(AnimatorListeners.forEndCallback(postAnimationAction));
        translationXAnimation.start();
    }


    private final class TaskBarRecentsAnimationListener implements
            RecentsAnimationCallbacks.RecentsAnimationListener {
        private final RecentsAnimationCallbacks mCallbacks;
+3 −1
Original line number Diff line number Diff line
@@ -159,7 +159,9 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
    private final View.OnLayoutChangeListener mTaskbarViewLayoutChangeListener =
            (v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
                updateTaskbarIconTranslationXForPinning();
                mControllers.navbarButtonsViewController.onTaskbarLayoutChanged();
                if (BubbleBarController.isBubbleBarEnabled()) {
                    mControllers.navbarButtonsViewController.onLayoutsUpdated();
                }
            };

    // Animation to align icons with Launcher, created lazily. This allows the controller to be