From ac7f0032afa8a408af98984f50a120e4567d21e7 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 6 Sep 2018 22:05:15 +0200 Subject: [PATCH] properly clear file adding notification if forground service channel is disabled --- .../eu/siacs/conversations/services/NotificationService.java | 5 +++++ .../siacs/conversations/services/XmppConnectionService.java | 1 + 2 files changed, 6 insertions(+) diff --git a/src/main/java/eu/siacs/conversations/services/NotificationService.java b/src/main/java/eu/siacs/conversations/services/NotificationService.java index 677dfd4d2..6d4dd7c3f 100644 --- a/src/main/java/eu/siacs/conversations/services/NotificationService.java +++ b/src/main/java/eu/siacs/conversations/services/NotificationService.java @@ -883,6 +883,7 @@ public class NotificationService { mBuilder.setProgress(100, current, false); mBuilder.setSmallIcon(R.drawable.ic_hourglass_empty_white_24dp); mBuilder.setContentIntent(createContentIntent(message.getConversation())); + mBuilder.setOngoing(true); if (Compatibility.twentySix()) { mBuilder.setChannelId("compression"); } @@ -890,6 +891,10 @@ public class NotificationService { notify(FOREGROUND_NOTIFICATION_ID, notification); } + public void dismissForcedForegroundNotification() { + cancel(FOREGROUND_NOTIFICATION_ID); + } + private void notify(String tag, int id, Notification notification) { final NotificationManagerCompat notificationManager = NotificationManagerCompat.from(mXmppConnectionService); try { diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 86f212066..04a29067d 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -407,6 +407,7 @@ public class XmppConnectionService extends Service { public void stopForcingForegroundNotification() { mForceForegroundService.set(false); toggleForegroundService(); + mNotificationService.dismissForcedForegroundNotification(); } public boolean areMessagesInitialized() {