Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b43d8720 authored by PETER LIANG's avatar PETER LIANG Committed by Android (Google) Code Review
Browse files

Merge "Update the background of the Daltonizer preview."

parents c8fc56e3 b408e19f
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -18,7 +18,9 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/preview_viewport"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    android:layout_height="wrap_content"
    android:paddingStart="?android:attr/listPreferredItemPaddingStart"
    android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">

    <LinearLayout
        android:id="@+id/palette_view"
+1 −0
Original line number Diff line number Diff line
@@ -289,6 +289,7 @@
    <dimen name="accessibility_layout_margin_start_end">16dp</dimen>
    <dimen name="accessibility_button_preference_padding_top_bottom">18dp</dimen>
    <dimen name="accessibility_imageview_size">176dp</dimen>
    <dimen name="accessibility_illustration_view_radius">28dp</dimen>
    <!-- The margin between two Textviews-->
    <dimen name="accessibility_textview_layout_margin_bottom">24dp</dimen>

+15 −0
Original line number Diff line number Diff line
@@ -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);