add share action to screenshots in notification

Now you can brag with your pebble watchfaces and send them straight to Conversations.
master
Andreas Shimokawa 2015-06-27 18:09:49 +02:00
parent c16510003c
commit 27e611c583
1 changed files with 10 additions and 0 deletions

View File

@ -164,6 +164,13 @@ public abstract class AbstractDeviceSupport implements DeviceSupport {
PendingIntent pIntent = PendingIntent.getActivity(context, 0, intent, 0);
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("image/*");
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(fullpath)));
PendingIntent pendingShareIntent = PendingIntent.getActivity(context, 0, Intent.createChooser(shareIntent, "share screenshot"),
PendingIntent.FLAG_UPDATE_CURRENT);
Notification notif = new Notification.Builder(context)
.setContentTitle("Screenshot taken")
.setTicker("Screenshot taken")
@ -172,7 +179,10 @@ public abstract class AbstractDeviceSupport implements DeviceSupport {
.setStyle(new Notification.BigPictureStyle()
.bigPicture(bmp))
.setContentIntent(pIntent)
.addAction(android.R.drawable.ic_menu_share, "share", pendingShareIntent)
.build();
notif.flags |= Notification.FLAG_AUTO_CANCEL;
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);