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

Commit 63d08c4e authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 12735943 from 79fb6dfb to 25Q1-release

Change-Id: I56fa830920320f3495e84626b96ae626d27e6169
parents 123d8f96 79fb6dfb
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -113,13 +113,13 @@ class ManageWindowsTaskbarShortcut<T>(
    private fun createAndPositionTaskbarShortcut(taskList: ArrayList<Pair<Int, Bitmap?>>) {
        val onIconClickListener =
            ({ taskId: Int? ->
                taskbarShortcutAllWindowsView.removeFromContainer()
                taskbarShortcutAllWindowsView.animateClose()
                if (taskId != null) {
                    SystemUiProxy.INSTANCE.get(target).showDesktopApp(taskId, null)
                }
            })

        val onOutsideClickListener = { taskbarShortcutAllWindowsView.removeFromContainer() }
        val onOutsideClickListener = { taskbarShortcutAllWindowsView.animateClose() }

        taskbarShortcutAllWindowsView =
            TaskbarShortcutManageWindowsView(
@@ -172,6 +172,7 @@ class ManageWindowsTaskbarShortcut<T>(
        init {
            createAndShowMenuView(snapshotList, onIconClickListener, onOutsideClickListener)
            taskbarOverlayContext.dragLayer.addTouchController(this)
            animateOpen()
        }

        /** Adds the carousel menu to the taskbar overlay drag layer */
@@ -245,7 +246,7 @@ class ManageWindowsTaskbarShortcut<T>(
                    it.action == MotionEvent.ACTION_DOWN &&
                        !taskbarOverlayContext.dragLayer.isEventOverView(menuView.rootView, it)
                ) {
                    removeFromContainer()
                    animateClose()
                }
            }
            return false
+31 −2
Original line number Diff line number Diff line
@@ -81,6 +81,7 @@ public class BubbleBarView extends FrameLayout {

    public static final long FADE_OUT_ANIM_POSITION_DURATION_MS = 100L;
    public static final long FADE_IN_ANIM_ALPHA_DURATION_MS = 100L;
    public static final long FADE_OUT_BUBBLE_BAR_DURATION_MS = 150L;
    private static final String TAG = "BubbleBarView";
    // TODO: (b/273594744) calculate the amount of space we have and base the max on that
    //  if it's smaller than 5.
@@ -146,6 +147,9 @@ public class BubbleBarView extends FrameLayout {
    // collapsed state and 1 to the fully expanded state.
    private ValueAnimator mWidthAnimator = createExpansionAnimator(/* expanding = */ false);

    @Nullable
    private ValueAnimator mDismissAnimator = null;

    /** An animator used for animating individual bubbles in the bubble bar while expanded. */
    @Nullable
    private BubbleAnimator mBubbleAnimator = null;
@@ -798,11 +802,11 @@ public class BubbleBarView extends FrameLayout {
    /** Removes the given bubble from the bubble bar. */
    public void removeBubble(View bubble) {
        if (isExpanded()) {
            // TODO b/347062801 - animate the bubble bar if the last bubble is removed
            final boolean dismissedByDrag = mDraggedBubbleView == bubble;
            if (dismissedByDrag) {
                mDismissedByDragBubbleView = mDraggedBubbleView;
            }
            boolean removingLastRemainingBubble = getBubbleChildCount() == 1;
            int bubbleCount = getChildCount();
            mBubbleAnimator = new BubbleAnimator(mIconSize, mExpandedBarIconsSpacing,
                    bubbleCount, mBubbleBarLocation.isOnLeft(isLayoutRtl()));
@@ -840,7 +844,10 @@ public class BubbleBarView extends FrameLayout {
                            : bubbleIndex == bubbleCount - 1;
            mBubbleAnimator.animateRemovedBubble(
                    indexOfChild(bubble), indexOfChild(mSelectedBubbleView), removingLastBubble,
                    listener);
                    removingLastRemainingBubble, listener);
            if (removingLastRemainingBubble && mDismissAnimator == null) {
                createDismissAnimator().start();
            }
        } else {
            removeView(bubble);
        }
@@ -861,6 +868,28 @@ public class BubbleBarView extends FrameLayout {
        updateDotsAndBadgesIfCollapsed();
    }

    private ValueAnimator createDismissAnimator() {
        ValueAnimator animator =
                ValueAnimator.ofFloat(0, 1).setDuration(FADE_OUT_BUBBLE_BAR_DURATION_MS);
        animator.setInterpolator(Interpolators.EMPHASIZED);
        Runnable onEnd = () -> {
            mDismissAnimator = null;
            setAlpha(0);
        };
        addAnimationCallBacks(animator, /* onStart= */ null, onEnd,
                /* onUpdate= */ anim -> setAlpha(1 - anim.getAnimatedFraction()));
        mDismissAnimator = animator;
        return animator;
    }

    /** Dismisses the bubble bar */
    public void dismiss(Runnable onDismissed) {
        if (mDismissAnimator == null) {
            createDismissAnimator().start();
        }
        addAnimationCallBacks(mDismissAnimator, null, onDismissed, null);
    }

    /**
     * Return child views in the order which they are shown on the screen.
     * <p>
+9 −6
Original line number Diff line number Diff line
@@ -597,13 +597,17 @@ public class BubbleBarViewController {
    public void setHiddenForBubbles(boolean hidden) {
        if (mHiddenForNoBubbles != hidden) {
            mHiddenForNoBubbles = hidden;
            updateVisibilityForStateChange();
            if (hidden) {
                mBarView.setAlpha(0);
                mBarView.dismiss(() -> {
                    updateVisibilityForStateChange();
                    mBarView.setExpanded(false);
                    adjustTaskbarAndHotseatToBubbleBarState(/* isBubbleBarExpanded= */ false);
                    mActivity.bubbleBarVisibilityChanged(/* isVisible= */ false);
                });
            } else {
                updateVisibilityForStateChange();
                mActivity.bubbleBarVisibilityChanged(/* isVisible= */ true);
            }
            mActivity.bubbleBarVisibilityChanged(!hidden);
        }
    }

@@ -636,7 +640,6 @@ public class BubbleBarViewController {
        }
    }

    // TODO: (b/273592694) animate it
    private void updateVisibilityForStateChange() {
        if (!mHiddenForSysui && !mHiddenForNoBubbles && !mHiddenForStashed) {
            mBarView.setVisibility(VISIBLE);
+30 −18
Original line number Diff line number Diff line
@@ -49,23 +49,30 @@ class BubbleAnimator(
        bubbleIndex: Int,
        selectedBubbleIndex: Int,
        removingLastBubble: Boolean,
        listener: Listener
        removingLastRemainingBubble: Boolean,
        listener: Listener,
    ) {
        animator = createAnimator(listener)
        state = State.RemovingBubble(bubbleIndex, selectedBubbleIndex, removingLastBubble)
        state =
            State.RemovingBubble(
                bubbleIndex = bubbleIndex,
                selectedBubbleIndex = selectedBubbleIndex,
                removingLastBubble = removingLastBubble,
                removingLastRemainingBubble = removingLastRemainingBubble,
            )
        animator.start()
    }

    fun animateNewAndRemoveOld(
        selectedBubbleIndex: Int,
        removedBubbleIndex: Int,
        listener: Listener
        listener: Listener,
    ) {
        animator = createAnimator(listener)
        state =
            State.AddingAndRemoving(
                selectedBubbleIndex = selectedBubbleIndex,
                removedBubbleIndex = removedBubbleIndex
                removedBubbleIndex = removedBubbleIndex,
            )
        animator.start()
    }
@@ -111,20 +118,22 @@ class BubbleAnimator(
                getBubbleTranslationXWhileScalingBubble(
                    bubbleIndex = bubbleIndex,
                    scalingBubbleIndex = 0,
                    bubbleScale = animator.animatedFraction
                    bubbleScale = animator.animatedFraction,
                )

            is State.RemovingBubble ->
                getBubbleTranslationXWhileScalingBubble(
                    bubbleIndex = bubbleIndex,
                    scalingBubbleIndex = state.bubbleIndex,
                    bubbleScale = 1 - animator.animatedFraction
                    bubbleScale = 1 - animator.animatedFraction,
                )

            is State.AddingAndRemoving ->
                getBubbleTranslationXWhileAddingBubbleAtLimit(
                    bubbleIndex = bubbleIndex,
                    removedBubbleIndex = state.removedBubbleIndex,
                    addedBubbleScale = animator.animatedFraction,
                    removedBubbleScale = 1 - animator.animatedFraction
                    removedBubbleScale = 1 - animator.animatedFraction,
                )
        }
    }
@@ -176,10 +185,11 @@ class BubbleAnimator(
                    getBubbleTranslationXWhileScalingBubble(
                        bubbleIndex = state.selectedBubbleIndex,
                        scalingBubbleIndex = 0,
                        bubbleScale = animator.animatedFraction
                        bubbleScale = animator.animatedFraction,
                    )
                tx + iconSize / 2f
            }

            is State.RemovingBubble -> getArrowPositionWhenRemovingBubble(state)
            is State.AddingAndRemoving -> {
                // we never remove the selected bubble, so the arrow stays pointing to its center
@@ -188,22 +198,23 @@ class BubbleAnimator(
                        bubbleIndex = state.selectedBubbleIndex,
                        removedBubbleIndex = state.removedBubbleIndex,
                        addedBubbleScale = animator.animatedFraction,
                        removedBubbleScale = 1 - animator.animatedFraction
                        removedBubbleScale = 1 - animator.animatedFraction,
                    )
                tx + iconSize / 2f
            }
        }
    }

    private fun getArrowPositionWhenRemovingBubble(state: State.RemovingBubble): Float {
        return if (state.selectedBubbleIndex != state.bubbleIndex) {
            // if we're not removing the selected bubble, the selected bubble doesn't change so just
            // return the translation X of the selected bubble and add half icon
    private fun getArrowPositionWhenRemovingBubble(state: State.RemovingBubble): Float =
        if (state.selectedBubbleIndex != state.bubbleIndex || state.removingLastRemainingBubble) {
            // if we're not removing the selected bubble or if we're removing the last remaining
            // bubble, the selected bubble doesn't change so just return the translation X of the
            // selected bubble and add half icon
            val tx =
                getBubbleTranslationXWhileScalingBubble(
                    bubbleIndex = state.selectedBubbleIndex,
                    scalingBubbleIndex = state.bubbleIndex,
                    bubbleScale = 1 - animator.animatedFraction
                    bubbleScale = 1 - animator.animatedFraction,
                )
            tx + iconSize / 2f
        } else {
@@ -238,7 +249,6 @@ class BubbleAnimator(
                }
            }
        }
    }

    /**
     * Returns the translation X for the bubble at index {@code bubbleIndex} when the bubble bar is
@@ -251,7 +261,7 @@ class BubbleAnimator(
    private fun getBubbleTranslationXWhileScalingBubble(
        bubbleIndex: Int,
        scalingBubbleIndex: Int,
        bubbleScale: Float
        bubbleScale: Float,
    ): Float {
        val iconAndSpacing = iconSize + expandedBarIconSpacing
        // the bubble is scaling from the center, so we need to adjust its translation so
@@ -300,7 +310,7 @@ class BubbleAnimator(
        bubbleIndex: Int,
        removedBubbleIndex: Int,
        addedBubbleScale: Float,
        removedBubbleScale: Float
        removedBubbleScale: Float,
    ): Float {
        val iconAndSpacing = iconSize + expandedBarIconSpacing
        // the bubbles are scaling from the center, so we need to adjust their translation so
@@ -377,7 +387,9 @@ class BubbleAnimator(
            /** The index of the selected bubble. */
            val selectedBubbleIndex: Int,
            /** Whether the bubble being removed is also the last bubble. */
            val removingLastBubble: Boolean
            val removingLastBubble: Boolean,
            /** Whether we're removing the last remaining bubble. */
            val removingLastRemainingBubble: Boolean,
        ) : State

        /** A new bubble is being added and an old bubble is being removed from the bubble bar. */
