Limit the maximum number of themes
We don't want more than 10 in total.
Also increment the space between the options to make sure
the last one is cut to hint scrolling.
Bug: 133903562
Change-Id: Ic81de761f0e80a67e69337ee68e9e73ece7d0aa4
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 0c7f502..f3f0e86 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -58,7 +58,7 @@
<dimen name="theme_option_font_text_size">16dp</dimen>
<dimen name="theme_option_title_font_text_size">12sp</dimen>
- <dimen name="option_tile_margin_horizontal">2dp</dimen>
+ <dimen name="option_tile_margin_horizontal">6dp</dimen>
<dimen name="theme_option_label_margin">4dp</dimen>
<dimen name="preview_card_padding">20dp</dimen>
diff --git a/src/com/android/customization/model/theme/DefaultThemeProvider.java b/src/com/android/customization/model/theme/DefaultThemeProvider.java
index d7c250f..87b5b4a 100644
--- a/src/com/android/customization/model/theme/DefaultThemeProvider.java
+++ b/src/com/android/customization/model/theme/DefaultThemeProvider.java
@@ -94,6 +94,9 @@
private static final String THEME_TITLE_FIELD = "_theme_title";
private static final String THEME_ID_FIELD = "_theme_id";
+ // Maximum number of themes allowed (including default, pre-bundled and custom)
+ private static final int MAX_TOTAL_THEMES = 10;
+
private final OverlayThemeExtractor mOverlayProvider;
private List<ThemeBundle> mThemes;
private final CustomizationPreferences mCustomizationPreferences;
@@ -403,9 +406,11 @@
}
}
- // Add an empty one at the end.
- mThemes.add(new CustomTheme(CustomTheme.newId(), mContext.getString(
- R.string.custom_theme_title, customThemesCount + 1), new HashMap<>(), null));
+ if (mThemes.size() < MAX_TOTAL_THEMES) {
+ // Add an empty one at the end.
+ mThemes.add(new CustomTheme(CustomTheme.newId(), mContext.getString(
+ R.string.custom_theme_title, customThemesCount + 1), new HashMap<>(), null));
+ }
}