From fe0ace3583bc57adbaaec730b1b1757032e90c41 Mon Sep 17 00:00:00 2001 From: Michael Jurka Date: Thu, 3 Oct 2013 01:05:14 -0700 Subject: Fix RTL bugs with wallpaper parallax Bug: 10901046 Change-Id: Id4277173b0c13d25eb0507bd6fa9fa1309946510 --- .../android/launcher3/WallpaperCropActivity.java | 23 ++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'src/com/android/launcher3/WallpaperCropActivity.java') diff --git a/src/com/android/launcher3/WallpaperCropActivity.java b/src/com/android/launcher3/WallpaperCropActivity.java index 343d0ffbf..703db9a94 100644 --- a/src/com/android/launcher3/WallpaperCropActivity.java +++ b/src/com/android/launcher3/WallpaperCropActivity.java @@ -221,9 +221,11 @@ public class WallpaperCropActivity extends Activity { protected void cropImageAndSetWallpaper(Uri uri, OnBitmapCroppedHandler onBitmapCroppedHandler, final boolean finishActivityWhenDone) { - // Get the crop + // Get the crop Point inSize = mCropView.getSourceDimensions(); + boolean ltr = mCropView.getLayoutDirection() == View.LAYOUT_DIRECTION_LTR; + Point minDims = new Point(); Point maxDims = new Point(); Display d = getWindowManager().getDefaultDisplay(); @@ -234,12 +236,12 @@ public class WallpaperCropActivity extends Activity { int maxDim = Math.max(maxDims.x, maxDims.y); final int minDim = Math.min(minDims.x, minDims.y); - int defaultWidth; + int defaultWallpaperWidth; if (isScreenLarge(getResources())) { - defaultWidth = (int) (maxDim * + defaultWallpaperWidth = (int) (maxDim * wallpaperTravelToScreenWidthRatio(maxDim, minDim)); } else { - defaultWidth = Math.max((int) + defaultWallpaperWidth = Math.max((int) (minDim * WALLPAPER_SCREENS_SPAN), maxDim); } @@ -264,12 +266,17 @@ public class WallpaperCropActivity extends Activity { // ADJUST CROP WIDTH // Extend the crop all the way to the right, for parallax - float extraSpaceToRight = inSize.x - cropRect.right; + // (or all the way to the left, in RTL) + float extraSpace = ltr ? inSize.x - cropRect.right : cropRect.left; // Cap the amount of extra width - float maxExtraSpace = defaultWidth / cropScale - cropRect.width(); - extraSpaceToRight = Math.min(extraSpaceToRight, maxExtraSpace); + float maxExtraSpace = defaultWallpaperWidth / cropScale - cropRect.width(); + extraSpace = Math.min(extraSpace, maxExtraSpace); - cropRect.right += extraSpaceToRight; + if (ltr) { + cropRect.right += extraSpace; + } else { + cropRect.left -= extraSpace; + } // ADJUST CROP HEIGHT if (isPortrait) { -- cgit v1.2.3