diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2014-08-19 19:49:31 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-08-16 04:03:42 +0000 |
commit | f8177d383a86bf0e5230f70c1635fa044ed4b0be (patch) | |
tree | 63524a0cc9a7d126e98d8d4c5e8470e725cbc23f | |
parent | 178879c72dad2b0dd85e77267281dee26907bfff (diff) | |
parent | 0af0d8422b1496dc3c60245264949debfa862057 (diff) | |
download | android_packages_apps_Trebuchet-f8177d383a86bf0e5230f70c1635fa044ed4b0be.tar.gz android_packages_apps_Trebuchet-f8177d383a86bf0e5230f70c1635fa044ed4b0be.tar.bz2 android_packages_apps_Trebuchet-f8177d383a86bf0e5230f70c1635fa044ed4b0be.zip |
Merge "Saving the system wallpaper thumbnail prefixed by the SDK_INT so that it is recreated after a system update." into ub-now-porkchop
-rw-r--r-- | WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java b/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java index 95b19ce74..cb132915e 100644 --- a/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java +++ b/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java @@ -997,11 +997,27 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { return false; } + private File getDefaultThumbFile() { + return new File(getFilesDir(), Build.VERSION.SDK_INT + + "_" + DEFAULT_WALLPAPER_THUMBNAIL_FILENAME); + } + + private boolean saveDefaultWallpaperThumb(Bitmap b) { + // Delete old thumbnails. + new File(getFilesDir(), OLD_DEFAULT_WALLPAPER_THUMBNAIL_FILENAME).delete(); + new File(getFilesDir(), DEFAULT_WALLPAPER_THUMBNAIL_FILENAME).delete(); + + for (int i = Build.VERSION_CODES.JELLY_BEAN; i < Build.VERSION.SDK_INT; i++) { + new File(getFilesDir(), i + "_" + DEFAULT_WALLPAPER_THUMBNAIL_FILENAME).delete(); + } + return writeImageToFileAsJpeg(getDefaultThumbFile(), b); + } + private ResourceWallpaperInfo getPreKKDefaultWallpaperInfo() { Resources sysRes = Resources.getSystem(); int resId = sysRes.getIdentifier("default_wallpaper", "drawable", "android"); - File defaultThumbFile = new File(getFilesDir(), DEFAULT_WALLPAPER_THUMBNAIL_FILENAME); + File defaultThumbFile = getDefaultThumbFile(); Bitmap thumb = null; boolean defaultWallpaperExists = false; if (defaultThumbFile.exists()) { @@ -1014,7 +1030,7 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { thumb = createThumbnail( defaultThumbSize, this, null, null, sysRes, resId, rotation, false); if (thumb != null) { - defaultWallpaperExists = writeImageToFileAsJpeg(defaultThumbFile, thumb); + defaultWallpaperExists = saveDefaultWallpaperThumb(thumb); } } if (defaultWallpaperExists) { @@ -1025,17 +1041,13 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { @TargetApi(Build.VERSION_CODES.KITKAT) private DefaultWallpaperInfo getDefaultWallpaper() { - File defaultThumbFile = new File(getFilesDir(), DEFAULT_WALLPAPER_THUMBNAIL_FILENAME); + File defaultThumbFile = getDefaultThumbFile(); Bitmap thumb = null; boolean defaultWallpaperExists = false; if (defaultThumbFile.exists()) { thumb = BitmapFactory.decodeFile(defaultThumbFile.getAbsolutePath()); defaultWallpaperExists = true; } else { - // Delete old thumbnail file, since we had a bug where the thumbnail wasn't being drawn - // before - new File(getFilesDir(), OLD_DEFAULT_WALLPAPER_THUMBNAIL_FILENAME).delete(); - Resources res = getResources(); Point defaultThumbSize = getDefaultThumbnailSize(res); Drawable wallpaperDrawable = WallpaperManager.getInstance(this).getBuiltInDrawable( @@ -1049,7 +1061,7 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { c.setBitmap(null); } if (thumb != null) { - defaultWallpaperExists = writeImageToFileAsJpeg(defaultThumbFile, thumb); + defaultWallpaperExists = saveDefaultWallpaperThumb(thumb); } } if (defaultWallpaperExists) { |