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
This commit is contained in:
Pat Manning
2024-09-11 16:08:33 +00:00
parent 78da1fec93
commit 4a552541aa
12 changed files with 318 additions and 136 deletions

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2024 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:pathData="M9,16.17L4.83,12l-1.42,1.41L9,19 21,7l-1.41,-1.41z"
android:fillColor="@android:color/white"/>
</vector>

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2024 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:insetBottom="@dimen/pointer_fill_style_circle_offset"
android:insetLeft="@dimen/pointer_fill_style_circle_offset"
android:insetRight="@dimen/pointer_fill_style_circle_offset"
android:insetTop="@dimen/pointer_fill_style_circle_offset">
<shape android:shape="oval">
<size
android:width="@dimen/pointer_fill_style_circle_inner_diameter"
android:height="@dimen/pointer_fill_style_circle_inner_diameter" />
<solid android:color="@android:color/white" />
</shape>
</inset>

View File

@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2024 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true" android:state_hovered="true">
<layer-list>
<item>
<shape android:shape="oval">
<size android:width="@dimen/pointer_fill_style_circle_hover_selected_diameter"
android:height="@dimen/pointer_fill_style_circle_hover_selected_diameter" />
<stroke android:width="@dimen/pointer_fill_style_shape_hovered_stroke"
android:color="@color/pointer_fill_outline_color" />
</shape>
</item>
<item
android:top="@dimen/pointer_fill_style_checkmark_hovered_padding"
android:left="@dimen/pointer_fill_style_checkmark_hovered_padding"
android:bottom="@dimen/pointer_fill_style_checkmark_hovered_padding"
android:right="@dimen/pointer_fill_style_checkmark_hovered_padding"
android:drawable="@drawable/pointer_fill_check_24dp" />
</layer-list>
</item>
<item android:state_selected="true">
<layer-list>
<item>
<inset android:insetTop="@dimen/pointer_fill_style_circle_selected_offset"
android:insetLeft="@dimen/pointer_fill_style_circle_selected_offset"
android:insetBottom="@dimen/pointer_fill_style_circle_selected_offset"
android:insetRight="@dimen/pointer_fill_style_circle_selected_offset">
<shape android:shape="oval">
<size android:width="@dimen/pointer_fill_style_circle_selected_diameter"
android:height="@dimen/pointer_fill_style_circle_selected_diameter" />
<stroke android:width="@dimen/pointer_fill_style_shape_selected_stroke"
android:color="@color/pointer_fill_outline_color" />
</shape>
</inset>
</item>
<item
android:top="@dimen/pointer_fill_style_checkmark_selected_padding"
android:left="@dimen/pointer_fill_style_checkmark_selected_padding"
android:bottom="@dimen/pointer_fill_style_checkmark_selected_padding"
android:right="@dimen/pointer_fill_style_checkmark_selected_padding"
android:drawable="@drawable/pointer_fill_check_24dp" />
</layer-list>
</item>
<item android:state_hovered="true">
<shape android:shape="oval">
<size android:width="@dimen/pointer_fill_style_circle_hover_diameter"
android:height="@dimen/pointer_fill_style_circle_hover_diameter" />
<stroke android:width="@dimen/pointer_fill_style_shape_hovered_stroke"
android:color="@color/pointer_fill_outline_color" />
</shape>
</item>
</selector>

View File

@@ -17,6 +17,6 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
android:shape="rectangle">
<corners android:radius="16dp" />
<solid android:color="?androidprv:attr/materialColorSurface"/>
<corners android:radius="20dp" />
<solid android:color="?androidprv:attr/materialColorSurfaceContainerHigh"/>
</shape>

View File

