Wallpaper preview parallax matches the actual wallpaper's.

Cherry picking the following changes from ub-launcher3-master:
Change-Id: I41c5bbbfdabfeb4e20d77e9b5804842a03211edf
Change-Id: I69afa3f8cc59c77e9c4c25e29e8db8c4beb87462
Change-Id: I82b7ba506d51ee4b3812af5fbdf95d3303b37aef
Change-Id: Id7c2b5483c5535d59be2f8a459ce7788e3c8318a

Bug: 23568800
Change-Id: I343169b9fdc5ceaab3d4b39044627d78b7267868
This commit is contained in:
Tony Wickham
2015-09-09 18:21:49 -07:00
parent 01251b0dc4
commit 3e776a87dc
8 changed files with 141 additions and 56 deletions
@@ -45,6 +45,10 @@ public class BitmapCropTask extends AsyncTask<Void, Void, Boolean> {
public void onBitmapCropped(byte[] imageBytes);
}
public interface OnEndCropHandler {
public void run(boolean cropSucceeded);
}
private static final int DEFAULT_COMPRESS_QUALITY = 90;
private static final String LOGTAG = "BitmapCropTask";
@@ -59,56 +63,56 @@ public class BitmapCropTask extends AsyncTask<Void, Void, Boolean> {
boolean mSetWallpaper;
boolean mSaveCroppedBitmap;
Bitmap mCroppedBitmap;
Runnable mOnEndRunnable;
BitmapCropTask.OnEndCropHandler mOnEndCropHandler;
Resources mResources;
BitmapCropTask.OnBitmapCroppedHandler mOnBitmapCroppedHandler;
boolean mNoCrop;
public BitmapCropTask(Context c, String filePath,
RectF cropBounds, int rotation, int outWidth, int outHeight,
boolean setWallpaper, boolean saveCroppedBitmap, Runnable onEndRunnable) {
boolean setWallpaper, boolean saveCroppedBitmap, OnEndCropHandler onEndCropHandler) {
mContext = c;
mInFilePath = filePath;
init(cropBounds, rotation,
outWidth, outHeight, setWallpaper, saveCroppedBitmap, onEndRunnable);
outWidth, outHeight, setWallpaper, saveCroppedBitmap, onEndCropHandler);
}
public BitmapCropTask(byte[] imageBytes,
RectF cropBounds, int rotation, int outWidth, int outHeight,
boolean setWallpaper, boolean saveCroppedBitmap, Runnable onEndRunnable) {
boolean setWallpaper, boolean saveCroppedBitmap, OnEndCropHandler onEndCropHandler) {
mInImageBytes = imageBytes;
init(cropBounds, rotation,
outWidth, outHeight, setWallpaper, saveCroppedBitmap, onEndRunnable);
outWidth, outHeight, setWallpaper, saveCroppedBitmap, onEndCropHandler);
}
public BitmapCropTask(Context c, Uri inUri,
RectF cropBounds, int rotation, int outWidth, int outHeight,
boolean setWallpaper, boolean saveCroppedBitmap, Runnable onEndRunnable) {
boolean setWallpaper, boolean saveCroppedBitmap, OnEndCropHandler onEndCropHandler) {
mContext = c;
mInUri = inUri;
init(cropBounds, rotation,
outWidth, outHeight, setWallpaper, saveCroppedBitmap, onEndRunnable);
outWidth, outHeight, setWallpaper, saveCroppedBitmap, onEndCropHandler);
}
public BitmapCropTask(Context c, Resources res, int inResId,
RectF cropBounds, int rotation, int outWidth, int outHeight,
boolean setWallpaper, boolean saveCroppedBitmap, Runnable onEndRunnable) {
boolean setWallpaper, boolean saveCroppedBitmap, OnEndCropHandler onEndCropHandler) {
mContext = c;
mInResId = inResId;
mResources = res;
init(cropBounds, rotation,
outWidth, outHeight, setWallpaper, saveCroppedBitmap, onEndRunnable);
outWidth, outHeight, setWallpaper, saveCroppedBitmap, onEndCropHandler);
}
private void init(RectF cropBounds, int rotation, int outWidth, int outHeight,
boolean setWallpaper, boolean saveCroppedBitmap, Runnable onEndRunnable) {
boolean setWallpaper, boolean saveCroppedBitmap, OnEndCropHandler onEndCropHandler) {
mCropBounds = cropBounds;
mRotation = rotation;
mOutWidth = outWidth;
mOutHeight = outHeight;
mSetWallpaper = setWallpaper;
mSaveCroppedBitmap = saveCroppedBitmap;
mOnEndRunnable = onEndRunnable;
mOnEndCropHandler = onEndCropHandler;
}
public void setOnBitmapCropped(BitmapCropTask.OnBitmapCroppedHandler handler) {
@@ -119,8 +123,8 @@ public class BitmapCropTask extends AsyncTask<Void, Void, Boolean> {
mNoCrop = value;
}
public void setOnEndRunnable(Runnable onEndRunnable) {
mOnEndRunnable = onEndRunnable;
public void setOnEndRunnable(OnEndCropHandler onEndCropHandler) {
mOnEndCropHandler = onEndCropHandler;
}
// Helper to setup input stream
@@ -398,8 +402,8 @@ public class BitmapCropTask extends AsyncTask<Void, Void, Boolean> {
@Override
protected void onPostExecute(Boolean result) {
if (mOnEndRunnable != null) {
mOnEndRunnable.run();
if (mOnEndCropHandler != null) {
mOnEndCropHandler.run(result);
}
}
}