diff options
author | Michael Jurka <mikejurka@google.com> | 2014-01-14 14:48:20 +0100 |
---|---|---|
committer | Michael Jurka <mikejurka@google.com> | 2014-01-14 15:11:37 +0100 |
commit | 2ab14daebac46307d2364733481edc3115bbf98c (patch) | |
tree | d1ed214c60b43d25f621cc7f5e878caa749a36e9 /packages | |
parent | 35f922d1d038d14f94b584baae324513610f7813 (diff) | |
download | frameworks_base-2ab14daebac46307d2364733481edc3115bbf98c.zip frameworks_base-2ab14daebac46307d2364733481edc3115bbf98c.tar.gz frameworks_base-2ab14daebac46307d2364733481edc3115bbf98c.tar.bz2 |
Centering the crop by default in system wallpaper cropper
Bug: 12034934
Change-Id: Ice1b1140bd6e351dd4e520f555f245d84a645aac
Diffstat (limited to 'packages')
-rw-r--r-- | packages/WallpaperCropper/res/values/config.xml | 3 | ||||
-rw-r--r-- | packages/WallpaperCropper/src/com/android/wallpapercropper/WallpaperCropActivity.java | 20 |
2 files changed, 18 insertions, 5 deletions
diff --git a/packages/WallpaperCropper/res/values/config.xml b/packages/WallpaperCropper/res/values/config.xml index 1b24190..2e2fa6f 100644 --- a/packages/WallpaperCropper/res/values/config.xml +++ b/packages/WallpaperCropper/res/values/config.xml @@ -15,4 +15,7 @@ --> <resources> <bool name="allow_rotation">false</bool> + <!-- Specifies whether to expand the cropped area on both sides (rather + than just to one side) --> + <bool name="center_crop">true</bool> </resources> diff --git a/packages/WallpaperCropper/src/com/android/wallpapercropper/WallpaperCropActivity.java b/packages/WallpaperCropper/src/com/android/wallpapercropper/WallpaperCropActivity.java index e0c59ab..cbf0c52 100644 --- a/packages/WallpaperCropper/src/com/android/wallpapercropper/WallpaperCropActivity.java +++ b/packages/WallpaperCropper/src/com/android/wallpapercropper/WallpaperCropActivity.java @@ -330,10 +330,10 @@ public class WallpaperCropActivity extends Activity { protected void cropImageAndSetWallpaper(Uri uri, OnBitmapCroppedHandler onBitmapCroppedHandler, final boolean finishActivityWhenDone) { + boolean centerCrop = getResources().getBoolean(R.bool.center_crop); // Get the crop boolean ltr = mCropView.getLayoutDirection() == View.LAYOUT_DIRECTION_LTR; - Display d = getWindowManager().getDefaultDisplay(); Point displaySize = new Point(); @@ -358,15 +358,25 @@ public class WallpaperCropActivity extends Activity { // ADJUST CROP WIDTH // Extend the crop all the way to the right, for parallax // (or all the way to the left, in RTL) - float extraSpace = ltr ? rotatedInSize[0] - cropRect.right : cropRect.left; + float extraSpace; + if (centerCrop) { + extraSpace = 2f * Math.min(rotatedInSize[0] - cropRect.right, cropRect.left); + } else { + extraSpace = ltr ? rotatedInSize[0] - cropRect.right : cropRect.left; + } // Cap the amount of extra width float maxExtraSpace = defaultWallpaperSize.x / cropScale - cropRect.width(); extraSpace = Math.min(extraSpace, maxExtraSpace); - if (ltr) { - cropRect.right += extraSpace; + if (centerCrop) { + cropRect.left -= extraSpace / 2f; + cropRect.right += extraSpace / 2f; } else { - cropRect.left -= extraSpace; + if (ltr) { + cropRect.right += extraSpace; + } else { + cropRect.left -= extraSpace; + } } // ADJUST CROP HEIGHT |