From 4a552541aa43958ce66b0aeb0b3f4d419ca296bd Mon Sep 17 00:00:00 2001 From: Pat Manning Date: Wed, 11 Sep 2024 16:08:33 +0000 Subject: [PATCH] Style changes for Pointer fill color settings. Fix: 362455374 Test: Manual. Visual Changes only. Flag: android.view.flags.enable_vector_cursor_a11y_settings Change-Id: Id7a9d7eef540ea33f6bb47451b3d5c25328f9707 --- res/drawable/pointer_fill_check_24dp.xml | 24 +++ .../pointer_icon_fill_color_background.xml | 28 +++ .../pointer_icon_fill_color_foreground.xml | 67 ++++++ ...ointer_icon_fill_container_background.xml} | 4 +- res/layout/pointer_icon_fill_style_layout.xml | 197 ++++++++++++------ .../pointer_icon_stroke_style_layout.xml | 22 +- res/values-night/colors.xml | 3 + res/values-sw600dp/dimens.xml | 5 + res/values/colors.xml | 3 + res/values/dimens.xml | 20 +- res/values/strings.xml | 10 +- .../PointerFillStylePreference.java | 71 +------ 12 files changed, 318 insertions(+), 136 deletions(-) create mode 100644 res/drawable/pointer_fill_check_24dp.xml create mode 100644 res/drawable/pointer_icon_fill_color_background.xml create mode 100644 res/drawable/pointer_icon_fill_color_foreground.xml rename res/drawable/{pointer_icon_fill_style_background.xml => pointer_icon_fill_container_background.xml} (87%) diff --git a/res/drawable/pointer_fill_check_24dp.xml b/res/drawable/pointer_fill_check_24dp.xml new file mode 100644 index 00000000000..c4b39d18e02 --- /dev/null +++ b/res/drawable/pointer_fill_check_24dp.xml @@ -0,0 +1,24 @@ + + + + + diff --git a/res/drawable/pointer_icon_fill_color_background.xml b/res/drawable/pointer_icon_fill_color_background.xml new file mode 100644 index 00000000000..20deb5c5455 --- /dev/null +++ b/res/drawable/pointer_icon_fill_color_background.xml @@ -0,0 +1,28 @@ + + + + + + + + diff --git a/res/drawable/pointer_icon_fill_color_foreground.xml b/res/drawable/pointer_icon_fill_color_foreground.xml new file mode 100644 index 00000000000..3d416203d6d --- /dev/null +++ b/res/drawable/pointer_icon_fill_color_foreground.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/res/drawable/pointer_icon_fill_style_background.xml b/res/drawable/pointer_icon_fill_container_background.xml similarity index 87% rename from res/drawable/pointer_icon_fill_style_background.xml rename to res/drawable/pointer_icon_fill_container_background.xml index 1e98cf5c17f..ca930a74540 100644 --- a/res/drawable/pointer_icon_fill_style_background.xml +++ b/res/drawable/pointer_icon_fill_container_background.xml @@ -17,6 +17,6 @@ - - + + diff --git a/res/layout/pointer_icon_fill_style_layout.xml b/res/layout/pointer_icon_fill_style_layout.xml index 1fa9baf7de4..63c8ebde7db 100644 --- a/res/layout/pointer_icon_fill_style_layout.xml +++ b/res/layout/pointer_icon_fill_style_layout.xml @@ -16,6 +16,7 @@ --> + android:fontWeight="500" /> - + - + - + - + - + - + - - - + + + + + + + + + + + + + + + + diff --git a/res/layout/pointer_icon_stroke_style_layout.xml b/res/layout/pointer_icon_stroke_style_layout.xml index acf919ada99..01b58b294ce 100644 --- a/res/layout/pointer_icon_stroke_style_layout.xml +++ b/res/layout/pointer_icon_stroke_style_layout.xml @@ -15,6 +15,7 @@ --> + android:layout_marginBottom="@dimen/pointer_stroke_style_padding"> + android:paddingStart="@dimen/pointer_stroke_style_text_padding" + android:text="@string/pointer_stroke_style_name_white" + android:textSize="20sp" + android:textAppearance="?android:attr/textAppearanceListItem" /> + android:paddingStart="@dimen/pointer_stroke_style_text_padding" + android:text="@string/pointer_stroke_style_name_black" + android:textSize="20sp" + android:textAppearance="?android:attr/textAppearanceListItem" /> + android:paddingStart="@dimen/pointer_stroke_style_text_padding" + android:text="@string/pointer_stroke_style_name_none" + android:textSize="20sp" + android:textAppearance="?android:attr/textAppearanceListItem" /> \ No newline at end of file diff --git a/res/values-night/colors.xml b/res/values-night/colors.xml index fb73e6ecc44..57453ce5a2c 100644 --- a/res/values-night/colors.xml +++ b/res/values-night/colors.xml @@ -76,5 +76,8 @@ #1FE3E3E3 + + + #FFFFFF diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml index 391a30426c9..55735e66322 100755 --- a/res/values-sw600dp/dimens.xml +++ b/res/values-sw600dp/dimens.xml @@ -28,4 +28,9 @@ 348dp + + + 104dp + 448dp + 32dp diff --git a/res/values/colors.xml b/res/values/colors.xml index 6d925261979..95b38cb5250 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -218,4 +218,7 @@ #1F1F1F1F + + + #000000 diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 2a9b4334e29..c9a67e462bb 100755 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -175,11 +175,23 @@ 16sp - 52dp - 8dp - 1dp - 3dp + 88dp + 448dp + 32dp + 56dp + 52dp + 56dp + 50dp + 40dp + 8dp + 16dp + 3dp + 14dp + 17dp + 2dp + 4dp 8dp + 21dp 8dp 1.0 2.5 diff --git a/res/values/strings.xml b/res/values/strings.xml index 22708041c7f..41bc9ed3e46 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -4538,14 +4538,16 @@ Change pointer fill style to black Change pointer fill style to green - - Change pointer fill style to yellow + + Change pointer fill style to red Change pointer fill style to pink Change pointer fill style to blue - - Pointer stroke style + + Change pointer fill style to purple + + Pointer stroke color White diff --git a/src/com/android/settings/inputmethod/PointerFillStylePreference.java b/src/com/android/settings/inputmethod/PointerFillStylePreference.java index 3ea656f1b94..52535f9321d 100644 --- a/src/com/android/settings/inputmethod/PointerFillStylePreference.java +++ b/src/com/android/settings/inputmethod/PointerFillStylePreference.java @@ -19,21 +19,14 @@ import static android.view.PointerIcon.POINTER_ICON_VECTOR_STYLE_FILL_BLACK; import static android.view.PointerIcon.POINTER_ICON_VECTOR_STYLE_FILL_BLUE; import static android.view.PointerIcon.POINTER_ICON_VECTOR_STYLE_FILL_GREEN; import static android.view.PointerIcon.POINTER_ICON_VECTOR_STYLE_FILL_PINK; -import static android.view.PointerIcon.POINTER_ICON_VECTOR_STYLE_FILL_YELLOW; +import static android.view.PointerIcon.POINTER_ICON_VECTOR_STYLE_FILL_PURPLE; +import static android.view.PointerIcon.POINTER_ICON_VECTOR_STYLE_FILL_RED; import android.content.Context; -import android.content.res.Resources; import android.content.res.TypedArray; -import android.graphics.BlendMode; -import android.graphics.BlendModeColorFilter; import android.graphics.Color; -import android.graphics.drawable.Drawable; -import android.graphics.drawable.GradientDrawable; -import android.graphics.drawable.StateListDrawable; import android.provider.Settings; import android.util.AttributeSet; -import android.util.StateSet; -import android.view.Gravity; import android.view.PointerIcon; import android.view.View; import android.widget.ImageView; @@ -45,7 +38,6 @@ import androidx.preference.Preference; import androidx.preference.PreferenceViewHolder; import com.android.settings.R; -import com.android.settingslib.Utils; public class PointerFillStylePreference extends Preference { @@ -62,7 +54,7 @@ public class PointerFillStylePreference extends Preference { super.onBindViewHolder(holder); mButtonHolder = (LinearLayout) holder.findViewById(R.id.button_holder); - // Intercept hover events so setting row does not highlight when hovering buttons. + // Intercept hover events so container does not highlight when hovering buttons. if (mButtonHolder != null) { mButtonHolder.setOnHoverListener((v, e) -> true); } @@ -73,12 +65,14 @@ public class PointerFillStylePreference extends Preference { currentStyle); initStyleButton(holder, R.id.button_green, POINTER_ICON_VECTOR_STYLE_FILL_GREEN, currentStyle); - initStyleButton(holder, R.id.button_yellow, POINTER_ICON_VECTOR_STYLE_FILL_YELLOW, + initStyleButton(holder, R.id.button_red, POINTER_ICON_VECTOR_STYLE_FILL_RED, currentStyle); initStyleButton(holder, R.id.button_pink, POINTER_ICON_VECTOR_STYLE_FILL_PINK, currentStyle); initStyleButton(holder, R.id.button_blue, POINTER_ICON_VECTOR_STYLE_FILL_BLUE, currentStyle); + initStyleButton(holder, R.id.button_purple, POINTER_ICON_VECTOR_STYLE_FILL_PURPLE, + currentStyle); } private void initStyleButton(@NonNull PreferenceViewHolder holder, int id, int style, @@ -90,70 +84,25 @@ public class PointerFillStylePreference extends Preference { int[] attrs = {com.android.internal.R.attr.pointerIconVectorFill}; try (TypedArray ta = getContext().obtainStyledAttributes( PointerIcon.vectorFillStyleToResource(style), attrs)) { - button.setBackground(getBackgroundSelector(ta.getColor(0, Color.BLACK))); + button.getBackground().setTint(ta.getColor(0, Color.BLACK)); } - button.setForeground(getForegroundDrawable(style, currentStyle)); - button.setForegroundGravity(Gravity.CENTER); button.setOnClickListener( (v) -> { getPreferenceDataStore().putInt(Settings.System.POINTER_FILL_STYLE, style); setButtonChecked(id); }); + button.setSelected(style == currentStyle); button.setPointerIcon(PointerIcon.getSystemIcon(getContext(), PointerIcon.TYPE_ARROW)); } - // Generate background instead of defining in XML so we can use res color from the platform. - private StateListDrawable getBackgroundSelector(int color) { - StateListDrawable background = new StateListDrawable(); - Resources res = getContext().getResources(); - int ovalSize = res.getDimensionPixelSize(R.dimen.pointer_fill_style_circle_diameter); - background.setBounds(0, 0, ovalSize, ovalSize); - - // Add hovered state first! The order states are added matters for a StateListDrawable. - GradientDrawable hoveredOval = new GradientDrawable(); - hoveredOval.setColor(color); - int textColor = Utils.getColorAttr(getContext(), - com.android.internal.R.attr.materialColorOutline).getDefaultColor(); - hoveredOval.setStroke( - res.getDimensionPixelSize(R.dimen.pointer_fill_style_shape_hovered_stroke), - textColor); - hoveredOval.setSize(ovalSize, ovalSize); - hoveredOval.setBounds(0, 0, ovalSize, ovalSize); - hoveredOval.setCornerRadius(ovalSize / 2f); - background.addState(new int[]{android.R.attr.state_hovered}, hoveredOval); - - GradientDrawable defaultOval = new GradientDrawable(); - defaultOval.setColor(color); - defaultOval.setStroke( - res.getDimensionPixelSize(R.dimen.pointer_fill_style_shape_default_stroke), - textColor); - defaultOval.setSize(ovalSize, ovalSize); - defaultOval.setBounds(0, 0, ovalSize, ovalSize); - defaultOval.setCornerRadius(ovalSize / 2f); - background.addState(StateSet.WILD_CARD, defaultOval); - - return background; - } - - private Drawable getForegroundDrawable(int style, int currentStyle) { - Resources res = getContext().getResources(); - int ovalSize = res.getDimensionPixelSize(R.dimen.pointer_fill_style_circle_diameter); - Drawable checkMark = getContext().getDrawable(R.drawable.ic_check_24dp); - int padding = res.getDimensionPixelSize(R.dimen.pointer_fill_style_circle_padding) / 2; - checkMark.setBounds(padding, padding, ovalSize - padding, ovalSize - padding); - checkMark.setColorFilter(new BlendModeColorFilter(Color.WHITE, BlendMode.SRC_IN)); - checkMark.setAlpha(style == currentStyle ? 255 : 0); - return checkMark; - } - private void setButtonChecked(int id) { if (mButtonHolder == null) { return; } for (int i = 0; i < mButtonHolder.getChildCount(); i++) { View child = mButtonHolder.getChildAt(i); - if (child != null) { - child.getForeground().setAlpha(child.getId() == id ? 255 : 0); + if (child instanceof ImageView) { + child.setSelected(child.getId() == id); } } }