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

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

Send bubble bar bounds in display coordinates to wmshell

Bubble bar can be positioned to the left or right side of the screen.
Instead of sending offsets to wmshell, send the bounds of the bar, in
screen coordinates. WMShell can choose how to use that information.

Flag: LEGACY persist.wm.debug.bubble_bar DEVELOPMENT
Bug: 273310265
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: Id2d24831e567171b442ae7f34f055b7195a3e060
parent 14f76fe1
Loading
Loading
Loading
Loading
+25 −8
Original line number Diff line number Diff line
@@ -46,6 +46,8 @@ import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Path;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.drawable.AdaptiveIconDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
@@ -66,6 +68,7 @@ import com.android.launcher3.icons.BitmapInfo;
import com.android.launcher3.icons.BubbleIconFactory;
import com.android.launcher3.shortcuts.ShortcutRequest;
import com.android.launcher3.taskbar.TaskbarControllers;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.Executors.SimpleThreadFactory;
import com.android.quickstep.SystemUiProxy;
import com.android.wm.shell.bubbles.IBubblesListener;
@@ -408,8 +411,7 @@ public class BubbleBarController extends IBubblesListener.Stub {
                        info.getFlags() | Notification.BubbleMetadata.FLAG_SUPPRESS_NOTIFICATION);
                mSelectedBubble.getView().updateDotVisibility(true /* animate */);
            }
            mSystemUiProxy.showBubble(getSelectedBubbleKey(),
                    getBubbleBarOffsetX(), getBubbleBarOffsetY());
            mSystemUiProxy.showBubble(getSelectedBubbleKey(), getExpandedBubbleBarDisplayBounds());
        } else {
            Log.w(TAG, "Trying to show the selected bubble but it's null");
        }
@@ -577,12 +579,27 @@ public class BubbleBarController extends IBubblesListener.Stub {
        return mIconFactory.createBadgedIconBitmap(drawable).icon;
    }

    private int getBubbleBarOffsetY() {
        final int translation = (int) abs(mBubbleStashController.getBubbleBarTranslationY());
        return translation + mBarView.getHeight();
    /**
     * Get bounds of the bubble bar as if it would be expanded.
     * Calculates the bounds instead of retrieving current view location as the view may be
     * animating.
     */
    private Rect getExpandedBubbleBarDisplayBounds() {
        Point displaySize = DisplayController.INSTANCE.get(mContext).getInfo().currentSize;
        Rect currentBarBounds = mBarView.getBubbleBarBounds();
        Rect location = new Rect();
        // currentBarBounds is only useful for distance from left or right edge.
        // It contains the current bounds, calculate the expanded bounds.
        if (mBarView.isOnLeft()) {
            location.left = currentBarBounds.left;
            location.right = (int) (currentBarBounds.left + mBarView.expandedWidth());
        } else {
            location.left = (int) (currentBarBounds.right - mBarView.expandedWidth());
            location.right = currentBarBounds.right;
        }

    private int getBubbleBarOffsetX() {
        return mBarView.getWidth() + mBarView.getHorizontalMargin();
        final int translation = (int) abs(mBubbleStashController.getBubbleBarTranslationY());
        location.top = displaySize.y - mBarView.getHeight() - translation;
        location.bottom = displaySize.y - translation;
        return location;
    }
}
+10 −2
Original line number Diff line number Diff line
@@ -205,7 +205,10 @@ public class BubbleBarView extends FrameLayout {
        mRelativePivotX = onLeft ? 0f : 1f;
    }

    private boolean isOnLeft() {
    /**
     * @return <code>true</code> when bar is pinned to the left edge of the screen
     */
    public boolean isOnLeft() {
        return getLayoutDirection() == LAYOUT_DIRECTION_RTL;
    }

@@ -509,7 +512,12 @@ public class BubbleBarView extends FrameLayout {
        return mIsBarExpanded;
    }

    private float expandedWidth() {
    /**
     * Get width of the bubble bar as if it would be expanded.
     *
     * @return width of the bubble bar in its expanded state, regardless of current width
     */
    public float expandedWidth() {
        final int childCount = getChildCount();
        final int horizontalPadding = getPaddingStart() + getPaddingEnd();
        return childCount * (mIconSize + mIconSpacing) + horizontalPadding;
+3 −6
Original line number Diff line number Diff line
@@ -707,15 +707,12 @@ public class SystemUiProxy implements ISystemUiProxy {
    /**
     * Tells SysUI to show the bubble with the provided key.
     * @param key the key of the bubble to show.
     * @param bubbleBarOffsetX the offset of the bubble bar from the edge of the screen on the X
     *                         axis.
     * @param bubbleBarOffsetY the offset of the bubble bar from the edge of the screen on the Y
     *                         axis.
     * @param bubbleBarBounds bounds of the bubble bar in display coordinates
     */
    public void showBubble(String key, int bubbleBarOffsetX, int bubbleBarOffsetY) {
    public void showBubble(String key, Rect bubbleBarBounds) {
        if (mBubbles != null) {
            try {
                mBubbles.showBubble(key, bubbleBarOffsetX, bubbleBarOffsetY);
                mBubbles.showBubble(key, bubbleBarBounds);
            } catch (RemoteException e) {
                Log.w(TAG, "Failed call showBubble");
            }