diff --git a/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceController.java b/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceController.java index 475e3a29b..96822fd71 100644 --- a/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceController.java +++ b/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceController.java @@ -366,7 +366,7 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc public boolean onPreferenceChange(Preference preference, Object o) { if (o instanceof String) { int newValue = Integer.valueOf((String) o) * 1024 * 1024; - if(newValue != UserPreferences.getImageCacheSize()) { + if (newValue != UserPreferences.getImageCacheSize()) { AlertDialog.Builder dialog = new AlertDialog.Builder(ui.getActivity()); dialog.setTitle(android.R.string.dialog_alert_title); dialog.setMessage(R.string.pref_restart_required); @@ -379,6 +379,7 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc } } ); + buildEpisodeCleanupPreference(); buildSmartMarkAsPlayedPreference(); buildAutodownloadSelectedNetworsPreference(); setSelectedNetworksEnabled(UserPreferences @@ -432,6 +433,26 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc return entries; } + private void buildEpisodeCleanupPreference() { + final Resources res = ui.getActivity().getResources(); + + ListPreference pref = (ListPreference) ui.findPreference(UserPreferences.PREF_EPISODE_CLEANUP); + String[] values = res.getStringArray( + R.array.episode_cleanup_values); + String[] entries = new String[values.length]; + for (int x = 0; x < values.length; x++) { + int v = Integer.parseInt(values[x]); + if (v == 0) { + entries[x] = res.getString(R.string.episode_cleanup_immediately); + } else if (v == -1){ + entries[x] = res.getString(R.string.episode_cleanup_never); + } else { + entries[x] = res.getQuantityString(R.plurals.time_days_quantified, v, v); + } + } + pref.setEntries(entries); + } + private void buildSmartMarkAsPlayedPreference() { final Resources res = ui.getActivity().getResources(); diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 30381162c..6f058b257 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -137,6 +137,15 @@ android:key="prefMobileUpdate" android:summary="@string/pref_mobileUpdate_sum" android:title="@string/pref_mobileUpdate_title"/> + + + 100 @string/pref_episode_cache_unlimited + 5 10 @@ -53,6 +54,24 @@ -1 + + @string/episode_cleanup_immediately + 1 + 3 + 5 + 7 + @string/episode_cleanup_never + + + + 0 + 1 + 3 + 5 + 7 + -1 + + 0.5 0.6 diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index ae1381de3..4feef0ecd 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -86,6 +86,8 @@ Always Never Send... + Never + when not in queue Feed URL @@ -266,6 +268,8 @@ Queue Services Flattr + Episode Cleanup + Episodes that aren\'t in the queue and aren\'t favorites should be eligible for removal if space is needed Pause playback when the headphones are disconnected Resume playback when the headphones are reconnected Jump to next queue item when playback completes @@ -417,6 +421,10 @@ %d hours + + 1 day + %d days + CATEGORIES TOP PODCASTS