[LSC] Add LOCAL_LICENSE_KINDS to packages/apps/ThemePicker am: fddada2377 am: 5886614427
Original change: https://android-review.googlesource.com/c/platform/packages/apps/ThemePicker/+/1587896
MUST ONLY BE SUBMITTED BY AUTOMERGER
Change-Id: Id9e4da14175030cb4363197b9b5139d667ab8724
diff --git a/src/com/android/customization/picker/WallpaperPreviewer.java b/src/com/android/customization/picker/WallpaperPreviewer.java
index 21ec51d..50010c5 100644
--- a/src/com/android/customization/picker/WallpaperPreviewer.java
+++ b/src/com/android/customization/picker/WallpaperPreviewer.java
@@ -148,34 +148,36 @@
private void setUpWallpaperPreview() {
ImageView homeImageWallpaper = mWallpaperSurfaceCallback.getHomeImageWallpaper();
if (mWallpaper != null && homeImageWallpaper != null) {
- boolean renderInImageWallpaperSurface = !(mWallpaper instanceof LiveWallpaperInfo);
- mWallpaper.getThumbAsset(mActivity.getApplicationContext())
- .loadPreviewImage(mActivity,
- renderInImageWallpaperSurface ? homeImageWallpaper : mHomePreview,
- mActivity.getResources().getColor(R.color.secondary_color));
- LiveTileOverlay.INSTANCE.detach(mHomePreview.getOverlay());
- if (mWallpaper instanceof LiveWallpaperInfo) {
+ homeImageWallpaper.post(() -> {
+ boolean renderInImageWallpaperSurface = !(mWallpaper instanceof LiveWallpaperInfo);
mWallpaper.getThumbAsset(mActivity.getApplicationContext())
- .loadPreviewImage(
- mActivity,
- homeImageWallpaper,
- mActivity.getColor(R.color.secondary_color));
- setUpLiveWallpaperPreview(mWallpaper);
- } else {
- // Ensure live wallpaper connection is disconnected.
- if (mWallpaperConnection != null) {
- mWallpaperConnection.disconnect();
- mWallpaperConnection = null;
- }
+ .loadPreviewImage(mActivity,
+ renderInImageWallpaperSurface ? homeImageWallpaper : mHomePreview,
+ mActivity.getResources().getColor(R.color.secondary_color));
+ LiveTileOverlay.INSTANCE.detach(mHomePreview.getOverlay());
+ if (mWallpaper instanceof LiveWallpaperInfo) {
+ mWallpaper.getThumbAsset(mActivity.getApplicationContext())
+ .loadPreviewImage(
+ mActivity,
+ homeImageWallpaper,
+ mActivity.getColor(R.color.secondary_color));
+ setUpLiveWallpaperPreview(mWallpaper);
+ } else {
+ // Ensure live wallpaper connection is disconnected.
+ if (mWallpaperConnection != null) {
+ mWallpaperConnection.disconnect();
+ mWallpaperConnection = null;
+ }
- // Load wallpaper color for static wallpaper.
- if (mWallpaperColorsListener != null) {
- WallpaperColorsLoader.getWallpaperColors(
- mActivity,
- mWallpaper.getThumbAsset(mActivity),
- mWallpaperColorsListener::onWallpaperColorsChanged);
+ // Load wallpaper color for static wallpaper.
+ if (mWallpaperColorsListener != null) {
+ WallpaperColorsLoader.getWallpaperColors(
+ mActivity,
+ mWallpaper.getThumbAsset(mActivity),
+ mWallpaperColorsListener::onWallpaperColorsChanged);
+ }
}
- }
+ });
}
}
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;
}
}