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

Commit e1cf9e43 authored by Mady Mellor's avatar Mady Mellor Committed by Automerger Merge Worker
Browse files

Merge changes I477f34de,I74b0d66c,I3c93e472 into sc-v2-dev am: e176359f am: 6d7df36c

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15806663

Change-Id: If6e0adf2f1cbde56ef9fc0fd14908a760bfc8d95
parents b4466eea 6d7df36c
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -422,14 +422,6 @@ public class Bubble implements BubbleViewProvider {
        }
    }

    @Override
    public void setExpandedContentAlpha(float alpha) {
        if (mExpandedView != null) {
            mExpandedView.setAlpha(alpha);
            mExpandedView.setTaskViewAlpha(alpha);
        }
    }

    /**
     * Set visibility of bubble in the expanded state.
     *
+2 −2
Original line number Diff line number Diff line
@@ -144,7 +144,6 @@ public class BubbleController {

    private BubbleLogger mLogger;
    private BubbleData mBubbleData;
    private View mBubbleScrim;
    @Nullable private BubbleStackView mStackView;
    private BubbleIconFactory mBubbleIconFactory;
    private BubblePositioner mBubblePositioner;
@@ -1372,8 +1371,9 @@ public class BubbleController {
    private class BubblesImeListener extends PinnedStackListenerForwarder.PinnedTaskListener {
        @Override
        public void onImeVisibilityChanged(boolean imeVisible, int imeHeight) {
            mBubblePositioner.setImeVisible(imeVisible, imeHeight);
            if (mStackView != null) {
                mStackView.onImeVisibilityChanged(imeVisible, imeHeight);
                mStackView.animateForIme(imeVisible);
            }
        }
    }
+14 −9
Original line number Diff line number Diff line
@@ -398,6 +398,7 @@ public class BubbleExpandedView extends LinearLayout {
        updatePointerView();
    }

    /** Updates the size and visuals of the pointer. **/
    private void updatePointerView() {
        LayoutParams lp = (LayoutParams) mPointerView.getLayoutParams();
        if (mCurrentPointer == mLeftPointer || mCurrentPointer == mRightPointer) {
@@ -524,9 +525,8 @@ public class BubbleExpandedView extends LinearLayout {
        if (mTaskView != null) {
            mTaskView.setAlpha(alpha);
        }
        if (mManageButton != null && mManageButton.getVisibility() == View.VISIBLE) {
            mManageButton.setAlpha(alpha);
        }
        mPointerView.setAlpha(alpha);
        setAlpha(alpha);
    }

    /**
@@ -545,6 +545,7 @@ public class BubbleExpandedView extends LinearLayout {
        mIsContentVisible = visibility;
        if (mTaskView != null && !mIsAlphaAnimating) {
            mTaskView.setAlpha(visibility ? 1f : 0f);
            mPointerView.setAlpha(visibility ? 1f : 0f);
        }
    }

@@ -689,7 +690,7 @@ public class BubbleExpandedView extends LinearLayout {
     *                       the bubble if showing vertically.
     * @param onLeft whether the stack was on the left side of the screen when expanded.
     */
    public void setPointerPosition(float bubblePosition, boolean onLeft) {
    public void setPointerPosition(float bubblePosition, boolean onLeft, boolean animate) {
        // Pointer gets drawn in the padding
        final boolean showVertically = mPositioner.showBubblesVertically();
        final float paddingLeft = (showVertically && onLeft)
@@ -710,6 +711,8 @@ public class BubbleExpandedView extends LinearLayout {
                : pointerPosition;
        // Post because we need the width of the view
        post(() -> {
            mCurrentPointer = showVertically ? onLeft ? mLeftPointer : mRightPointer : mTopPointer;
            updatePointerView();
            float pointerY;
            float pointerX;
            if (showVertically) {
@@ -721,11 +724,13 @@ public class BubbleExpandedView extends LinearLayout {
                pointerY = mPointerOverlap;
                pointerX = bubbleCenter - (mPointerWidth / 2f);
            }
            if (animate) {
                mPointerView.animate().translationX(pointerX).translationY(pointerY).start();
            } else {
                mPointerView.setTranslationY(pointerY);
                mPointerView.setTranslationX(pointerX);
            mCurrentPointer = showVertically ? onLeft ? mLeftPointer : mRightPointer : mTopPointer;
            updatePointerView();
                mPointerView.setVisibility(VISIBLE);
            }
        });
    }

+0 −4
Original line number Diff line number Diff line
@@ -154,10 +154,6 @@ class BubbleOverflow(
        return dotPath
    }

    override fun setExpandedContentAlpha(alpha: Float) {
        expandedView?.alpha = alpha
    }

    override fun setTaskViewVisibility(visible: Boolean) {
        // Overflow does not have a TaskView.
    }
+76 −15
Original line number Diff line number Diff line
@@ -70,13 +70,16 @@ public class BubblePositioner {

    private Context mContext;
    private WindowManager mWindowManager;
    private Rect mPositionRect;
    private Rect mScreenRect;
    private @Surface.Rotation int mRotation = Surface.ROTATION_0;
    private Insets mInsets;
    private boolean mImeVisible;
    private int mImeHeight;
    private boolean mIsLargeScreen;

    private Rect mPositionRect;
    private int mDefaultMaxBubbles;
    private int mMaxBubbles;

    private int mBubbleSize;
    private int mSpacingBetweenBubbles;

@@ -98,7 +101,6 @@ public class BubblePositioner {
    private PointF mRestingStackPosition;
    private int[] mPaddings = new int[4];

    private boolean mIsLargeScreen;
    private boolean mShowingInTaskbar;
    private @TaskbarPosition int mTaskbarPosition = TASKBAR_POSITION_NONE;
    private int mTaskbarIconSize;
@@ -302,6 +304,17 @@ public class BubblePositioner {
        return mMaxBubbles;
    }

    /** The height for the IME if it's visible. **/
    public int getImeHeight() {
        return mImeVisible ? mImeHeight : 0;
    }

    /** Sets whether the IME is visible. **/
    public void setImeVisible(boolean visible, int height) {
        mImeVisible = visible;
        mImeHeight = height;
    }

    /**
     * Calculates the padding for the bubble expanded view.
     *
@@ -357,7 +370,7 @@ public class BubblePositioner {
    }

    /** Gets the y position of the expanded view if it was top-aligned. */
    private float getExpandedViewYTopAligned() {
    public float getExpandedViewYTopAligned() {
        final int top = getAvailableRect().top;
        if (showBubblesVertically()) {
            return top - mPointerWidth + mExpandedViewPadding;
@@ -366,10 +379,6 @@ public class BubblePositioner {
        }
    }

    public float getExpandedBubblesY() {
        return getAvailableRect().top + mExpandedViewPadding;
    }

    /**
     * Calculate the maximum height the expanded view can be depending on where it's placed on
     * the screen and the size of the elements around it (e.g. padding, pointer, manage button).
@@ -464,18 +473,21 @@ public class BubblePositioner {
                : bubblePosition + (normalizedSize / 2f) - mPointerWidth;
    }

    private int getExpandedStackSize(int numberOfBubbles) {
        return (numberOfBubbles * mBubbleSize)
                + ((numberOfBubbles - 1) * mSpacingBetweenBubbles);
    }

    /**
     * Returns the position of the bubble on-screen when the stack is expanded.
     *
     * @param index the index of the bubble in the stack.
     * @param numberOfBubbles the total number of bubbles in the stack.
     * @param onLeftEdge whether the stack would rest on the left edge of the screen when collapsed.
     * @return the x, y position of the bubble on-screen when the stack is expanded.
     * @param state state information about the stack to help with calculations.
     * @return the position of the bubble on-screen when the stack is expanded.
     */
    public PointF getExpandedBubbleXY(int index, int numberOfBubbles, boolean onLeftEdge) {
    public PointF getExpandedBubbleXY(int index, BubbleStackView.StackViewState state) {
        final float positionInRow = index * (mBubbleSize + mSpacingBetweenBubbles);
        final float expandedStackSize = (numberOfBubbles * mBubbleSize)
                + ((numberOfBubbles - 1) * mSpacingBetweenBubbles);
        final float expandedStackSize = getExpandedStackSize(state.numberOfBubbles);
        final float centerPosition = showBubblesVertically()
                ? mPositionRect.centerY()
                : mPositionRect.centerX();
@@ -491,16 +503,65 @@ public class BubblePositioner {
            int right = mIsLargeScreen
                    ? mPositionRect.right - mExpandedViewLargeScreenInset + mExpandedViewPadding
                    : mPositionRect.right - mBubbleSize;
            x = onLeftEdge
            x = state.onLeft
                    ? left
                    : right;
        } else {
            y = mPositionRect.top + mExpandedViewPadding;
            x = rowStart + positionInRow;
        }

        if (showBubblesVertically() && mImeVisible) {
            return new PointF(x, getExpandedBubbleYForIme(index, state.numberOfBubbles));
        }
        return new PointF(x, y);
    }

    /**
     * Returns the position of the bubble on-screen when the stack is expanded and the IME
     * is showing.
     *
     * @param index the index of the bubble in the stack.
     * @param numberOfBubbles the total number of bubbles in the stack.
     * @return y position of the bubble on-screen when the stack is expanded.
     */
    private float getExpandedBubbleYForIme(int index, int numberOfBubbles) {
        final float top = getAvailableRect().top + mExpandedViewPadding;
        if (!showBubblesVertically()) {
            // Showing horizontally: align to top
            return top;
        }

        // Showing vertically: might need to translate the bubbles above the IME.
        // Subtract spacing here to provide a margin between top of IME and bottom of bubble row.
        final float bottomInset = getImeHeight() + mInsets.bottom - (mSpacingBetweenBubbles * 2);
        final float expandedStackSize = getExpandedStackSize(numberOfBubbles);
        final float centerPosition = showBubblesVertically()
                ? mPositionRect.centerY()
                : mPositionRect.centerX();
        final float rowBottom = centerPosition + (expandedStackSize / 2f);
        final float rowTop = centerPosition - (expandedStackSize / 2f);
        float rowTopForIme = rowTop;
        if (rowBottom > bottomInset) {
            // We overlap with IME, must shift the bubbles
            float translationY = rowBottom - bottomInset;
            rowTopForIme = Math.max(rowTop - translationY, top);
            if (rowTop - translationY < top) {
                // Even if we shift the bubbles, they will still overlap with the IME.
                // Hide the overflow for a lil more space:
                final float expandedStackSizeNoO = getExpandedStackSize(numberOfBubbles - 1);
                final float centerPositionNoO = showBubblesVertically()
                        ? mPositionRect.centerY()
                        : mPositionRect.centerX();
                final float rowBottomNoO = centerPositionNoO + (expandedStackSizeNoO / 2f);
                final float rowTopNoO = centerPositionNoO - (expandedStackSizeNoO / 2f);
                translationY = rowBottomNoO - bottomInset;
                rowTopForIme = rowTopNoO - translationY;
            }
        }
        return rowTopForIme + (index * (mBubbleSize + mSpacingBetweenBubbles));
    }

    /**
     * @return the width of the bubble flyout (message originating from the bubble).
     */
Loading