Remove auto-download notification setting (#6625)
Also, add episode notifications to multi select options
This commit is contained in:
parent
e4df6222c2
commit
37c29a6372
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,11 @@
|
|||
android:menuCategory="container"
|
||||
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"
|
||||
|
|
|
@ -2,16 +2,6 @@
|
|||
<PreferenceScreen
|
||||
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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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";
|
||||
|
@ -289,18 +288,6 @@ public class UserPreferences {
|
|||
return prefs.getBoolean(PREF_PERSISTENT_NOTIFICATION, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
@ -308,31 +295,10 @@ public class UserPreferences {
|
|||
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
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
Loading…
Reference in New Issue