Messaging: Add "Mark as read" quick action for message notifications

Signed-off-by: Luca Stefani <luca.stefani.ge1@gmail.com>
Change-Id: I7194dca022e5062926fa35709de282721ca64320
This commit is contained in:
Paul Keith
2018-10-30 15:46:18 +01:00
committed by Luca Stefani
parent 1dc43f0e09
commit f19e916a0d
8 changed files with 85 additions and 4 deletions

View File

@@ -833,7 +833,8 @@ public class BugleNotifications {
maybeAddWearableConversationLog(wearableExtender,
(MultiMessageNotificationState) notificationState);
addDownloadMmsAction(notifBuilder, wearableExtender, notificationState);
addWearableVoiceReplyAction(wearableExtender, notificationState);
addReplyAction(notifBuilder, wearableExtender, notificationState);
addReadAction(notifBuilder, wearableExtender, notificationState);
}
// Apply the wearable options and build & post the notification
@@ -875,7 +876,7 @@ public class BugleNotifications {
}
}
private static void addWearableVoiceReplyAction(
private static void addReplyAction(final NotificationCompat.Builder notifBuilder,
final WearableExtender wearableExtender, final NotificationState notificationState) {
if (!(notificationState instanceof MultiMessageNotificationState)) {
return;
@@ -912,9 +913,25 @@ public class BugleNotifications {
setChoices(choices)
.build();
actionBuilder.addRemoteInput(remoteInput);
notifBuilder.addAction(actionBuilder.build());
// Support the action on a wearable device as well
wearableExtender.addAction(actionBuilder.build());
}
private static void addReadAction(final NotificationCompat.Builder notifBuilder,
final WearableExtender wearableExtender, final NotificationState notificationState) {
final Context context = Factory.get().getApplicationContext();
final PendingIntent readPendingIntent = notificationState.getReadIntent();
final NotificationCompat.Action.Builder readActionBuilder =
new NotificationCompat.Action.Builder(R.drawable.ic_wear_read,
context.getString(R.string.notification_mark_as_read), readPendingIntent);
notifBuilder.addAction(readActionBuilder.build());
// Support the action on a wearable device as well
wearableExtender.addAction(readActionBuilder.build());
}
private static void addDownloadMmsAction(final NotificationCompat.Builder notifBuilder,
final WearableExtender wearableExtender, final NotificationState notificationState) {
if (!(notificationState instanceof MultiMessageNotificationState)) {