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

Commit dfb48214 authored by mpodolian's avatar mpodolian
Browse files

Update placement of the hotseat according to the bubble bar location.

Update the hotseat and Qsb placement according to the 3 nav buttons bar.

Test: Manual.
Set navigation mode to 3 buttons.
On launcher home screen move the bubble bar from one side to another.
Observe that the Hotseat and Qsb moving together with the navigation
bar.
Once moved the bubble bar, expand the bubble bar and collapse it.
Observe how the Hotseat is stashing and un-stashing.
After bubble bar changes position hit the recent apps button, observe
the transition.
On launcher home screen start application with the hotseat icon and exit
opened application. Observe that flying icon comes back to the correct
position in the hotseat.
Video with the above scenarios:
http://recall/-/gx8ASgewUeUS3QYohfrd1J/blTYrKopTyufOcRoPuVpYK
Bug: 346381754
Flag: com.android.wm.shell.enable_bubble_bar_in_persistent_task_bar

Change-Id: Ic8c6acdffbbb111cbe4f3fd6bc60195578d7035d
parent bce3fb11
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -1353,8 +1353,13 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
                            ? null
                            : mLauncher.getTaskbarUIController().findMatchingView(launcherView),
                    true /* hideOriginal */, targetRect, false /* isOpening */);
            isInHotseat = launcherView.getTag() instanceof ItemInfo
                    && ((ItemInfo) launcherView.getTag()).isInHotseat();
            if (launcherView.getTag() instanceof ItemInfo itemInfo) {
                isInHotseat = itemInfo.isInHotseat();
                if (isInHotseat) {
                    int dx = mLauncher.getHotseatItemTranslationX(itemInfo);
                    targetRect.offset(dx, 0);
                }
            }
        } else {
            targetRect.set(getDefaultWindowTargetRect());
        }
+13 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ import com.android.quickstep.util.GroupTask;
import com.android.quickstep.util.TISBindHelper;
import com.android.quickstep.views.RecentsView;
import com.android.systemui.shared.system.QuickStepContract.SystemUiStateFlags;
import com.android.wm.shell.shared.bubbles.BubbleBarLocation;
import com.android.wm.shell.shared.desktopmode.DesktopModeStatus;

