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

Commit 1c03ed00 authored by Liran Binyamin's avatar Liran Binyamin
Browse files

Pass bubble bar offsets instead of position to WMShell

This allows WMShell to calculate the position of the expanded view
correctly when the bubble bar is being expanded from stashed.

Test: See ag/24012908
Change-Id: I7b917e761c827135942d918917c920b06650f496
parent 3e952e03
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@ import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_Q
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING_OCCLUDED;

import static java.lang.Math.abs;

import android.annotation.BinderThread;
import android.annotation.Nullable;
import android.content.Context;
@@ -334,8 +336,8 @@ public class BubbleBarController extends IBubblesListener.Stub {
            // TODO: (b/273316505) handle suppression
        }
        if (update.selectedBubbleKey != null) {
            if (mSelectedBubble != null
                    && !update.selectedBubbleKey.equals(mSelectedBubble.getKey())) {
            if (mSelectedBubble == null
                    || !update.selectedBubbleKey.equals(mSelectedBubble.getKey())) {
                BubbleBarBubble newlySelected = mBubbles.get(update.selectedBubbleKey);
                if (newlySelected != null) {
                    bubbleToSelect = newlySelected;
@@ -360,12 +362,11 @@ public class BubbleBarController extends IBubblesListener.Stub {
    /** Tells WMShell to show the currently selected bubble. */
    public void showSelectedBubble() {
        if (getSelectedBubbleKey() != null) {
            int[] bubbleBarCoords = mBarView.getLocationOnScreen();
            if (mSelectedBubble instanceof BubbleBarBubble) {
                // TODO (b/269670235): hide the update dot on the view if needed.
            }
            mSystemUiProxy.showBubble(getSelectedBubbleKey(),
                    bubbleBarCoords[0], bubbleBarCoords[1]);
                    getBubbleBarOffsetX(), getBubbleBarOffsetY());
        } else {
            Log.w(TAG, "Trying to show the selected bubble but it's null");
        }
@@ -520,4 +521,13 @@ 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();
    }

    private int getBubbleBarOffsetX() {
        return mBarView.getWidth() + mBarView.getHorizontalMargin();
    }
}
+6 −0
Original line number Diff line number Diff line
@@ -223,6 +223,12 @@ public class BubbleBarView extends FrameLayout {
        setLayoutParams(lp);
    }

    /** @return the horizontal margin between the bubble bar and the edge of the screen. */
    int getHorizontalMargin() {
        LayoutParams lp = (FrameLayout.LayoutParams) getLayoutParams();
        return lp.getMarginEnd();
    }

    /**
     * Updates the z order, positions, and badge visibility of the bubble views in the bar based
     * on the expanded state.
+5 −0
Original line number Diff line number Diff line
@@ -309,4 +309,9 @@ public class BubbleStashController {
        return -hotseatBottomSpace - hotseatCellHeight + mUnstashedHeight - abs(
                hotseatCellHeight - mUnstashedHeight) / 2;
    }

    float getBubbleBarTranslationY() {
        return mBubblesShowingOnHome ? getBubbleBarTranslationYForHotseat()
                : getBubbleBarTranslationYForTaskbar();
    }
}
+6 −4
Original line number Diff line number Diff line
@@ -646,13 +646,15 @@ 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 bubbleBarXCoordinate the X coordinate of the bubble bar on the screen.
     * @param bubbleBarYCoordinate the Y coordinate of the bubble bar on the screen.
     * @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.
     */
    public void showBubble(String key, int bubbleBarXCoordinate, int bubbleBarYCoordinate) {
    public void showBubble(String key, int bubbleBarOffsetX, int bubbleBarOffsetY) {
        if (mBubbles != null) {
            try {
                mBubbles.showBubble(key, bubbleBarXCoordinate, bubbleBarYCoordinate);
                mBubbles.showBubble(key, bubbleBarOffsetX, bubbleBarOffsetY);
            } catch (RemoteException e) {
                Log.w(TAG, "Failed call showBubble");
            }