Merge "Various custom flow fixes." into ub-launcher3-qt-dev
diff --git a/res/drawable/option_border.xml b/res/drawable/option_border.xml
index e715fcd..7221f95 100644
--- a/res/drawable/option_border.xml
+++ b/res/drawable/option_border.xml
@@ -15,6 +15,6 @@
 -->
 <shape xmlns:android="http://schemas.android.com/apk/res/android"
     android:shape="rectangle">
-    <stroke android:color="@color/option_border_color" android:width="2dp" />
+    <stroke android:color="@color/option_border_color" android:width="@dimen/option_border_width" />
     <corners android:radius="4dp" />
 </shape>
diff --git a/res/layout/fragment_custom_theme_component.xml b/res/layout/fragment_custom_theme_component.xml
index fb26432..4acc884 100644
--- a/res/layout/fragment_custom_theme_component.xml
+++ b/res/layout/fragment_custom_theme_component.xml
@@ -36,14 +36,6 @@
             android:layout_marginTop="@dimen/preview_page_top_margin"
             android:layout_marginBottom="@dimen/component_preview_page_bottom_margin"
             layout="@layout/theme_preview_card"/>
-        <TextView
-            android:id="@+id/component_step_counter"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_gravity="bottom|center_horizontal"
-            android:layout_marginVertical="10dp"
-            android:textAlignment="center"
-            android:textAppearance="@style/ComponentCounterTextAppearance"/>
     </FrameLayout>
 
     <LinearLayout
@@ -68,7 +60,6 @@
             android:layout_height="@dimen/options_container_height"
             android:layout_gravity="center_horizontal"/>
 
-
     </LinearLayout>
 
 </LinearLayout>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index f17f344..bd03aa8 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -34,7 +34,7 @@
     <dimen name="preview_page_horizontal_margin">56dp</dimen>
     <dimen name="preview_page_top_margin">16dp</dimen>
     <dimen name="preview_page_bottom_margin">2dp</dimen>
-    <dimen name="component_preview_page_bottom_margin">36dp</dimen>
+    <dimen name="component_preview_page_bottom_margin">16dp</dimen>
 
     <!-- Dimensions for the customization option tiles -->
     <dimen name="options_container_height">100dp</dimen>
@@ -83,7 +83,7 @@
     <dimen name="component_color_chip_size">42dp</dimen>
 
     <dimen name="component_shape_thumb_size">72dp</dimen>
-    <dimen name="component_shape_border_width">3dp</dimen>
+    <dimen name="option_border_width">2dp</dimen>
 
     <!-- For a corner radius of this size or larger, we'll preview a rounded qsb widget. -->
     <dimen name="roundCornerThreshold">16dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index fd7233b..0723542 100755
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -132,13 +132,8 @@
     <!-- Title of a set of icons that the user can chose for their custom style (eg, "Icons 2") -->
     <string name="icon_component_label">Icons <xliff:g name="component_number" example="1">%1$d</xliff:g></string>
 
-
     <string name="font_component_option_thumbnail" translatable="false">A</string>
 
-    <!-- Text explaining what the current step is in setting a custom theme, eg: "1 of 4".
-    [CHAR_LIMIT=40] -->
-    <string name="component_step_counter"><xliff:g name="current_step" example="1">%1$d</xliff:g> of <xliff:g name="total_steps" example="4">%2$d</xliff:g></string>
-
     <!-- Dialog box asking the user to confirm if they want to delete the current custom style
         [CHAR_LIMIT=NONE] -->
     <string name="delete_custom_theme_confirmation">Delete Custom style?</string>
diff --git a/src/com/android/customization/model/theme/custom/ThemeComponentOption.java b/src/com/android/customization/model/theme/custom/ThemeComponentOption.java
index 9aef1e5..9427208 100644
--- a/src/com/android/customization/model/theme/custom/ThemeComponentOption.java
+++ b/src/com/android/customization/model/theme/custom/ThemeComponentOption.java
@@ -181,7 +181,7 @@
         @Override
         public void bindPreview(ViewGroup container) {
             TextView header = container.findViewById(R.id.theme_preview_card_header);
-            header.setText(mLabel);
+            header.setText(R.string.preview_name_icon);
             header.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.ic_wifi_24px, 0, 0);
 
             ViewGroup cardBody = container.findViewById(R.id.theme_preview_card_body_container);
