diff options
-rw-r--r-- | res/values/arrays.xml | 9 | ||||
-rw-r--r-- | res/values/strings.xml | 1 | ||||
-rw-r--r-- | res/xml/preferences.xml | 3 | ||||
-rw-r--r-- | src/de/danoeh/antennapod/activity/PreferenceActivity.java | 21 | ||||
-rw-r--r-- | src/de/danoeh/antennapod/preferences/UserPreferences.java | 15 |
5 files changed, 47 insertions, 2 deletions
diff --git a/res/values/arrays.xml b/res/values/arrays.xml index 6b9650469..aebc74b33 100644 --- a/res/values/arrays.xml +++ b/res/values/arrays.xml @@ -21,6 +21,15 @@ <item>24</item> </string-array> + <string-array name="episode_cache_size"> + <item>10</item> + <item>20</item> + <item>40</item> + <item>60</item> + <item>80</item> + <item>100</item> + </string-array> + <string-array name="autodl_select_networks_default_entries"> <item>N/A</item> </string-array> diff --git a/res/values/strings.xml b/res/values/strings.xml index ebd2dfcd8..367a91916 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -177,6 +177,7 @@ <string name="pref_automatic_download_sum">Configure the automatic download of episodes.</string> <string name="pref_autodl_wifi_filter_title">Enable Wi-Fi filter</string> <string name="pref_autodl_wifi_filter_sum">Allow automatic download only for selected Wi-Fi networks.</string> + <string name="pref_episode_cache_title">Episode cache</string> <!-- Search --> <string name="search_hint">Search for Feeds or Episodes</string> diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml index ebc020fe5..7f2a4d4bb 100644 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@ -35,9 +35,10 @@ android:summary="@string/pref_mobileUpdate_sum" android:title="@string/pref_mobileUpdate_title" /> <CheckBoxPreference android:summary="@string/pref_autoQueue_sum" android:defaultValue="true" android:key="prefAutoQueue" android:title="@string/pref_autoQueue_title"/> - <PreferenceScreen android:summary="@string/pref_automatic_download_sum" android:key="prefAutoDownloadSettings" android:title="@string/pref_automatic_download_title"> + <ListPreference android:defaultValue="20" android:entries="@array/episode_cache_size" android:key="prefEpisodeCacheSize" android:title="@string/pref_episode_cache_title" android:entryValues="@array/episode_cache_size"/><PreferenceScreen android:summary="@string/pref_automatic_download_sum" android:key="prefAutoDownloadSettings" android:title="@string/pref_automatic_download_title"> <CheckBoxPreference android:key="prefEnableAutoDownloadWifiFilter" android:title="@string/pref_autodl_wifi_filter_title" android:summary="@string/pref_autodl_wifi_filter_sum"/> </PreferenceScreen> + </PreferenceCategory> <PreferenceCategory android:title="@string/flattr_settings_label" > <PreferenceScreen diff --git a/src/de/danoeh/antennapod/activity/PreferenceActivity.java b/src/de/danoeh/antennapod/activity/PreferenceActivity.java index 7df0c17bd..6bad316a6 100644 --- a/src/de/danoeh/antennapod/activity/PreferenceActivity.java +++ b/src/de/danoeh/antennapod/activity/PreferenceActivity.java @@ -144,6 +144,20 @@ public class PreferenceActivity extends SherlockPreferenceActivity { } } }); + findPreference(UserPreferences.PREF_EPISODE_CACHE_SIZE) + .setOnPreferenceChangeListener( + new OnPreferenceChangeListener() { + + @Override + public boolean onPreferenceChange( + Preference preference, Object newValue) { + if (newValue instanceof String) { + setEpisodeCacheSizeText(Integer + .valueOf((String) newValue)); + } + return true; + } + }); buildAutodownloadSelectedNetworsPreference(); setSelectedNetworksEnabled(UserPreferences .isEnableAutodownloadWifiFilter()); @@ -162,6 +176,7 @@ public class PreferenceActivity extends SherlockPreferenceActivity { protected void onResume() { super.onResume(); checkItemVisibility(); + setEpisodeCacheSizeText(UserPreferences.getEpisodeCacheSize()); setDataFolderText(); } @@ -175,6 +190,12 @@ public class PreferenceActivity extends SherlockPreferenceActivity { } + private void setEpisodeCacheSizeText(int cacheSize) { + findPreference(UserPreferences.PREF_EPISODE_CACHE_SIZE).setSummary( + Integer.toString(cacheSize) + + getString(R.string.episodes_suffix)); + } + private void setDataFolderText() { File f = UserPreferences.getDataFolder(this, null); if (f != null) { diff --git a/src/de/danoeh/antennapod/preferences/UserPreferences.java b/src/de/danoeh/antennapod/preferences/UserPreferences.java index 72fd7a46a..5684c5f37 100644 --- a/src/de/danoeh/antennapod/preferences/UserPreferences.java +++ b/src/de/danoeh/antennapod/preferences/UserPreferences.java @@ -41,6 +41,7 @@ public class UserPreferences implements public static final String PREF_DATA_FOLDER = "prefDataFolder"; public static final String PREF_ENABLE_AUTODL_WIFI_FILTER = "prefEnableAutoDownloadWifiFilter"; private static final String PREF_AUTODL_SELECTED_NETWORKS = "prefAutodownloadSelectedNetworks"; + public static final String PREF_EPISODE_CACHE_SIZE = "prefEpisodeCacheSize"; private static UserPreferences instance; private Context context; @@ -57,6 +58,7 @@ public class UserPreferences implements private int theme; private boolean enableAutodownloadWifiFilter; private String[] autodownloadSelectedNetworks; + private int episodeCacheSize; private UserPreferences(Context context) { this.context = context; @@ -101,6 +103,8 @@ public class UserPreferences implements PREF_ENABLE_AUTODL_WIFI_FILTER, false); autodownloadSelectedNetworks = StringUtils.split( sp.getString(PREF_AUTODL_SELECTED_NETWORKS, ""), ','); + episodeCacheSize = Integer.valueOf(sp.getString( + PREF_EPISODE_CACHE_SIZE, "20")); } private int readThemeValue(String valueFromPrefs) { @@ -181,6 +185,11 @@ public class UserPreferences implements return instance.autodownloadSelectedNetworks; } + public static int getEpisodeCacheSize() { + instanceAvailable(); + return instance.episodeCacheSize; + } + @Override public void onSharedPreferenceChanged(SharedPreferences sp, String key) { if (AppConfig.DEBUG) @@ -231,10 +240,14 @@ public class UserPreferences implements } else if (key.equals(PREF_AUTODL_SELECTED_NETWORKS)) { autodownloadSelectedNetworks = StringUtils.split( sp.getString(PREF_AUTODL_SELECTED_NETWORKS, ""), ','); + } else if (key.equals(PREF_EPISODE_CACHE_SIZE)) { + episodeCacheSize = Integer.valueOf(sp.getString( + PREF_EPISODE_CACHE_SIZE, "20")); } } - public static void setAutodownloadSelectedNetworks(Context context, String[] value) { + public static void setAutodownloadSelectedNetworks(Context context, + String[] value) { SharedPreferences.Editor editor = PreferenceManager .getDefaultSharedPreferences(context.getApplicationContext()) .edit(); |