From 3dcb19f33a242176207fb0f72621132a213cd7e7 Mon Sep 17 00:00:00 2001 From: mpodolian Date: Mon, 7 Oct 2024 10:21:11 -0700 Subject: [PATCH] Fixed the hotseat placement in RTL mode Updated logic that computest the hotseat shift. Fixes: 372014534 Flag: com.android.wm.shell.enable_bubble_bar Test: Manual. Put device into 3 buttons navigation mode, force RTL. Hotseat is placed next to the navigation buttons bar. Change-Id: Ie7b6be11a093ffa4006182bdc0b73018ba799246 --- .../taskbar/TaskbarLauncherStateController.java | 5 +++-- .../launcher3/taskbar/TaskbarViewController.java | 7 ++++--- .../launcher3/uioverrides/QuickstepLauncher.java | 9 +++++---- src/com/android/launcher3/DeviceProfile.java | 10 ++++------ 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java index 8a1d71ac4b..a4fbb25eb5 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java @@ -879,9 +879,10 @@ public class TaskbarLauncherStateController { mControllers.taskbarActivityContext)) { return; } - boolean isBubblesOnLeft = location.isOnLeft(isRtl(mLauncher.getResources())); + boolean isRtl = isRtl(mLauncher.getResources()); + boolean isBubblesOnLeft = location.isOnLeft(isRtl); int targetX = deviceProfile - .getHotseatTranslationXForBubbleBar(/* isNavbarOnRight= */ isBubblesOnLeft); + .getHotseatTranslationXForBubbleBar(isBubblesOnLeft, isRtl); updateHotseatAndQsbTranslationX(targetX, animate); } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java index 21d0cda43b..bc61c72212 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java @@ -23,6 +23,7 @@ import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY; import static com.android.launcher3.LauncherAnimUtils.VIEW_ALPHA; import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X; import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y; +import static com.android.launcher3.Utilities.isRtl; import static com.android.launcher3.Utilities.mapRange; import static com.android.launcher3.anim.AnimatedFloat.VALUE; import static com.android.launcher3.anim.AnimatorListeners.forEndCallback; @@ -839,10 +840,10 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar int hotseatNavBarTranslationX = 0; if (mCurrentBubbleBarLocation != null && taskbarDp.shouldAdjustHotseatOnBubblesLocationUpdate(mActivity)) { - boolean isBubblesOnLeft = mCurrentBubbleBarLocation.isOnLeft( - mTaskbarView.isLayoutRtl()); + boolean isRtl = mTaskbarView.isLayoutRtl(); + boolean isBubblesOnLeft = mCurrentBubbleBarLocation.isOnLeft(isRtl); hotseatNavBarTranslationX = taskbarDp - .getHotseatTranslationXForBubbleBar(/* isNavbarOnRight = */ isBubblesOnLeft); + .getHotseatTranslationXForBubbleBar(isBubblesOnLeft, isRtl); } for (int i = 0; i < mTaskbarView.getChildCount(); i++) { View child = mTaskbarView.getChildAt(i); diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java index bc0ace24df..0e7abf2c82 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java @@ -202,6 +202,8 @@ import com.android.systemui.unfold.updates.RotationChangeProvider; import com.android.wm.shell.shared.bubbles.BubbleBarLocation; import com.android.wm.shell.shared.desktopmode.DesktopModeStatus; +import kotlin.Unit; + import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.ArrayList; @@ -214,8 +216,6 @@ import java.util.function.BiConsumer; import java.util.function.Predicate; import java.util.stream.Stream; -import kotlin.Unit; - public class QuickstepLauncher extends Launcher implements RecentsViewContainer, SystemShortcut.BubbleActivityStarter { private static final boolean TRACE_LAYOUTS = @@ -1103,9 +1103,10 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer, if (isBubbleBarEnabled() && enableBubbleBarInPersistentTaskBar() && mBubbleBarLocation != null) { - boolean isBubblesOnLeft = mBubbleBarLocation.isOnLeft(isRtl(getResources())); + boolean isRtl = isRtl(getResources()); + boolean isBubblesOnLeft = mBubbleBarLocation.isOnLeft(isRtl); translationX += mDeviceProfile - .getHotseatTranslationXForBubbleBar(/* isNavbarOnRight = */ isBubblesOnLeft); + .getHotseatTranslationXForBubbleBar(isBubblesOnLeft, isRtl); } if (isBubbleBarEnabled() && hasBubbles()) { // TODO(368379159) : create a class to reuse computation logic diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 4eca04825d..1e7fd7f57d 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -69,7 +69,6 @@ import com.android.launcher3.util.CellContentDimensions; import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.DisplayController.Info; import com.android.launcher3.util.IconSizeSteps; -import com.android.launcher3.util.NavigationMode; import com.android.launcher3.util.ResourceHelper; import com.android.launcher3.util.WindowBounds; import com.android.launcher3.util.window.WindowManagerProxy; @@ -2337,16 +2336,15 @@ public class DeviceProfile { public boolean shouldAdjustHotseatOnBubblesLocationUpdate(Context context) { return enableBubbleBar() && enableBubbleBarInPersistentTaskBar() - && DisplayController.getNavigationMode(context) - == NavigationMode.THREE_BUTTONS; + && !DisplayController.getNavigationMode(context).hasGestures; } /** Returns hotseat translation X for the bubble bar position. */ - public int getHotseatTranslationXForBubbleBar(boolean isNavbarOnRight) { + public int getHotseatTranslationXForBubbleBar(boolean isNavbarOnRight, boolean isRtl) { if (isNavbarOnRight) { - return 0; + return isRtl ? -navButtonsLayoutWidthPx : 0; } else { - return navButtonsLayoutWidthPx; + return isRtl ? 0 : navButtonsLayoutWidthPx; } }