mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2025-01-31 02:44:53 +01:00
Migrate notification channel settings
This commit is contained in:
parent
151cccce66
commit
7ac4f18561
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user