Messaging: Show quick reply choices only on wearable devices

Change-Id: I4b81643c051a9b1377f2046c1aa0515c590736fc
This commit is contained in:
Han Wang
2024-09-09 05:46:58 +03:00
committed by Michael Bestas
parent 76219e63bf
commit 1970f9ea99
@@ -788,7 +788,7 @@ public class BugleNotifications {
maybeAddWearableConversationLog(wearableExtender, maybeAddWearableConversationLog(wearableExtender,
(MultiMessageNotificationState) notificationState); (MultiMessageNotificationState) notificationState);
addDownloadMmsAction(notifBuilder, wearableExtender, notificationState); addDownloadMmsAction(notifBuilder, wearableExtender, notificationState);
addWearableVoiceReplyAction(wearableExtender, notificationState); addWearableVoiceReplyAction(notifBuilder, wearableExtender, notificationState);
} }
// Apply the wearable options and build & post the notification // Apply the wearable options and build & post the notification
@@ -830,7 +830,7 @@ public class BugleNotifications {
} }
} }
private static void addWearableVoiceReplyAction( private static void addWearableVoiceReplyAction(final NotificationCompat.Builder notifBuilder,
final WearableExtender wearableExtender, final NotificationState notificationState) { final WearableExtender wearableExtender, final NotificationState notificationState) {
if (!(notificationState instanceof MultiMessageNotificationState)) { if (!(notificationState instanceof MultiMessageNotificationState)) {
return; return;
@@ -860,14 +860,20 @@ public class BugleNotifications {
final NotificationCompat.Action.Builder actionBuilder = final NotificationCompat.Action.Builder actionBuilder =
new NotificationCompat.Action.Builder(R.drawable.ic_wear_reply, new NotificationCompat.Action.Builder(R.drawable.ic_wear_reply,
context.getString(replyLabelRes), replyPendingIntent); context.getString(replyLabelRes), replyPendingIntent);
final RemoteInput.Builder remoteInputBuilder = new RemoteInput.Builder(Intent.EXTRA_TEXT);
remoteInputBuilder.setLabel(context.getString(R.string.notification_reply_prompt));
actionBuilder.addRemoteInput(remoteInputBuilder.build());
notifBuilder.addAction(actionBuilder.build());
// Support the action on a wearable device
final NotificationCompat.Action.Builder wearActionBuilder =
new NotificationCompat.Action.Builder(R.drawable.ic_wear_reply,
context.getString(replyLabelRes), replyPendingIntent);
final String[] choices = context.getResources().getStringArray( final String[] choices = context.getResources().getStringArray(
R.array.notification_reply_choices); R.array.notification_reply_choices);
final RemoteInput remoteInput = new RemoteInput.Builder(Intent.EXTRA_TEXT).setLabel( remoteInputBuilder.setChoices(choices);
context.getString(R.string.notification_reply_prompt)). wearActionBuilder.addRemoteInput(remoteInputBuilder.build());
setChoices(choices) wearableExtender.addAction(wearActionBuilder.build());
.build();
actionBuilder.addRemoteInput(remoteInput);
wearableExtender.addAction(actionBuilder.build());
} }
private static void addDownloadMmsAction(final NotificationCompat.Builder notifBuilder, private static void addDownloadMmsAction(final NotificationCompat.Builder notifBuilder,