From 7a42c388ce9363de0a7cc668fc098aebc23d0ce6 Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Thu, 13 Sep 2018 19:19:22 +0200 Subject: properly clear file adding notification if forground service channel is disabled --- .../java/de/pixart/messenger/services/NotificationService.java | 7 +++++++ .../java/de/pixart/messenger/services/XmppConnectionService.java | 1 + 2 files changed, 8 insertions(+) (limited to 'src/main/java/de/pixart/messenger/services') diff --git a/src/main/java/de/pixart/messenger/services/NotificationService.java b/src/main/java/de/pixart/messenger/services/NotificationService.java index fdf48258f..e37dc14f4 100644 --- a/src/main/java/de/pixart/messenger/services/NotificationService.java +++ b/src/main/java/de/pixart/messenger/services/NotificationService.java @@ -934,6 +934,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(VIDEOCOMPRESSION_CHANNEL_ID); } @@ -941,12 +942,17 @@ public class NotificationService { notify(FOREGROUND_NOTIFICATION_ID, notification); } + public void dismissForcedForegroundNotification() { + cancel(FOREGROUND_NOTIFICATION_ID); + } + public Notification exportLogsNotification() { Notification.Builder mBuilder = new Notification.Builder(mXmppConnectionService); mBuilder.setContentTitle(mXmppConnectionService.getString(R.string.app_name)); mBuilder.setContentText(mXmppConnectionService.getString(R.string.notification_export_logs_title)); mBuilder.setProgress(0, 0, true); mBuilder.setSmallIcon(R.drawable.ic_import_export_white_24dp); + mBuilder.setOngoing(true); if (Compatibility.twentySix()) { mBuilder.setChannelId(BACKUP_CHANNEL_ID); } @@ -964,6 +970,7 @@ public class NotificationService { mBuilder.setContentText(String.format(mXmppConnectionService.getString(R.string.update_available), version, filesize)); mBuilder.setSmallIcon(R.drawable.ic_update_notification); mBuilder.setContentIntent(intent); + mBuilder.setOngoing(true); if (Compatibility.twentySix()) { mBuilder.setChannelId(UPDATE_CHANNEL_ID); } diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index d9181aa95..01295c242 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -428,6 +428,7 @@ public class XmppConnectionService extends Service { public void stopForcingForegroundNotification() { mForceForegroundService.set(false); toggleForegroundService(); + mNotificationService.dismissForcedForegroundNotification(); } public boolean areMessagesInitialized() { -- cgit v1.2.3