diff options
Diffstat (limited to 'core/src/main/java')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java | 21 | ||||
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/util/gui/NotificationUtils.java | 18 |
2 files changed, 38 insertions, 1 deletions
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 5ded1d447..ed9c519a6 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 @@ -307,6 +307,13 @@ public class UserPreferences { return prefs.getBoolean(PREF_SHOW_DOWNLOAD_REPORT, true); } + /** + * Used for migration of the preference to system notification channels. + */ + public static boolean getShowDownloadReportRaw() { + return prefs.getBoolean(PREF_SHOW_DOWNLOAD_REPORT, true); + } + public static boolean showAutoDownloadReport() { if (Build.VERSION.SDK_INT >= 26) { return true; // System handles notification preferences @@ -314,6 +321,13 @@ public class UserPreferences { return prefs.getBoolean(PREF_SHOW_AUTO_DOWNLOAD_REPORT, false); } + /** + * Used for migration of the preference to system notification channels. + */ + public static boolean getShowAutoDownloadReportRaw() { + return prefs.getBoolean(PREF_SHOW_AUTO_DOWNLOAD_REPORT, false); + } + public static boolean enqueueDownloadedEpisodes() { return prefs.getBoolean(PREF_ENQUEUE_DOWNLOADED, true); } @@ -740,6 +754,13 @@ public class UserPreferences { return prefs.getBoolean(PREF_GPODNET_NOTIFICATIONS, true); } + /** + * Used for migration of the preference to system notification channels. + */ + public static boolean getGpodnetNotificationsEnabledRaw() { + return prefs.getBoolean(PREF_GPODNET_NOTIFICATIONS, true); + } + public static void setGpodnetNotificationsEnabled() { prefs.edit() .putBoolean(PREF_GPODNET_NOTIFICATIONS, true) 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 168350b34..3101eac34 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 @@ -9,6 +9,7 @@ import android.os.Build; import androidx.annotation.RequiresApi; import de.danoeh.antennapod.core.R; +import de.danoeh.antennapod.core.preferences.UserPreferences; public class NotificationUtils { public static final String CHANNEL_ID_USER_ACTION = "user_action"; @@ -73,6 +74,11 @@ public class NotificationUtils { c.getString(R.string.notification_channel_download_error), NotificationManager.IMPORTANCE_HIGH); notificationChannel.setDescription(c.getString(R.string.notification_channel_download_error_description)); notificationChannel.setGroup(GROUP_ID_ERRORS); + + if (!UserPreferences.getShowDownloadReportRaw()) { + // Migration from app managed setting: disable notification + notificationChannel.setImportance(NotificationManager.IMPORTANCE_NONE); + } return notificationChannel; } @@ -82,15 +88,25 @@ public class NotificationUtils { c.getString(R.string.notification_channel_sync_error), NotificationManager.IMPORTANCE_HIGH); notificationChannel.setDescription(c.getString(R.string.notification_channel_sync_error_description)); notificationChannel.setGroup(GROUP_ID_ERRORS); + + if (!UserPreferences.getGpodnetNotificationsEnabledRaw()) { + // Migration from app managed setting: disable notification + notificationChannel.setImportance(NotificationManager.IMPORTANCE_NONE); + } return notificationChannel; } @RequiresApi(api = Build.VERSION_CODES.O) private static NotificationChannel createChannelAutoDownload(Context c) { NotificationChannel notificationChannel = new NotificationChannel(CHANNEL_ID_AUTO_DOWNLOAD, - c.getString(R.string.notification_channel_auto_download), NotificationManager.IMPORTANCE_DEFAULT); + c.getString(R.string.notification_channel_auto_download), NotificationManager.IMPORTANCE_NONE); notificationChannel.setDescription(c.getString(R.string.notification_channel_episode_auto_download)); notificationChannel.setGroup(GROUP_ID_NEWS); + + if (UserPreferences.getShowAutoDownloadReportRaw()) { + // Migration from app managed setting: enable notification + notificationChannel.setImportance(NotificationManager.IMPORTANCE_DEFAULT); + } return notificationChannel; } |