Merge "Fix the gradient drawable orientation is not mirrored for RTL alignment" into udc-dev am: 1f4ec6257f

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/22869958

Change-Id: Id25283b14118bcc075158c6dd53e255f9b449c3f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Menghan Li
2023-04-26 22:04:51 +00:00
committed by Automerger Merge Worker

View File

@@ -34,6 +34,7 @@ import android.widget.TextView;
import androidx.annotation.ColorInt; import androidx.annotation.ColorInt;
import androidx.annotation.IntDef; import androidx.annotation.IntDef;
import androidx.core.text.TextUtilsCompat;
import androidx.preference.Preference; import androidx.preference.Preference;
import androidx.preference.PreferenceViewHolder; import androidx.preference.PreferenceViewHolder;
@@ -49,6 +50,7 @@ import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** Preference that easier preview by matching name to color. */ /** Preference that easier preview by matching name to color. */
@@ -156,8 +158,9 @@ public final class PaletteListPreference extends Preference {
mGradientColors.set(Position.END, color); mGradientColors.set(Position.END, color);
final GradientDrawable gradientDrawable = new GradientDrawable(); final GradientDrawable gradientDrawable = new GradientDrawable();
final Locale locale = Locale.getDefault();
final Orientation orientation = final Orientation orientation =
rootView.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL TextUtilsCompat.getLayoutDirectionFromLocale(locale) == View.LAYOUT_DIRECTION_RTL
? Orientation.RIGHT_LEFT ? Orientation.RIGHT_LEFT
: Orientation.LEFT_RIGHT; : Orientation.LEFT_RIGHT;
gradientDrawable.setOrientation(orientation); gradientDrawable.setOrientation(orientation);