From 6f4bd49a8d3c5c90722f272cd07ec13ad87c8968 Mon Sep 17 00:00:00 2001 From: Peter Liang Date: Tue, 10 Jan 2023 20:39:51 +0800 Subject: [PATCH] The default position of the menu view should be on the left side under RTL mode. Action: Set the default position x percentage as 0.0f. Bug: 264664188 Test: manual test Change-Id: I4f6ec944f0ea2c9eb2f8bde030e78d953560a5b3 --- .../accessibility/floatingmenu/MenuInfoRepository.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuInfoRepository.java b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuInfoRepository.java index f79c3d27b2ec6..2472c2ba08769 100644 --- a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuInfoRepository.java +++ b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuInfoRepository.java @@ -42,6 +42,7 @@ import android.os.UserHandle; import android.provider.Settings; import android.text.TextUtils; import android.util.Log; +import android.view.View; import android.view.accessibility.AccessibilityManager; import androidx.annotation.NonNull; @@ -64,6 +65,9 @@ class MenuInfoRepository { @FloatRange(from = 0.0, to = 1.0) private static final float DEFAULT_MENU_POSITION_X_PERCENT = 1.0f; + @FloatRange(from = 0.0, to = 1.0) + private static final float DEFAULT_MENU_POSITION_X_PERCENT_RTL = 0.0f; + @FloatRange(from = 0.0, to = 1.0) private static final float DEFAULT_MENU_POSITION_Y_PERCENT = 0.77f; private static final boolean DEFAULT_MOVE_TO_TUCKED_VALUE = false; @@ -223,8 +227,12 @@ class MenuInfoRepository { final String absolutePositionString = Prefs.getString(mContext, Prefs.Key.ACCESSIBILITY_FLOATING_MENU_POSITION, /* defaultValue= */ null); + final float defaultPositionXPercent = + mConfiguration.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL + ? DEFAULT_MENU_POSITION_X_PERCENT_RTL + : DEFAULT_MENU_POSITION_X_PERCENT; return TextUtils.isEmpty(absolutePositionString) - ? new Position(DEFAULT_MENU_POSITION_X_PERCENT, DEFAULT_MENU_POSITION_Y_PERCENT) + ? new Position(defaultPositionXPercent, DEFAULT_MENU_POSITION_Y_PERCENT) : Position.fromString(absolutePositionString); }