@@ -16,6 +16,7 @@
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
@@ -30,73 +31,149 @@
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/pointer_fill_style_circle_padding"
android:text="@string/pointer_fill_style"
android:textSize="14sp"
android:textColor="?androidprv:attr/materialColorPrimary"
android:textAlignment="viewStart"
android:textAppearance="?android:attr/textAppearanceListItem" />
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:fontWeight="500" />
<LinearLayout
android:id="@+id/button_holder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="@dimen/pointer_fill_container_max_width"
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_style_background"
android:gravity="center_horizontal"
android:padding="@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">
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:focusable="false"
android:clickable="false"
android:importantForAccessibility="no"
android:layout_weight="4" />
<ImageView
android:id="@+id/button_black"
android:layout_width="@dimen/pointer_fill_style_circle_diameter"
android:layout_weight="0"
android:layout_height="@dimen/pointer_fill_style_circle_diameter"
android:layout_margin="@dimen/pointer_fill_style_circle_padding"
android:adjustViewBounds="true"
android:maxWidth="@dimen/pointer_fill_style_circle_diameter"
android:contentDescription="@string/pointer_fill_style_black_button"
android:scaleType="fitCenter" />
android:scaleType="center"
android:background="@drawable/pointer_icon_fill_color_background"
android:src="@drawable/pointer_icon_fill_color_foreground" />
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:focusable="false"
android:clickable="false"
android:importantForAccessibility="no"
android:layout_weight="3" />
<ImageView
android:id="@+id/button_green"
android:layout_width="@dimen/pointer_fill_style_circle_diameter"
android:layout_weight="0"
android:layout_height="@dimen/pointer_fill_style_circle_diameter"
android:layout_margin="@dimen/pointer_fill_style_circle_padding"
android:adjustViewBounds="true"
android:maxWidth="@dimen/pointer_fill_style_circle_diameter"
android:contentDescription="@string/pointer_fill_style_green_button"
android:scaleType="fitCenter" />
android:scaleType="center"
android:background="@drawable/pointer_icon_fill_color_background"
android:src="@drawable/pointer_icon_fill_color_foreground" />
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:focusable="false"
android:clickable="false"
android:importantForAccessibility="no"
android:layout_weight="3" />
<ImageView
android:id="@+id/button_yellow"
android:id="@+id/button_red"
android:layout_width="@dimen/pointer_fill_style_circle_diameter"
android:layout_weight="0"
android:layout_height="@dimen/pointer_fill_style_circle_diameter"
android:layout_margin="@dimen/pointer_fill_style_circle_padding"
android:adjustViewBounds="true"
android:maxWidth="@dimen/pointer_fill_style_circle_diameter"
android:contentDescription="@string/pointer_fill_style_yellow_button"
android:scaleType="fitCenter" />
android:contentDescription="@string/pointer_fill_style_red_button"
android:scaleType="center"
android:background="@drawable/pointer_icon_fill_color_background"
android:src="@drawable/pointer_icon_fill_color_foreground" />
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:focusable="false"
android:clickable="false"
android:importantForAccessibility="no"
android:layout_weight="3" />
<ImageView
android:id="@+id/button_pink"
android:layout_width="@dimen/pointer_fill_style_circle_diameter"
android:layout_weight="0"
android:layout_height="@dimen/pointer_fill_style_circle_diameter"
android:layout_margin="@dimen/pointer_fill_style_circle_padding"
android:adjustViewBounds="true"
android:maxWidth="@dimen/pointer_fill_style_circle_diameter"
android:contentDescription="@string/pointer_fill_style_pink_button"
android:scaleType="fitCenter" />
android:scaleType="center"
android:background="@drawable/pointer_icon_fill_color_background"
android:src="@drawable/pointer_icon_fill_color_foreground" />
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:focusable="false"
android:clickable="false"
android:importantForAccessibility="no"
android:layout_weight="3" />
<ImageView
android:id="@+id/button_blue"
android:layout_width="@dimen/pointer_fill_style_circle_diameter"
android:layout_weight="0"
android:layout_height="@dimen/pointer_fill_style_circle_diameter"
android:layout_margin="@dimen/pointer_fill_style_circle_padding"
android:adjustViewBounds="true"
android:maxWidth="@dimen/pointer_fill_style_circle_diameter"
android:contentDescription="@string/pointer_fill_style_blue_button"
android:scaleType="fitCenter" />
android:scaleType="center"
android:background="@drawable/pointer_icon_fill_color_background"
android:src="@drawable/pointer_icon_fill_color_foreground" />
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:focusable="false"
android:clickable="false"
android:importantForAccessibility="no"
android:layout_weight="3" />
<ImageView
android:id="@+id/button_purple"
android:layout_width="@dimen/pointer_fill_style_circle_diameter"
android:layout_weight="0"
android:layout_height="@dimen/pointer_fill_style_circle_diameter"
android:adjustViewBounds="true"
android:maxWidth="@dimen/pointer_fill_style_circle_diameter"
android:contentDescription="@string/pointer_fill_style_purple_button"
android:scaleType="center"
android:background="@drawable/pointer_icon_fill_color_background"
android:src="@drawable/pointer_icon_fill_color_foreground" />
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:focusable="false"
android:clickable="false"
android:importantForAccessibility="no"
android:layout_weight="4" />
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>

