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

Commit fbf3393f authored by Ats Jenk's avatar Ats Jenk Committed by Android (Google) Code Review
Browse files

Merge "Send bubble bar bounds in display coordinates to wmshell" into main

parents 558196ef d22d73a0
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
@@ -731,15 +731,12 @@ public class SystemUiProxy implements ISystemUiProxy, NavHandle {
    /**
     * 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");
            }