diff options
author | Michael Jurka <mikejurka@google.com> | 2013-10-31 16:32:43 +0100 |
---|---|---|
committer | Danesh M <daneshm90@gmail.com> | 2014-06-05 23:29:09 -0700 |
commit | 6a2146f8835bb455d9799742150cb36785be2a96 (patch) | |
tree | cab3b7d3f382c4b56551f771125d237ef35795fd | |
parent | 2d1b3ea4af56cb81639a9fa76643fe77b1ef3c54 (diff) | |
download | android_packages_apps_Trebuchet-6a2146f8835bb455d9799742150cb36785be2a96.tar.gz android_packages_apps_Trebuchet-6a2146f8835bb455d9799742150cb36785be2a96.tar.bz2 android_packages_apps_Trebuchet-6a2146f8835bb455d9799742150cb36785be2a96.zip |
Fix issues with sizing wallpapers
- properly sync size across Launcher and wallpaper
picker
- remove code that was calculating wrong default
wallpaper size
Bug: 11324470
Change-Id: Ib4e7202363c56e3cb0c09d4448a7f96eef0a0915
-rw-r--r-- | src/com/android/launcher3/WallpaperCropActivity.java | 41 | ||||
-rw-r--r-- | src/com/android/launcher3/Workspace.java | 2 |
2 files changed, 9 insertions, 34 deletions
diff --git a/src/com/android/launcher3/WallpaperCropActivity.java b/src/com/android/launcher3/WallpaperCropActivity.java index f9aec2b08..276aba306 100644 --- a/src/com/android/launcher3/WallpaperCropActivity.java +++ b/src/com/android/launcher3/WallpaperCropActivity.java @@ -329,40 +329,15 @@ public class WallpaperCropActivity extends Activity { // Get the crop boolean ltr = mCropView.getLayoutDirection() == View.LAYOUT_DIRECTION_LTR; - Point minDims = new Point(); - Point maxDims = new Point(); + Display d = getWindowManager().getDefaultDisplay(); - d.getCurrentSizeRange(minDims, maxDims); Point displaySize = new Point(); d.getSize(displaySize); - - int maxDim = Math.max(maxDims.x, maxDims.y); - final int minDim = Math.min(minDims.x, minDims.y); - int defaultWallpaperWidth; - if (isScreenLarge(getResources())) { - defaultWallpaperWidth = (int) (maxDim * - wallpaperTravelToScreenWidthRatio(maxDim, minDim)); - } else { - defaultWallpaperWidth = Math.max((int) - (minDim * WALLPAPER_SCREENS_SPAN), maxDim); - } - boolean isPortrait = displaySize.x < displaySize.y; - int portraitHeight; - if (isPortrait) { - portraitHeight = mCropView.getHeight(); - } else { - // TODO: how to actually get the proper portrait height? - // This is not quite right: - portraitHeight = Math.max(maxDims.x, maxDims.y); - } - if (android.os.Build.VERSION.SDK_INT >= - android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) { - Point realSize = new Point(); - d.getRealSize(realSize); - portraitHeight = Math.max(realSize.x, realSize.y); - } + + Point defaultWallpaperSize = getDefaultWallpaperSize(getResources(), + getWindowManager()); // Get the crop RectF cropRect = mCropView.getCrop(); int cropRotation = mCropView.getImageRotation(); @@ -381,7 +356,7 @@ public class WallpaperCropActivity extends Activity { // (or all the way to the left, in RTL) float extraSpace = ltr ? rotatedInSize[0] - cropRect.right : cropRect.left; // Cap the amount of extra width - float maxExtraSpace = defaultWallpaperWidth / cropScale - cropRect.width(); + float maxExtraSpace = defaultWallpaperSize.x / cropScale - cropRect.width(); extraSpace = Math.min(extraSpace, maxExtraSpace); if (ltr) { @@ -392,10 +367,10 @@ public class WallpaperCropActivity extends Activity { // ADJUST CROP HEIGHT if (isPortrait) { - cropRect.bottom = cropRect.top + portraitHeight / cropScale; + cropRect.bottom = cropRect.top + defaultWallpaperSize.y / cropScale; } else { // LANDSCAPE float extraPortraitHeight = - portraitHeight / cropScale - cropRect.height(); + defaultWallpaperSize.y / cropScale - cropRect.height(); float expandHeight = Math.min(Math.min(rotatedInSize[1] - cropRect.bottom, cropRect.top), extraPortraitHeight / 2); @@ -763,7 +738,7 @@ public class WallpaperCropActivity extends Activity { protected void updateWallpaperDimensions(int width, int height) { String spKey = getSharedPreferencesKey(); - SharedPreferences sp = getSharedPreferences(spKey, Context.MODE_PRIVATE); + SharedPreferences sp = getSharedPreferences(spKey, Context.MODE_MULTI_PROCESS); SharedPreferences.Editor editor = sp.edit(); if (width != 0 && height != 0) { editor.putInt(WALLPAPER_WIDTH_KEY, width); diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index db1ae6487..82037f427 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -1259,7 +1259,7 @@ public class Workspace extends SmoothPagedView protected void setWallpaperDimension() { String spKey = WallpaperCropActivity.getSharedPreferencesKey(); - SharedPreferences sp = mLauncher.getSharedPreferences(spKey, Context.MODE_PRIVATE); + SharedPreferences sp = mLauncher.getSharedPreferences(spKey, Context.MODE_MULTI_PROCESS); WallpaperPickerActivity.suggestWallpaperDimension(mLauncher.getResources(), sp, mLauncher.getWindowManager(), mWallpaperManager); } |