Revert "ThemePicker: Update UI for custom sections"

This reverts commit 935b65e8b3b31c996271a702d8165ea85ec98a80.

Change-Id: Id6d40aad882c7b0085183f102ded4387e870ddda
Signed-off-by: micky387 <mickaelsaibi@free.fr>
diff --git a/res/layout/font_preview_card.xml b/res/layout/font_preview_card.xml
index 7d270e8..17b4ea8 100644
--- a/res/layout/font_preview_card.xml
+++ b/res/layout/font_preview_card.xml
@@ -16,14 +16,12 @@
 -->
 <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"
-    app:cardBackgroundColor="@color/system_surface_container">
+    android:layout_gravity="center">
 
     <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 4eb434f..fde5b1e 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="@color/system_on_surface"
+            android:textColor="?android:attr/colorForeground"
             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 73e87c1..c6c05ba 100644
--- a/res/layout/icon_preview_card.xml
+++ b/res/layout/icon_preview_card.xml
@@ -13,14 +13,12 @@
 -->
 <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"
-    app:cardBackgroundColor="@color/system_surface_container">
+    android:layout_gravity="center">
 
     <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 c970812..9d5cd39 100644
--- a/res/layout/icon_shape_preview_card.xml
+++ b/res/layout/icon_shape_preview_card.xml
@@ -13,14 +13,12 @@
 -->
 <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"
-    app:cardBackgroundColor="@color/system_surface_container">
+    android:layout_gravity="center">
 
     <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 79f0282..9d37dec 100644
--- a/res/layout/icon_shape_section_view.xml
+++ b/res/layout/icon_shape_section_view.xml
@@ -36,12 +36,11 @@
         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="@dimen/component_icon_thumb_size"
-            android:layout_height="@dimen/component_icon_thumb_size"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
             android:layout_gravity="center"/>
     </FrameLayout>
 
diff --git a/res/layout/theme_font_option.xml b/res/layout/theme_font_option.xml
index 1240557..583ddde 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_custom">
+        android:background="@drawable/option_border">
         <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="@color/system_on_surface"
+            android:textColor="?android:attr/colorForeground"
             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:textColor="@color/system_on_surface"
+        android:textAppearance="@style/OptionTitleTextAppearance"
         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 52edf67..0c61372 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_custom">
+        android:background="@drawable/option_border">
         <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="@color/system_on_surface"/>
+            android:tint="?android:colorForeground"/>
     </FrameLayout>
 
     <TextView
@@ -43,7 +43,7 @@
         android:layout_gravity="center_horizontal"
         android:layout_marginTop="@dimen/theme_option_label_margin"
         android:gravity="center"
-        android:textColor="@color/system_on_surface"
+        android:textAppearance="@style/OptionTitleTextAppearance"
         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 17b7a1f..850714f 100644
--- a/res/layout/theme_shape_option.xml
+++ b/res/layout/theme_shape_option.xml
@@ -18,18 +18,16 @@
               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:background="@drawable/option_border_custom">
+        android:layout_marginHorizontal="@dimen/component_options_margin_horizontal">
         <ImageView
             android:id="@+id/shape_thumbnail"
-            android:layout_width="52dp"
-            android:layout_height="52dp"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
             android:layout_gravity="center"/>
     </FrameLayout>
 
@@ -40,7 +38,7 @@
         android:layout_gravity="center_horizontal"
         android:layout_marginTop="@dimen/theme_option_label_margin"
         android:gravity="center"
-        android:textColor="@color/system_on_surface"
+        android:textAppearance="@style/OptionTitleTextAppearance"
         android:singleLine="true"
         android:scrollHorizontally="true"
         android:ellipsize="marquee"
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 20ea933..fc2fd8a 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -20,7 +20,6 @@
     <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
deleted file mode 100644
index 88ac267..0000000
--- a/res_override/drawable/check_circle_accent_24dp.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<!--
-     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 2d1ef5b..bb95d4b 100644
--- a/res_override/values/override.xml
+++ b/res_override/values/override.xml
@@ -41,11 +41,4 @@
         <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 96d1f48..05e3ad4 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 = view.getContext().getResources().getColor(
+        int colorFilter = ResourceUtils.getColorAttr(view.getContext(),
                 view.isActivated() || view.getId() == R.id.font_section_tile
-                        ? R.color.system_on_surface
-                        : R.color.system_on_surface_variant);
+                        ? android.R.attr.textColorPrimary
+                        : android.R.attr.textColorTertiary);
         ((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 5035fec..ba83e1a 100644
--- a/src/com/android/customization/model/iconpack/IconPackOption.java
+++ b/src/com/android/customization/model/iconpack/IconPackOption.java
@@ -75,15 +75,14 @@
         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 = view.getContext().getResources().getColor(
-                    view.isActivated()
-                            ? R.color.system_on_surface
-                            : R.color.system_on_surface_variant);
+            colorFilter = ResourceUtils.getColorAttr(view.getContext(),
+                view.isActivated() ? android.R.attr.textColorPrimary :
+                android.R.attr.textColorTertiary);
         }
         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 e2fd8f9..f9624fb 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 Drawable mShape;
+    private final LayerDrawable mShape;
     private final List<ShapeAppIcon> mAppIcons;
     private final String mTitle;
     private final String mOverlayPackage;
@@ -65,21 +65,39 @@
         mAppIcons = appIcons;
         mPath = path;
         mCornerRadius = cornerRadius;
-        mShape = shapeDrawable.getConstantState().newDrawable();
+        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);
     }
 
     @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;
         }
 
-        mShape.setTint(view.getContext().getResources().getColor(
-                view.isActivated() || isSectionView ? R.color.system_on_surface
-                : R.color.system_on_surface_variant));
+        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));
 
         ((ImageView) view.findViewById(resId)).setImageDrawable(mShape);
         view.setContentDescription(mTitle);