getting preferences setup for different cleanup method

This commit is contained in:
Tom Hennen 2015-09-29 17:29:26 -04:00
parent 18e409523b
commit 057900bc1b
5 changed files with 61 additions and 1 deletions

View File

@ -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();

View File

@ -137,6 +137,15 @@
android:key="prefMobileUpdate"
android:summary="@string/pref_mobileUpdate_sum"
android:title="@string/pref_mobileUpdate_title"/>
<ListPreference
android:defaultValue="3"
android:entries="@array/episode_cleanup_entries"
android:key="prefEpisodeCleanup"
android:title="@string/pref_episode_cleanup_title"
android:summary="@string/pref_episode_cleanup_summary"
android:entryValues="@array/episode_cache_size_values"/>
<de.danoeh.antennapod.preferences.CustomEditTextPreference
android:defaultValue="6"
android:inputType="number"

View File

@ -67,6 +67,7 @@ public class UserPreferences {
// Network
public static final String PREF_UPDATE_INTERVAL = "prefAutoUpdateIntervall";
public static final String PREF_MOBILE_UPDATE = "prefMobileUpdate";
public static final String PREF_EPISODE_CLEANUP = "prefEpisodeCleanup";
public static final String PREF_PARALLEL_DOWNLOADS = "prefParallelDownloads";
public static final String PREF_EPISODE_CACHE_SIZE = "prefEpisodeCacheSize";
public static final String PREF_ENABLE_AUTODL = "prefEnableAutoDl";
@ -217,6 +218,8 @@ public class UserPreferences {
return prefs.getBoolean(PREF_FOLLOW_QUEUE, true);
}
public static int getEpisodeCleanupDays() { return Integer.valueOf(prefs.getString(PREF_EPISODE_CLEANUP, "3")); }
public static boolean shouldSkipRemoveFromQueue() { return prefs.getBoolean(PREF_SKIP_REMOVES, false); }
public static boolean isAutoDelete() {

View File

@ -44,6 +44,7 @@
<item>100</item>
<item>@string/pref_episode_cache_unlimited</item>
</string-array>
<string-array name="episode_cache_size_values">
<item>5</item>
<item>10</item>
@ -53,6 +54,24 @@
<item>-1</item>
</string-array>
<string-array name="episode_cleanup_entries">
<item>@string/episode_cleanup_immediately</item>
<item>1</item>
<item>3</item>
<item>5</item>
<item>7</item>
<item>@string/episode_cleanup_never</item>
</string-array>
<string-array name="episode_cleanup_values">
<item>0</item>
<item>1</item>
<item>3</item>
<item>5</item>
<item>7</item>
<item>-1</item>
</string-array>
<string-array name="playback_speed_values">
<item>0.5</item>
<item>0.6</item>

View File

@ -86,6 +86,8 @@
<string name="feed_auto_download_always">Always</string>
<string name="feed_auto_download_never">Never</string>
<string name="send_label">Send...</string>
<string name="episode_cleanup_never">Never</string>
<string name="episode_cleanup_immediately">when not in queue</string>
<!-- 'Add Feed' Activity labels -->
<string name="feedurl_label">Feed URL</string>
@ -266,6 +268,8 @@
<string name="queue_label">Queue</string>
<string name="services_label">Services</string>
<string name="flattr_label">Flattr</string>
<string name="pref_episode_cleanup_title">Episode Cleanup</string>
<string name="pref_episode_cleanup_summary">Episodes that aren\'t in the queue and aren\'t favorites should be eligible for removal if space is needed</string>
<string name="pref_pauseOnHeadsetDisconnect_sum">Pause playback when the headphones are disconnected</string>
<string name="pref_unpauseOnHeadsetReconnect_sum">Resume playback when the headphones are reconnected</string>
<string name="pref_followQueue_sum">Jump to next queue item when playback completes</string>
@ -417,6 +421,10 @@
<item quantity="other">%d hours</item>
</plurals>
<plurals name="time_days_quantified">
<item quantity="one">1 day</item>
<item quantity="other">%d days</item>
</plurals>
<!-- gpodder.net -->
<string name="gpodnet_taglist_header">CATEGORIES</string>
<string name="gpodnet_toplist_header">TOP PODCASTS</string>