Page MenuHomePhabricator

D8730.id29540.diff
No OneTemporary

D8730.id29540.diff

diff --git a/native/android/app/src/main/java/app/comm/android/notifications/CommNotificationsHandler.java b/native/android/app/src/main/java/app/comm/android/notifications/CommNotificationsHandler.java
--- a/native/android/app/src/main/java/app/comm/android/notifications/CommNotificationsHandler.java
+++ b/native/android/app/src/main/java/app/comm/android/notifications/CommNotificationsHandler.java
@@ -27,10 +27,10 @@
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
import java.io.File;
+import java.lang.StringBuilder;
import me.leolin.shortcutbadger.ShortcutBadger;
import org.json.JSONException;
import org.json.JSONObject;
-
public class CommNotificationsHandler extends FirebaseMessagingService {
private static final String BADGE_KEY = "badge";
private static final String BADGE_ONLY_KEY = "badgeOnly";
@@ -180,6 +180,10 @@
boolean groupSummaryPresent = false;
boolean threadGroupPresent = false;
+ boolean anotherGroupSummaryPresent = false;
+ StringBuilder groupSummariesDataBuilder =
+ new StringBuilder("Group summaries present for: ");
+
for (StatusBarNotification notification :
notificationManager.getActiveNotifications()) {
String tag = notification.getTag();
@@ -194,11 +198,23 @@
groupSummaryPresent = true;
} else if (isGroupMember) {
threadGroupPresent = true;
+ } else if (isGroupSummary) {
+ anotherGroupSummaryPresent = true;
+ groupSummariesDataBuilder.append(
+ System.lineSeparator() + notification.getNotification().getGroup());
}
}
if (groupSummaryPresent && !threadGroupPresent) {
notificationManager.cancel(threadID, threadID.hashCode());
+ return;
+ }
+
+ if (anotherGroupSummaryPresent && !threadGroupPresent) {
+ displayErrorMessageNotification(
+ "Group Summary not found for threadID " + threadID,
+ "Group Summary Not Deleted",
+ groupSummariesDataBuilder.toString());
}
}
@@ -239,6 +255,13 @@
String body = message.getData().get(BODY_KEY);
String threadID = message.getData().get(THREAD_ID_KEY);
+ if (body == null) {
+ displayErrorMessageNotification(
+ "Empty notification body for notif id " + id,
+ "Empty notification body",
+ "Notification data: " + message.getData().toString());
+ }
+
if (prefix != null) {
body = prefix + " " + body;
}
@@ -319,4 +342,37 @@
message.getData().forEach(bundle::putString);
return bundle;
}
+
+ private void displayErrorMessageNotification(
+ String errorMessage,
+ String errorTitle,
+ String largeErrorData) {
+
+ NotificationCompat.Builder errorNotificationBuilder =
+ new NotificationCompat.Builder(this.getApplicationContext())
+ .setDefaults(Notification.DEFAULT_ALL)
+ .setChannelId(CHANNEL_ID)
+ .setSmallIcon(R.drawable.notif_icon)
+ .setLargeIcon(displayableNotificationLargeIcon);
+
+ if (errorMessage != null) {
+ errorNotificationBuilder =
+ errorNotificationBuilder.setContentText(errorMessage);
+ }
+
+ if (errorTitle != null) {
+ errorNotificationBuilder =
+ errorNotificationBuilder.setContentTitle(errorTitle);
+ }
+
+ if (largeErrorData != null) {
+ errorNotificationBuilder = errorNotificationBuilder.setStyle(
+ new NotificationCompat.BigTextStyle().bigText(largeErrorData));
+ }
+
+ notificationManager.notify(
+ errorMessage,
+ errorMessage.hashCode(),
+ errorNotificationBuilder.build());
+ }
}

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 17, 8:48 PM (21 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2531783
Default Alt Text
D8730.id29540.diff (3 KB)

Event Timeline