@@ -384,7 +384,7 @@
             ImageView thumb = view.findViewById(R.id.shape_thumbnail);
             Resources res = view.getResources();
             Theme theme = view.getContext().getTheme();
-            int borderWidth = res.getDimensionPixelSize(R.dimen.component_shape_border_width);
+            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));
diff --git a/src/com/android/customization/picker/theme/CustomThemeActivity.java b/src/com/android/customization/picker/theme/CustomThemeActivity.java
index 6c21d4a..f7603ad 100644
--- a/src/com/android/customization/picker/theme/CustomThemeActivity.java
+++ b/src/com/android/customization/picker/theme/CustomThemeActivity.java
@@ -269,16 +269,14 @@
     private static abstract class ComponentStep<T extends ThemeComponentOption> {
         @StringRes final int titleResId;
         final ThemeComponentOptionProvider<T> provider;
-        final int totalSteps;
         final int position;
         private CustomThemeComponentFragment mFragment;
 
         protected ComponentStep(@StringRes int titleResId, ThemeComponentOptionProvider<T> provider,
-                int position, int totalSteps) {
+                                int position) {
             this.titleResId = titleResId;
             this.provider = provider;
             this.position = position;
-            this.totalSteps = totalSteps;
         }
 
         CustomThemeComponentFragment getFragment() {
@@ -298,7 +296,7 @@
 
         protected FontStep(ThemeComponentOptionProvider<FontOption> provider,
                 int position, int totalSteps) {
-            super(R.string.font_component_title, provider, position, totalSteps);
+            super(R.string.font_component_title, provider, position);
         }
 
         @Override
@@ -306,7 +304,6 @@
             return CustomThemeComponentFragment.newInstance(
                     CustomThemeActivity.this.getString(R.string.custom_theme_fragment_title),
                     position,
-                    totalSteps,
                     titleResId);
         }
     }
@@ -315,7 +312,7 @@
 
         protected IconStep(ThemeComponentOptionProvider<IconOption> provider,
                 int position, int totalSteps) {
-            super(R.string.icon_component_title, provider, position, totalSteps);
+            super(R.string.icon_component_title, provider, position);
         }
 
         @Override
@@ -323,7 +320,6 @@
             return CustomThemeComponentFragment.newInstance(
                     CustomThemeActivity.this.getString(R.string.custom_theme_fragment_title),
                     position,
-                    totalSteps,
                     titleResId);
         }
     }
@@ -332,7 +328,7 @@
 
         protected ColorStep(ThemeComponentOptionProvider<ColorOption> provider,
                 int position, int totalSteps) {
-            super(R.string.color_component_title, provider, position, totalSteps);
+            super(R.string.color_component_title, provider, position);
         }
 
         @Override
@@ -340,7 +336,6 @@
             return CustomThemeComponentFragment.newInstance(
                     CustomThemeActivity.this.getString(R.string.custom_theme_fragment_title),
                     position,
-                    totalSteps,
                     titleResId);
         }
     }
@@ -349,7 +344,7 @@
 
         protected ShapeStep(ThemeComponentOptionProvider<ShapeOption> provider,
                 int position, int totalSteps) {
-            super(R.string.shape_component_title, provider, position, totalSteps);
+            super(R.string.shape_component_title, provider, position);
         }
 
         @Override
@@ -357,7 +352,6 @@
             return CustomThemeComponentFragment.newInstance(
                     CustomThemeActivity.this.getString(R.string.custom_theme_fragment_title),
                     position,
-                    totalSteps,
                     titleResId);
         }
     }
