Merge "Fixing issue with screenshot icon being stretched." into mnc-dev
This commit is contained in:
@@ -137,21 +137,31 @@ class SaveImageInBackgroundTask extends AsyncTask<SaveImageInBackgroundData, Voi
|
|||||||
int previewWidth = data.previewWidth;
|
int previewWidth = data.previewWidth;
|
||||||
int previewHeight = data.previewheight;
|
int previewHeight = data.previewheight;
|
||||||
|
|
||||||
final int shortSide = mImageWidth < mImageHeight ? mImageWidth : mImageHeight;
|
Canvas c = new Canvas();
|
||||||
Bitmap preview = Bitmap.createBitmap(previewWidth, previewHeight, data.image.getConfig());
|
|
||||||
Canvas c = new Canvas(preview);
|
|
||||||
Paint paint = new Paint();
|
Paint paint = new Paint();
|
||||||
ColorMatrix desat = new ColorMatrix();
|
ColorMatrix desat = new ColorMatrix();
|
||||||
desat.setSaturation(0.25f);
|
desat.setSaturation(0.25f);
|
||||||
paint.setColorFilter(new ColorMatrixColorFilter(desat));
|
paint.setColorFilter(new ColorMatrixColorFilter(desat));
|
||||||
Matrix matrix = new Matrix();
|
Matrix matrix = new Matrix();
|
||||||
matrix.postTranslate((previewWidth - mImageWidth) / 2,
|
int overlayColor = 0x40FFFFFF;
|
||||||
(previewHeight - mImageHeight) / 2);
|
|
||||||
|
Bitmap picture = Bitmap.createBitmap(previewWidth, previewHeight, data.image.getConfig());
|
||||||
|
matrix.setTranslate((previewWidth - mImageWidth) / 2, (previewHeight - mImageHeight) / 2);
|
||||||
|
c.setBitmap(picture);
|
||||||
c.drawBitmap(data.image, matrix, paint);
|
c.drawBitmap(data.image, matrix, paint);
|
||||||
c.drawColor(0x40FFFFFF);
|
c.drawColor(overlayColor);
|
||||||
c.setBitmap(null);
|
c.setBitmap(null);
|
||||||
|
|
||||||
Bitmap croppedIcon = Bitmap.createScaledBitmap(preview, iconSize, iconSize, true);
|
// Note, we can't use the preview for the small icon, since it is non-square
|
||||||
|
float scale = (float) iconSize / Math.min(mImageWidth, mImageHeight);
|
||||||
|
Bitmap icon = Bitmap.createBitmap(iconSize, iconSize, data.image.getConfig());
|
||||||
|
matrix.setScale(scale, scale);
|
||||||
|
matrix.postTranslate((iconSize - (scale * mImageWidth)) / 2,
|
||||||
|
(iconSize - (scale * mImageHeight)) / 2);
|
||||||
|
c.setBitmap(icon);
|
||||||
|
c.drawBitmap(data.image, matrix, paint);
|
||||||
|
c.drawColor(overlayColor);
|
||||||
|
c.setBitmap(null);
|
||||||
|
|
||||||
// Show the intermediate notification
|
// Show the intermediate notification
|
||||||
mTickerAddSpace = !mTickerAddSpace;
|
mTickerAddSpace = !mTickerAddSpace;
|
||||||
@@ -169,7 +179,7 @@ class SaveImageInBackgroundTask extends AsyncTask<SaveImageInBackgroundData, Voi
|
|||||||
.setColor(r.getColor(com.android.internal.R.color.system_notification_accent_color));
|
.setColor(r.getColor(com.android.internal.R.color.system_notification_accent_color));
|
||||||
|
|
||||||
mNotificationStyle = new Notification.BigPictureStyle()
|
mNotificationStyle = new Notification.BigPictureStyle()
|
||||||
.bigPicture(preview);
|
.bigPicture(picture);
|
||||||
mNotificationBuilder.setStyle(mNotificationStyle);
|
mNotificationBuilder.setStyle(mNotificationStyle);
|
||||||
|
|
||||||
// For "public" situations we want to show all the same info but
|
// For "public" situations we want to show all the same info but
|
||||||
@@ -192,7 +202,7 @@ class SaveImageInBackgroundTask extends AsyncTask<SaveImageInBackgroundData, Voi
|
|||||||
// On the tablet, the large icon makes the notification appear as if it is clickable (and
|
// On the tablet, the large icon makes the notification appear as if it is clickable (and
|
||||||
// on small devices, the large icon is not shown) so defer showing the large icon until
|
// on small devices, the large icon is not shown) so defer showing the large icon until
|
||||||
// we compose the final post-save notification below.
|
// we compose the final post-save notification below.
|
||||||
mNotificationBuilder.setLargeIcon(croppedIcon);
|
mNotificationBuilder.setLargeIcon(icon);
|
||||||
// But we still don't set it for the expanded view, allowing the smallIcon to show here.
|
// But we still don't set it for the expanded view, allowing the smallIcon to show here.
|
||||||
mNotificationStyle.bigLargeIcon((Bitmap) null);
|
mNotificationStyle.bigLargeIcon((Bitmap) null);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user