Update the background of the Daltonizer preview.

Add the corner radii in to be consistent with the Settings style.

Bug: 213440059
Test: manual test
Change-Id: I68edf243ae33e9bb1e39020ad7553451fad66477
This commit is contained in:
Peter_Liang
2022-01-06 20:55:21 +08:00
parent 1511407370
commit b408e19f4e
3 changed files with 19 additions and 1 deletions

View File

@@ -148,6 +148,8 @@ public final class PaletteListPreference extends Preference {
rootView.addView(textView);
}
updateFirstAndLastItemsBackground(context, rootView, paletteData.size());
}
private GradientDrawable createGradientDrawable(ViewGroup rootView, @ColorInt int color) {
@@ -164,6 +166,19 @@ public final class PaletteListPreference extends Preference {
return gradientDrawable;
}
private void updateFirstAndLastItemsBackground(Context context, ViewGroup rootView, int size) {
final int radius =
context.getResources().getDimensionPixelSize(
R.dimen.accessibility_illustration_view_radius);
final int lastIndex = size - 1;
final GradientDrawable firstItem =
(GradientDrawable) rootView.getChildAt(0).getBackground();
final GradientDrawable lastItem =
(GradientDrawable) rootView.getChildAt(lastIndex).getBackground();
firstItem.setCornerRadii(new float[]{radius, radius, radius, radius, 0, 0, 0, 0});
lastItem.setCornerRadii(new float[]{0, 0, 0, 0, radius, radius, radius, radius});
}
private List<Integer> getPaletteColors(Context context) {
final int[] paletteResources =
context.getResources().getIntArray(R.array.setting_palette_colors);