Merge "Pass bubble bar offsets instead of position to WMShell" into udc-qpr-dev

This commit is contained in:
Liran Binyamin
2023-07-12 14:41:32 +00:00
committed by Android (Google) Code Review
4 changed files with 31 additions and 8 deletions
@@ -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.app.Notification;
@@ -341,8 +343,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;
@@ -367,7 +369,6 @@ 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) {
// Because we've visited this bubble, we should suppress the notification.
// This is updated on WMShell side when we show the bubble, but that update isn't
@@ -378,7 +379,7 @@ public class BubbleBarController extends IBubblesListener.Stub {
mSelectedBubble.getView().updateDotVisibility(true /* animate */);
}
mSystemUiProxy.showBubble(getSelectedBubbleKey(),
bubbleBarCoords[0], bubbleBarCoords[1]);
getBubbleBarOffsetX(), getBubbleBarOffsetY());
} else {
Log.w(TAG, "Trying to show the selected bubble but it's null");
}
@@ -545,4 +546,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();
}
}
@@ -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.
@@ -309,4 +309,9 @@ public class BubbleStashController {
return -hotseatBottomSpace - hotseatCellHeight + mUnstashedHeight - abs(
hotseatCellHeight - mUnstashedHeight) / 2;
}
float getBubbleBarTranslationY() {
return mBubblesShowingOnHome ? getBubbleBarTranslationYForHotseat()
: getBubbleBarTranslationYForTaskbar();
}
}
@@ -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");
}