+11 −7
Original line number Diff line number Diff line
@@ -511,23 +511,21 @@ constructor(

    /** Interrupts the animation due to touching the bubble bar or flyout. */
    fun interruptForTouch() {
        animatingBubble?.hideAnimation?.let { scheduler.cancel(it) }
        PhysicsAnimator.getInstance(bubbleBarView).cancelIfRunning()
        bubbleStashController.getStashedHandlePhysicsAnimator().cancelIfRunning()
        cancelFlyout()
        val hideAnimation = animatingBubble?.hideAnimation ?: return
        scheduler.cancel(hideAnimation)
        bubbleBarView.relativePivotY = 1f
        resetBubbleBarPropertiesOnInterrupt()
        clearAnimatingBubble()
    }

    /** Notifies the animator that the taskbar area was touched during an animation. */
    fun onStashStateChangingWhileAnimating() {
        animatingBubble?.hideAnimation?.let { scheduler.cancel(it) }
        cancelFlyout()
        val hideAnimation = animatingBubble?.hideAnimation ?: return
        scheduler.cancel(hideAnimation)
        clearAnimatingBubble()
        bubbleStashController.getStashedHandlePhysicsAnimator().cancelIfRunning()
        bubbleBarView.relativePivotY = 1f
        resetBubbleBarPropertiesOnInterrupt()
        bubbleStashController.onNewBubbleAnimationInterrupted(
            /* isStashed= */ bubbleBarView.alpha == 0f,
            bubbleBarView.translationY,
@@ -541,7 +539,7 @@ constructor(
        scheduler.cancel(hideAnimation)
        animatingBubble = null
        bubbleStashController.getStashedHandlePhysicsAnimator().cancelIfRunning()
        bubbleBarView.relativePivotY = 1f
        resetBubbleBarPropertiesOnInterrupt()
        // stash the bubble bar since the IME is now visible
        bubbleStashController.onNewBubbleAnimationInterrupted(
            /* isStashed= */ true,
@@ -679,6 +677,12 @@ constructor(
        bubbleStashController.showBubbleBarImmediate()
    }

    private fun resetBubbleBarPropertiesOnInterrupt() {
        bubbleBarView.relativePivotY = 1f
        bubbleBarView.scaleX = 1f
        bubbleBarView.scaleY = 1f
    }

    private fun <T> PhysicsAnimator<T>?.cancelIfRunning() {
        if (this?.isRunning() == true) cancel()
    }
Loading