diff --git a/src/com/android/customization/picker/theme/CustomThemeComponentFragment.java b/src/com/android/customization/picker/theme/CustomThemeComponentFragment.java
index 801bb0c..f2088ae 100644
--- a/src/com/android/customization/picker/theme/CustomThemeComponentFragment.java
+++ b/src/com/android/customization/picker/theme/CustomThemeComponentFragment.java
@@ -39,7 +39,6 @@
 
 public class CustomThemeComponentFragment extends ToolbarFragment {
     private static final String ARG_KEY_POSITION = "CustomThemeComponentFragment.position";
-    private static final String ARG_KEY_TOTAL_STEPS = "CustomThemeComponentFragment.steps";
     private static final String ARG_KEY_TITLE_RES_ID = "CustomThemeComponentFragment.title_res";
     private CustomThemeComponentFragmentHost mHost;
 
@@ -55,11 +54,10 @@
     }
 
     public static CustomThemeComponentFragment newInstance(CharSequence toolbarTitle, int position,
-            int totalSteps, int titleResId) {
+            int titleResId) {
         CustomThemeComponentFragment fragment = new CustomThemeComponentFragment();
         Bundle arguments = ToolbarFragment.createArguments(toolbarTitle);
         arguments.putInt(ARG_KEY_POSITION, position);
-        arguments.putInt(ARG_KEY_TOTAL_STEPS, totalSteps);
         arguments.putInt(ARG_KEY_TITLE_RES_ID, titleResId);
         fragment.setArguments(arguments);
         return fragment;
@@ -68,7 +66,6 @@
     private ThemeComponentOptionProvider<? extends ThemeComponentOption> mProvider;
     private CustomThemeManager mCustomThemeManager;
     private int mPosition;
-    private int mTotalSteps;
     @StringRes private int mTitleResId;
 
     private RecyclerView mOptionsContainer;
@@ -81,7 +78,6 @@
     public void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         mPosition = getArguments().getInt(ARG_KEY_POSITION);
-        mTotalSteps = getArguments().getInt(ARG_KEY_TOTAL_STEPS);
         mTitleResId = getArguments().getInt(ARG_KEY_TITLE_RES_ID);
         mProvider = mHost.getComponentOptionProvider(mPosition);
         mCustomThemeManager = mHost.getCustomThemeManager();
@@ -112,9 +108,6 @@
         mPreviewCard = view.findViewById(R.id.component_preview_card);
         mTitle = view.findViewById(R.id.component_options_title);
         mTitle.setText(mTitleResId);
-        TextView stepCounter = view.findViewById(R.id.component_step_counter);
-        stepCounter.setText(getContext().getString(R.string.component_step_counter,
-                mPosition + 1, mTotalSteps));
         setUpOptions();
 
         return view;
diff --git a/src/com/android/customization/picker/theme/ThemeFragment.java b/src/com/android/customization/picker/theme/ThemeFragment.java
index bc17a27..3d135ed 100644
--- a/src/com/android/customization/picker/theme/ThemeFragment.java
+++ b/src/com/android/customization/picker/theme/ThemeFragment.java
@@ -300,19 +300,17 @@
         @DrawableRes final int iconSrc;
         @LayoutRes final int contentLayoutRes;
         @ColorInt final int accentColor;
-        protected final OnClickListener editClickListener;
         protected final LayoutInflater inflater;
 
         private ThemePreviewPage(Context context, @StringRes int titleResId,
                 @DrawableRes int iconSrc, @LayoutRes int contentLayoutRes,
-                @ColorInt int accentColor, OnClickListener editClickListener) {
+                @ColorInt int accentColor) {
             super(null);
             this.nameResId = titleResId;
             this.iconSrc = iconSrc;
             this.contentLayoutRes = contentLayoutRes;
             this.accentColor = accentColor;
             this.inflater = LayoutInflater.from(context);
-            this.editClickListener = editClickListener;
         }
 
         @Override
@@ -326,9 +324,6 @@
             ViewGroup body = card.findViewById(R.id.theme_preview_card_body_container);
             inflater.inflate(contentLayoutRes, body, true);
             bindBody(false);
-            card.setOnClickListener(editClickListener);
-            card.findViewById(R.id.edit_label).setVisibility(editClickListener != null
-                    ? View.VISIBLE : View.INVISIBLE);
         }
 
         protected boolean containsWallpaper() {
@@ -343,6 +338,7 @@
         private final Typeface mHeadlineFont;
         private final List<Drawable> mIcons;
         private String mTitle;
+        private OnClickListener mEditClickListener;
         private final ThemePreviewAdapter.WallpaperPreviewLayoutListener mListener;
         private final int mCornerRadius;
 
@@ -350,12 +346,12 @@
                 Typeface headlineFont, int cornerRadius,
                 OnClickListener editClickListener,
                 ThemePreviewAdapter.WallpaperPreviewLayoutListener wallpaperListener) {
-            super(context, 0, 0, R.layout.preview_card_cover_content, accentColor,
-                    editClickListener);
+            super(context, 0, 0, R.layout.preview_card_cover_content, accentColor);
             mTitle = title;
             mHeadlineFont = headlineFont;
             mIcons = icons;
             mCornerRadius = cornerRadius;
+            mEditClickListener = editClickListener;
             mListener = wallpaperListener;
         }
 
