diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java index 1ecf8dac42..b49c9201be 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java @@ -123,8 +123,7 @@ public class BubbleBarController extends IBubblesListener.Stub { private BubbleCreator mBubbleCreator; private BubbleBarLocationListener mBubbleBarLocationListener; - // Cache last sent top coordinate to avoid sending duplicate updates to shell - private int mLastSentBubbleBarTop; + private int mLastSentBubbleBarTopToScreenBottom; private boolean mIsImeVisible = false; @@ -554,8 +553,8 @@ public class BubbleBarController extends IBubblesListener.Stub { /** Tells WMShell to show the currently selected bubble. */ public void showSelectedBubble() { if (getSelectedBubbleKey() != null) { - mLastSentBubbleBarTop = mBarView.getRestingTopPositionOnScreen(); - mSystemUiProxy.showBubble(getSelectedBubbleKey(), mLastSentBubbleBarTop); + mLastSentBubbleBarTopToScreenBottom = mBarView.getTopToScreenBottom(); + mSystemUiProxy.showBubble(getSelectedBubbleKey(), mLastSentBubbleBarTopToScreenBottom); } else { Log.w(TAG, "Trying to show the selected bubble but it's null"); } @@ -653,10 +652,10 @@ public class BubbleBarController extends IBubblesListener.Stub { } private void onBubbleBarBoundsChanged(boolean forceUpdate) { - int newTop = mBarView.getRestingTopPositionOnScreen(); - if (newTop != mLastSentBubbleBarTop || forceUpdate) { - mLastSentBubbleBarTop = newTop; - mSystemUiProxy.updateBubbleBarTopOnScreen(newTop); + int bubbleBarTopToScreenBottom = mBarView.getTopToScreenBottom(); + if (bubbleBarTopToScreenBottom != mLastSentBubbleBarTopToScreenBottom || forceUpdate) { + mLastSentBubbleBarTopToScreenBottom = bubbleBarTopToScreenBottom; + mSystemUiProxy.updateBubbleBarTopToScreenBottom(bubbleBarTopToScreenBottom); } } diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java index d973432d56..adfe59a93f 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java @@ -652,13 +652,15 @@ public class BubbleBarView extends FrameLayout { } } - /** - * Get bubble bar top coordinate on screen when bar is resting - */ - public int getRestingTopPositionOnScreen() { - int displayHeight = mController.getScreenHeight(); + /** Get the distance between the bubble bar top coordinate and the bottom of the screen */ + public int getTopToScreenBottom() { + // the bottom of the bubble bar is aligned with the bottom of the screen. the distance + // between the top of the bubble bar and the bottom of the screen is the height of the + // bubble bar minus the y translation. since the bubble bar is always above the bottom of + // the screen, the translation is negative and the overall result is a positive value that + // represents the distance int bubbleBarHeight = getBubbleBarBounds().height(); - return displayHeight - bubbleBarHeight + (int) mController.getBubbleBarTranslationY(); + return bubbleBarHeight - (int) mController.getBubbleBarTranslationY(); } /** Returns the bounds with translation that may have been applied. */ @@ -1672,9 +1674,6 @@ public class BubbleBarView extends FrameLayout { /** Interface for BubbleBarView to communicate with its controller. */ public interface Controller { - /** Returns the screen height. */ - int getScreenHeight(); - /** Returns the translation Y that the bubble bar should have. */ float getBubbleBarTranslationY(); diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java index 7b9a0371e9..bf4c605534 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java @@ -280,11 +280,6 @@ public class BubbleBarViewController { : PINNING_PERSISTENT; mBubbleBarPinning.updateValue(pinningValue); mBarView.setController(new BubbleBarView.Controller() { - @Override - public int getScreenHeight() { - return mActivity.getScreenSize().y; - } - @Override public float getBubbleBarTranslationY() { return mBubbleStashController.getBubbleBarTranslationY(); @@ -741,7 +736,8 @@ public class BubbleBarViewController { public boolean isEventOverBubbleBar(MotionEvent event) { if (!isBubbleBarVisible()) return false; final Rect bounds = getBubbleBarBounds(); - final int bubbleBarTopOnScreen = mBarView.getRestingTopPositionOnScreen(); + final int bubbleBarTopOnScreen = + mActivity.getScreenSize().y - mBarView.getTopToScreenBottom(); final float x = event.getX(); return event.getRawY() >= bubbleBarTopOnScreen && x >= bounds.left && x <= bounds.right; } @@ -1359,7 +1355,7 @@ public class BubbleBarViewController { * Notifies SystemUI to expand the selected bubble when the bubble is released. */ public void onBubbleDragRelease(BubbleBarLocation location) { - mSystemUiProxy.stopBubbleDrag(location, mBarView.getRestingTopPositionOnScreen()); + mSystemUiProxy.stopBubbleDrag(location, mBarView.getTopToScreenBottom()); } /** Handle given bubble being dismissed */ diff --git a/quickstep/src/com/android/quickstep/SystemUiProxy.kt b/quickstep/src/com/android/quickstep/SystemUiProxy.kt index 8214e7cb75..3b4638103f 100644 --- a/quickstep/src/com/android/quickstep/SystemUiProxy.kt +++ b/quickstep/src/com/android/quickstep/SystemUiProxy.kt @@ -588,10 +588,13 @@ class SystemUiProxy @Inject constructor(@ApplicationContext private val context: * Tells SysUI to show the bubble with the provided key. * * @param key the key of the bubble to show. - * @param top top coordinate of bubble bar on screen + * @param bubbleBarTopToScreenBottom distance between the top coordinate of bubble bar and the + * bottom of the screen */ - fun showBubble(key: String?, top: Int) = - executeWithErrorLog({ "Failed call showBubble" }) { bubbles?.showBubble(key, top) } + fun showBubble(key: String?, bubbleBarTopToScreenBottom: Int) = + executeWithErrorLog({ "Failed call showBubble" }) { + bubbles?.showBubble(key, bubbleBarTopToScreenBottom) + } /** Tells SysUI to remove all bubbles. */ fun removeAllBubbles() = @@ -617,11 +620,12 @@ class SystemUiProxy @Inject constructor(@ApplicationContext private val context: * expanded. * * @param location location of the bubble bar - * @param top new top coordinate for bubble bar on screen + * @param bubbleBarTopToScreenBottom distance between the new top coordinate for bubble bar and + * the bottom of the screen */ - fun stopBubbleDrag(location: BubbleBarLocation?, top: Int) = + fun stopBubbleDrag(location: BubbleBarLocation?, bubbleBarTopToScreenBottom: Int) = executeWithErrorLog({ "Failed call stopBubbleDrag" }) { - bubbles?.stopBubbleDrag(location, top) + bubbles?.stopBubbleDrag(location, bubbleBarTopToScreenBottom) } /** @@ -657,13 +661,12 @@ class SystemUiProxy @Inject constructor(@ApplicationContext private val context: } /** - * Tells SysUI the top coordinate of bubble bar on screen - * - * @param topOnScreen top coordinate for bubble bar on screen + * Tells SysUI the distance between the top coordinate of the bubble bar and the bottom of the + * screen */ - fun updateBubbleBarTopOnScreen(topOnScreen: Int) = - executeWithErrorLog({ "Failed call updateBubbleBarTopOnScreen" }) { - bubbles?.updateBubbleBarTopOnScreen(topOnScreen) + fun updateBubbleBarTopToScreenBottom(bubbleBarTopToScreenBottom: Int) = + executeWithErrorLog({ "Failed call updateBubbleBarTopToScreenBottom" }) { + bubbles?.updateBubbleBarTopToScreenBottom(bubbleBarTopToScreenBottom) } /** diff --git a/quickstep/tests/multivalentScreenshotTests/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewScreenshotTest.kt b/quickstep/tests/multivalentScreenshotTests/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewScreenshotTest.kt index 2a391a1833..2d473f1479 100644 --- a/quickstep/tests/multivalentScreenshotTests/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewScreenshotTest.kt +++ b/quickstep/tests/multivalentScreenshotTests/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewScreenshotTest.kt @@ -127,8 +127,6 @@ class BubbleBarViewScreenshotTest(emulationSpec: DeviceEmulationSpec) { bubbleBarView.setPadding(0, paddingTop, 0, 0) bubbleBarView.setController( object : BubbleBarView.Controller { - override fun getScreenHeight(): Int = 0 - override fun getBubbleBarTranslationY(): Float = 0f override fun onBubbleBarTouched() {} diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/stashing/PersistentBubbleStashControllerTest.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/stashing/PersistentBubbleStashControllerTest.kt index 4f88ec1544..0421a13aec 100644 --- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/stashing/PersistentBubbleStashControllerTest.kt +++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/stashing/PersistentBubbleStashControllerTest.kt @@ -394,8 +394,6 @@ class PersistentBubbleStashControllerTest { bubbleBarView.layoutParams = FrameLayout.LayoutParams(0, 0) bubbleBarView.setController( object : BubbleBarView.Controller { - override fun getScreenHeight(): Int = 0 - override fun getBubbleBarTranslationY(): Float = 0f override fun onBubbleBarTouched() {} diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/stashing/TransientBubbleStashControllerTest.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/stashing/TransientBubbleStashControllerTest.kt index d2baec12a7..3b6412d787 100644 --- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/stashing/TransientBubbleStashControllerTest.kt +++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/bubbles/stashing/TransientBubbleStashControllerTest.kt @@ -559,8 +559,6 @@ class TransientBubbleStashControllerTest { FrameLayout.LayoutParams(BUBBLE_BAR_WIDTH, BUBBLE_BAR_HEIGHT) bubbleBarView.setController( object : BubbleBarView.Controller { - override fun getScreenHeight(): Int = 0 - override fun getBubbleBarTranslationY(): Float = 0f override fun onBubbleBarTouched() {} diff --git a/quickstep/tests/src/com/android/launcher3/taskbar/bubbles/animation/BubbleBarViewAnimatorTest.kt b/quickstep/tests/src/com/android/launcher3/taskbar/bubbles/animation/BubbleBarViewAnimatorTest.kt index 3e6d53f545..0a9ee2c8b6 100644 --- a/quickstep/tests/src/com/android/launcher3/taskbar/bubbles/animation/BubbleBarViewAnimatorTest.kt +++ b/quickstep/tests/src/com/android/launcher3/taskbar/bubbles/animation/BubbleBarViewAnimatorTest.kt @@ -1398,8 +1398,6 @@ class BubbleBarViewAnimatorTest { bubbleBarView = BubbleBarView(context) bubbleBarView.setController( object : BubbleBarView.Controller { - override fun getScreenHeight(): Int = 0 - override fun getBubbleBarTranslationY(): Float = 0f override fun onBubbleBarTouched() {}