Merge changes I7b04b164,I7d5ef1ef into ub-launcher3-master
* changes:
Fix Grid tab's option list vanish issue
Change Style tab's content layout
diff --git a/res/layout/fragment_grid_picker.xml b/res/layout/fragment_grid_picker.xml
index 5238137..af70e0c 100644
--- a/res/layout/fragment_grid_picker.xml
+++ b/res/layout/fragment_grid_picker.xml
@@ -56,7 +56,7 @@
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/options_container"
android:layout_width="match_parent"
- android:layout_height="@dimen/options_container_height"
+ android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"/>
</LinearLayout>
diff --git a/res/values/bools.xml b/res/values/bools.xml
index 078b50c..409538d 100644
--- a/res/values/bools.xml
+++ b/res/values/bools.xml
@@ -16,5 +16,5 @@
limitations under the License.
-->
<resources>
- <bool name="use_grid_for_options">false</bool>
+ <bool name="use_grid_for_options">true</bool>
</resources>
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index c0aef7a..3454653 100755
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -119,6 +119,9 @@
[CHAR LIMIT=20] -->
<string name="custom_theme_previous">Previous</string>
+ <!-- Title for "Custom theme" option. [CHAR LIMIT=15] -->
+ <string name="custom_theme">Custom</string>
+
<!-- Generic label for one system Style/Theme (combination of fonts/colors/icons) that is
defined and customized by the user (note there could be more than one so the label includes
a number, eg "Custom 1, Custom 2, etc") [CHAR LIMIT=15] -->
diff --git a/src/com/android/customization/model/theme/DefaultThemeProvider.java b/src/com/android/customization/model/theme/DefaultThemeProvider.java
index 7c99f9c..1528c0d 100644
--- a/src/com/android/customization/model/theme/DefaultThemeProvider.java
+++ b/src/com/android/customization/model/theme/DefaultThemeProvider.java
@@ -78,9 +78,6 @@
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;
@@ -109,6 +106,10 @@
}
private void loadAll() {
+ // Add "Custom" option at the first.
+ mThemes.add(new CustomTheme(CustomTheme.newId(), mContext.getString(
+ R.string.custom_theme), new HashMap<>(), null));
+
addDefaultTheme();
String[] themeNames = getItemsFromStub(THEMES_ARRAY);
@@ -321,13 +322,6 @@
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));
- }
-
}
@Override
diff --git a/src/com/android/customization/picker/theme/ThemeFragment.java b/src/com/android/customization/picker/theme/ThemeFragment.java
index d73214c..d8f3a6e 100644
--- a/src/com/android/customization/picker/theme/ThemeFragment.java
+++ b/src/com/android/customization/picker/theme/ThemeFragment.java
@@ -322,8 +322,7 @@
}
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);
+ mSelectedTheme = findDefaultThemeBundle(options);
} else {
// Only show show checkmark if we found a matching theme
mOptionsController.setAppliedOption(mSelectedTheme);
@@ -354,8 +353,7 @@
}
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);
+ mSelectedTheme = findDefaultThemeBundle(options);
} else {
// Only show show checkmark if we found a matching theme
mOptionsController.setAppliedOption(mSelectedTheme);
@@ -364,6 +362,17 @@
}, true);
}
+ private ThemeBundle findDefaultThemeBundle(List<ThemeBundle> options) {
+ String defaultThemeTitle =
+ getActivity().getResources().getString(R.string.default_theme_title);
+ for (ThemeBundle bundle : options) {
+ if (bundle.getTitle().equals(defaultThemeTitle)) {
+ return bundle;
+ }
+ }
+ return null;
+ }
+
private void navigateToCustomTheme(CustomTheme themeToEdit) {
Intent intent = new Intent(getActivity(), CustomThemeActivity.class);
intent.putExtra(CustomThemeActivity.EXTRA_THEME_TITLE, themeToEdit.getTitle());