diff options
author | Michael Jurka <mikejurka@google.com> | 2014-01-14 13:50:53 +0100 |
---|---|---|
committer | Danesh M <daneshm90@gmail.com> | 2014-06-06 22:54:25 -0700 |
commit | bc4ea1cde2aa98cedb33bbbb4d697906049d72a9 (patch) | |
tree | c8fb60ff6c87c71f0c9aa197a9b8e19916f9ffb7 /WallpaperPicker/src/com | |
parent | a0770b9e3a307eec1d2c81747e807a3716f74b87 (diff) | |
download | android_packages_apps_Trebuchet-bc4ea1cde2aa98cedb33bbbb4d697906049d72a9.tar.gz android_packages_apps_Trebuchet-bc4ea1cde2aa98cedb33bbbb4d697906049d72a9.tar.bz2 android_packages_apps_Trebuchet-bc4ea1cde2aa98cedb33bbbb4d697906049d72a9.zip |
Add ability to center the crop (disabled)
Diffstat (limited to 'WallpaperPicker/src/com')
-rw-r--r-- | WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java b/WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java index b3ef07309..ee7b81951 100644 --- a/WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java +++ b/WallpaperPicker/src/com/android/launcher3/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 |