From 151cccce666d7eca4026bd90c64243c0afa92380 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Thu, 29 Oct 2020 20:21:43 +0100 Subject: Use system's notification settings on supported devices --- .../de/danoeh/antennapod/core/preferences/UserPreferences.java | 9 +++++++++ .../main/java/de/danoeh/antennapod/core/sync/SyncService.java | 6 +++++- .../de/danoeh/antennapod/core/util/gui/NotificationUtils.java | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) (limited to 'core/src/main/java/de') diff --git a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java index 56dd95fe6..5ded1d447 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java +++ b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java @@ -301,10 +301,16 @@ public class UserPreferences { * @return {@code true} if download reports are shown, {@code false} otherwise */ public static boolean showDownloadReport() { + if (Build.VERSION.SDK_INT >= 26) { + return true; // System handles notification preferences + } return prefs.getBoolean(PREF_SHOW_DOWNLOAD_REPORT, true); } public static boolean showAutoDownloadReport() { + if (Build.VERSION.SDK_INT >= 26) { + return true; // System handles notification preferences + } return prefs.getBoolean(PREF_SHOW_AUTO_DOWNLOAD_REPORT, false); } @@ -728,6 +734,9 @@ public class UserPreferences { } public static boolean gpodnetNotificationsEnabled() { + if (Build.VERSION.SDK_INT >= 26) { + return true; // System handles notification preferences + } return prefs.getBoolean(PREF_GPODNET_NOTIFICATIONS, true); } diff --git a/core/src/main/java/de/danoeh/antennapod/core/sync/SyncService.java b/core/src/main/java/de/danoeh/antennapod/core/sync/SyncService.java index 1f5d9b75f..ffe90eee2 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/sync/SyncService.java +++ b/core/src/main/java/de/danoeh/antennapod/core/sync/SyncService.java @@ -485,7 +485,11 @@ public class SyncService extends Worker { } private void updateErrorNotification(SyncServiceException exception) { - Log.d(TAG, "Posting error notification"); + if (!UserPreferences.gpodnetNotificationsEnabled()) { + Log.d(TAG, "Skipping sync error notification because of user setting"); + return; + } + Log.d(TAG, "Posting sync error notification"); final String description = getApplicationContext().getString(R.string.gpodnetsync_error_descr) + exception.getMessage(); diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/gui/NotificationUtils.java b/core/src/main/java/de/danoeh/antennapod/core/util/gui/NotificationUtils.java index 47975b013..168350b34 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/gui/NotificationUtils.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/gui/NotificationUtils.java @@ -22,7 +22,7 @@ public class NotificationUtils { public static final String GROUP_ID_NEWS = "group_news"; public static void createChannels(Context context) { - if (android.os.Build.VERSION.SDK_INT < 26) { + if (Build.VERSION.SDK_INT < 26) { return; } NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); -- cgit v1.2.3