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

Commit b6e47ce9 authored by Ats Jenk's avatar Ats Jenk
Browse files

Return full bubble bar bounds on display when expanded

Bubble bar can be positioned left or right of the screen. That controls
where the expanded view animation is triggered from.
Update API between launcher and wmshell to include bubble bar bounds in
display coordinates instead of offset values.

Flag: LEGACY persist.wm.debug.bubble_bar DEVELOPMENT
Bug: 273310265
Test: atest SystemUITests:BubblesTest
Test: repeat with LTR and RTL system languages:
  - have some bubbles, open an app, expand the bubbles by swiping up
    from bubble bar handle
  - have some bubbles, open an app, expand bubble bar by swiping up on
    navbar handle, tap on bubble bar to expand bubbles
  - have some bubbles, be on home screen, tap on bubble bar to expand a
    bubble
Change-Id: I485220f6a11009f033eb2461cd6a9ac09aa7e5e2
parent a68a5720
Loading
Loading
Loading
Loading
+4 −5
Original line number Original line Diff line number Diff line
@@ -1105,9 +1105,8 @@ public class BubbleController implements ConfigurationChangeListener,
     * <p>This is used by external callers (launcher).
     * <p>This is used by external callers (launcher).
     */
     */
    @VisibleForTesting
    @VisibleForTesting
    public void expandStackAndSelectBubbleFromLauncher(String key, int bubbleBarOffsetX,
    public void expandStackAndSelectBubbleFromLauncher(String key, Rect bubbleBarBounds) {
            int bubbleBarOffsetY) {
        mBubblePositioner.setBubbleBarPosition(bubbleBarBounds);
        mBubblePositioner.setBubbleBarPosition(bubbleBarOffsetX, bubbleBarOffsetY);


        if (BubbleOverflow.KEY.equals(key)) {
        if (BubbleOverflow.KEY.equals(key)) {
            mBubbleData.setSelectedBubbleFromLauncher(mBubbleData.getOverflow());
            mBubbleData.setSelectedBubbleFromLauncher(mBubbleData.getOverflow());
@@ -2193,10 +2192,10 @@ public class BubbleController implements ConfigurationChangeListener,
        }
        }


        @Override
        @Override
        public void showBubble(String key, int bubbleBarOffsetX, int bubbleBarOffsetY) {
        public void showBubble(String key, Rect bubbleBarBounds) {
            mMainExecutor.execute(
            mMainExecutor.execute(
                    () -> mController.expandStackAndSelectBubbleFromLauncher(
                    () -> mController.expandStackAndSelectBubbleFromLauncher(
                            key, bubbleBarOffsetX, bubbleBarOffsetY));
                            key, bubbleBarBounds));
        }
        }


        @Override
        @Override
+8 −14
Original line number Original line Diff line number Diff line
@@ -19,7 +19,6 @@ package com.android.wm.shell.bubbles;
import android.content.Context;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.Resources;
import android.graphics.Insets;
import android.graphics.Insets;
import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.RectF;
@@ -97,7 +96,7 @@ public class BubblePositioner {
    private PointF mRestingStackPosition;
    private PointF mRestingStackPosition;


    private boolean mShowingInBubbleBar;
    private boolean mShowingInBubbleBar;
    private final Point mBubbleBarPosition = new Point();
    private final Rect mBubbleBarBounds = new Rect();


    public BubblePositioner(Context context, WindowManager windowManager) {
    public BubblePositioner(Context context, WindowManager windowManager) {
        mContext = context;
        mContext = context;
@@ -791,15 +790,10 @@ public class BubblePositioner {
    }
    }


    /**
    /**
     * Sets the position of the bubble bar in screen coordinates.
     * Sets the position of the bubble bar in display coordinates.
     *
     * @param offsetX the offset of the bubble bar from the edge of the screen on the X axis
     * @param offsetY the offset of the bubble bar from the edge of the screen on the Y axis
     */
     */
    public void setBubbleBarPosition(int offsetX, int offsetY) {
    public void setBubbleBarPosition(Rect bubbleBarBounds) {
        mBubbleBarPosition.set(
        mBubbleBarBounds.set(bubbleBarBounds);
                getAvailableRect().width() - offsetX,
                getAvailableRect().height() + mInsets.top + mInsets.bottom - offsetY);
    }
    }


    /**
    /**
@@ -820,7 +814,7 @@ public class BubblePositioner {


    /** The bottom position of the expanded view when showing above the bubble bar. */
    /** The bottom position of the expanded view when showing above the bubble bar. */
    public int getExpandedViewBottomForBubbleBar() {
    public int getExpandedViewBottomForBubbleBar() {
        return mBubbleBarPosition.y - mExpandedViewPadding;
        return mBubbleBarBounds.top - mExpandedViewPadding;
    }
    }


    /**
    /**
@@ -831,9 +825,9 @@ public class BubblePositioner {
    }
    }


    /**
    /**
     * Returns the on screen co-ordinates of the bubble bar.
     * Returns the display coordinates of the bubble bar.
     */
     */
    public Point getBubbleBarPosition() {
    public Rect getBubbleBarBounds() {
        return mBubbleBarPosition;
        return mBubbleBarBounds;
    }
    }
}
}
+2 −1
Original line number Original line Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.wm.shell.bubbles;
package com.android.wm.shell.bubbles;


import android.content.Intent;
import android.content.Intent;
import android.graphics.Rect;
import com.android.wm.shell.bubbles.IBubblesListener;
import com.android.wm.shell.bubbles.IBubblesListener;


/**
/**
@@ -29,7 +30,7 @@ interface IBubbles {


    oneway void unregisterBubbleListener(in IBubblesListener listener) = 2;
    oneway void unregisterBubbleListener(in IBubblesListener listener) = 2;


    oneway void showBubble(in String key, in int bubbleBarOffsetX, in int bubbleBarOffsetY) = 3;
    oneway void showBubble(in String key, in Rect bubbleBarBounds) = 3;


    oneway void removeBubble(in String key) = 4;
    oneway void removeBubble(in String key) = 4;


+4 −3
Original line number Original line Diff line number Diff line
@@ -22,6 +22,7 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.Context;
import android.graphics.Point;
import android.graphics.Point;
import android.graphics.Rect;
import android.util.Log;
import android.util.Log;
import android.util.Size;
import android.util.Size;
import android.view.View;
import android.view.View;
@@ -149,12 +150,12 @@ public class BubbleBarAnimationHelper {
        bbev.setVisibility(VISIBLE);
        bbev.setVisibility(VISIBLE);


        // Set the pivot point for the scale, so the view animates out from the bubble bar.
        // Set the pivot point for the scale, so the view animates out from the bubble bar.
        Point bubbleBarPosition = mPositioner.getBubbleBarPosition();
        Rect bubbleBarBounds = mPositioner.getBubbleBarBounds();
        mExpandedViewContainerMatrix.setScale(
        mExpandedViewContainerMatrix.setScale(
                1f - EXPANDED_VIEW_ANIMATE_SCALE_AMOUNT,
                1f - EXPANDED_VIEW_ANIMATE_SCALE_AMOUNT,
                1f - EXPANDED_VIEW_ANIMATE_SCALE_AMOUNT,
                1f - EXPANDED_VIEW_ANIMATE_SCALE_AMOUNT,
                bubbleBarPosition.x,
                bubbleBarBounds.centerX(),
                bubbleBarPosition.y);
                bubbleBarBounds.top);


        bbev.setAnimationMatrix(mExpandedViewContainerMatrix);
        bbev.setAnimationMatrix(mExpandedViewContainerMatrix);


+2 −1
Original line number Original line Diff line number Diff line
@@ -2196,7 +2196,8 @@ public class BubblesTest extends SysuiTestCase {


        FakeBubbleStateListener bubbleStateListener = new FakeBubbleStateListener();
        FakeBubbleStateListener bubbleStateListener = new FakeBubbleStateListener();
        mBubbleController.registerBubbleStateListener(bubbleStateListener);
        mBubbleController.registerBubbleStateListener(bubbleStateListener);
        mBubbleController.expandStackAndSelectBubbleFromLauncher(mBubbleEntry.getKey(), 500, 1000);
        mBubbleController.expandStackAndSelectBubbleFromLauncher(mBubbleEntry.getKey(),
                new Rect(500, 1000, 600, 1100));


        assertThat(mBubbleController.getLayerView().isExpanded()).isTrue();
        assertThat(mBubbleController.getLayerView().isExpanded()).isTrue();