From c06c7ff6fafa3a312df227c71488f6c1e905b1e1 Mon Sep 17 00:00:00 2001 From: Liran Binyamin Date: Tue, 27 Jun 2023 17:06:02 -0400 Subject: [PATCH 1/2] Update the bubble bar offset on Home This is an initial change that positions the bubble bar aligning it with the center of the hotseat icons. We still need to center it with the taskbar when in overview. This change also fixes the touch issues where sometimes the hotseat icons don't respond to taps. The fix is twofold: 1. Make sure that taskbar insets are always updated when BubbleStashController#setBubblesShowingOnHome is called. 2. Update the touchable region in TaskbarInsetsController to account for the Y translation of the bubble bar bounds when the bubble bar is visible. Demo: https://screenshot.googleplex.com/6NRyu2CR7Bjs32x Bug: 286247080 Test: Manual on a physical device Change-Id: I00daff8341e4d8f5d141b5e0220726f6c03b437c --- quickstep/res/layout/transient_taskbar.xml | 1 - .../taskbar/TaskbarInsetsController.kt | 6 ++++-- .../taskbar/bubbles/BubbleBarView.java | 10 ++++++++-- .../taskbar/bubbles/BubbleStashController.java | 17 +++++++++++++++-- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/quickstep/res/layout/transient_taskbar.xml b/quickstep/res/layout/transient_taskbar.xml index bf4b811bb3..7a6d16a083 100644 --- a/quickstep/res/layout/transient_taskbar.xml +++ b/quickstep/res/layout/transient_taskbar.xml @@ -44,7 +44,6 @@ android:layout_height="@dimen/bubblebar_size" android:layout_gravity="bottom|end" android:layout_marginEnd="@dimen/transient_taskbar_bottom_margin" - android:layout_marginBottom="@dimen/transient_taskbar_bottom_margin" android:paddingEnd="@dimen/taskbar_icon_spacing" android:paddingStart="@dimen/taskbar_icon_spacing" android:visibility="gone" diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt index 07cd8ff1de..2062e2cb11 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt @@ -123,9 +123,11 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas val taskbarTouchableHeight = controllers.taskbarStashController.touchableHeight val bubblesTouchableHeight = - if (controllers.bubbleControllers.isPresent) + if (controllers.bubbleControllers.isPresent) { controllers.bubbleControllers.get().bubbleStashController.touchableHeight - else 0 + } else { + 0 + } val touchableHeight = Math.max(taskbarTouchableHeight, bubblesTouchableHeight) if ( diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java index 58c67e366e..3c308b5312 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java @@ -71,7 +71,11 @@ public class BubbleBarView extends FrameLayout { private final BubbleBarBackground mBubbleBarBackground; - // The current bounds of all the bubble bar. + /** + * The current bounds of all the bubble bar. Note that these bounds may not account for + * translation. The bounds should be retrieved using {@link #getBubbleBarBounds()} which + * updates the bounds and accounts for translation. + */ private final Rect mBubbleBarBounds = new Rect(); // The amount the bubbles overlap when they are stacked in the bubble bar private final float mIconOverlapAmount; @@ -175,9 +179,11 @@ public class BubbleBarView extends FrameLayout { } /** - * Returns the bounds of the bubble bar. + * Updates the bounds with translation that may have been applied and returns the result. */ public Rect getBubbleBarBounds() { + mBubbleBarBounds.top = getTop() + (int) getTranslationY(); + mBubbleBarBounds.bottom = getBottom() + (int) getTranslationY(); return mBubbleBarBounds; } diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleStashController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleStashController.java index b3c7d41e37..59b38eaaec 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleStashController.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleStashController.java @@ -15,6 +15,8 @@ */ package com.android.launcher3.taskbar.bubbles; +import static java.lang.Math.abs; + import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; @@ -125,6 +127,10 @@ public class BubbleStashController { mBubblesShowingOnHome = onHome; if (mBubblesShowingOnHome) { showBubbleBar(/* expanded= */ false); + // If the bubble bar is already unstashed, the taskbar touchable region won't be + // updated correctly, so force an update here. + mControllers.runAfterInit(() -> + mTaskbarInsetsController.onTaskbarOrBubblebarWindowHeightOrInsetsChanged()); } else if (!mBarViewController.isExpanded()) { stashBubbleBar(); } @@ -234,8 +240,14 @@ public class BubbleStashController { secondHalfDurationScale = 0.75f; // If we're on home, adjust the translation so the bubble bar aligns with hotseat. - final float hotseatTransY = mActivity.getDeviceProfile().getTaskbarOffsetY(); - final float translationY = mBubblesShowingOnHome ? hotseatTransY : 0; + // TODO(b/286247080): Update the offset for overview. + final float hotseatBottomSpace = mActivity.getDeviceProfile().hotseatBarBottomSpacePx; + final float hotseatCellHeight = mActivity.getDeviceProfile().hotseatCellHeightPx; + + final float translationY = + -hotseatBottomSpace - hotseatCellHeight + mUnstashedHeight - abs( + hotseatCellHeight - mUnstashedHeight) / 2; + fullLengthAnimatorSet.playTogether( mIconScaleForStash.animateToValue(1), mIconTranslationYForStash.animateToValue(translationY)); @@ -265,6 +277,7 @@ public class BubbleStashController { if (isStashed) { mBarViewController.setExpanded(false); } + mTaskbarInsetsController.onTaskbarOrBubblebarWindowHeightOrInsetsChanged(); }); } }); From d76a9d92405ce8bf80177e959b663f2e68b4d8b3 Mon Sep 17 00:00:00 2001 From: Liran Binyamin Date: Thu, 6 Jul 2023 11:56:44 -0400 Subject: [PATCH 2/2] Align the bubble bar with the taskbar in overview and app Whenever the bubble bar is unstashed and taskbar is present, the translationY of the bubble bar is now adjusted so that it is aligned with the taskbar. Demo: http://recall/-/bJtug1HhvXkkeA4MQvIaiP/e3dlacSsSebQfEFTEt10JM Fixes: 286247080 Test: Manual: - Add bubbles to the bubble bar. - On home observe the bar is aligned with hotseat - Switch to overview and observe the bar is aligned with taskbar - Go back to home. Bar aligns with hotseat. - Launch an app. Swipe up to load taskbar. Bar is aligned with taskbar. - Go back to home. Bar aligns with hotseat. Change-Id: I93c2232d4862be4c97e36ddb6c9d680b01e555ad --- .../bubbles/BubbleStashController.java | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleStashController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleStashController.java index 59b38eaaec..5177d932f1 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleStashController.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleStashController.java @@ -127,6 +127,12 @@ public class BubbleStashController { mBubblesShowingOnHome = onHome; if (mBubblesShowingOnHome) { showBubbleBar(/* expanded= */ false); + // When transitioning from app to home the stash animator may already have been + // created, so we need to animate the bubble bar here to align with hotseat. + if (!mIsStashed) { + mIconTranslationYForStash.animateToValue(getBubbleBarTranslationYForHotseat()) + .start(); + } // If the bubble bar is already unstashed, the taskbar touchable region won't be // updated correctly, so force an update here. mControllers.runAfterInit(() -> @@ -149,6 +155,11 @@ public class BubbleStashController { mBubblesShowingOnOverview = onOverview; if (!mBubblesShowingOnOverview && !mBarViewController.isExpanded()) { stashBubbleBar(); + } else { + // When transitioning to overview the stash animator may already have been + // created, so we need to animate the bubble bar here to align with taskbar. + mIconTranslationYForStash.animateToValue(getBubbleBarTranslationYForTaskbar()) + .start(); } } } @@ -240,13 +251,10 @@ public class BubbleStashController { secondHalfDurationScale = 0.75f; // If we're on home, adjust the translation so the bubble bar aligns with hotseat. - // TODO(b/286247080): Update the offset for overview. - final float hotseatBottomSpace = mActivity.getDeviceProfile().hotseatBarBottomSpacePx; - final float hotseatCellHeight = mActivity.getDeviceProfile().hotseatCellHeightPx; - - final float translationY = - -hotseatBottomSpace - hotseatCellHeight + mUnstashedHeight - abs( - hotseatCellHeight - mUnstashedHeight) / 2; + // Otherwise we're either showing in an app or in overview. In either case adjust it so + // the bubble bar aligns with the taskbar. + final float translationY = mBubblesShowingOnHome ? getBubbleBarTranslationYForHotseat() + : getBubbleBarTranslationYForTaskbar(); fullLengthAnimatorSet.playTogether( mIconScaleForStash.animateToValue(1), @@ -290,4 +298,15 @@ public class BubbleStashController { mTaskbarInsetsController.onTaskbarOrBubblebarWindowHeightOrInsetsChanged(); }); } + + private float getBubbleBarTranslationYForTaskbar() { + return -mActivity.getDeviceProfile().taskbarBottomMargin; + } + + private float getBubbleBarTranslationYForHotseat() { + final float hotseatBottomSpace = mActivity.getDeviceProfile().hotseatBarBottomSpacePx; + final float hotseatCellHeight = mActivity.getDeviceProfile().hotseatCellHeightPx; + return -hotseatBottomSpace - hotseatCellHeight + mUnstashedHeight - abs( + hotseatCellHeight - mUnstashedHeight) / 2; + } }