ThemePicker: Update UI for custom sections
Adapt font and icon pickers to the new colors in U-QPR1.
Change-Id: Ibd65374e5badda79af085cfd4345ee925ed72482
diff --git a/res/layout/font_preview_card.xml b/res/layout/font_preview_card.xml
index 17b4ea8..7d270e8 100644
--- a/res/layout/font_preview_card.xml
+++ b/res/layout/font_preview_card.xml
@@ -16,12 +16,14 @@
-->
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
style="@style/FullContentPreviewCard"
android:id="@+id/font_preview_card"
android:contentDescription="@string/font_preview_content_description"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:layout_gravity="center">
+ android:layout_gravity="center"
+ app:cardBackgroundColor="@color/system_surface_container">
<FrameLayout
android:id="@+id/theme_preview_card_body_container"
diff --git a/res/layout/font_section_view.xml b/res/layout/font_section_view.xml
index fde5b1e..4eb434f 100644
--- a/res/layout/font_section_view.xml
+++ b/res/layout/font_section_view.xml
@@ -42,7 +42,7 @@
android:layout_gravity="center"
android:textSize="@dimen/font_comonent_option_thumbnail_size"
android:textAlignment="center"
- android:textColor="?android:attr/colorForeground"
+ android:textColor="@color/system_on_surface"
android:text="@string/font_component_option_thumbnail"/>
</FrameLayout>
diff --git a/res/layout/icon_preview_card.xml b/res/layout/icon_preview_card.xml
index c6c05ba..73e87c1 100644
--- a/res/layout/icon_preview_card.xml
+++ b/res/layout/icon_preview_card.xml
@@ -13,12 +13,14 @@
-->
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
style="@style/FullContentPreviewCard"
android:id="@+id/icon_preview_card"
android:contentDescription="@string/icon_preview_content_description"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:layout_gravity="center">
+ android:layout_gravity="center"
+ app:cardBackgroundColor="@color/system_surface_container">
<FrameLayout
android:id="@+id/theme_preview_card_body_container"
diff --git a/res/layout/icon_shape_preview_card.xml b/res/layout/icon_shape_preview_card.xml
index 9d5cd39..c970812 100644
--- a/res/layout/icon_shape_preview_card.xml
+++ b/res/layout/icon_shape_preview_card.xml
@@ -13,12 +13,14 @@
-->
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
style="@style/FullContentPreviewCard"
android:id="@+id/icon_shape_preview_card"
android:contentDescription="@string/shape_preview_content_description"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:layout_gravity="center">
+ android:layout_gravity="center"
+ app:cardBackgroundColor="@color/system_surface_container">
<FrameLayout
android:id="@+id/theme_preview_card_body_container"
diff --git a/res/layout/icon_shape_section_view.xml b/res/layout/icon_shape_section_view.xml
index 9d37dec..79f0282 100644
--- a/res/layout/icon_shape_section_view.xml
+++ b/res/layout/icon_shape_section_view.xml
@@ -36,11 +36,12 @@
android:layout_gravity="center_horizontal"
android:paddingHorizontal="@dimen/option_tile_padding_horizontal"
android:paddingVertical="@dimen/option_tile_padding_vertical"
+ android:tint="@color/system_on_surface"
android:background="@drawable/picker_section_icon_background">
<ImageView
android:id="@+id/icon_section_tile"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
+ android:layout_width="@dimen/component_icon_thumb_size"
+ android:layout_height="@dimen/component_icon_thumb_size"
android:layout_gravity="center"/>
</FrameLayout>
diff --git a/res/layout/theme_font_option.xml b/res/layout/theme_font_option.xml
index 583ddde..1240557 100644
--- a/res/layout/theme_font_option.xml
+++ b/res/layout/theme_font_option.xml
@@ -27,7 +27,7 @@
android:paddingHorizontal="@dimen/option_tile_padding_horizontal"
android:paddingVertical="@dimen/option_tile_padding_vertical"
android:layout_marginHorizontal="@dimen/component_options_margin_horizontal"
- android:background="@drawable/option_border">
+ android:background="@drawable/option_border_custom">
<TextView
android:id="@+id/thumbnail_text"
android:layout_width="wrap_content"
@@ -35,7 +35,7 @@
android:layout_gravity="center"
android:textSize="@dimen/font_comonent_option_thumbnail_size"
android:textAlignment="center"
- android:textColor="?android:attr/colorForeground"
+ android:textColor="@color/system_on_surface"
android:text="@string/font_component_option_thumbnail"/>
</FrameLayout>
@@ -46,7 +46,7 @@
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/theme_option_label_margin"
android:gravity="center"
- android:textAppearance="@style/OptionTitleTextAppearance"
+ android:textColor="@color/system_on_surface"
android:singleLine="true"
android:scrollHorizontally="true"
android:ellipsize="marquee"
diff --git a/res/layout/theme_icon_option.xml b/res/layout/theme_icon_option.xml
index 0c61372..52edf67 100644
--- a/res/layout/theme_icon_option.xml
+++ b/res/layout/theme_icon_option.xml
@@ -27,13 +27,13 @@
android:paddingHorizontal="@dimen/option_tile_padding_horizontal"
android:paddingVertical="@dimen/option_tile_padding_vertical"
android:layout_marginHorizontal="@dimen/component_options_margin_horizontal"
- android:background="@drawable/option_border">
+ android:background="@drawable/option_border_custom">
<ImageView
android:id="@+id/option_icon"
android:layout_width="@dimen/component_icon_thumb_size"
android:layout_height="@dimen/component_icon_thumb_size"
android:layout_gravity="center"
- android:tint="?android:colorForeground"/>
+ android:tint="@color/system_on_surface"/>
</FrameLayout>
<TextView
@@ -43,7 +43,7 @@
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/theme_option_label_margin"
android:gravity="center"
- android:textAppearance="@style/OptionTitleTextAppearance"
+ android:textColor="@color/system_on_surface"
android:singleLine="true"
android:scrollHorizontally="true"
android:ellipsize="marquee"
diff --git a/res/layout/theme_shape_option.xml b/res/layout/theme_shape_option.xml
index 850714f..17b7a1f 100644
--- a/res/layout/theme_shape_option.xml
+++ b/res/layout/theme_shape_option.xml
@@ -18,16 +18,18 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
+
<FrameLayout
android:id="@+id/option_tile"
android:layout_width="@dimen/option_tile_width"
android:layout_height="@dimen/option_tile_width"
android:layout_gravity="center"
- android:layout_marginHorizontal="@dimen/component_options_margin_horizontal">
+ android:layout_marginHorizontal="@dimen/component_options_margin_horizontal"
+ android:background="@drawable/option_border_custom">
<ImageView
android:id="@+id/shape_thumbnail"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
+ android:layout_width="52dp"
+ android:layout_height="52dp"
android:layout_gravity="center"/>
</FrameLayout>
@@ -38,7 +40,7 @@
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/theme_option_label_margin"
android:gravity="center"
- android:textAppearance="@style/OptionTitleTextAppearance"
+ android:textColor="@color/system_on_surface"
android:singleLine="true"
android:scrollHorizontally="true"
android:ellipsize="marquee"
diff --git a/res/values/styles.xml b/res/values/styles.xml
index fc2fd8a..20ea933 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -20,6 +20,7 @@
<style name="CustomizationTheme" parent="@android:style/Theme.DeviceDefault.Settings">
<item name="colorPrimary">?android:colorPrimary</item>
+ <item name="android:colorBackground">@color/system_surface_container</item>
<item name="android:navigationBarColor">?android:colorPrimaryDark</item>
<item name="android:navigationBarDividerColor">@android:color/transparent</item>
diff --git a/res_override/drawable/check_circle_accent_24dp.xml b/res_override/drawable/check_circle_accent_24dp.xml
new file mode 100644
index 0000000..88ac267
--- /dev/null
+++ b/res_override/drawable/check_circle_accent_24dp.xml
@@ -0,0 +1,24 @@
+<!--
+ Copyright (C) 2020 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.
+-->
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+ <item>
+ <shape android:shape="oval">
+ <size android:width="24dp" android:height="24dp" />
+ <solid android:color="@color/system_primary" />
+ </shape>
+ </item>
+ <item android:drawable="@drawable/ic_check_24dp" android:gravity="fill" />
+</layer-list>
diff --git a/res_override/values/override.xml b/res_override/values/override.xml
index bb95d4b..2d1ef5b 100644
--- a/res_override/values/override.xml
+++ b/res_override/values/override.xml
@@ -41,4 +41,11 @@
<item>com.android.dialer</item>
<item>org.omnirom.control</item>
</array>
+
+ <!-- Dynamic colors -->
+ <style name="CustomizationTheme">
+ <item name="android:colorBackground">@color/system_surface_container</item>
+ </style>
+
+ <color name="toolbar_color">@color/system_surface_container</color>
</resources>
diff --git a/src/com/android/customization/model/font/FontOption.java b/src/com/android/customization/model/font/FontOption.java
index 05e3ad4..96d1f48 100644
--- a/src/com/android/customization/model/font/FontOption.java
+++ b/src/com/android/customization/model/font/FontOption.java
@@ -58,10 +58,10 @@
Resources res = view.getContext().getResources();
((TextView) view.findViewById(R.id.thumbnail_text)).setTypeface(
mHeadlineFont);
- int colorFilter = ResourceUtils.getColorAttr(view.getContext(),
+ int colorFilter = view.getContext().getResources().getColor(
view.isActivated() || view.getId() == R.id.font_section_tile
- ? android.R.attr.textColorPrimary
- : android.R.attr.textColorTertiary);
+ ? R.color.system_on_surface
+ : R.color.system_on_surface_variant);
((TextView) view.findViewById(R.id.thumbnail_text)).setTextColor(colorFilter);
view.setContentDescription(mTitle);
}
diff --git a/src/com/android/customization/model/iconpack/IconPackOption.java b/src/com/android/customization/model/iconpack/IconPackOption.java
index ba83e1a..5035fec 100644
--- a/src/com/android/customization/model/iconpack/IconPackOption.java
+++ b/src/com/android/customization/model/iconpack/IconPackOption.java
@@ -75,14 +75,15 @@
Resources res = view.getContext().getResources();
Drawable icon = mIcons.get(THUMBNAIL_ICON_POSITION)
.getConstantState().newDrawable().mutate();
- int colorFilter = ResourceUtils.getColorAttr(view.getContext(),
- android.R.attr.textColorPrimary);
int resId = R.id.icon_section_tile;
+ int colorFilter = view.getContext().getResources().getColor(
+ R.color.system_on_surface);
if (view.findViewById(R.id.option_icon) != null) {
resId = R.id.option_icon;
- colorFilter = ResourceUtils.getColorAttr(view.getContext(),
- view.isActivated() ? android.R.attr.textColorPrimary :
- android.R.attr.textColorTertiary);
+ colorFilter = view.getContext().getResources().getColor(
+ view.isActivated()
+ ? R.color.system_on_surface
+ : R.color.system_on_surface_variant);
}
icon.setColorFilter(colorFilter, Mode.SRC_ATOP);
((ImageView) view.findViewById(resId)).setImageDrawable(icon);
diff --git a/src/com/android/customization/model/iconshape/IconShapeOption.java b/src/com/android/customization/model/iconshape/IconShapeOption.java
index f9624fb..e2fd8f9 100644
--- a/src/com/android/customization/model/iconshape/IconShapeOption.java
+++ b/src/com/android/customization/model/iconshape/IconShapeOption.java
@@ -46,7 +46,7 @@
public class IconShapeOption implements CustomizationOption<IconShapeOption> {
- private final LayerDrawable mShape;
+ private final Drawable mShape;
private final List<ShapeAppIcon> mAppIcons;
private final String mTitle;
private final String mOverlayPackage;
@@ -65,39 +65,21 @@
mAppIcons = appIcons;
mPath = path;
mCornerRadius = cornerRadius;
- Drawable background = shapeDrawable.getConstantState().newDrawable();
- Drawable foreground = shapeDrawable.getConstantState().newDrawable();
- mShape = new LayerDrawable(new Drawable[]{background, foreground});
- mShape.setLayerGravity(0, Gravity.CENTER);
- mShape.setLayerGravity(1, Gravity.CENTER);
+ mShape = shapeDrawable.getConstantState().newDrawable();
}
@Override
public void bindThumbnailTile(View view) {
- Resources res = view.getContext().getResources();
int resId = R.id.icon_section_tile;
+ boolean isSectionView = true;
if (view.findViewById(R.id.shape_thumbnail) != null) {
resId = R.id.shape_thumbnail;
+ isSectionView = false;
}
- Resources.Theme theme = view.getContext().getTheme();
- int borderWidth = 2 * res.getDimensionPixelSize(R.dimen.option_border_width);
-
- Drawable background = mShape.getDrawable(0);
- background.setTintList(res.getColorStateList(R.color.option_border_color, theme));
-
- ShapeDrawable foreground = (ShapeDrawable) mShape.getDrawable(1);
-
- foreground.setIntrinsicHeight(background.getIntrinsicHeight() - borderWidth);
- foreground.setIntrinsicWidth(background.getIntrinsicWidth() - borderWidth);
- TypedArray ta = view.getContext().obtainStyledAttributes(
- new int[]{android.R.attr.colorPrimary});
- int primaryColor = ta.getColor(0, 0);
- ta.recycle();
- int foregroundColor =
- ResourceUtils.getColorAttr(view.getContext(), android.R.attr.textColorPrimary);
-
- foreground.setTint(ColorUtils.blendARGB(primaryColor, foregroundColor, .05f));
+ mShape.setTint(view.getContext().getResources().getColor(
+ view.isActivated() || isSectionView ? R.color.system_on_surface
+ : R.color.system_on_surface_variant));
((ImageView) view.findViewById(resId)).setImageDrawable(mShape);
view.setContentDescription(mTitle);