diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2014-08-13 12:12:48 -0700 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2014-08-13 12:16:59 -0700 |
commit | 0af0d8422b1496dc3c60245264949debfa862057 (patch) | |
tree | ceda5b6c1565adb07b0a38da79a6fd9d3895164e /WallpaperPicker/src/com/android/launcher3 | |
parent | 0fe505bf82a265e51c556d7204976651cde7f55c (diff) | |
download | android_packages_apps_Trebuchet-0af0d8422b1496dc3c60245264949debfa862057.tar.gz android_packages_apps_Trebuchet-0af0d8422b1496dc3c60245264949debfa862057.tar.bz2 android_packages_apps_Trebuchet-0af0d8422b1496dc3c60245264949debfa862057.zip |
Saving the system wallpaper thumbnail prefixed by the SDK_INT
so that it is recreated after a system update.
issue: 15670065
Change-Id: I237ef1d99676d5a0ac6ff7b4a80a7a72905ef1ed
Diffstat (limited to 'WallpaperPicker/src/com/android/launcher3')
-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) { |