summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI/src/com/android/systemui/screenshot
diff options
context:
space:
mode:
authorChris Wren <cwren@android.com>2012-05-22 15:11:52 -0400
committerChris Wren <cwren@android.com>2012-05-22 17:47:33 -0400
commit3745a3da759a9510554c8d2c59f09185e52ed403 (patch)
treee015ee36529b145449df9373046e2af99d42b2aa /packages/SystemUI/src/com/android/systemui/screenshot
parent0eaeb69d1c4849da8ab1df70b84e90837193df67 (diff)
downloadframeworks_base-3745a3da759a9510554c8d2c59f09185e52ed403.zip
frameworks_base-3745a3da759a9510554c8d2c59f09185e52ed403.tar.gz
frameworks_base-3745a3da759a9510554c8d2c59f09185e52ed403.tar.bz2
BigPicture notifications for screenshots.
Needed a little extra help from the builder to make this happen (like the title, you might want a different largeIcon in the expanded view if---as in this case---it is redundant with the big picture). Needed to fix BigPicture template to reveal actions. Bug: 6289107 Change-Id: I19dc62e693ee2c87cbe82f7327fe9115768b4102
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/screenshot')
-rw-r--r--packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java52
1 files changed, 40 insertions, 12 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
index 9a76c14..8795154 100644
--- a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
+++ b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
@@ -22,6 +22,7 @@ import android.animation.AnimatorSet;
import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.app.Notification;
+import android.app.Notification.BigPictureStyle;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.ContentResolver;
@@ -31,9 +32,13 @@ import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
+import android.graphics.ColorMatrix;
+import android.graphics.ColorMatrixColorFilter;
import android.graphics.Matrix;
+import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.PointF;
+import android.graphics.RectF;
import android.media.MediaActionSound;
import android.net.Uri;
import android.os.AsyncTask;
@@ -85,6 +90,7 @@ class SaveImageInBackgroundTask extends AsyncTask<SaveImageInBackgroundData, Voi
private String mImageFileName;
private String mImageFilePath;
private long mImageTime;
+ private BigPictureStyle mNotificationStyle;
// WORKAROUND: We want the same notification across screenshots that we update so that we don't
// spam a user's notification drawer. However, we only show the ticker for the saving state
@@ -109,16 +115,22 @@ class SaveImageInBackgroundTask extends AsyncTask<SaveImageInBackgroundData, Voi
// Create the large notification icon
int imageWidth = data.image.getWidth();
int imageHeight = data.image.getHeight();
- int iconWidth = data.iconSize;
- int iconHeight = data.iconSize;
- if (imageWidth > imageHeight) {
- iconWidth = (int) (((float) iconHeight / imageHeight) * imageWidth);
- } else {
- iconHeight = (int) (((float) iconWidth / imageWidth) * imageHeight);
- }
- Bitmap rawIcon = Bitmap.createScaledBitmap(data.image, iconWidth, iconHeight, true);
- Bitmap croppedIcon = Bitmap.createBitmap(rawIcon, (iconWidth - data.iconSize) / 2,
- (iconHeight - data.iconSize) / 2, data.iconSize, data.iconSize);
+ int iconSize = data.iconSize;
+
+ final int shortSide = imageWidth < imageHeight ? imageWidth : imageHeight;
+ Bitmap preview = Bitmap.createBitmap(shortSide, shortSide, data.image.getConfig());
+ Canvas c = new Canvas(preview);
+ Paint paint = new Paint();
+ ColorMatrix desat = new ColorMatrix();
+ desat.setSaturation(0.25f);
+ paint.setColorFilter(new ColorMatrixColorFilter(desat));
+ Matrix matrix = new Matrix();
+ matrix.postTranslate((shortSide - imageWidth) / 2,
+ (shortSide - imageHeight) / 2);
+ c.drawBitmap(data.image, matrix, paint);
+ c.drawColor(0x40FFFFFF);
+
+ Bitmap croppedIcon = Bitmap.createScaledBitmap(preview, iconSize, iconSize, true);
// Show the intermediate notification
mTickerAddSpace = !mTickerAddSpace;
@@ -131,7 +143,12 @@ class SaveImageInBackgroundTask extends AsyncTask<SaveImageInBackgroundData, Voi
.setContentText(r.getString(R.string.screenshot_saving_text))
.setSmallIcon(R.drawable.stat_notify_image)
.setWhen(System.currentTimeMillis());
- Notification n = mNotificationBuilder.getNotification();
+
+ mNotificationStyle = new Notification.BigPictureStyle()
+ .bigPicture(preview);
+ mNotificationBuilder.setStyle(mNotificationStyle);
+
+ Notification n = mNotificationBuilder.build();
n.flags |= Notification.FLAG_NO_CLEAR;
mNotificationManager.notify(nId, n);
@@ -139,6 +156,8 @@ class SaveImageInBackgroundTask extends AsyncTask<SaveImageInBackgroundData, Voi
// 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);
+ // But we still don't set it for the expanded view, allowing the smallIcon to show here.
+ mNotificationStyle.bigLargeIcon(null);
}
@Override
@@ -151,6 +170,7 @@ class SaveImageInBackgroundTask extends AsyncTask<SaveImageInBackgroundData, Voi
Context context = params[0].context;
Bitmap image = params[0].image;
+ Resources r = context.getResources();
try {
// Save the screenshot to the MediaStore
@@ -165,6 +185,14 @@ class SaveImageInBackgroundTask extends AsyncTask<SaveImageInBackgroundData, Voi
values.put(MediaStore.Images.ImageColumns.MIME_TYPE, "image/png");
Uri uri = resolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
+ Intent sharingIntent = new Intent(Intent.ACTION_SEND);
+ sharingIntent.setType("image/png");
+ sharingIntent.putExtra(Intent.EXTRA_STREAM, uri);
+ sharingIntent.setFlags(Intent.FLAG_ACTIVITY_CLOSE_SYSTEM_DIALOGS);
+ mNotificationBuilder.addAction(R.drawable.ic_menu_share,
+ r.getString(com.android.internal.R.string.share),
+ PendingIntent.getActivity(context, 0, sharingIntent, 0));
+
OutputStream out = resolver.openOutputStream(uri);
image.compress(Bitmap.CompressFormat.PNG, 100, out);
out.flush();
@@ -207,7 +235,7 @@ class SaveImageInBackgroundTask extends AsyncTask<SaveImageInBackgroundData, Voi
.setWhen(System.currentTimeMillis())
.setAutoCancel(true);
- Notification n = mNotificationBuilder.getNotification();
+ Notification n = mNotificationBuilder.build();
n.flags &= ~Notification.FLAG_NO_CLEAR;
mNotificationManager.notify(mNotificationId, n);
}