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

Commit 29f74740 authored by Jon Miranda's avatar Jon Miranda
Browse files

Have responsive taskbar UI during swipe up gesture.

- Makes taskbar threshold an absolute Y threshold
  instead of a distance threshold.
- Moves handle, taskbar view, and taskbar background
  during the swipe up gesture

Next CL will address transforming the nav handle <-> taskbar
and ensuring that there's a clean handoff

Bug: 246631059
Test: swipe up on taskbar, release. see bounce
      swipe up on taskbar to go home, proper icon alignment
      swipe up on taskbar, pause for overview, see bounce
      -> further movement should not move taskbar
      test launcher3

Change-Id: I141236fd72428cda7edd0ff116de1d478d18c722
parent cd587212
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -193,7 +193,15 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
     */
    public Animator createAnimToLauncher(@NonNull LauncherState toState,
            @NonNull RecentsAnimationCallbacks callbacks, long duration) {
        return mTaskbarLauncherStateController.createAnimToLauncher(toState, callbacks, duration);
        AnimatorSet set = new AnimatorSet();
        Animator taskbarState = mTaskbarLauncherStateController
                .createAnimToLauncher(toState, callbacks, duration);
        long halfDuration = Math.round(duration * 0.5f);
        Animator translation =
                mControllers.taskbarTranslationController.createAnimToLauncher(halfDuration);

        set.playTogether(taskbarState, translation);
        return set;
    }

    /**
+25 −5
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.anim.RevealOutlineAnimation;
import com.android.launcher3.anim.RoundedRectRevealOutlineProvider;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.Executors;
import com.android.launcher3.util.MultiPropertyFactory;
import com.android.launcher3.util.MultiValueAlpha;
@@ -66,6 +67,7 @@ public class StashedHandleViewController implements TaskbarControllers.LoggableT

    // Initialized in init.
    private TaskbarControllers mControllers;
    private int mTaskbarSize;

    // The bounds we want to clip to in the settled state when showing the stashed handle.
    private final Rect mStashedHandleBounds = new Rect();
@@ -96,15 +98,18 @@ public class StashedHandleViewController implements TaskbarControllers.LoggableT
        DeviceProfile deviceProfile = mActivity.getDeviceProfile();
        Resources resources = mActivity.getResources();
        if (isPhoneGestureNavMode(mActivity.getDeviceProfile())) {
            mStashedHandleView.getLayoutParams().height =
                    resources.getDimensionPixelSize(R.dimen.taskbar_size);
            mTaskbarSize = resources.getDimensionPixelSize(R.dimen.taskbar_size);
            mStashedHandleWidth =
                    resources.getDimensionPixelSize(R.dimen.taskbar_stashed_small_screen);
        } else {
            mStashedHandleView.getLayoutParams().height = deviceProfile.taskbarSize;
            mTaskbarSize = deviceProfile.taskbarSize;
            mStashedHandleWidth = resources
                    .getDimensionPixelSize(R.dimen.taskbar_stashed_handle_width);
        }
        int taskbarBottomMargin = DisplayController.isTransientTaskbar(mActivity)
                ? resources.getDimensionPixelSize(R.dimen.transient_taskbar_margin)
                : 0;
        mStashedHandleView.getLayoutParams().height = mTaskbarSize + taskbarBottomMargin;

        mTaskbarStashedHandleAlpha.get(ALPHA_INDEX_STASHED).setValue(
                isPhoneGestureNavMode(deviceProfile) ? 1 : 0);
@@ -181,9 +186,17 @@ public class StashedHandleViewController implements TaskbarControllers.LoggableT
     * morphs into the size of where the taskbar icons will be.
     */
    public Animator createRevealAnimToIsStashed(boolean isStashed) {
        Rect visualBounds = new Rect(mControllers.taskbarViewController.getIconLayoutBounds());

        if (DisplayController.isTransientTaskbar(mActivity)) {
            // Account for the full visual height of the transient taskbar.
            int heightDiff = (mTaskbarSize - visualBounds.height()) / 2;
            visualBounds.top -= heightDiff;
            visualBounds.bottom += heightDiff;
        }

        final RevealOutlineAnimation handleRevealProvider = new RoundedRectRevealOutlineProvider(
                mStashedHandleRadius, mStashedHandleRadius,
                mControllers.taskbarViewController.getIconLayoutBounds(), mStashedHandleBounds);
                mStashedHandleRadius, mStashedHandleRadius, visualBounds, mStashedHandleBounds);

        boolean isReversed = !isStashed;
        boolean changingDirection = mWasLastRevealAnimReversed != isReversed;
@@ -219,6 +232,13 @@ public class StashedHandleViewController implements TaskbarControllers.LoggableT
        mStashedHandleView.setScaleY(mTaskbarStashedHandleHintScale.value);
    }

    /**
     * Sets the translation of the stashed handle during the swipe up gesture.
     */
    protected void setTranslationYForSwipe(float transY) {
        mStashedHandleView.setTranslationY(transY);
    }

    /**
     * Should be called when the home button is disabled, so we can hide this handle as well.
     */