@@ -388,8 +384,8 @@
             ViewGroup body = card.findViewById(R.id.theme_preview_card_body_container);
             inflater.inflate(contentLayoutRes, body, true);
             bindBody(false);
-            card.setOnClickListener(editClickListener);
-            card.findViewById(R.id.edit_label).setVisibility(editClickListener != null
+            card.setOnClickListener(mEditClickListener);
+            card.findViewById(R.id.edit_label).setVisibility(mEditClickListener != null
                     ? View.VISIBLE : View.INVISIBLE);
             View qsb = card.findViewById(R.id.theme_qsb);
             if (qsb != null && qsb.getVisibility() == View.VISIBLE) {
@@ -525,7 +521,7 @@
             });
             addPage(new ThemePreviewPage(activity, R.string.preview_name_font, R.drawable.ic_font,
                     R.layout.preview_card_font_content,
-                    previewInfo.resolveAccentColor(res), editClickListener) {
+                    previewInfo.resolveAccentColor(res)) {
                 @Override
                 protected void bindBody(boolean forceRebind) {
                     TextView title = card.findViewById(R.id.font_card_title);
@@ -538,7 +534,7 @@
             if (previewInfo.icons.size() >= mIconIds.length) {
                 addPage(new ThemePreviewPage(activity, R.string.preview_name_icon,
                         R.drawable.ic_wifi_24px, R.layout.preview_card_icon_content,
-                        previewInfo.resolveAccentColor(res), editClickListener) {
+                        previewInfo.resolveAccentColor(res)) {
                     @Override
                     protected void bindBody(boolean forceRebind) {
                         for (int i = 0; i < mIconIds.length && i < previewInfo.icons.size(); i++) {
@@ -551,7 +547,7 @@
             if (previewInfo.colorAccentDark != -1 && previewInfo.colorAccentLight != -1) {
                 addPage(new ThemePreviewPage(activity, R.string.preview_name_color,
                         R.drawable.ic_colorize_24px, R.layout.preview_card_color_content,
-                        previewInfo.resolveAccentColor(res), editClickListener) {
+                        previewInfo.resolveAccentColor(res)) {
                     @Override
                     protected void bindBody(boolean forceRebind) {
                         int controlGreyColor = res.getColor(R.color.control_grey);
@@ -612,7 +608,7 @@
             if (!previewInfo.shapeAppIcons.isEmpty()) {
                 addPage(new ThemePreviewPage(activity, R.string.preview_name_shape,
                         R.drawable.ic_shapes_24px, R.layout.preview_card_shape_content,
-                        previewInfo.resolveAccentColor(res), editClickListener) {
+                        previewInfo.resolveAccentColor(res)) {
                     @Override
                     protected void bindBody(boolean forceRebind) {
                         for (int i = 0; i < mShapeIconIds.length
@@ -627,7 +623,7 @@
             if (previewInfo.wallpaperAsset != null) {
                 addPage(new ThemePreviewPage(activity, R.string.preview_name_wallpaper,
                         R.drawable.ic_wallpaper_24px, R.layout.preview_card_wallpaper_content,
-                        previewInfo.resolveAccentColor(res), null) {
+                        previewInfo.resolveAccentColor(res)) {
 
                     private final WallpaperPreviewLayoutListener mListener =
                             new WallpaperPreviewLayoutListener(theme, previewInfo, false);