Initial unified commit for Android 14, with "light" GSI target
This commit is contained in:
@@ -0,0 +1,232 @@
|
||||
From b98a354d5dd11302672f2feed6eff815e8927342 Mon Sep 17 00:00:00 2001
|
||||
From: Paul Keith <javelinanddart@gmail.com>
|
||||
Date: Tue, 30 Oct 2018 15:46:18 +0100
|
||||
Subject: [PATCH 1/2] Messaging: Add "Mark as read" quick action for message
|
||||
notifications
|
||||
|
||||
Change-Id: I7194dca022e5062926fa35709de282721ca64320
|
||||
---
|
||||
res/drawable/ic_wear_read.xml | 9 +++++++++
|
||||
res/values-zh-rCN/cm_strings.xml | 1 +
|
||||
res/values/cm_strings.xml | 3 +++
|
||||
.../messaging/datamodel/BugleNotifications.java | 14 ++++++++++++++
|
||||
.../datamodel/MessageNotificationState.java | 8 ++++++++
|
||||
.../messaging/datamodel/NotificationState.java | 12 +++++++++++-
|
||||
.../messaging/receiver/NotificationReceiver.java | 12 +++++++++++-
|
||||
src/com/android/messaging/ui/UIIntents.java | 11 +++++++++++
|
||||
src/com/android/messaging/ui/UIIntentsImpl.java | 14 ++++++++++++++
|
||||
9 files changed, 82 insertions(+), 2 deletions(-)
|
||||
create mode 100644 res/drawable/ic_wear_read.xml
|
||||
|
||||
diff --git a/res/drawable/ic_wear_read.xml b/res/drawable/ic_wear_read.xml
|
||||
new file mode 100644
|
||||
index 0000000..9d017e6
|
||||
--- /dev/null
|
||||
+++ b/res/drawable/ic_wear_read.xml
|
||||
@@ -0,0 +1,9 @@
|
||||
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
+ android:height="24dp"
|
||||
+ android:width="24dp"
|
||||
+ android:viewportWidth="24"
|
||||
+ android:viewportHeight="24">
|
||||
+ <path
|
||||
+ android:fillColor="#ffffff"
|
||||
+ android:pathData="M0.41,13.41L6,19L7.41,17.58L1.83,12M22.24,5.58L11.66,16.17L7.5,12L6.07,13.41L11.66,19L23.66,7M18,7L16.59,5.58L10.24,11.93L11.66,13.34L18,7Z" />
|
||||
+</vector>
|
||||
diff --git a/res/values-zh-rCN/cm_strings.xml b/res/values-zh-rCN/cm_strings.xml
|
||||
index 074c13f..988d9f4 100644
|
||||
--- a/res/values-zh-rCN/cm_strings.xml
|
||||
+++ b/res/values-zh-rCN/cm_strings.xml
|
||||
@@ -18,4 +18,5 @@
|
||||
<string name="swipe_to_delete_conversation_pref_title">滑动删除邮件</string>
|
||||
<string name="swipe_to_delete_conversation_pref_summary">向右滑动以删除会话</string>
|
||||
<string name="notification_channel_messages_title">短信</string>
|
||||
+ <string name="notification_mark_as_read">标记为已读</string>
|
||||
</resources>
|
||||
diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml
|
||||
index 9f2382c..743cb8b 100644
|
||||
--- a/res/values/cm_strings.xml
|
||||
+++ b/res/values/cm_strings.xml
|
||||
@@ -21,4 +21,7 @@
|
||||
|
||||
<!-- Notification channel -->
|
||||
<string name="notification_channel_messages_title">Messages</string>
|
||||
+
|
||||
+ <!-- Mark message as read -->
|
||||
+ <string name="notification_mark_as_read">Mark as read</string>
|
||||
</resources>
|
||||
diff --git a/src/com/android/messaging/datamodel/BugleNotifications.java b/src/com/android/messaging/datamodel/BugleNotifications.java
|
||||
index 6df9e88..dbe86ff 100644
|
||||
--- a/src/com/android/messaging/datamodel/BugleNotifications.java
|
||||
+++ b/src/com/android/messaging/datamodel/BugleNotifications.java
|
||||
@@ -789,6 +789,7 @@ public class BugleNotifications {
|
||||
(MultiMessageNotificationState) notificationState);
|
||||
addDownloadMmsAction(notifBuilder, wearableExtender, notificationState);
|
||||
addWearableVoiceReplyAction(notifBuilder, wearableExtender, notificationState);
|
||||
+ addReadAction(notifBuilder, wearableExtender, notificationState);
|
||||
}
|
||||
|
||||
// Apply the wearable options and build & post the notification
|
||||
@@ -876,6 +877,19 @@ public class BugleNotifications {
|
||||
wearableExtender.addAction(wearActionBuilder.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)) {
|
||||
diff --git a/src/com/android/messaging/datamodel/MessageNotificationState.java b/src/com/android/messaging/datamodel/MessageNotificationState.java
|
||||
index fd82f74..b49774f 100644
|
||||
--- a/src/com/android/messaging/datamodel/MessageNotificationState.java
|
||||
+++ b/src/com/android/messaging/datamodel/MessageNotificationState.java
|
||||
@@ -335,6 +335,14 @@ public abstract class MessageNotificationState extends NotificationState {
|
||||
getClearIntentRequestCode());
|
||||
}
|
||||
|
||||
+ @Override
|
||||
+ public PendingIntent getReadIntent() {
|
||||
+ return UIIntents.get().getPendingIntentForMarkingAsRead(
|
||||
+ Factory.get().getApplicationContext(),
|
||||
+ mConversationIds,
|
||||
+ getReadIntentRequestCode());
|
||||
+ }
|
||||
+
|
||||
/**
|
||||
* Notification for multiple messages in at least 2 different conversations.
|
||||
*/
|
||||
diff --git a/src/com/android/messaging/datamodel/NotificationState.java b/src/com/android/messaging/datamodel/NotificationState.java
|
||||
index 144f0fe..4c11537 100644
|
||||
--- a/src/com/android/messaging/datamodel/NotificationState.java
|
||||
+++ b/src/com/android/messaging/datamodel/NotificationState.java
|
||||
@@ -43,7 +43,8 @@ import java.util.HashSet;
|
||||
public abstract class NotificationState {
|
||||
private static final int CONTENT_INTENT_REQUEST_CODE_OFFSET = 0;
|
||||
private static final int CLEAR_INTENT_REQUEST_CODE_OFFSET = 1;
|
||||
- private static final int NUM_REQUEST_CODES_NEEDED = 2;
|
||||
+ private static final int READ_INTENT_REQUEST_CODE_OFFSET = 2;
|
||||
+ private static final int NUM_REQUEST_CODES_NEEDED = 3;
|
||||
|
||||
public interface FailedMessageQuery {
|
||||
static final String FAILED_MESSAGES_WHERE_CLAUSE =
|
||||
@@ -78,6 +79,11 @@ public abstract class NotificationState {
|
||||
*/
|
||||
public abstract PendingIntent getClearIntent();
|
||||
|
||||
+ /**
|
||||
+ * The intent to be triggered when mark as read is pressed.
|
||||
+ */
|
||||
+ public abstract PendingIntent getReadIntent();
|
||||
+
|
||||
protected Uri getAttachmentUri() {
|
||||
return null;
|
||||
}
|
||||
@@ -116,6 +122,10 @@ public abstract class NotificationState {
|
||||
return mBaseRequestCode + CLEAR_INTENT_REQUEST_CODE_OFFSET;
|
||||
}
|
||||
|
||||
+ public int getReadIntentRequestCode() {
|
||||
+ return mBaseRequestCode + READ_INTENT_REQUEST_CODE_OFFSET;
|
||||
+ }
|
||||
+
|
||||
/**
|
||||
* Gets the appropriate icon needed for notifications.
|
||||
*/
|
||||
diff --git a/src/com/android/messaging/receiver/NotificationReceiver.java b/src/com/android/messaging/receiver/NotificationReceiver.java
|
||||
index bbb847d..f87779c 100644
|
||||
--- a/src/com/android/messaging/receiver/NotificationReceiver.java
|
||||
+++ b/src/com/android/messaging/receiver/NotificationReceiver.java
|
||||
@@ -20,6 +20,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.android.messaging.datamodel.BugleNotifications;
|
||||
+import com.android.messaging.datamodel.action.MarkAsReadAction;
|
||||
import com.android.messaging.datamodel.action.MarkAsSeenAction;
|
||||
import com.android.messaging.ui.UIIntents;
|
||||
import com.android.messaging.util.ConversationIdSet;
|
||||
@@ -52,6 +53,15 @@ public class NotificationReceiver extends BroadcastReceiver {
|
||||
BugleNotifications.resetLastMessageDing(conversationId);
|
||||
}
|
||||
}
|
||||
+ } else if (intent.getAction().equals(UIIntents.ACTION_MARK_AS_READ)) {
|
||||
+ final String conversationIdSetString =
|
||||
+ intent.getStringExtra(UIIntents.UI_INTENT_EXTRA_CONVERSATION_ID_SET);
|
||||
+ if (conversationIdSetString != null) {
|
||||
+ for (final String conversationId :
|
||||
+ ConversationIdSet.createSet(conversationIdSetString)) {
|
||||
+ MarkAsReadAction.markAsRead(conversationId);
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
}
|
||||
-}
|
||||
\ No newline at end of file
|
||||
+}
|
||||
diff --git a/src/com/android/messaging/ui/UIIntents.java b/src/com/android/messaging/ui/UIIntents.java
|
||||
index 2d10527..144e831 100644
|
||||
--- a/src/com/android/messaging/ui/UIIntents.java
|
||||
+++ b/src/com/android/messaging/ui/UIIntents.java
|
||||
@@ -69,6 +69,9 @@ public abstract class UIIntents {
|
||||
public static final String ACTION_RESET_NOTIFICATIONS =
|
||||
"com.android.messaging.reset_notifications";
|
||||
|
||||
+ public static final String ACTION_MARK_AS_READ =
|
||||
+ "com.android.messaging.mark_as_read";
|
||||
+
|
||||
// Sending VCard uri to VCard detail activity
|
||||
public static final String UI_INTENT_EXTRA_VCARD_URI = "vcard_uri";
|
||||
|
||||
@@ -323,6 +326,14 @@ public abstract class UIIntents {
|
||||
final int updateTargets, final ConversationIdSet conversationIdSet,
|
||||
final int requestCode);
|
||||
|
||||
+ /**
|
||||
+ * Get a PendingIntent for marking a conversation as read.
|
||||
+ *
|
||||
+ * <p>This is intended to be used by notifications.
|
||||
+ */
|
||||
+ public abstract PendingIntent getPendingIntentForMarkingAsRead(final Context context,
|
||||
+ final ConversationIdSet conversationIdSet, final int requestCode);
|
||||
+
|
||||
/**
|
||||
* Get a PendingIntent for showing low storage notifications.
|
||||
*/
|
||||
diff --git a/src/com/android/messaging/ui/UIIntentsImpl.java b/src/com/android/messaging/ui/UIIntentsImpl.java
|
||||
index d64082d..9281899 100644
|
||||
--- a/src/com/android/messaging/ui/UIIntentsImpl.java
|
||||
+++ b/src/com/android/messaging/ui/UIIntentsImpl.java
|
||||
@@ -430,6 +430,20 @@ public class UIIntentsImpl extends UIIntents {
|
||||
PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
}
|
||||
|
||||
+ @Override
|
||||
+ public PendingIntent getPendingIntentForMarkingAsRead(final Context context,
|
||||
+ final ConversationIdSet conversationIdSet, final int requestCode) {
|
||||
+ final Intent intent = new Intent(context, NotificationReceiver.class);
|
||||
+ intent.setAction(ACTION_MARK_AS_READ);
|
||||
+ if (conversationIdSet != null) {
|
||||
+ intent.putExtra(UI_INTENT_EXTRA_CONVERSATION_ID_SET,
|
||||
+ conversationIdSet.getDelimitedString());
|
||||
+ }
|
||||
+ return PendingIntent.getBroadcast(context,
|
||||
+ requestCode, intent,
|
||||
+ PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
+ }
|
||||
+
|
||||
/**
|
||||
* Gets a PendingIntent associated with an Intent to start an Activity. All notifications
|
||||
* that starts an Activity must use this method to get a PendingIntent, which achieves two
|
||||
--
|
||||
2.34.1
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
From a544ce840f27fbf140b43652e76f6cc6c8b5b00e Mon Sep 17 00:00:00 2001
|
||||
From: Luca Stefani <luca.stefani.ge1@gmail.com>
|
||||
Date: Sat, 28 Mar 2020 15:10:57 +0100
|
||||
Subject: [PATCH 2/2] Properly set conversation as read
|
||||
|
||||
* We were currently set the whole conversation set as read
|
||||
-> Get only the matching notification instead
|
||||
|
||||
Test: m, manual
|
||||
Change-Id: I468e0d50f82129a029fb1f27bb9fa4fec45f2945
|
||||
---
|
||||
.../messaging/datamodel/BugleNotifications.java | 16 +++++++++++++++-
|
||||
.../datamodel/MessageNotificationState.java | 8 --------
|
||||
.../messaging/datamodel/NotificationState.java | 5 -----
|
||||
.../messaging/receiver/NotificationReceiver.java | 11 ++++-------
|
||||
src/com/android/messaging/ui/UIIntents.java | 2 +-
|
||||
src/com/android/messaging/ui/UIIntentsImpl.java | 7 +++----
|
||||
6 files changed, 23 insertions(+), 26 deletions(-)
|
||||
|
||||
diff --git a/src/com/android/messaging/datamodel/BugleNotifications.java b/src/com/android/messaging/datamodel/BugleNotifications.java
|
||||
index dbe86ff..c9c6fca 100644
|
||||
--- a/src/com/android/messaging/datamodel/BugleNotifications.java
|
||||
+++ b/src/com/android/messaging/datamodel/BugleNotifications.java
|
||||
@@ -879,11 +879,25 @@ public class BugleNotifications {
|
||||
|
||||
private static void addReadAction(final NotificationCompat.Builder notifBuilder,
|
||||
final WearableExtender wearableExtender, final NotificationState notificationState) {
|
||||
+ if (!(notificationState instanceof MultiMessageNotificationState)) {
|
||||
+ return;
|
||||
+ }
|
||||
+ final MultiMessageNotificationState multiMessageNotificationState =
|
||||
+ (MultiMessageNotificationState) notificationState;
|
||||
final Context context = Factory.get().getApplicationContext();
|
||||
- final PendingIntent readPendingIntent = notificationState.getReadIntent();
|
||||
+
|
||||
+ final String conversationId = notificationState.mConversationIds.first();
|
||||
+
|
||||
+ final int requestCode = multiMessageNotificationState.getReadIntentRequestCode();
|
||||
+ final PendingIntent readPendingIntent = UIIntents.get().getPendingIntentForMarkingAsRead(
|
||||
+ Factory.get().getApplicationContext(),
|
||||
+ conversationId,
|
||||
+ requestCode);
|
||||
+
|
||||
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
|
||||
diff --git a/src/com/android/messaging/datamodel/MessageNotificationState.java b/src/com/android/messaging/datamodel/MessageNotificationState.java
|
||||
index b49774f..fd82f74 100644
|
||||
--- a/src/com/android/messaging/datamodel/MessageNotificationState.java
|
||||
+++ b/src/com/android/messaging/datamodel/MessageNotificationState.java
|
||||
@@ -335,14 +335,6 @@ public abstract class MessageNotificationState extends NotificationState {
|
||||
getClearIntentRequestCode());
|
||||
}
|
||||
|
||||
- @Override
|
||||
- public PendingIntent getReadIntent() {
|
||||
- return UIIntents.get().getPendingIntentForMarkingAsRead(
|
||||
- Factory.get().getApplicationContext(),
|
||||
- mConversationIds,
|
||||
- getReadIntentRequestCode());
|
||||
- }
|
||||
-
|
||||
/**
|
||||
* Notification for multiple messages in at least 2 different conversations.
|
||||
*/
|
||||
diff --git a/src/com/android/messaging/datamodel/NotificationState.java b/src/com/android/messaging/datamodel/NotificationState.java
|
||||
index 4c11537..780cb8e 100644
|
||||
--- a/src/com/android/messaging/datamodel/NotificationState.java
|
||||
+++ b/src/com/android/messaging/datamodel/NotificationState.java
|
||||
@@ -79,11 +79,6 @@ public abstract class NotificationState {
|
||||
*/
|
||||
public abstract PendingIntent getClearIntent();
|
||||
|
||||
- /**
|
||||
- * The intent to be triggered when mark as read is pressed.
|
||||
- */
|
||||
- public abstract PendingIntent getReadIntent();
|
||||
-
|
||||
protected Uri getAttachmentUri() {
|
||||
return null;
|
||||
}
|
||||
diff --git a/src/com/android/messaging/receiver/NotificationReceiver.java b/src/com/android/messaging/receiver/NotificationReceiver.java
|
||||
index f87779c..ae30f03 100644
|
||||
--- a/src/com/android/messaging/receiver/NotificationReceiver.java
|
||||
+++ b/src/com/android/messaging/receiver/NotificationReceiver.java
|
||||
@@ -54,13 +54,10 @@ public class NotificationReceiver extends BroadcastReceiver {
|
||||
}
|
||||
}
|
||||
} else if (intent.getAction().equals(UIIntents.ACTION_MARK_AS_READ)) {
|
||||
- final String conversationIdSetString =
|
||||
- intent.getStringExtra(UIIntents.UI_INTENT_EXTRA_CONVERSATION_ID_SET);
|
||||
- if (conversationIdSetString != null) {
|
||||
- for (final String conversationId :
|
||||
- ConversationIdSet.createSet(conversationIdSetString)) {
|
||||
- MarkAsReadAction.markAsRead(conversationId);
|
||||
- }
|
||||
+ final String conversationId =
|
||||
+ intent.getStringExtra(UIIntents.UI_INTENT_EXTRA_CONVERSATION_ID);
|
||||
+ if (conversationId != null) {
|
||||
+ MarkAsReadAction.markAsRead(conversationId);
|
||||
}
|
||||
}
|
||||
}
|
||||
diff --git a/src/com/android/messaging/ui/UIIntents.java b/src/com/android/messaging/ui/UIIntents.java
|
||||
index 144e831..ab81cab 100644
|
||||
--- a/src/com/android/messaging/ui/UIIntents.java
|
||||
+++ b/src/com/android/messaging/ui/UIIntents.java
|
||||
@@ -332,7 +332,7 @@ public abstract class UIIntents {
|
||||
* <p>This is intended to be used by notifications.
|
||||
*/
|
||||
public abstract PendingIntent getPendingIntentForMarkingAsRead(final Context context,
|
||||
- final ConversationIdSet conversationIdSet, final int requestCode);
|
||||
+ final String conversationId, final int requestCode);
|
||||
|
||||
/**
|
||||
* Get a PendingIntent for showing low storage notifications.
|
||||
diff --git a/src/com/android/messaging/ui/UIIntentsImpl.java b/src/com/android/messaging/ui/UIIntentsImpl.java
|
||||
index 9281899..858072d 100644
|
||||
--- a/src/com/android/messaging/ui/UIIntentsImpl.java
|
||||
+++ b/src/com/android/messaging/ui/UIIntentsImpl.java
|
||||
@@ -432,12 +432,11 @@ public class UIIntentsImpl extends UIIntents {
|
||||
|
||||
@Override
|
||||
public PendingIntent getPendingIntentForMarkingAsRead(final Context context,
|
||||
- final ConversationIdSet conversationIdSet, final int requestCode) {
|
||||
+ final String conversationId, final int requestCode) {
|
||||
final Intent intent = new Intent(context, NotificationReceiver.class);
|
||||
intent.setAction(ACTION_MARK_AS_READ);
|
||||
- if (conversationIdSet != null) {
|
||||
- intent.putExtra(UI_INTENT_EXTRA_CONVERSATION_ID_SET,
|
||||
- conversationIdSet.getDelimitedString());
|
||||
+ if (conversationId != null) {
|
||||
+ intent.putExtra(UI_INTENT_EXTRA_CONVERSATION_ID, conversationId);
|
||||
}
|
||||
return PendingIntent.getBroadcast(context,
|
||||
requestCode, intent,
|
||||
--
|
||||
2.34.1
|
||||
|
||||
Reference in New Issue
Block a user