summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Jurka <mikejurka@google.com>2014-01-14 13:50:53 +0100
committerMichael Jurka <mikejurka@google.com>2014-01-14 13:50:53 +0100
commit4808aa6b42ff31aa792b6dc0601bd6f24a554e21 (patch)
treedb3434fc54ae562bf781034bda0e2d5d893d4a2a
parentfe45a82ed90bd9e8d949c210d905fcf38e64aaf2 (diff)
downloadandroid_packages_apps_Trebuchet-4808aa6b42ff31aa792b6dc0601bd6f24a554e21.zip
android_packages_apps_Trebuchet-4808aa6b42ff31aa792b6dc0601bd6f24a554e21.tar.gz
android_packages_apps_Trebuchet-4808aa6b42ff31aa792b6dc0601bd6f24a554e21.tar.bz2
Add ability to center the crop (disabled)
-rw-r--r--WallpaperPicker/res/values/config.xml3
-rw-r--r--WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java20
2 files changed, 18 insertions, 5 deletions
diff --git a/WallpaperPicker/res/values/config.xml b/WallpaperPicker/res/values/config.xml
index 1b24190..71580b5 100644
--- a/WallpaperPicker/res/values/config.xml
+++ b/WallpaperPicker/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">false</bool>
</resources>
diff --git a/WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java b/WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java
index b3ef073..ee7b819 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