am cc8fbb59: am 8acbe888: Merge "[DO NOT MERGE] Centering the crop by default in system wallpaper cropper" into klp-dev
* commit 'cc8fbb5999687e9413a9b0a8576c21116fc558db': [DO NOT MERGE] Centering the crop by default in system wallpaper cropper
This commit is contained in:
@@ -15,4 +15,7 @@
|
|||||||
-->
|
-->
|
||||||
<resources>
|
<resources>
|
||||||
<bool name="allow_rotation">false</bool>
|
<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>
|
</resources>
|
||||||
|
|||||||
@@ -326,10 +326,10 @@ public class WallpaperCropActivity extends Activity {
|
|||||||
|
|
||||||
protected void cropImageAndSetWallpaper(Uri uri,
|
protected void cropImageAndSetWallpaper(Uri uri,
|
||||||
OnBitmapCroppedHandler onBitmapCroppedHandler, final boolean finishActivityWhenDone) {
|
OnBitmapCroppedHandler onBitmapCroppedHandler, final boolean finishActivityWhenDone) {
|
||||||
|
boolean centerCrop = getResources().getBoolean(R.bool.center_crop);
|
||||||
// Get the crop
|
// Get the crop
|
||||||
boolean ltr = mCropView.getLayoutDirection() == View.LAYOUT_DIRECTION_LTR;
|
boolean ltr = mCropView.getLayoutDirection() == View.LAYOUT_DIRECTION_LTR;
|
||||||
|
|
||||||
|
|
||||||
Display d = getWindowManager().getDefaultDisplay();
|
Display d = getWindowManager().getDefaultDisplay();
|
||||||
|
|
||||||
Point displaySize = new Point();
|
Point displaySize = new Point();
|
||||||
@@ -361,15 +361,25 @@ public class WallpaperCropActivity extends Activity {
|
|||||||
// ADJUST CROP WIDTH
|
// ADJUST CROP WIDTH
|
||||||
// Extend the crop all the way to the right, for parallax
|
// Extend the crop all the way to the right, for parallax
|
||||||
// (or all the way to the left, in RTL)
|
// (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
|
// Cap the amount of extra width
|
||||||
float maxExtraSpace = defaultWallpaperSize.x / cropScale - cropRect.width();
|
float maxExtraSpace = defaultWallpaperSize.x / cropScale - cropRect.width();
|
||||||
extraSpace = Math.min(extraSpace, maxExtraSpace);
|
extraSpace = Math.min(extraSpace, maxExtraSpace);
|
||||||
|
|
||||||
if (ltr) {
|
if (centerCrop) {
|
||||||
cropRect.right += extraSpace;
|
cropRect.left -= extraSpace / 2f;
|
||||||
|
cropRect.right += extraSpace / 2f;
|
||||||
} else {
|
} else {
|
||||||
cropRect.left -= extraSpace;
|
if (ltr) {
|
||||||
|
cropRect.right += extraSpace;
|
||||||
|
} else {
|
||||||
|
cropRect.left -= extraSpace;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ADJUST CROP HEIGHT
|
// ADJUST CROP HEIGHT
|
||||||
|
|||||||
Reference in New Issue
Block a user