diff options
-rw-r--r-- | res/xml/preferences.xml | 3 | ||||
-rw-r--r-- | src/de/danoeh/antennapod/activity/PreferenceActivity.java | 14 | ||||
-rw-r--r-- | src/de/danoeh/antennapod/feed/FeedManager.java | 3 | ||||
-rw-r--r-- | src/de/danoeh/antennapod/preferences/UserPreferences.java | 10 |
4 files changed, 28 insertions, 2 deletions
diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml index c8c947797..dfa67d4f9 100644 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@ -35,7 +35,8 @@ android:summary="@string/pref_mobileUpdate_sum" android:title="@string/pref_mobileUpdate_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"/> + <CheckBoxPreference android:key="prefEnableAutoDl" android:title="@string/pref_automatic_download_title" android:defaultValue="false"/><CheckBoxPreference android:key="prefEnableAutoDownloadWifiFilter" android:title="@string/pref_autodl_wifi_filter_title" android:summary="@string/pref_autodl_wifi_filter_sum"/> + </PreferenceScreen> </PreferenceCategory> diff --git a/src/de/danoeh/antennapod/activity/PreferenceActivity.java b/src/de/danoeh/antennapod/activity/PreferenceActivity.java index 8b3f2539a..b7e000785 100644 --- a/src/de/danoeh/antennapod/activity/PreferenceActivity.java +++ b/src/de/danoeh/antennapod/activity/PreferenceActivity.java @@ -157,6 +157,15 @@ public class PreferenceActivity extends SherlockPreferenceActivity { return true; } }); + findPreference(UserPreferences.PREF_ENABLE_AUTODL).setOnPreferenceClickListener(new OnPreferenceClickListener() { + + @Override + public boolean onPreferenceClick(Preference preference) { + checkItemVisibility(); + return true; + } + }); + buildAutodownloadSelectedNetworsPreference(); setSelectedNetworksEnabled(UserPreferences .isEnableAutodownloadWifiFilter()); @@ -187,6 +196,11 @@ public class PreferenceActivity extends SherlockPreferenceActivity { findPreference(PREF_FLATTR_AUTH).setEnabled(!hasFlattrToken); findPreference(PREF_FLATTR_REVOKE).setEnabled(hasFlattrToken); + findPreference(UserPreferences.PREF_ENABLE_AUTODL_WIFI_FILTER) + .setEnabled(UserPreferences.isEnableAutodownload()); + setSelectedNetworksEnabled(UserPreferences.isEnableAutodownload() + && UserPreferences.isEnableAutodownloadWifiFilter()); + } private void setEpisodeCacheSizeText(int cacheSize) { diff --git a/src/de/danoeh/antennapod/feed/FeedManager.java b/src/de/danoeh/antennapod/feed/FeedManager.java index 1322fd54a..2d552514e 100644 --- a/src/de/danoeh/antennapod/feed/FeedManager.java +++ b/src/de/danoeh/antennapod/feed/FeedManager.java @@ -629,7 +629,8 @@ public class FeedManager { public void autodownloadUndownloadedItems(Context context) { if (AppConfig.DEBUG) Log.d(TAG, "Performing auto-dl of undownloaded episodes"); - if (NetworkUtils.autodownloadNetworkAvailable(context)) { + if (NetworkUtils.autodownloadNetworkAvailable(context) + && UserPreferences.isEnableAutodownload()) { int undownloadedEpisodes = getNumberOfUndownloadedEpisodes(); int downloadedEpisodes = getNumberOfDownloadedEpisodes(); int deletedEpisodes = performAutoCleanup(context, diff --git a/src/de/danoeh/antennapod/preferences/UserPreferences.java b/src/de/danoeh/antennapod/preferences/UserPreferences.java index 489f9f02d..0239c72d4 100644 --- a/src/de/danoeh/antennapod/preferences/UserPreferences.java +++ b/src/de/danoeh/antennapod/preferences/UserPreferences.java @@ -37,6 +37,7 @@ public class UserPreferences implements public static final String PREF_AUTO_DELETE = "prefAutoDelete"; public static final String PREF_THEME = "prefTheme"; public static final String PREF_DATA_FOLDER = "prefDataFolder"; + public static final String PREF_ENABLE_AUTODL = "prefEnableAutoDl"; 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"; @@ -53,6 +54,7 @@ public class UserPreferences implements private boolean displayOnlyEpisodes; private boolean autoDelete; private int theme; + private boolean enableAutodownload; private boolean enableAutodownloadWifiFilter; private String[] autodownloadSelectedNetworks; private int episodeCacheSize; @@ -101,6 +103,7 @@ public class UserPreferences implements sp.getString(PREF_AUTODL_SELECTED_NETWORKS, ""), ','); episodeCacheSize = Integer.valueOf(sp.getString( PREF_EPISODE_CACHE_SIZE, "20")); + enableAutodownload = sp.getBoolean(PREF_ENABLE_AUTODL, false); } private int readThemeValue(String valueFromPrefs) { @@ -181,6 +184,11 @@ public class UserPreferences implements return instance.episodeCacheSize; } + public static boolean isEnableAutodownload() { + instanceAvailable(); + return instance.enableAutodownload; + } + @Override public void onSharedPreferenceChanged(SharedPreferences sp, String key) { if (AppConfig.DEBUG) @@ -218,6 +226,8 @@ public class UserPreferences implements } else if (key.equals(PREF_EPISODE_CACHE_SIZE)) { episodeCacheSize = Integer.valueOf(sp.getString( PREF_EPISODE_CACHE_SIZE, "20")); + } else if (key.equals(PREF_ENABLE_AUTODL)) { + enableAutodownload = sp.getBoolean(PREF_ENABLE_AUTODL, false); } } |