summaryrefslogtreecommitdiffstats
path: root/packages/WallpaperCropper/src/com/android
diff options
context:
space:
mode:
authorMichael Jurka <mikejurka@google.com>2014-01-14 14:48:20 +0100
committerMichael Jurka <mikejurka@google.com>2014-01-14 15:11:37 +0100
commit2ab14daebac46307d2364733481edc3115bbf98c (patch)
treed1ed214c60b43d25f621cc7f5e878caa749a36e9 /packages/WallpaperCropper/src/com/android
parent35f922d1d038d14f94b584baae324513610f7813 (diff)
downloadframeworks_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/WallpaperCropper/src/com/android')
-rw-r--r--packages/WallpaperCropper/src/com/android/wallpapercropper/WallpaperCropActivity.java20
1 files changed, 15 insertions, 5 deletions
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