diff options
7 files changed, 24 insertions, 73 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/actions/FeedMultiSelectActionHandler.java b/app/src/main/java/de/danoeh/antennapod/fragment/actions/FeedMultiSelectActionHandler.java index bbe78f4a2..78ddccf0b 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/actions/FeedMultiSelectActionHandler.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/actions/FeedMultiSelectActionHandler.java @@ -36,6 +36,8 @@ public class FeedMultiSelectActionHandler { public void handleAction(int id) { if (id == R.id.remove_feed) { RemoveFeedDialog.show(activity, selectedItems); + } else if (id == R.id.notify_new_episodes) { + notifyNewEpisodesPrefHandler(); } else if (id == R.id.keep_updated) { keepUpdatedPrefHandler(); } else if (id == R.id.autodownload) { @@ -51,16 +53,21 @@ public class FeedMultiSelectActionHandler { } } + private void notifyNewEpisodesPrefHandler() { + PreferenceSwitchDialog preferenceSwitchDialog = new PreferenceSwitchDialog(activity, + activity.getString(R.string.episode_notification), + activity.getString(R.string.episode_notification_summary)); + preferenceSwitchDialog.setOnPreferenceChangedListener(enabled -> + saveFeedPreferences(feedPreferences -> feedPreferences.setShowEpisodeNotification(enabled))); + preferenceSwitchDialog.openDialog(); + } + private void autoDownloadPrefHandler() { PreferenceSwitchDialog preferenceSwitchDialog = new PreferenceSwitchDialog(activity, activity.getString(R.string.auto_download_settings_label), activity.getString(R.string.auto_download_label)); - preferenceSwitchDialog.setOnPreferenceChangedListener(new PreferenceSwitchDialog.OnPreferenceChangedListener() { - @Override - public void preferenceChanged(boolean enabled) { - saveFeedPreferences(feedPreferences -> feedPreferences.setAutoDownload(enabled)); - } - }); + preferenceSwitchDialog.setOnPreferenceChangedListener(enabled -> + saveFeedPreferences(feedPreferences -> feedPreferences.setAutoDownload(enabled))); preferenceSwitchDialog.openDialog(); } @@ -102,11 +109,8 @@ public class FeedMultiSelectActionHandler { PreferenceSwitchDialog preferenceSwitchDialog = new PreferenceSwitchDialog(activity, activity.getString(R.string.kept_updated), activity.getString(R.string.keep_updated_summary)); - preferenceSwitchDialog.setOnPreferenceChangedListener(keepUpdated -> { - saveFeedPreferences(feedPreferences -> { - feedPreferences.setKeepUpdated(keepUpdated); - }); - }); + preferenceSwitchDialog.setOnPreferenceChangedListener(keepUpdated -> + saveFeedPreferences(feedPreferences -> feedPreferences.setKeepUpdated(keepUpdated))); preferenceSwitchDialog.openDialog(); } diff --git a/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceUpgrader.java b/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceUpgrader.java index 275e9a279..cc298b38d 100644 --- a/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceUpgrader.java +++ b/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceUpgrader.java @@ -3,6 +3,7 @@ package de.danoeh.antennapod.preferences; import android.content.Context; import android.content.SharedPreferences; import android.view.KeyEvent; +import androidx.core.app.NotificationManagerCompat; import androidx.preference.PreferenceManager; import java.util.concurrent.TimeUnit; @@ -145,5 +146,8 @@ public class PreferenceUpgrader { prefs.edit().putString(UserPreferences.PREF_UPDATE_INTERVAL, "12").apply(); } } + if (oldVersion < 3020000) { + NotificationManagerCompat.from(context).deleteNotificationChannel("auto_download"); + } } } diff --git a/app/src/main/res/menu/nav_feed_action_speeddial.xml b/app/src/main/res/menu/nav_feed_action_speeddial.xml index 15f2511fb..250d12bc2 100644 --- a/app/src/main/res/menu/nav_feed_action_speeddial.xml +++ b/app/src/main/res/menu/nav_feed_action_speeddial.xml @@ -11,6 +11,11 @@ android:title="@string/keep_updated" android:icon="@drawable/ic_refresh"/> <item + android:id="@+id/notify_new_episodes" + android:menuCategory="container" + android:title="@string/episode_notification" + android:icon="@drawable/ic_notifications"/> + <item android:id="@+id/autodownload" android:menuCategory="container" android:title="@string/auto_download_label" diff --git a/app/src/main/res/xml/preferences_notifications.xml b/app/src/main/res/xml/preferences_notifications.xml index 237ea5c99..34d327340 100644 --- a/app/src/main/res/xml/preferences_notifications.xml +++ b/app/src/main/res/xml/preferences_notifications.xml @@ -3,16 +3,6 @@ xmlns:android="http://schemas.android.com/apk/res/android"> <PreferenceCategory - android:title="@string/notification_group_news"> - <SwitchPreferenceCompat - android:defaultValue="false" - android:enabled="true" - android:key="prefShowAutoDownloadReport" - android:summary="@string/notification_channel_episode_auto_download" - android:title="@string/notification_channel_auto_download" /> - </PreferenceCategory> - - <PreferenceCategory android:title="@string/notification_group_errors"> <SwitchPreferenceCompat android:defaultValue="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 79732ff32..d870cb1f8 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 @@ -18,7 +18,6 @@ public class NotificationUtils { public static final String CHANNEL_ID_PLAYING = "playing"; public static final String CHANNEL_ID_DOWNLOAD_ERROR = "error"; public static final String CHANNEL_ID_SYNC_ERROR = "sync_error"; - public static final String CHANNEL_ID_AUTO_DOWNLOAD = "auto_download"; public static final String CHANNEL_ID_EPISODE_NOTIFICATIONS = "episode_notifications"; public static final String GROUP_ID_ERRORS = "group_errors"; @@ -38,7 +37,6 @@ public class NotificationUtils { createChannelPlaying(context), createChannelError(context), createChannelSyncError(context), - createChannelAutoDownload(context), createChannelEpisodeNotification(context)); mNotificationManager.createNotificationChannelsCompat(channels); } @@ -98,20 +96,6 @@ public class NotificationUtils { return notificationChannel.build(); } - private static NotificationChannelCompat createChannelAutoDownload(final Context c) { - final NotificationChannelCompat.Builder notificationChannel = new NotificationChannelCompat.Builder( - CHANNEL_ID_AUTO_DOWNLOAD, NotificationManagerCompat.IMPORTANCE_NONE) - .setName(c.getString(R.string.notification_channel_auto_download)) - .setDescription(c.getString(R.string.notification_channel_episode_auto_download)) - .setGroup(GROUP_ID_NEWS); - - if (UserPreferences.getShowAutoDownloadReportRaw()) { - // Migration from app managed setting: enable notification - notificationChannel.setImportance(NotificationManagerCompat.IMPORTANCE_DEFAULT); - } - return notificationChannel.build(); - } - private static NotificationChannelCompat createChannelEpisodeNotification(final Context c) { return new NotificationChannelCompat.Builder( CHANNEL_ID_EPISODE_NOTIFICATIONS, NotificationManagerCompat.IMPORTANCE_DEFAULT) diff --git a/storage/preferences/src/main/java/de/danoeh/antennapod/storage/preferences/UserPreferences.java b/storage/preferences/src/main/java/de/danoeh/antennapod/storage/preferences/UserPreferences.java index f2b122fcc..c8ad3eec5 100644 --- a/storage/preferences/src/main/java/de/danoeh/antennapod/storage/preferences/UserPreferences.java +++ b/storage/preferences/src/main/java/de/danoeh/antennapod/storage/preferences/UserPreferences.java @@ -56,7 +56,6 @@ public class UserPreferences { private static final String PREF_PERSISTENT_NOTIFICATION = "prefPersistNotify"; public static final String PREF_COMPACT_NOTIFICATION_BUTTONS = "prefCompactNotificationButtons"; private static final String PREF_SHOW_DOWNLOAD_REPORT = "prefShowDownloadReport"; - private static final String PREF_SHOW_AUTO_DOWNLOAD_REPORT = "prefShowAutoDownloadReport"; public static final String PREF_DEFAULT_PAGE = "prefDefaultPage"; public static final String PREF_FILTER_FEED = "prefSubscriptionsFilter"; public static final String PREF_SUBSCRIPTION_TITLE = "prefSubscriptionTitle"; @@ -290,49 +289,16 @@ public class UserPreferences { } /** - * Returns true if download reports are shown - * - * @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); - } - - /** * 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 - } - 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); } - @VisibleForTesting - public static void setEnqueueDownloadedEpisodes(boolean enqueueDownloadedEpisodes) { - prefs.edit() - .putBoolean(PREF_ENQUEUE_DOWNLOADED, enqueueDownloadedEpisodes) - .apply(); - } - public enum EnqueueLocation { BACK, FRONT, AFTER_CURRENTLY_PLAYING, RANDOM } diff --git a/ui/i18n/src/main/res/values/strings.xml b/ui/i18n/src/main/res/values/strings.xml index baed14c55..37ab9f0f7 100644 --- a/ui/i18n/src/main/res/values/strings.xml +++ b/ui/i18n/src/main/res/values/strings.xml @@ -815,8 +815,6 @@ <string name="notification_channel_download_error_description">Shown when download or feed update fails.</string> <string name="notification_channel_sync_error">Synchronization failed</string> <string name="notification_channel_sync_error_description">Shown when gpodder synchronization fails.</string> - <string name="notification_channel_auto_download">Automatic download completed</string> - <string name="notification_channel_episode_auto_download">Shown when episodes have been automatically downloaded.</string> <string name="notification_channel_new_episode">New episode</string> <string name="notification_channel_new_episode_description">Shown when a new episode of a podcast was found, where notifications are enabled</string> |