From 4d8145d572803b288c2f2f0bd425575ced7bbcce Mon Sep 17 00:00:00 2001 From: Richard MacGregor Date: Wed, 26 Aug 2015 17:28:23 -0700 Subject: Fix wallpaperpreview for default wallpaper Preview isn't scaled and cropped correctly when previewing wallpaper. Change-Id: Idfb42c321f8872e6ca49a2b59e16ea01067856be Ticket: QRDL-1019 (cherry picked from commit 5bae6967aedafe578f87f3233016601d08e76814) --- .../src/com/android/launcher3/WallpaperPickerActivity.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java b/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java index 27f1a53aa..2b253fd75 100755 --- a/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java +++ b/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java @@ -286,7 +286,7 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { CropView c = a.getCropView(); Drawable defaultWallpaper = WallpaperManager.getInstance(a).getBuiltInDrawable( - c.getWidth(), c.getHeight(), false, 0.5f, 0.5f); + 0, 0, false, 0.5f, 0.5f); if (defaultWallpaper == null) { Log.w(TAG, "Null default wallpaper encountered."); @@ -294,9 +294,14 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { return; } - c.setTileSource( - new DrawableTileSource(a, defaultWallpaper, DrawableTileSource.MAX_PREVIEW_SIZE), null); - c.setScale(1f); + c.setTileSource(new DrawableTileSource( + a, defaultWallpaper, DrawableTileSource.MAX_PREVIEW_SIZE), null); + Point wallpaperSize = WallpaperCropActivity.getDefaultWallpaperSize( + a.getResources(), a.getWindowManager()); + RectF crop = WallpaperCropActivity.getMaxCropRect( + defaultWallpaper.getIntrinsicWidth(), defaultWallpaper.getIntrinsicHeight(), + wallpaperSize.x, wallpaperSize.y, false); + c.setScale(wallpaperSize.x / crop.width()); c.setTouchEnabled(false); a.setSystemWallpaperVisiblity(false); } -- cgit v1.2.3