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) {
|
public void handleAction(int id) {
|
||||||
if (id == R.id.remove_feed) {
|
if (id == R.id.remove_feed) {
|
||||||
RemoveFeedDialog.show(activity, selectedItems);
|
RemoveFeedDialog.show(activity, selectedItems);
|
||||||
|
} else if (id == R.id.notify_new_episodes) {
|
||||||
|
notifyNewEpisodesPrefHandler();
|
||||||
} else if (id == R.id.keep_updated) {
|
} else if (id == R.id.keep_updated) {
|
||||||
keepUpdatedPrefHandler();
|
keepUpdatedPrefHandler();
|
||||||
} else if (id == R.id.autodownload) {
|
} 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() {
|
private void autoDownloadPrefHandler() {
|
||||||
PreferenceSwitchDialog preferenceSwitchDialog = new PreferenceSwitchDialog(activity,
|
PreferenceSwitchDialog preferenceSwitchDialog = new PreferenceSwitchDialog(activity,
|
||||||
activity.getString(R.string.auto_download_settings_label),
|
activity.getString(R.string.auto_download_settings_label),
|
||||||
activity.getString(R.string.auto_download_label));
|
activity.getString(R.string.auto_download_label));
|
||||||
preferenceSwitchDialog.setOnPreferenceChangedListener(new PreferenceSwitchDialog.OnPreferenceChangedListener() {
|
preferenceSwitchDialog.setOnPreferenceChangedListener(enabled ->
|
||||||
@Override
|
saveFeedPreferences(feedPreferences -> feedPreferences.setAutoDownload(enabled)));
|
||||||
public void preferenceChanged(boolean enabled) {
|
|
||||||
saveFeedPreferences(feedPreferences -> feedPreferences.setAutoDownload(enabled));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
preferenceSwitchDialog.openDialog();
|
preferenceSwitchDialog.openDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,11 +109,8 @@ public class FeedMultiSelectActionHandler {
|
|||||||
PreferenceSwitchDialog preferenceSwitchDialog = new PreferenceSwitchDialog(activity,
|
PreferenceSwitchDialog preferenceSwitchDialog = new PreferenceSwitchDialog(activity,
|
||||||
activity.getString(R.string.kept_updated),
|
activity.getString(R.string.kept_updated),
|
||||||
activity.getString(R.string.keep_updated_summary));
|
activity.getString(R.string.keep_updated_summary));
|
||||||
preferenceSwitchDialog.setOnPreferenceChangedListener(keepUpdated -> {
|
preferenceSwitchDialog.setOnPreferenceChangedListener(keepUpdated ->
|
||||||
saveFeedPreferences(feedPreferences -> {
|
saveFeedPreferences(feedPreferences -> feedPreferences.setKeepUpdated(keepUpdated)));
|
||||||
feedPreferences.setKeepUpdated(keepUpdated);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
preferenceSwitchDialog.openDialog();
|
preferenceSwitchDialog.openDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package de.danoeh.antennapod.preferences;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
|
import androidx.core.app.NotificationManagerCompat;
|
||||||
import androidx.preference.PreferenceManager;
|
import androidx.preference.PreferenceManager;
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@ -145,5 +146,8 @@ public class PreferenceUpgrader {
|
|||||||
prefs.edit().putString(UserPreferences.PREF_UPDATE_INTERVAL, "12").apply();
|
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:menuCategory="container"
|
||||||
android:title="@string/keep_updated"
|
android:title="@string/keep_updated"
|
||||||
android:icon="@drawable/ic_refresh"/>
|
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
|
<item
|
||||||
android:id="@+id/autodownload"
|
android:id="@+id/autodownload"
|
||||||
android:menuCategory="container"
|
android:menuCategory="container"
|
||||||
|
@ -2,16 +2,6 @@
|
|||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
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
|
<PreferenceCategory
|
||||||
android:title="@string/notification_group_errors">
|
android:title="@string/notification_group_errors">
|
||||||
<SwitchPreferenceCompat
|
<SwitchPreferenceCompat
|
||||||
|
@ -18,7 +18,6 @@ public class NotificationUtils {
|
|||||||
public static final String CHANNEL_ID_PLAYING = "playing";
|
public static final String CHANNEL_ID_PLAYING = "playing";
|
||||||
public static final String CHANNEL_ID_DOWNLOAD_ERROR = "error";
|
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_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 CHANNEL_ID_EPISODE_NOTIFICATIONS = "episode_notifications";
|
||||||
|
|
||||||
public static final String GROUP_ID_ERRORS = "group_errors";
|
public static final String GROUP_ID_ERRORS = "group_errors";
|
||||||
@ -38,7 +37,6 @@ public class NotificationUtils {
|
|||||||
createChannelPlaying(context),
|
createChannelPlaying(context),
|
||||||
createChannelError(context),
|
createChannelError(context),
|
||||||
createChannelSyncError(context),
|
createChannelSyncError(context),
|
||||||
createChannelAutoDownload(context),
|
|
||||||
createChannelEpisodeNotification(context));
|
createChannelEpisodeNotification(context));
|
||||||
mNotificationManager.createNotificationChannelsCompat(channels);
|
mNotificationManager.createNotificationChannelsCompat(channels);
|
||||||
}
|
}
|
||||||
@ -98,20 +96,6 @@ public class NotificationUtils {
|
|||||||
return notificationChannel.build();
|
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) {
|
private static NotificationChannelCompat createChannelEpisodeNotification(final Context c) {
|
||||||
return new NotificationChannelCompat.Builder(
|
return new NotificationChannelCompat.Builder(
|
||||||
CHANNEL_ID_EPISODE_NOTIFICATIONS, NotificationManagerCompat.IMPORTANCE_DEFAULT)
|
CHANNEL_ID_EPISODE_NOTIFICATIONS, NotificationManagerCompat.IMPORTANCE_DEFAULT)
|
||||||
|
@ -56,7 +56,6 @@ public class UserPreferences {
|
|||||||
private static final String PREF_PERSISTENT_NOTIFICATION = "prefPersistNotify";
|
private static final String PREF_PERSISTENT_NOTIFICATION = "prefPersistNotify";
|
||||||
public static final String PREF_COMPACT_NOTIFICATION_BUTTONS = "prefCompactNotificationButtons";
|
public static final String PREF_COMPACT_NOTIFICATION_BUTTONS = "prefCompactNotificationButtons";
|
||||||
private static final String PREF_SHOW_DOWNLOAD_REPORT = "prefShowDownloadReport";
|
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_DEFAULT_PAGE = "prefDefaultPage";
|
||||||
public static final String PREF_FILTER_FEED = "prefSubscriptionsFilter";
|
public static final String PREF_FILTER_FEED = "prefSubscriptionsFilter";
|
||||||
public static final String PREF_SUBSCRIPTION_TITLE = "prefSubscriptionTitle";
|
public static final String PREF_SUBSCRIPTION_TITLE = "prefSubscriptionTitle";
|
||||||
@ -289,18 +288,6 @@ public class UserPreferences {
|
|||||||
return prefs.getBoolean(PREF_PERSISTENT_NOTIFICATION, true);
|
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.
|
* 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);
|
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() {
|
public static boolean enqueueDownloadedEpisodes() {
|
||||||
return prefs.getBoolean(PREF_ENQUEUE_DOWNLOADED, true);
|
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 {
|
public enum EnqueueLocation {
|
||||||
BACK, FRONT, AFTER_CURRENTLY_PLAYING, RANDOM
|
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_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">Synchronization failed</string>
|
||||||
<string name="notification_channel_sync_error_description">Shown when gpodder synchronization fails.</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">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>
|
<string name="notification_channel_new_episode_description">Shown when a new episode of a podcast was found, where notifications are enabled</string>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user