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

Commit 41ffb72c authored by Wesley.CW Wang's avatar Wesley.CW Wang
Browse files

Change color rings color to system accent

 - Create state drawable programmatically and fill options center part
 only with accent color
 video: https://drive.google.com/file/d/1swM0i_vfUg1CQj8m7F9h28Cr45020SHr/view?usp=sharing

 Fixes: 158625350
 Test: manually

Change-Id: Ica0f4a30b15e8195544a9619bc1af21c9f11ecc1
parent 3e5a805a
Loading
Loading
Loading
Loading

res/drawable/color_chip.xml

deleted100644 → 0
+0 −27
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--

     Copyright (C) 2019 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_activated="true"
        android:drawable="@drawable/color_chip_hollow" />
    <item
        android:state_activated="false"
        android:drawable="@drawable/color_chip_filled" />
    <item
        android:drawable="@drawable/color_chip_filled"/>
</selector>
 No newline at end of file
+2 −2
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<!--
<!--

     Copyright (C) 2019 The Android Open Source Project
     Copyright (C) 2019 The Android Open Source Project


     Licensed under the Apache License, Version 2.0 (the "License");
     Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,6 +16,7 @@
-->
-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
    <item
        android:id="@+id/center_fill"
        android:height="@dimen/component_color_chip_size"
        android:height="@dimen/component_color_chip_size"
        android:width="@dimen/component_color_chip_size"
        android:width="@dimen/component_color_chip_size"
        android:gravity="center">
        android:gravity="center">
@@ -34,7 +34,7 @@
            android:innerRadius="24dp"
            android:innerRadius="24dp"
            android:thickness="@dimen/option_border_width"
            android:thickness="@dimen/option_border_width"
            android:useLevel="false">
            android:useLevel="false">
        <solid android:color="@android:color/black"/>
        <solid android:color="?android:colorAccent"/>
        </shape>
        </shape>
    </item>
    </item>
</layer-list>
</layer-list>
+1 −2
Original line number Original line Diff line number Diff line
@@ -26,6 +26,5 @@
        android:layout_width="@dimen/component_color_chip_container_size"
        android:layout_width="@dimen/component_color_chip_container_size"
        android:layout_height="@dimen/component_color_chip_container_size"
        android:layout_height="@dimen/component_color_chip_container_size"
        android:layout_gravity="center"
        android:layout_gravity="center"
        android:scaleType="center"
        android:scaleType="center"/>
        android:src="@drawable/color_chip"/>
</FrameLayout>
</FrameLayout>
+15 −1
Original line number Original line Diff line number Diff line
@@ -35,6 +35,7 @@ import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.StateListDrawable;
import android.view.Gravity;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View;
@@ -315,8 +316,21 @@ public abstract class ThemeComponentOption implements CustomizationOption<ThemeC
        @Override
        @Override
        public void bindThumbnailTile(View view) {
        public void bindThumbnailTile(View view) {
            @ColorInt int color = resolveColor(view.getResources());
            @ColorInt int color = resolveColor(view.getResources());
            ((ImageView) view.findViewById(R.id.option_tile)).setImageTintList(
            LayerDrawable selectedOption = (LayerDrawable) view.getResources().getDrawable(
                    R.drawable.color_chip_hollow, view.getContext().getTheme());
            Drawable unselectedOption = view.getResources().getDrawable(
                    R.drawable.color_chip_filled, view.getContext().getTheme());

            selectedOption.findDrawableByLayerId(R.id.center_fill).setTintList(
                    ColorStateList.valueOf(color));
                    ColorStateList.valueOf(color));
            unselectedOption.setTintList(ColorStateList.valueOf(color));

            StateListDrawable stateListDrawable = new StateListDrawable();
            stateListDrawable.addState(new int[] {android.R.attr.state_activated}, selectedOption);
            stateListDrawable.addState(
                    new int[] {-android.R.attr.state_activated}, unselectedOption);

            ((ImageView) view.findViewById(R.id.option_tile)).setImageDrawable(stateListDrawable);
            view.setContentDescription(mLabel);
            view.setContentDescription(mLabel);
        }
        }