diff --git a/AndroidManifest.xml b/AndroidManifest.xml index a242e1af0..2b42c3ce3 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -460,7 +460,7 @@ - diff --git a/src/org/thoughtcrime/securesms/notifications/MessageNotifier.java b/src/org/thoughtcrime/securesms/notifications/MessageNotifier.java index fc758c4b5..0325a5f8a 100644 --- a/src/org/thoughtcrime/securesms/notifications/MessageNotifier.java +++ b/src/org/thoughtcrime/securesms/notifications/MessageNotifier.java @@ -86,7 +86,7 @@ public class MessageNotifier { private static final String TAG = MessageNotifier.class.getSimpleName(); - public static final String EXTRA_VOICE_REPLY = "extra_voice_reply"; + public static final String EXTRA_REMOTE_REPLY = "extra_remote_reply"; private static final int SUMMARY_NOTIFICATION_ID = 1338; private static final String NOTIFICATION_GROUP = "messages"; @@ -309,7 +309,8 @@ public class MessageNotifier { builder.addActions(masterSecret, notificationState.getMarkAsReadIntent(context, notificationId), notificationState.getQuickReplyIntent(context, notifications.get(0).getRecipients()), - notificationState.getWearableReplyIntent(context, notifications.get(0).getRecipients())); + notificationState.getRemoteReplyIntent(context, notifications.get(0).getRecipients())); + builder.addAndroidAutoAction(notificationState.getAndroidAutoReplyIntent(context, notifications.get(0).getRecipients()), notificationState.getAndroidAutoHeardIntent(context, notificationId), notifications.get(0).getTimestamp()); diff --git a/src/org/thoughtcrime/securesms/notifications/NotificationState.java b/src/org/thoughtcrime/securesms/notifications/NotificationState.java index 730dd33f3..f80a51025 100644 --- a/src/org/thoughtcrime/securesms/notifications/NotificationState.java +++ b/src/org/thoughtcrime/securesms/notifications/NotificationState.java @@ -13,11 +13,9 @@ import org.thoughtcrime.securesms.ConversationPopupActivity; import org.thoughtcrime.securesms.database.RecipientPreferenceDatabase.VibrateState; import org.thoughtcrime.securesms.recipients.Recipients; -import java.util.HashSet; import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; -import java.util.Set; public class NotificationState { @@ -117,13 +115,13 @@ public class NotificationState { return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); } - public PendingIntent getWearableReplyIntent(Context context, Recipients recipients) { + public PendingIntent getRemoteReplyIntent(Context context, Recipients recipients) { if (threads.size() != 1) throw new AssertionError("We only support replies to single thread notifications!"); - Intent intent = new Intent(WearReplyReceiver.REPLY_ACTION); - intent.setClass(context, WearReplyReceiver.class); + Intent intent = new Intent(RemoteReplyReceiver.REPLY_ACTION); + intent.setClass(context, RemoteReplyReceiver.class); intent.setData((Uri.parse("custom://"+System.currentTimeMillis()))); - intent.putExtra(WearReplyReceiver.RECIPIENT_IDS_EXTRA, recipients.getIds()); + intent.putExtra(RemoteReplyReceiver.RECIPIENT_IDS_EXTRA, recipients.getIds()); intent.setPackage(context.getPackageName()); return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); diff --git a/src/org/thoughtcrime/securesms/notifications/WearReplyReceiver.java b/src/org/thoughtcrime/securesms/notifications/RemoteReplyReceiver.java similarity index 94% rename from src/org/thoughtcrime/securesms/notifications/WearReplyReceiver.java rename to src/org/thoughtcrime/securesms/notifications/RemoteReplyReceiver.java index 8df9063e9..8efba0c74 100644 --- a/src/org/thoughtcrime/securesms/notifications/WearReplyReceiver.java +++ b/src/org/thoughtcrime/securesms/notifications/RemoteReplyReceiver.java @@ -1,5 +1,5 @@ /** - * Copyright (C) 2011 Whisper Systems + * Copyright (C) 2016 Open Whisper Systems * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -42,9 +42,9 @@ import java.util.List; /** * Get the response text from the Wearable Device and sends an message as a reply */ -public class WearReplyReceiver extends MasterSecretBroadcastReceiver { +public class RemoteReplyReceiver extends MasterSecretBroadcastReceiver { - public static final String TAG = WearReplyReceiver.class.getSimpleName(); + public static final String TAG = RemoteReplyReceiver.class.getSimpleName(); public static final String REPLY_ACTION = "org.thoughtcrime.securesms.notifications.WEAR_REPLY"; public static final String RECIPIENT_IDS_EXTRA = "recipient_ids"; @@ -59,7 +59,7 @@ public class WearReplyReceiver extends MasterSecretBroadcastReceiver { if (remoteInput == null) return; final long[] recipientIds = intent.getLongArrayExtra(RECIPIENT_IDS_EXTRA); - final CharSequence responseText = remoteInput.getCharSequence(MessageNotifier.EXTRA_VOICE_REPLY); + final CharSequence responseText = remoteInput.getCharSequence(MessageNotifier.EXTRA_REMOTE_REPLY); final Recipients recipients = RecipientFactory.getRecipientsForIds(context, recipientIds, false); if (masterSecret != null && responseText != null) { diff --git a/src/org/thoughtcrime/securesms/notifications/SingleRecipientNotificationBuilder.java b/src/org/thoughtcrime/securesms/notifications/SingleRecipientNotificationBuilder.java index 4a2bc529e..519068d2e 100644 --- a/src/org/thoughtcrime/securesms/notifications/SingleRecipientNotificationBuilder.java +++ b/src/org/thoughtcrime/securesms/notifications/SingleRecipientNotificationBuilder.java @@ -136,10 +136,19 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil context.getString(R.string.MessageNotifier_reply), quickReplyIntent); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + replyAction = new Action.Builder(R.drawable.ic_reply_white_36dp, + context.getString(R.string.MessageNotifier_reply), + wearableReplyIntent) + .addRemoteInput(new RemoteInput.Builder(MessageNotifier.EXTRA_REMOTE_REPLY) + .setLabel(context.getString(R.string.MessageNotifier_reply)).build()) + .build(); + } + Action wearableReplyAction = new Action.Builder(R.drawable.ic_reply, context.getString(R.string.MessageNotifier_reply), wearableReplyIntent) - .addRemoteInput(new RemoteInput.Builder(MessageNotifier.EXTRA_VOICE_REPLY) + .addRemoteInput(new RemoteInput.Builder(MessageNotifier.EXTRA_REMOTE_REPLY) .setLabel(context.getString(R.string.MessageNotifier_reply)).build()) .build();