import java.io.PrintWriter;
@@ -487,6 +488,18 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
        return "LauncherTaskbarUIController";
    }

    @Override
    public void onBubbleBarLocationAnimated(BubbleBarLocation location) {
        mTaskbarLauncherStateController.onBubbleBarLocationChanged(location, /* animate = */ true);
        mLauncher.setBubbleBarLocation(location);
    }

    @Override
    public void onBubbleBarLocationUpdated(BubbleBarLocation location) {
        mTaskbarLauncherStateController.onBubbleBarLocationChanged(location, /* animate = */ false);
        mLauncher.setBubbleBarLocation(location);
    }

    @Override
    public void onSwipeToUnstashTaskbar() {
        // Once taskbar is unstashed, the user cannot return back to the overlay. We can
+10 −3
Original line number Diff line number Diff line
@@ -201,6 +201,8 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT

    private final Rect mFloatingRotationButtonBounds = new Rect();

    private @Nullable BubbleBarLocation mBubbleBarLocation;

    // Initialized in init.
    private TaskbarControllers mControllers;
    private boolean mIsImeRenderingNavButtons;
@@ -1174,6 +1176,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
    /** Adjusts navigation buttons layout accordingly to the bubble bar position. */
    @Override
    public void onBubbleBarLocationUpdated(BubbleBarLocation location) {
        mBubbleBarLocation = location;
        mNavButtonContainer.setTranslationX(getNavBarTranslationX(location));
    }

@@ -1181,6 +1184,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
    @Override
    public void onBubbleBarLocationAnimated(BubbleBarLocation location) {
        // TODO(b/346381754) add the teleport animation similarly to the bubble bar
        mBubbleBarLocation = location;
        mNavButtonContainer.setTranslationX(getNavBarTranslationX(location));
    }

@@ -1221,9 +1225,12 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
    public void onTaskbarLayoutChange() {
        if (com.android.wm.shell.Flags.enableBubbleBarInPersistentTaskBar()
                && mControllers.bubbleControllers.isPresent()) {
            BubbleBarLocation bubblesLocation = mControllers.bubbleControllers.get()
            if (mBubbleBarLocation == null) {
                // only set bubble bar location if it was not set before, e.g. at device boot
                mBubbleBarLocation = mControllers.bubbleControllers.get()
                        .bubbleBarViewController.getBubbleBarLocation();
            onBubbleBarLocationUpdated(bubblesLocation);
            }
            onBubbleBarLocationUpdated(mBubbleBarLocation);
        }
    }

+6 −1
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import com.android.launcher3.taskbar.allapps.TaskbarAllAppsController;
import com.android.launcher3.taskbar.bubbles.BubbleControllers;
import com.android.launcher3.taskbar.overlay.TaskbarOverlayController;
import com.android.systemui.shared.rotation.RotationButtonController;
import com.android.wm.shell.shared.bubbles.BubbleBarLocation;

import java.io.PrintWriter;
import java.util.ArrayList;
@@ -219,7 +220,11 @@ public class TaskbarControllers {
        uiController = newUiController;
        uiController.init(this);
        uiController.updateStateForSysuiFlags(mSharedState.sysuiStateFlags);

        bubbleControllers.ifPresent(bubbleControllers -> {
            BubbleBarLocation location =
                    bubbleControllers.bubbleBarViewController.getBubbleBarLocation();
            uiController.onBubbleBarLocationUpdated(location);
        });
        // Notify that the ui controller has changed
        navbarButtonsViewController.onUiControllerChanged();
    }
+79 −0
Original line number Diff line number Diff line
@@ -19,11 +19,14 @@ import static com.android.app.animation.Interpolators.EMPHASIZED;
import static com.android.launcher3.Hotseat.ALPHA_CHANNEL_TASKBAR_ALIGNMENT;
import static com.android.launcher3.Hotseat.ALPHA_CHANNEL_TASKBAR_STASH;
import static com.android.launcher3.LauncherState.HOTSEAT_ICONS;
import static com.android.launcher3.Utilities.isRtl;
import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_IN_APP;
import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_IN_OVERVIEW;
import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_IN_STASHED_LAUNCHER_STATE;
import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_STASHED_FOR_BUBBLES;
import static com.android.launcher3.taskbar.TaskbarViewController.ALPHA_INDEX_HOME;
import static com.android.launcher3.taskbar.bubbles.BubbleBarView.FADE_IN_ANIM_ALPHA_DURATION_MS;
import static com.android.launcher3.taskbar.bubbles.BubbleBarView.FADE_OUT_ANIM_POSITION_DURATION_MS;
import static com.android.launcher3.util.FlagDebugUtils.appendFlag;
import static com.android.launcher3.util.FlagDebugUtils.formatFlagChange;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_AWAKE;
@@ -42,8 +45,10 @@ import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.android.app.animation.Interpolators;
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Hotseat;
import com.android.launcher3.Hotseat.HotseatQsbAlphaId;
import com.android.launcher3.LauncherState;
import com.android.launcher3.QuickstepTransitionManager;
@@ -62,6 +67,7 @@ import com.android.quickstep.views.RecentsView;
import com.android.systemui.animation.ViewRootSync;
import com.android.systemui.shared.recents.model.ThumbnailData;
import com.android.systemui.shared.system.QuickStepContract.SystemUiStateFlags;
import com.android.wm.shell.shared.bubbles.BubbleBarLocation;

import java.io.PrintWriter;
import java.util.HashMap;
@@ -151,6 +157,7 @@ public class TaskbarLauncherStateController {
    private AnimatedFloat mTaskbarAlpha;
    private AnimatedFloat mTaskbarCornerRoundness;
    private MultiProperty mTaskbarAlphaForHome;
    private @Nullable Animator mHotseatTranslationXAnimation;
    private QuickstepLauncher mLauncher;

    private boolean mIsDestroyed = false;
@@ -168,6 +175,8 @@ public class TaskbarLauncherStateController {

    private boolean mShouldDelayLauncherStateAnim;

    private @Nullable BubbleBarLocation mBubbleBarLocation;

    // We skip any view synchronizations during init/destroy.
    private boolean mCanSyncViews;

@@ -185,6 +194,8 @@ public class TaskbarLauncherStateController {
                    mIsQsbInline = dp.isQsbInline;
                    TaskbarLauncherStateController.this.updateIconAlphaForHome(
                            mTaskbarAlphaForHome.getValue(), ALPHA_CHANNEL_TASKBAR_ALIGNMENT);
                    TaskbarLauncherStateController.this.onBubbleBarLocationChanged(
                            mBubbleBarLocation, /* animate = */ false);
                }
            };

@@ -833,6 +844,74 @@ 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;
        mBubbleBarLocation = location;
        if (!deviceProfile.shouldAdjustHotseatOnBubblesLocationUpdate(
                mControllers.taskbarActivityContext)) {
            return;
        }
        int targetX = 0;
        if (mBubbleBarLocation != null) {
            boolean isBubblesOnLeft = location.isOnLeft(isRtl(mLauncher.getResources()));
            targetX = deviceProfile.getHotseatTranslationXForBubbleBar(/* isNavbarOnRight= */
                    isBubblesOnLeft);
        }
        updateHotseatAndQsbTranslationX(targetX, animate);
    }

    private void updateHotseatAndQsbTranslationX(float targetValue, boolean animate) {
        // cancel existing animation
        if (mHotseatTranslationXAnimation != null) {
            mHotseatTranslationXAnimation.cancel();
        }
        Runnable alignTaskbar = new Runnable() {
            @Override
            public void run() {
                // 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);
                }
            }
        };
        Hotseat hotseat = mLauncher.getHotseat();
        AnimatorSet translationXAnimation = new AnimatorSet();
        MultiProperty iconsTranslationX = hotseat.getIconsTranslationX(
                Hotseat.ICONS_TRANSLATION_X_NAV_BAR_ALIGNMENT);
        if (animate) {
            translationXAnimation.playTogether(iconsTranslationX.animateToValue(targetValue));
        } else {
            iconsTranslationX.setValue(targetValue);
        }
        float qsbTargetX = 0;
        if (mIsQsbInline) {
            qsbTargetX = targetValue;
        }
        MultiProperty qsbTranslationX = hotseat.getQsbTranslationX();
        if (qsbTranslationX != null) {
            if (animate) {
                translationXAnimation.playTogether(qsbTranslationX.animateToValue(qsbTargetX));
            } else {
                qsbTranslationX.setValue(qsbTargetX);
            }
        }
        if (!animate) {
            alignTaskbar.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.start();
    }


    private final class TaskBarRecentsAnimationListener implements
            RecentsAnimationCallbacks.RecentsAnimationListener {
        private final RecentsAnimationCallbacks mCallbacks;
Loading