From b50acbfeeaa817e1fc3da9712c3e273abfcf599f Mon Sep 17 00:00:00 2001 From: Pat Manning Date: Tue, 3 Dec 2024 13:56:28 +0000 Subject: [PATCH] Update pointer fill option backgrounds for color contrast and touch target size. Fix: 374885995 Fix: 374886964 Test: Manual. Flag: EXEMPT Bugfix. Change-Id: Ibf09bfae4a93868ac3605748854ccaaa10847eb6 --- .../pointer_icon_fill_color_background.xml | 226 +++++++++++++++++- .../pointer_icon_fill_color_foreground.xml | 67 ------ res/layout/pointer_icon_fill_style_layout.xml | 69 +++--- res/values-night/colors.xml | 4 +- res/values/colors.xml | 4 +- res/values/dimens.xml | 33 ++- .../PointerFillStylePreference.java | 40 +++- 7 files changed, 304 insertions(+), 139 deletions(-) delete mode 100644 res/drawable/pointer_icon_fill_color_foreground.xml diff --git a/res/drawable/pointer_icon_fill_color_background.xml b/res/drawable/pointer_icon_fill_color_background.xml index 20deb5c5455..89cfe5502de 100644 --- a/res/drawable/pointer_icon_fill_color_background.xml +++ b/res/drawable/pointer_icon_fill_color_background.xml @@ -14,15 +14,217 @@ See the License for the specific language governing permissions and limitations under the License. --> - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/res/drawable/pointer_icon_fill_color_foreground.xml b/res/drawable/pointer_icon_fill_color_foreground.xml deleted file mode 100644 index 3d416203d6d..00000000000 --- a/res/drawable/pointer_icon_fill_color_foreground.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/res/layout/pointer_icon_fill_style_layout.xml b/res/layout/pointer_icon_fill_style_layout.xml index aba57a6fe6d..2be750f6147 100644 --- a/res/layout/pointer_icon_fill_style_layout.xml +++ b/res/layout/pointer_icon_fill_style_layout.xml @@ -42,7 +42,6 @@ android:layout_height="@dimen/pointer_fill_container_height" android:layout_marginBottom="@dimen/pointer_fill_style_circle_padding" android:layout_marginTop="@dimen/pointer_fill_style_circle_padding" - android:background="@drawable/pointer_icon_fill_container_background" android:gravity="center" android:paddingTop="@dimen/pointer_fill_style_container_padding" android:paddingBottom="@dimen/pointer_fill_style_container_padding"> @@ -53,19 +52,18 @@ android:focusable="false" android:clickable="false" android:importantForAccessibility="no" - android:layout_weight="4" /> + android:layout_weight="1" /> + android:src="@drawable/pointer_icon_fill_color_background" /> + android:layout_weight="1" /> + android:src="@drawable/pointer_icon_fill_color_background" /> + android:layout_weight="1" /> + android:src="@drawable/pointer_icon_fill_color_background" /> + android:layout_weight="1" /> + android:src="@drawable/pointer_icon_fill_color_background" /> + android:layout_weight="1" /> + android:src="@drawable/pointer_icon_fill_color_background" /> + android:layout_weight="1" /> + android:src="@drawable/pointer_icon_fill_color_background" /> + android:layout_weight="1" /> diff --git a/res/values-night/colors.xml b/res/values-night/colors.xml index a117e47a93f..3892138bc25 100644 --- a/res/values-night/colors.xml +++ b/res/values-night/colors.xml @@ -77,8 +77,8 @@ #1FE3E3E3 - - #FFFFFF + + #3E373C @color/settingslib_color_charcoal diff --git a/res/values/colors.xml b/res/values/colors.xml index 0b7e0c1eb65..6e3f96fc32c 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -219,8 +219,8 @@ #1F1F1F1F - - #000000 + + #1C201A1E @color/settingslib_color_grey100 diff --git a/res/values/dimens.xml b/res/values/dimens.xml index d202f850a11..2784f379a07 100755 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -180,21 +180,28 @@ 16sp - 88dp - 448dp + 80dp + 468dp 32dp - 56dp - 52dp - 56dp - 50dp - 40dp - 8dp + 64dp + 39dp + 39.5dp + 20dp + 16dp + 64dp + 62dp + 52dp + 1dp + 12.5dp + 13.25dp + 12.25dp + 13dp + 7dp + 1dp + 2dp 16dp - 3dp - 14dp - 17dp - 2dp - 4dp + 16dp + 24dp 8dp 21dp 8dp diff --git a/src/com/android/settings/inputmethod/PointerFillStylePreference.java b/src/com/android/settings/inputmethod/PointerFillStylePreference.java index 74284d64250..9c9d076d4d9 100644 --- a/src/com/android/settings/inputmethod/PointerFillStylePreference.java +++ b/src/com/android/settings/inputmethod/PointerFillStylePreference.java @@ -25,6 +25,9 @@ import static android.view.PointerIcon.POINTER_ICON_VECTOR_STYLE_FILL_RED; import android.content.Context; import android.content.res.TypedArray; import android.graphics.Color; +import android.graphics.drawable.Drawable; +import android.graphics.drawable.LayerDrawable; +import android.graphics.drawable.StateListDrawable; import android.provider.Settings; import android.util.AttributeSet; import android.view.PointerIcon; @@ -41,6 +44,11 @@ import com.android.settings.R; public class PointerFillStylePreference extends Preference { + private static final int[] STATE_HOVERED_SELECTED = + new int[]{android.R.attr.state_hovered, android.R.attr.state_selected}; + private static final int[] STATE_SELECTED = new int[]{android.R.attr.state_selected}; + private static final int[] STATE_HOVERED = new int[]{android.R.attr.state_hovered}; + private static final int[] STATE_DEFAULT = new int[]{}; @Nullable private LinearLayout mButtonHolder; @@ -82,11 +90,7 @@ public class PointerFillStylePreference extends Preference { if (button == null) { return; } - int[] attrs = {com.android.internal.R.attr.pointerIconVectorFill}; - try (TypedArray ta = getContext().obtainStyledAttributes( - PointerIcon.vectorFillStyleToResource(style), attrs)) { - button.getBackground().setTint(ta.getColor(0, Color.BLACK)); - } + tintButtonByStyle(button, style); button.setOnClickListener( (v) -> { getPreferenceDataStore().putInt(Settings.System.POINTER_FILL_STYLE, style); @@ -96,6 +100,32 @@ public class PointerFillStylePreference extends Preference { button.setPointerIcon(PointerIcon.getSystemIcon(getContext(), PointerIcon.TYPE_ARROW)); } + private void tintButtonByStyle(ImageView button, int style) { + int[] attrs = {com.android.internal.R.attr.pointerIconVectorFill}; + try (TypedArray ta = getContext().obtainStyledAttributes( + PointerIcon.vectorFillStyleToResource(style), attrs)) { + // Index 0, as there is only one attribute returned here. + int color = ta.getColor(/* index= */ 0, Color.BLACK); + StateListDrawable stateListDrawable = (StateListDrawable) button.getDrawable(); + tintDrawableByLayerId(stateListDrawable, STATE_HOVERED_SELECTED, + R.id.tintableCircleHoveredSelected, color); + tintDrawableByLayerId(stateListDrawable, STATE_SELECTED, R.id.tintableCircleSelected, + color); + tintDrawableByLayerId(stateListDrawable, STATE_HOVERED, R.id.tintableCircleHovered, + color); + tintDrawableByLayerId(stateListDrawable, STATE_DEFAULT, R.id.tintableCircleDefault, + color); + } + } + + private void tintDrawableByLayerId(StateListDrawable stateListDrawable, int[] stateSet, + int layerId, int color) { + int index = stateListDrawable.findStateDrawableIndex(stateSet); + LayerDrawable layerDrawable = (LayerDrawable) stateListDrawable.getStateDrawable(index); + Drawable drawable = layerDrawable.findDrawableByLayerId(layerId); + drawable.setTint(color); + } + private void setButtonChecked(int id) { if (mButtonHolder == null) { return;