From 424a463b21869b9afa674430709a4dc3e03be31c Mon Sep 17 00:00:00 2001 From: Christoph Haefner Date: Wed, 15 Apr 2015 18:46:57 +0200 Subject: [PATCH] Add notification functionality to Android Wear devices. This should allow for Android Wear device- and Pebble-users to easily mark an incoming message as read via the smartwatch. http://developer.getpebble.com/blog/2014/12/19/Leverage-Android-Actionable-Notifications/ Closes #3010 --- .../securesms/notifications/MessageNotifier.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/org/thoughtcrime/securesms/notifications/MessageNotifier.java b/src/org/thoughtcrime/securesms/notifications/MessageNotifier.java index 98778d8b6d..12af949543 100644 --- a/src/org/thoughtcrime/securesms/notifications/MessageNotifier.java +++ b/src/org/thoughtcrime/securesms/notifications/MessageNotifier.java @@ -31,6 +31,7 @@ import android.media.AudioManager; import android.media.MediaPlayer; import android.net.Uri; import android.support.v4.app.NotificationCompat; +import android.support.v4.app.NotificationCompat.Action; import android.support.v4.app.NotificationCompat.BigTextStyle; import android.support.v4.app.NotificationCompat.InboxStyle; import android.text.Spannable; @@ -199,8 +200,11 @@ public class MessageNotifier { if (timestamp != 0) builder.setWhen(timestamp); if (masterSecret != null) { - builder.addAction(R.drawable.check, context.getString(R.string.MessageNotifier_mark_as_read), - notificationState.getMarkAsReadIntent(context, masterSecret)); + Action markAsReadAction = new Action(R.drawable.check, + context.getString(R.string.MessageNotifier_mark_as_read), + notificationState.getMarkAsReadIntent(context, masterSecret)); + builder.addAction(markAsReadAction); + builder.extend(new NotificationCompat.WearableExtender().addAction(markAsReadAction)); } SpannableStringBuilder content = new SpannableStringBuilder(); @@ -252,8 +256,11 @@ public class MessageNotifier { builder.setDeleteIntent(PendingIntent.getBroadcast(context, 0, new Intent(DeleteReceiver.DELETE_REMINDER_ACTION), 0)); if (masterSecret != null) { - builder.addAction(R.drawable.check, context.getString(R.string.MessageNotifier_mark_all_as_read), - notificationState.getMarkAsReadIntent(context, masterSecret)); + Action markAllAsReadAction = new Action(R.drawable.check, + context.getString(R.string.MessageNotifier_mark_all_as_read), + notificationState.getMarkAsReadIntent(context, masterSecret)); + builder.addAction(markAllAsReadAction); + builder.extend(new NotificationCompat.WearableExtender().addAction(markAllAsReadAction)); } InboxStyle style = new InboxStyle();