Merge "UI bug fixes" into ub-launcher3-master
diff --git a/src/com/android/customization/model/theme/DefaultThemeProvider.java b/src/com/android/customization/model/theme/DefaultThemeProvider.java
index a48c67b..3ba8f55 100644
--- a/src/com/android/customization/model/theme/DefaultThemeProvider.java
+++ b/src/com/android/customization/model/theme/DefaultThemeProvider.java
@@ -56,6 +56,8 @@
 public class DefaultThemeProvider extends ResourcesApkProvider implements ThemeBundleProvider {
 
     private static final String TAG = "DefaultThemeProvider";
+    // TODO(b/124796742): remove once custom theme picker is ready to merge
+    private static final boolean SHOW_CUSTOM_THEME_OPTION = false;
 
     private static final String THEMES_ARRAY = "themes";
     private static final String TITLE_PREFIX = "theme_title_";
@@ -227,7 +229,10 @@
                         e);
             }
         }
-        addCustomTheme();
+
+        if (SHOW_CUSTOM_THEME_OPTION) {
+            addCustomTheme();
+        }
     }
 
     /**
diff --git a/src/com/android/customization/picker/theme/ThemeFragment.java b/src/com/android/customization/picker/theme/ThemeFragment.java
index 4487247..a93ff71 100644
--- a/src/com/android/customization/picker/theme/ThemeFragment.java
+++ b/src/com/android/customization/picker/theme/ThemeFragment.java
@@ -182,7 +182,6 @@
     private void setUpOptions(@Nullable Bundle savedInstanceState) {
         mThemeManager.fetchOptions(options -> {
             mOptionsController = new OptionSelectorController(mOptionsContainer, options);
-
             mOptionsController.addListener(selected -> {
                 if (selected instanceof CustomTheme && !((CustomTheme) selected).isDefined()) {
                     navigateToCustomTheme();
@@ -195,7 +194,6 @@
             mOptionsController.initOptions(mThemeManager);
             String previouslySelected = savedInstanceState != null
                     ? savedInstanceState.getString(KEY_SELECTED_THEME) : null;
-
             for (ThemeBundle theme : options) {
                 if (previouslySelected != null
                         && previouslySelected.equals(theme.getSerializedPackages())) {
@@ -205,6 +203,11 @@
                     break;
                 }
             }
+            if (mSelectedTheme == null) {
+                // Select the default theme if there is no matching custom enabled theme
+                // TODO(b/124796742): default to custom if there is no matching theme bundle
+                mSelectedTheme = options.get(0);
+            }
             mOptionsController.setSelectedOption(mSelectedTheme);
         });
         createAdapter();