Merge "Fix folder and qsb inconsistency issue in ThemePicker Bug: 126417894" into ub-launcher3-master
diff --git a/res/layout/preview_card_color_content.xml b/res/layout/preview_card_color_content.xml
new file mode 100644
index 0000000..cbfe1d6
--- /dev/null
+++ b/res/layout/preview_card_color_content.xml
@@ -0,0 +1,152 @@
+<?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.
+-->
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="200dp"
+    android:layout_height="200dp"
+    android:layout_gravity="center"
+    android:gravity="center_horizontal|bottom"
+    android:orientation="vertical"
+    tools:showIn="@layout/theme_preview_card">
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_weight="0"
+        android:gravity="center|bottom"
+        android:orientation="horizontal">
+        <FrameLayout
+            android:layout_width="@dimen/preview_theme_icon_size"
+            android:layout_height="@dimen/preview_theme_icon_size">
+            <ImageView
+                android:layout_width="@dimen/preview_theme_icon_size"
+                android:layout_height="@dimen/preview_theme_icon_size"
+                android:id="@+id/preview_color_qs_0_bg"/>
+            <ImageView
+                android:layout_width="@dimen/preview_theme_tile_size"
+                android:layout_height="@dimen/preview_theme_tile_size"
+                android:id="@+id/preview_color_qs_0_icon"
+                android:tint="@color/tile_enabled_icon_color"
+                android:layout_gravity="center"/>
+        </FrameLayout>
+        <FrameLayout
+            android:layout_width="@dimen/preview_theme_icon_size"
+            android:layout_height="@dimen/preview_theme_icon_size"
+            android:layout_marginHorizontal="28dp">
+            <ImageView
+                android:layout_width="@dimen/preview_theme_icon_size"
+                android:layout_height="@dimen/preview_theme_icon_size"
+                android:id="@+id/preview_color_qs_1_bg"/>
+            <ImageView
+                android:layout_width="@dimen/preview_theme_tile_size"
+                android:layout_height="@dimen/preview_theme_tile_size"
+                android:id="@+id/preview_color_qs_1_icon"
+                android:tint="@color/tile_enabled_icon_color"
+                android:layout_gravity="center"/>
+        </FrameLayout>
+        <FrameLayout
+            android:layout_width="@dimen/preview_theme_icon_size"
+            android:layout_height="@dimen/preview_theme_icon_size">
+            <ImageView
+                android:layout_width="@dimen/preview_theme_icon_size"
+                android:layout_height="@dimen/preview_theme_icon_size"
+                android:id="@+id/preview_color_qs_2_bg"
+                android:tint="@color/tile_disabled_background_color"/>
+            <ImageView
+                android:layout_width="@dimen/preview_theme_tile_size"
+                android:layout_height="@dimen/preview_theme_tile_size"
+                android:id="@+id/preview_color_qs_2_icon"
+                android:color="@color/tile_disabled_icon_color"
+                android:layout_gravity="center"/>
+        </FrameLayout>
+    </LinearLayout>
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_weight="0"
+        android:orientation="horizontal"
+        android:layout_marginTop="30dp"
+        android:gravity="center|bottom">
+        <SeekBar
+            android:id="@+id/preview_seekbar"
+            android:layout_height="wrap_content"
+            android:layout_width="match_parent"
+            android:tint="@color/theme_preview_icon_color"
+            android:maxHeight="2dp"
+            android:progress="1"
+            android:max="3"/>
+    </LinearLayout>
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_weight="0"
+        android:layout_marginTop="15dp"
+        android:gravity="center"
+        android:orientation="horizontal">
+        <CheckBox
+            android:id="@+id/preview_check_selected"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:checked="true"
+            android:layout_gravity="center"
+            android:clickable="false"/>
+        <RadioButton
+            android:id="@+id/preview_radio_selected"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginLeft="30dp"
+            android:layout_marginRight="22dp"
+            android:checked="true"
+            android:layout_gravity="center"
+            android:clickable="false"/>
+        <Switch
+            android:id="@+id/preview_toggle_selected"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:checked="true"
+            android:layout_gravity="center"
+            android:clickable="false"/>
+    </LinearLayout>
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_weight="0"
+        android:layout_marginTop="20dp"
+        android:gravity="center"
+        android:orientation="horizontal">
+        <CheckBox
+            android:id="@+id/preview_check_unselected"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center"
+            android:clickable="false"/>
+        <RadioButton
+            android:id="@+id/preview_radio_unselected"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginLeft="30dp"
+            android:layout_marginRight="22dp"
+            android:layout_gravity="center"
+            android:clickable="false"/>
+        <Switch
+            android:id="@+id/preview_toggle_unselected"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center"
+            android:clickable="false"/>
+    </LinearLayout>
+</LinearLayout>
diff --git a/res/values-night/colors.xml b/res/values-night/colors.xml
index f9509e6..d2f580c 100644
--- a/res/values-night/colors.xml
+++ b/res/values-night/colors.xml
@@ -19,4 +19,8 @@
     <color name="theme_preview_icon_color">@color/white_70_alpha</color>
 
     <color name="icon_thumbnail_color">@color/white_70_alpha</color>