View File

@@ -15,6 +15,7 @@
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
@@ -29,7 +30,10 @@
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/pointer_stroke_style_padding"
android:text="@string/pointer_stroke_style"
android:textSize="14sp"
android:textColor="?androidprv:attr/materialColorPrimary"
android:textAlignment="viewStart"
android:fontWeight="500"
android:textAppearance="?android:attr/textAppearanceListItem" />
<RadioGroup
@@ -38,23 +42,31 @@
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="@dimen/pointer_stroke_style_padding"
android:layout_marginBottom="@dimen/pointer_stroke_style_padding"
android:padding="@dimen/pointer_stroke_style_padding">
android:layout_marginBottom="@dimen/pointer_stroke_style_padding">
<RadioButton android:id="@+id/stroke_style_white"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/pointer_stroke_style_padding"
android:text="@string/pointer_stroke_style_name_white"/>
android:paddingStart="@dimen/pointer_stroke_style_text_padding"
android:text="@string/pointer_stroke_style_name_white"
android:textSize="20sp"
android:textAppearance="?android:attr/textAppearanceListItem" />
<RadioButton android:id="@+id/stroke_style_black"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/pointer_stroke_style_padding"
android:text="@string/pointer_stroke_style_name_black"/>
android:paddingStart="@dimen/pointer_stroke_style_text_padding"
android:text="@string/pointer_stroke_style_name_black"
android:textSize="20sp"
android:textAppearance="?android:attr/textAppearanceListItem" />
<RadioButton android:id="@+id/stroke_style_none"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/pointer_stroke_style_padding"
android:text="@string/pointer_stroke_style_name_none"/>
android:paddingStart="@dimen/pointer_stroke_style_text_padding"
android:text="@string/pointer_stroke_style_name_none"
android:textSize="20sp"
android:textAppearance="?android:attr/textAppearanceListItem" />
</RadioGroup>
</LinearLayout>

View File

@@ -76,5 +76,8 @@
<!-- Switch bar disabled state color-->
<color name="switch_bar_state_disabled_color">#1FE3E3E3</color>
<!-- Pointer fill color setting outline color-->
<color name="pointer_fill_outline_color">#FFFFFF</color>
</resources>

View File

@@ -28,4 +28,9 @@
<!-- Lock pattern view size, align sysui biometric_auth_pattern_view_size -->
<dimen name="biometric_auth_pattern_view_size">348dp</dimen>
<!-- Pointer fill color preference -->
<dimen name="pointer_fill_container_height">104dp</dimen>
<dimen name="pointer_fill_container_max_width">448dp</dimen>
<dimen name="pointer_fill_style_container_padding">32dp</dimen>
</resources>

View File

