Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3380076
D4237.id13603.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D4237.id13603.diff
View Options
diff --git a/native/android/app/src/main/java/app/comm/android/CommNotificationsHandler.java b/native/android/app/src/main/java/app/comm/android/CommNotificationsHandler.java
--- a/native/android/app/src/main/java/app/comm/android/CommNotificationsHandler.java
+++ b/native/android/app/src/main/java/app/comm/android/CommNotificationsHandler.java
@@ -4,9 +4,13 @@
import android.content.Context;
import android.service.notification.StatusBarNotification;
import android.util.Log;
+import app.comm.android.fbjni.CommSecureStore;
import app.comm.android.fbjni.NetworkModule;
+import app.comm.android.fbjni.ThreadOperations;
import com.google.firebase.messaging.RemoteMessage;
+import expo.modules.securestore.SecureStoreModule;
import io.invertase.firebase.messaging.RNFirebaseMessagingService;
+import java.io.File;
import me.leolin.shortcutbadger.ShortcutBadger;
/**
@@ -40,11 +44,15 @@
private static final String BADGE_KEY = "badge";
private static final String BADGE_ONLY_KEY = "badgeOnly";
private static final String BACKGROUND_NOTIF_TYPE_KEY = "backgroundNotifType";
+ private static final String THREAD_ID_KEY = "threadID";
+ private static final String SET_UNREAD_STATUS_KEY = "setUnreadStatus";
private NotificationManager notificationManager;
@Override
public void onCreate() {
super.onCreate();
+ CommSecureStore.getInstance().initialize(
+ () -> new SecureStoreModule(this.getApplicationContext()));
notificationManager = (NotificationManager)this.getSystemService(
Context.NOTIFICATION_SERVICE);
}
@@ -52,16 +60,9 @@
@Override
public void onMessageReceived(RemoteMessage message) {
String rescind = message.getData().get(RESCIND_KEY);
- String rescindID = message.getData().get(RESCIND_ID_KEY);
if ("true".equals(rescind) &&
android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
- for (StatusBarNotification notification :
- notificationManager.getActiveNotifications()) {
- if (notification.getTag().equals(rescindID)) {
- notificationManager.cancel(
- notification.getTag(), notification.getId());
- }
- }
+ handleNotificationRescind(message);
}
String badge = message.getData().get(BADGE_KEY);
@@ -92,4 +93,28 @@
super.onMessageReceived(message);
}
+
+ private void handleNotificationRescind(RemoteMessage message) {
+ String setUnreadStatus = message.getData().get(SET_UNREAD_STATUS_KEY);
+ if ("true".equals(setUnreadStatus)) {
+ File sqliteFile =
+ this.getApplicationContext().getDatabasePath("comm.sqlite");
+ if (sqliteFile.exists()) {
+ String threadID = message.getData().get(THREAD_ID_KEY);
+ ThreadOperations.updateSQLiteUnreadStatus(
+ sqliteFile.getPath(), threadID, false);
+ } else {
+ Log.w(
+ "COMM",
+ "Database not existing yet. Skipping thread status update.");
+ }
+ }
+ String rescindID = message.getData().get(RESCIND_ID_KEY);
+ for (StatusBarNotification notification :
+ notificationManager.getActiveNotifications()) {
+ if (notification.getTag().equals(rescindID)) {
+ notificationManager.cancel(notification.getTag(), notification.getId());
+ }
+ }
+ }
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 28, 8:53 PM (20 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2594601
Default Alt Text
D4237.id13603.diff (3 KB)
Attached To
Mode
D4237: Update thread unread status from CommNotificationsHandler on Android
Attached
Detach File
Event Timeline
Log In to Comment