Fix can't find default theme bundle for some specific languages.
It's because the translation of R.string.default_theme_title in some language is different with the title of the default theme bundle.
Change the logic of finding default theme bundle to get rid of string comparison.
Bug: 176087825
Change-Id: I471a711ad51515c8b4586b4e8a9b1e8e88b5b7d4
(cherry picked from commit 6c1e6fec5656918707623bed1e5787c4a946ba35)
diff --git a/src/com/android/customization/picker/theme/ThemeFragment.java b/src/com/android/customization/picker/theme/ThemeFragment.java
index de8aa69..7b58274 100644
--- a/src/com/android/customization/picker/theme/ThemeFragment.java
+++ b/src/com/android/customization/picker/theme/ThemeFragment.java
@@ -287,9 +287,10 @@
mSelectedTheme = previouslySelectedTheme != null
? previouslySelectedTheme
: activeTheme;
- // 3. Select the default theme if there is no matching custom enabled theme.
+ // 3. Select the first system theme(default theme currently)
+ // if there is no matching custom enabled theme.
if (mSelectedTheme == null) {
- mSelectedTheme = findDefaultThemeBundle(options);
+ mSelectedTheme = findFirstSystemThemeBundle(options);
}
mOptionsController.setSelectedOption(mSelectedTheme);
@@ -324,8 +325,7 @@
}
}
if (mSelectedTheme == null) {
- // Select the default theme if there is no matching custom enabled theme
- mSelectedTheme = findDefaultThemeBundle(options);
+ mSelectedTheme = findFirstSystemThemeBundle(options);
}
mOptionsController.setSelectedOption(mSelectedTheme);
// Set selected option above will show BottomActionBar,
@@ -334,11 +334,9 @@
}, true);
}
- private ThemeBundle findDefaultThemeBundle(List<ThemeBundle> options) {
- String defaultThemeTitle =
- getActivity().getResources().getString(R.string.default_theme_title);
+ private ThemeBundle findFirstSystemThemeBundle(List<ThemeBundle> options) {
for (ThemeBundle bundle : options) {
- if (bundle.getTitle().equals(defaultThemeTitle)) {
+ if (!(bundle instanceof CustomTheme)) {
return bundle;
}
}