+16 −0
Original line number Diff line number Diff line
@@ -78,6 +78,7 @@ import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.popup.PopupDataProvider;
import com.android.launcher3.taskbar.TaskbarAutohideSuspendController.AutohideSuspendFlag;
import com.android.launcher3.taskbar.TaskbarTranslationController.TransitionCallback;
import com.android.launcher3.taskbar.allapps.TaskbarAllAppsController;
import com.android.launcher3.taskbar.overlay.TaskbarOverlayController;
import com.android.launcher3.testing.TestLogging;
@@ -223,6 +224,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
                new TaskbarAllAppsController(),
                new TaskbarInsetsController(this),
                new VoiceInteractionWindowController(this),
                new TaskbarTranslationController(this),
                isDesktopMode
                        ? new DesktopTaskbarRecentAppsController(this)
                        : TaskbarRecentAppsController.DEFAULT);
@@ -833,6 +835,20 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
        mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(false);
    }

    /**
     * Called to start the taskbar translation spring to its settled translation (0).
     */
    public void startTranslationSpring() {
        mControllers.taskbarTranslationController.startSpring();
    }

    /**
     * Returns a callback to help monitor the swipe gesture.
     */
    public TransitionCallback getTranslationCallbacks() {
        return mControllers.taskbarTranslationController.getTransitionCallback();
    }

    /**
     * Called when a transient Autohide flag suspend status changes.
     */
+5 −2
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ class TaskbarBackgroundRenderer(context: TaskbarActivityContext) {

    val paint: Paint = Paint()
    var backgroundHeight = context.deviceProfile.taskbarSize.toFloat()
    var translationYForSwipe = 0f

    private var maxBackgroundHeight = context.deviceProfile.taskbarSize.toFloat()
    private val transientBackgroundBounds = context.transientTaskbarBounds
@@ -114,11 +115,13 @@ class TaskbarBackgroundRenderer(context: TaskbarActivityContext) {
            canvas.translate(canvas.width - rightCornerRadius, -rightCornerRadius)
            canvas.drawPath(invertedRightCornerPath, paint)
        } else {
            // Approximates the stash/unstash animation to transform the background.
            val scaleFactor = backgroundHeight / maxBackgroundHeight
            val width = transientBackgroundBounds.width()
            val widthScale = mapToRange(scaleFactor, 0f, 1f, 0.4f, 1f, Interpolators.LINEAR)
            val newWidth = widthScale * width
            val delta = width - newWidth
            canvas.translate(0f, bottomMargin * ((1f - scaleFactor) / 2f))

            // Draw shadow.
            val shadowAlpha = mapToRange(paint.alpha.toFloat(), 0f, 255f, 0f, 25f,
@@ -132,9 +135,9 @@ class TaskbarBackgroundRenderer(context: TaskbarActivityContext) {

            canvas.drawRoundRect(
                transientBackgroundBounds.left + (delta / 2f),
                0f,
                translationYForSwipe,
                transientBackgroundBounds.right - (delta / 2f),
                backgroundHeight,
                backgroundHeight + translationYForSwipe,
                radius, radius, paint
            )
        }
+5 −1
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ public class TaskbarControllers {
    public final TaskbarInsetsController taskbarInsetsController;
    public final VoiceInteractionWindowController voiceInteractionWindowController;
    public final TaskbarRecentAppsController taskbarRecentAppsController;
    public final TaskbarTranslationController taskbarTranslationController;
    public final TaskbarOverlayController taskbarOverlayController;

    @Nullable private LoggableTaskbarController[] mControllersToLog = null;
@@ -92,6 +93,7 @@ public class TaskbarControllers {
            TaskbarAllAppsController taskbarAllAppsController,
            TaskbarInsetsController taskbarInsetsController,
            VoiceInteractionWindowController voiceInteractionWindowController,
            TaskbarTranslationController taskbarTranslationController,
            TaskbarRecentAppsController taskbarRecentAppsController) {
        this.taskbarActivityContext = taskbarActivityContext;
        this.taskbarDragController = taskbarDragController;
@@ -113,6 +115,7 @@ public class TaskbarControllers {
        this.taskbarAllAppsController = taskbarAllAppsController;
        this.taskbarInsetsController = taskbarInsetsController;
        this.voiceInteractionWindowController = voiceInteractionWindowController;
        this.taskbarTranslationController = taskbarTranslationController;
        this.taskbarRecentAppsController = taskbarRecentAppsController;
    }

@@ -144,6 +147,7 @@ public class TaskbarControllers {
        taskbarInsetsController.init(this);
        voiceInteractionWindowController.init(this);
        taskbarRecentAppsController.init(this);
        taskbarTranslationController.init(this);

        mControllersToLog = new LoggableTaskbarController[] {
                taskbarDragController, navButtonController, navbarButtonsViewController,
@@ -151,7 +155,7 @@ public class TaskbarControllers {
                taskbarUnfoldAnimationController, taskbarKeyguardController,
                stashedHandleViewController, taskbarStashController, taskbarEduController,
                taskbarAutohideSuspendController, taskbarPopupController, taskbarInsetsController,
                voiceInteractionWindowController
                voiceInteractionWindowController, taskbarTranslationController
        };
        mBackgroundRendererControllers = new BackgroundRendererController[] {
                taskbarDragLayerController, taskbarScrimViewController,
Loading