@@ -218,4 +218,7 @@
<!-- Switch bar disabled state color-->
<color name="switch_bar_state_disabled_color">#1F1F1F1F</color>
<!-- Pointer fill color setting outline color-->
<color name="pointer_fill_outline_color">#000000</color>
</resources>

View File

@@ -175,11 +175,23 @@
<dimen name="keyboard_picker_text_size">16sp</dimen>
<!-- Pointer -->
<dimen name="pointer_fill_style_circle_diameter">52dp</dimen>
<dimen name="pointer_fill_style_circle_padding">8dp</dimen>
<dimen name="pointer_fill_style_shape_default_stroke">1dp</dimen>
<dimen name="pointer_fill_style_shape_hovered_stroke">3dp</dimen>
<dimen name="pointer_fill_container_height">88dp</dimen>
<dimen name="pointer_fill_container_max_width">448dp</dimen>
<dimen name="pointer_fill_style_container_padding">32dp</dimen>
<dimen name="pointer_fill_style_circle_diameter">56dp</dimen>
<dimen name="pointer_fill_style_circle_hover_selected_diameter">52dp</dimen>
<dimen name="pointer_fill_style_circle_hover_diameter">56dp</dimen>
<dimen name="pointer_fill_style_circle_selected_diameter">50dp</dimen>
<dimen name="pointer_fill_style_circle_inner_diameter">40dp</dimen>
<dimen name="pointer_fill_style_circle_offset">8dp</dimen>
<dimen name="pointer_fill_style_circle_padding">16dp</dimen>
<dimen name="pointer_fill_style_circle_selected_offset">3dp</dimen>
<dimen name="pointer_fill_style_checkmark_selected_padding">14dp</dimen>
<dimen name="pointer_fill_style_checkmark_hovered_padding">17dp</dimen>
<dimen name="pointer_fill_style_shape_selected_stroke">2dp</dimen>
<dimen name="pointer_fill_style_shape_hovered_stroke">4dp</dimen>
<dimen name="pointer_stroke_style_padding">8dp</dimen>
<dimen name="pointer_stroke_style_text_padding">21dp</dimen>
<dimen name="pointer_scale_padding">8dp</dimen>
<item name="pointer_scale_size_start" format="float" type="dimen">1.0</item>
<item name="pointer_scale_size_end" format="float" type="dimen">2.5</item>

View File

@@ -4538,14 +4538,16 @@
<string name="pointer_fill_style_black_button">Change pointer fill style to black</string>
<!-- Content description for green pointer fill style. [CHAR LIMIT=60] -->
<string name="pointer_fill_style_green_button">Change pointer fill style to green</string>
<!-- Content description for yellow pointer fill style. [CHAR LIMIT=60] -->
<string name="pointer_fill_style_yellow_button">Change pointer fill style to yellow</string>
<!-- Content description for red pointer fill style. [CHAR LIMIT=60] -->
<string name="pointer_fill_style_red_button">Change pointer fill style to red</string>
<!-- Content description for pink pointer fill style. [CHAR LIMIT=60] -->
<string name="pointer_fill_style_pink_button">Change pointer fill style to pink</string>
<!-- Content description for blue pointer fill style. [CHAR LIMIT=60] -->
<string name="pointer_fill_style_blue_button">Change pointer fill style to blue</string>
<!-- Title text for mouse pointer stroke style. [CHAR LIMIT=35] -->
<string name="pointer_stroke_style">Pointer stroke style</string>
<!-- Content description for purple pointer fill style. [CHAR LIMIT=60] -->
<string name="pointer_fill_style_purple_button">Change pointer fill style to purple</string>
<!-- Title text for mouse pointer stroke color. [CHAR LIMIT=35] -->
<string name="pointer_stroke_style">Pointer stroke color</string>
<!-- White value for pointer stroke style. [CHAR LIMIT=35] -->
<string name="pointer_stroke_style_name_white">White</string>
<!-- Black value pointer stroke style. [CHAR LIMIT=35] -->

View File

@@ -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);
}
}
}