Loading res/drawable/color_chip.xmldeleted 100644 → 0 +0 −27 Original line number 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 res/drawable/color_chip_hollow.xml +2 −2 Original line number 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"); Loading @@ -17,6 +16,7 @@ --> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/center_fill" android:height="@dimen/component_color_chip_size" android:width="@dimen/component_color_chip_size" android:gravity="center"> Loading @@ -34,7 +34,7 @@ android:innerRadius="24dp" android:thickness="@dimen/option_border_width" android:useLevel="false"> <solid android:color="@android:color/black"/> <solid android:color="?android:colorAccent"/> </shape> </item> </layer-list> Loading res/layout/theme_color_option.xml +1 −2 Original line number Diff line number Diff line Loading @@ -26,6 +26,5 @@ android:layout_width="@dimen/component_color_chip_container_size" android:layout_height="@dimen/component_color_chip_container_size" android:layout_gravity="center" android:scaleType="center" android:src="@drawable/color_chip"/> android:scaleType="center"/> </FrameLayout> src/com/android/customization/model/theme/custom/ThemeComponentOption.java +15 −1 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.graphics.drawable.LayerDrawable; import android.graphics.drawable.ShapeDrawable; import android.graphics.drawable.StateListDrawable; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; Loading Loading @@ -315,8 +316,21 @@ public abstract class ThemeComponentOption implements CustomizationOption<ThemeC @Override public void bindThumbnailTile(View view) { @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)); 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); } Loading Loading
res/drawable/color_chip.xmldeleted 100644 → 0 +0 −27 Original line number 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
res/drawable/color_chip_hollow.xml +2 −2 Original line number 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"); Loading @@ -17,6 +16,7 @@ --> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/center_fill" android:height="@dimen/component_color_chip_size" android:width="@dimen/component_color_chip_size" android:gravity="center"> Loading @@ -34,7 +34,7 @@ android:innerRadius="24dp" android:thickness="@dimen/option_border_width" android:useLevel="false"> <solid android:color="@android:color/black"/> <solid android:color="?android:colorAccent"/> </shape> </item> </layer-list> Loading
res/layout/theme_color_option.xml +1 −2 Original line number Diff line number Diff line Loading @@ -26,6 +26,5 @@ android:layout_width="@dimen/component_color_chip_container_size" android:layout_height="@dimen/component_color_chip_container_size" android:layout_gravity="center" android:scaleType="center" android:src="@drawable/color_chip"/> android:scaleType="center"/> </FrameLayout>
src/com/android/customization/model/theme/custom/ThemeComponentOption.java +15 −1 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.graphics.drawable.LayerDrawable; import android.graphics.drawable.ShapeDrawable; import android.graphics.drawable.StateListDrawable; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; Loading Loading @@ -315,8 +316,21 @@ public abstract class ThemeComponentOption implements CustomizationOption<ThemeC @Override public void bindThumbnailTile(View view) { @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)); 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); } Loading