From 90bf76e01314c8ec388a6b030a38a0ee56b48a79 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 20 Apr 2021 07:48:49 +0200 Subject: [PATCH 1/5] Support delete-multiple push notification Signed-off-by: Joas Schilling --- .../talk/services/firebase/MagicFirebaseMessagingService.kt | 4 ++++ .../java/com/nextcloud/talk/jobs/NotificationWorker.java | 4 ++++ .../talk/models/json/push/DecryptedPushMessage.java | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/app/src/gplay/java/com/nextcloud/talk/services/firebase/MagicFirebaseMessagingService.kt b/app/src/gplay/java/com/nextcloud/talk/services/firebase/MagicFirebaseMessagingService.kt index f94110196a..cecdd14d99 100644 --- a/app/src/gplay/java/com/nextcloud/talk/services/firebase/MagicFirebaseMessagingService.kt +++ b/app/src/gplay/java/com/nextcloud/talk/services/firebase/MagicFirebaseMessagingService.kt @@ -169,6 +169,10 @@ class MagicFirebaseMessagingService : FirebaseMessagingService() { ) } else if (deleteAll) { cancelAllNotificationsForAccount(applicationContext, signatureVerification!!.userEntity) + } else if (deleteMultiple) { + notificationIds.forEach { + cancelExistingNotificationWithId(applicationContext, signatureVerification!!.userEntity, it) + } } else if (type == "call") { val fullScreenIntent = Intent(applicationContext, MagicCallActivity::class.java) val bundle = Bundle() diff --git a/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.java b/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.java index 12362217c5..60ef8115f4 100644 --- a/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.java +++ b/app/src/main/java/com/nextcloud/talk/jobs/NotificationWorker.java @@ -586,6 +586,10 @@ public Result doWork() { NotificationUtils.INSTANCE.cancelExistingNotificationWithId(context, signatureVerification.getUserEntity(), decryptedPushMessage.getNotificationId()); } else if (decryptedPushMessage.isDeleteAll()) { NotificationUtils.INSTANCE.cancelAllNotificationsForAccount(context, signatureVerification.getUserEntity()); + } else if (decryptedPushMessage.isDeleteMultiple()) { + for (long notificationId : decryptedPushMessage.getNotificationIds()) { + NotificationUtils.INSTANCE.cancelExistingNotificationWithId(context, signatureVerification.getUserEntity(), notificationId); + } } else { credentials = ApiUtils.getCredentials(signatureVerification.getUserEntity().getUsername(), signatureVerification.getUserEntity().getToken()); diff --git a/app/src/main/java/com/nextcloud/talk/models/json/push/DecryptedPushMessage.java b/app/src/main/java/com/nextcloud/talk/models/json/push/DecryptedPushMessage.java index 245bde2028..8b7fe886b2 100644 --- a/app/src/main/java/com/nextcloud/talk/models/json/push/DecryptedPushMessage.java +++ b/app/src/main/java/com/nextcloud/talk/models/json/push/DecryptedPushMessage.java @@ -44,12 +44,18 @@ public class DecryptedPushMessage { @JsonField(name = "nid") public long notificationId; + @JsonField(name = "nids") + public long[] notificationIds; + @JsonField(name = "delete") public boolean delete; @JsonField(name = "delete-all") public boolean deleteAll; + @JsonField(name = "delete-multiple") + public boolean deleteMultiple; + @JsonIgnore public NotificationUser notificationUser; From 5c26a0c5a84bf70052fb1cda906de32934812f4d Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Wed, 21 Apr 2021 13:36:18 +0200 Subject: [PATCH 2/5] exclude JSON/Data classes for push content Signed-off-by: Andy Scherzinger --- spotbugs-filter.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spotbugs-filter.xml b/spotbugs-filter.xml index e9a5d30f4f..cb023898c6 100644 --- a/spotbugs-filter.xml +++ b/spotbugs-filter.xml @@ -33,6 +33,10 @@ + + + + From 712fdfeac4ea3a566daa6bbf130b61f786c7af15 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Fri, 30 Apr 2021 08:50:24 +0200 Subject: [PATCH 3/5] adapt to de-lomboked code-base Signed-off-by: Andy Scherzinger --- .../models/json/push/DecryptedPushMessage.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/src/main/java/com/nextcloud/talk/models/json/push/DecryptedPushMessage.java b/app/src/main/java/com/nextcloud/talk/models/json/push/DecryptedPushMessage.java index 8b7fe886b2..1f34989500 100644 --- a/app/src/main/java/com/nextcloud/talk/models/json/push/DecryptedPushMessage.java +++ b/app/src/main/java/com/nextcloud/talk/models/json/push/DecryptedPushMessage.java @@ -105,6 +105,14 @@ public long getTimestamp() { return this.timestamp; } + public long[] getNotificationIds() { + return notificationIds; + } + + public boolean isDeleteMultiple() { + return deleteMultiple; + } + public void setApp(String app) { this.app = app; } @@ -145,6 +153,14 @@ public void setTimestamp(long timestamp) { this.timestamp = timestamp; } + public void setNotificationIds(long[] notificationIds) { + this.notificationIds = notificationIds; + } + + public void setDeleteMultiple(boolean deleteMultiple) { + this.deleteMultiple = deleteMultiple; + } + public boolean equals(final Object o) { if (o == this) { return true; From 97e748b3c1006a2bb11554bb13aec22bb10185e5 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Fri, 30 Apr 2021 08:56:45 +0200 Subject: [PATCH 4/5] reformat to 120 line length Signed-off-by: Andy Scherzinger --- .../firebase/MagicFirebaseMessagingService.kt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/src/gplay/java/com/nextcloud/talk/services/firebase/MagicFirebaseMessagingService.kt b/app/src/gplay/java/com/nextcloud/talk/services/firebase/MagicFirebaseMessagingService.kt index cecdd14d99..f966235f53 100644 --- a/app/src/gplay/java/com/nextcloud/talk/services/firebase/MagicFirebaseMessagingService.kt +++ b/app/src/gplay/java/com/nextcloud/talk/services/firebase/MagicFirebaseMessagingService.kt @@ -171,7 +171,11 @@ class MagicFirebaseMessagingService : FirebaseMessagingService() { cancelAllNotificationsForAccount(applicationContext, signatureVerification!!.userEntity) } else if (deleteMultiple) { notificationIds.forEach { - cancelExistingNotificationWithId(applicationContext, signatureVerification!!.userEntity, it) + cancelExistingNotificationWithId( + applicationContext, + signatureVerification!!.userEntity, + it + ) } } else if (type == "call") { val fullScreenIntent = Intent(applicationContext, MagicCallActivity::class.java) @@ -205,7 +209,11 @@ class MagicFirebaseMessagingService : FirebaseMessagingService() { LoganSquare.parse(ringtonePreferencesString, RingtoneSettings::class.java) ringtoneSettings.ringtoneUri } catch (exception: IOException) { - Uri.parse("android.resource://" + applicationContext.packageName + "/raw/librem_by_feandesign_call") + Uri.parse( + "android.resource://" + + applicationContext.packageName + + "/raw/librem_by_feandesign_call" + ) } } From c81a272d220f7ee33a64e3f6326971e1a4a54dce Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Fri, 30 Apr 2021 09:13:28 +0200 Subject: [PATCH 5/5] Drone: update FindBugs results to reflect reduced error/warning count [skip ci] Signed-off-by: Andy Scherzinger --- scripts/analysis/findbugs-results.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/analysis/findbugs-results.txt b/scripts/analysis/findbugs-results.txt index 9889789bab..e1170b6414 100644 --- a/scripts/analysis/findbugs-results.txt +++ b/scripts/analysis/findbugs-results.txt @@ -1 +1 @@ -499 \ No newline at end of file +489 \ No newline at end of file