summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2015-05-27 12:41:29 -0700
committerWinson Chung <winsonc@google.com>2015-05-27 14:24:40 -0700
commitc6caff84a4d8d22d7764950e1f2ed81087cc94d8 (patch)
treea86b77c12d348db202db3ebd3cb45611d9b01f9f
parent80ce4ad644af507b20eeac3d2ecf937ef4abd2de (diff)
downloadframeworks_base-c6caff84a4d8d22d7764950e1f2ed81087cc94d8.zip
frameworks_base-c6caff84a4d8d22d7764950e1f2ed81087cc94d8.tar.gz
frameworks_base-c6caff84a4d8d22d7764950e1f2ed81087cc94d8.tar.bz2
Fixing issue with screenshot icon being stretched.
Bug: 17491725 Change-Id: Iea36ed204dc9431fe1d80be5224a1fcbf6ff1c40
-rw-r--r--packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java28
1 files changed, 19 insertions, 9 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
index be33085..f16f6bd 100644
--- a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
+++ b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
@@ -137,21 +137,31 @@ class SaveImageInBackgroundTask extends AsyncTask<SaveImageInBackgroundData, Voi
int previewWidth = data.previewWidth;
int previewHeight = data.previewheight;
- final int shortSide = mImageWidth < mImageHeight ? mImageWidth : mImageHeight;
- Bitmap preview = Bitmap.createBitmap(previewWidth, previewHeight, data.image.getConfig());
- Canvas c = new Canvas(preview);
+ Canvas c = new Canvas();
Paint paint = new Paint();
ColorMatrix desat = new ColorMatrix();
desat.setSaturation(0.25f);
paint.setColorFilter(new ColorMatrixColorFilter(desat));
Matrix matrix = new Matrix();
- matrix.postTranslate((previewWidth - mImageWidth) / 2,
- (previewHeight - mImageHeight) / 2);
+ int overlayColor = 0x40FFFFFF;
+
+ 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.drawColor(0x40FFFFFF);
+ c.drawColor(overlayColor);
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
mTickerAddSpace = !mTickerAddSpace;
@@ -169,7 +179,7 @@ class SaveImageInBackgroundTask extends AsyncTask<SaveImageInBackgroundData, Voi
.setColor(r.getColor(com.android.internal.R.color.system_notification_accent_color));
mNotificationStyle = new Notification.BigPictureStyle()
- .bigPicture(preview);
+ .bigPicture(picture);
mNotificationBuilder.setStyle(mNotificationStyle);
// 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 small devices, the large icon is not shown) so defer showing the large icon until
// 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.
mNotificationStyle.bigLargeIcon((Bitmap) null);
}