Scale icons instead of relying on intrinsic size

Keep icons at 24dp and scale programmatically to keep
consistency when icons are overlaid

Fixes: 136285765
Change-Id: I273ab789ccf1ba4a9b7d1486d15ba6ebe0e4d367
diff --git a/res/drawable/ic_colorize_24px.xml b/res/drawable/ic_colorize_24px.xml
index 8363683..fb70972 100644
--- a/res/drawable/ic_colorize_24px.xml
+++ b/res/drawable/ic_colorize_24px.xml
@@ -14,8 +14,8 @@
      limitations under the License.
 -->
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="32dp"
-    android:height="32dp"
+    android:width="24dp"
+    android:height="24dp"
     android:viewportWidth="24"
     android:viewportHeight="24">
     <path
diff --git a/res/drawable/ic_font.xml b/res/drawable/ic_font.xml
index 6ce8308..f5df7ba 100644
--- a/res/drawable/ic_font.xml
+++ b/res/drawable/ic_font.xml
@@ -14,8 +14,8 @@
      limitations under the License.
 -->
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="32dp"
-    android:height="32dp"
+    android:width="24dp"
+    android:height="24dp"
     android:viewportWidth="24"
     android:viewportHeight="24">
     <!-- This path represents a square with rounded corners -->
diff --git a/res/drawable/ic_nav_wallpaper.xml b/res/drawable/ic_nav_wallpaper.xml
index a884a44..c935666 100644
--- a/res/drawable/ic_nav_wallpaper.xml
+++ b/res/drawable/ic_nav_wallpaper.xml
@@ -15,8 +15,8 @@
 -->
 <!-- Represents the wallpaper icon (a "landscape" shape in a box) -->
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="32dp"
-    android:height="32dp"
+    android:width="24dp"
+    android:height="24dp"
     android:viewportWidth="24"
     android:viewportHeight="24">
     <path
diff --git a/res/drawable/ic_shapes_24px.xml b/res/drawable/ic_shapes_24px.xml
index 6debc53..525f757 100644
--- a/res/drawable/ic_shapes_24px.xml
+++ b/res/drawable/ic_shapes_24px.xml
@@ -14,8 +14,8 @@
      limitations under the License.
 -->
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="32dp"
-    android:height="32dp"
+    android:width="24dp"
+    android:height="24dp"
     android:viewportWidth="24"
     android:viewportHeight="24">
     <path
diff --git a/res/drawable/ic_wifi_24px.xml b/res/drawable/ic_wifi_24px.xml
index 64834e0..0e27c57 100644
--- a/res/drawable/ic_wifi_24px.xml
+++ b/res/drawable/ic_wifi_24px.xml
@@ -14,8 +14,8 @@
      limitations under the License.
 -->
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="32dp"
-    android:height="32dp"
+    android:width="24dp"
+    android:height="24dp"
     android:viewportWidth="24"
     android:viewportHeight="24">
     <path
diff --git a/res/values-land/dimens.xml b/res/values-land/dimens.xml
index ddf84e8..985987f 100644
--- a/res/values-land/dimens.xml
+++ b/res/values-land/dimens.xml
@@ -18,6 +18,7 @@
 <resources>
     <dimen name="card_title_text_size">12sp</dimen>
     <dimen name="card_cover_title_text_size">14sp</dimen>
+    <dimen name="card_header_icon_size">24dp</dimen>
     <dimen name="card_header_top_margin">6dp</dimen>
     <dimen name="preview_card_padding">8dp</dimen>
     <dimen name="preview_card_top_padding">6dp</dimen>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 5c98fda..b6aac0b 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -66,6 +66,7 @@
 
     <dimen name="card_title_text_size">16sp</dimen>
     <dimen name="card_cover_title_text_size">24sp</dimen>
+    <dimen name="card_header_icon_size">32dp</dimen>
     <dimen name="card_header_top_margin">0dp</dimen>
     <dimen name="preview_pager_max_height">450dp</dimen>
     <dimen name="preview_pager_min_height">350dp</dimen>
diff --git a/src/com/android/customization/model/theme/custom/ThemeComponentOption.java b/src/com/android/customization/model/theme/custom/ThemeComponentOption.java
index ff8da08..f918d8e 100644
--- a/src/com/android/customization/model/theme/custom/ThemeComponentOption.java
+++ b/src/com/android/customization/model/theme/custom/ThemeComponentOption.java
@@ -163,7 +163,13 @@
             @DrawableRes int headerIcon) {
         TextView header = container.findViewById(R.id.theme_preview_card_header);
         header.setText(headerTextResId);
-        header.setCompoundDrawablesWithIntrinsicBounds(0, headerIcon, 0, 0);
+
+        Context context = container.getContext();
+        Drawable icon = context.getResources().getDrawable(headerIcon, context.getTheme());
+        int size = context.getResources().getDimensionPixelSize(R.dimen.card_header_icon_size);
+        icon.setBounds(0, 0, size, size);
+
+        header.setCompoundDrawables(null, icon, null, null);
         header.setCompoundDrawableTintList(ColorStateList.valueOf(
                 header.getCurrentTextColor()));
     }
diff --git a/src/com/android/customization/picker/theme/ThemePreviewPage.java b/src/com/android/customization/picker/theme/ThemePreviewPage.java
index f00cd3f..0543b24 100644
--- a/src/com/android/customization/picker/theme/ThemePreviewPage.java
+++ b/src/com/android/customization/picker/theme/ThemePreviewPage.java
@@ -38,8 +38,7 @@
 
     @StringRes
     final int nameResId;
-    @DrawableRes
-    final int iconSrc;
+    final Drawable icon;
     @LayoutRes
     final int contentLayoutRes;
     @ColorInt
@@ -51,7 +50,13 @@
             @ColorInt int accentColor) {
         super(null);
         this.nameResId = titleResId;
-        this.iconSrc = iconSrc;
+        if (iconSrc != Resources.ID_NULL) {
+            this.icon = context.getResources().getDrawable(iconSrc, context.getTheme());
+            int size = context.getResources().getDimensionPixelSize(R.dimen.card_header_icon_size);
+            icon.setBounds(0, 0, size, size);
+        } else {
+            this.icon = null;
+        }
         this.contentLayoutRes = contentLayoutRes;
         this.accentColor = accentColor;
         this.inflater = LayoutInflater.from(context);
@@ -61,7 +66,7 @@
     public void bindPreviewContent() {
         TextView header = card.findViewById(R.id.theme_preview_card_header);
         header.setText(nameResId);
-        header.setCompoundDrawablesWithIntrinsicBounds(0, iconSrc, 0, 0);
+        header.setCompoundDrawables(null, icon, null, null);
         header.setCompoundDrawableTintList(ColorStateList.valueOf(accentColor));
         card.findViewById(R.id.theme_preview_top_bar).setVisibility(View.GONE);
         card.findViewById(R.id.edit_label).setVisibility(View.GONE);