-</resources>
\ No newline at end of file
+
+    <color name="tile_enabled_icon_color">#2d2d2d</color>
+    <color name="tile_disabled_icon_color">@color/light_grey</color>
+    <color name="tile_disabled_background_color">#353535</color>
+</resources>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 19177e4..3aa48ce 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -34,4 +34,8 @@
 
     <color name="text_color_dark">#2d2d2d</color>
     <color name="text_color_light">@color/material_white_text</color>
+
+    <color name="tile_enabled_icon_color">@color/material_white_100</color>
+    <color name="tile_disabled_icon_color">#2d2d2d</color>
+    <color name="tile_disabled_background_color">@color/light_grey</color>
 </resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index c81742b..8476fd3 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -59,6 +59,7 @@
 
     <dimen name="card_title_text_size">16sp</dimen>
     <dimen name="preview_theme_icon_size">40dp</dimen>
+    <dimen name="preview_theme_tile_size">20dp</dimen>
 
     <dimen name="color_preview_image_width">182dp</dimen>
     <dimen name="color_preview_image_height">194dp</dimen>
diff --git a/src/com/android/customization/picker/theme/ThemeFragment.java b/src/com/android/customization/picker/theme/ThemeFragment.java
index 9ad8e84..6df43f0 100644
--- a/src/com/android/customization/picker/theme/ThemeFragment.java
+++ b/src/com/android/customization/picker/theme/ThemeFragment.java
@@ -23,6 +23,7 @@
 import android.content.res.Resources;
 import android.graphics.Bitmap;
 import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.Drawable;
 import android.os.Bundle;
 import android.util.Log;
 import android.view.LayoutInflater;
@@ -32,6 +33,8 @@
 import android.widget.CheckBox;
 import android.widget.CompoundButton;
 import android.widget.ImageView;
+import android.widget.SeekBar;
+import android.widget.Switch;
 import android.widget.TextView;
 import android.widget.Toast;
 
@@ -267,6 +270,15 @@
                 R.id.preview_icon_0, R.id.preview_icon_1, R.id.preview_icon_2, R.id.preview_icon_3,
                 R.id.preview_icon_4, R.id.preview_icon_5
         };
+        private int[] mColorButtonIds = {
+            R.id.preview_check_selected, R.id.preview_radio_selected, R.id.preview_toggle_selected,
+        };
+        private int[] mColorTileIds = {
+            R.id.preview_color_qs_0_bg, R.id.preview_color_qs_1_bg, R.id.preview_color_qs_2_bg
+        };
+        private int[] mColorTileIconIds = {
+            R.id.preview_color_qs_0_icon, R.id.preview_color_qs_1_icon, R.id.preview_color_qs_2_icon
+        };
 
         ThemePreviewAdapter(Activity activity, ThemeBundle theme) {
             super(activity, R.layout.theme_preview_card);
@@ -298,17 +310,50 @@
             }
             if (previewInfo.colorPreviewAsset != null) {
                 addPage(new ThemePreviewPage(activity, R.string.preview_name_color,
-                        R.drawable.ic_colorize_24px, R.layout.preview_card_static_content,
+                        R.drawable.ic_colorize_24px, R.layout.preview_card_color_content,
                         previewInfo.resolveAccentColor(res)) {
                     @Override
                     protected void bindBody(boolean forceRebind) {
-                        ImageView staticImage = card.findViewById(R.id.preview_static_image);
-                        previewInfo.colorPreviewAsset.loadDrawable(activity,
-                                staticImage, card.getCardBackgroundColor().getDefaultColor());
-                        staticImage.getLayoutParams().width = res.getDimensionPixelSize(
-                                R.dimen.color_preview_image_width);
-                        staticImage.getLayoutParams().height = res.getDimensionPixelSize(
-                                R.dimen.color_preview_image_height);
+                        ColorStateList tintList = new ColorStateList(
+                                new int[][]{
+                                    new int[]{android.R.attr.state_selected},
+                                    new int[]{android.R.attr.state_checked}
+                                },
+                                new int[] {
+                                    accentColor,
+                                    accentColor
+                                }
+                            );
+
+                        for (int i = 0; i < mColorButtonIds.length; i++) {
+                            CompoundButton button = card.findViewById(mColorButtonIds[i]);
+                            button.setButtonTintList(tintList);
+                        }
+
+                        Switch switch1 = card.findViewById(R.id.preview_toggle_selected);
+                        switch1.setThumbTintList(tintList);
+                        switch1.setTrackTintList(tintList);
+
+                        ColorStateList seekbarTintList = ColorStateList.valueOf(accentColor);
+                        SeekBar seekbar = card.findViewById(R.id.preview_seekbar);
+                        seekbar.setThumbTintList(seekbarTintList);
+                        seekbar.setProgressTintList(seekbarTintList);
+                        seekbar.setProgressBackgroundTintList(seekbarTintList);
+                        // Disable seekbar
+                        seekbar.setOnTouchListener((view, motionEvent) -> true);
+
+                        for (int i = 0; i < mColorTileIds.length; i++) {
+                            Drawable icon =
+                                previewInfo.icons.get(i).getConstantState().newDrawable();
+                            Drawable bgShape =
+                                previewInfo.shapeDrawable.getConstantState().newDrawable();
+                            bgShape.setTint(accentColor);
+
+                            ImageView bg = card.findViewById(mColorTileIds[i]);
+                            bg.setImageDrawable(bgShape);
+                            ImageView fg = card.findViewById(mColorTileIconIds[i]);
+                            fg.setImageDrawable(icon);
+                        }
                     }
                 });
             }