Merge pull request #2426 from fuzzdk/develop

Add auto download on mobile connection option
This commit is contained in:
Martin Fietz 2017-10-15 21:53:40 +02:00 committed by GitHub
commit c69c48b62f
4 changed files with 23 additions and 0 deletions

View File

@ -224,6 +224,11 @@
android:title="@string/pref_automatic_download_on_battery_title"
android:summary="@string/pref_automatic_download_on_battery_sum"
android:defaultValue="true"/>
<de.danoeh.antennapod.preferences.SwitchCompatPreference
android:key="prefEnableAutoDownloadOnMobile"
android:title="@string/pref_autodl_allow_on_mobile_title"
android:summary="@string/pref_autodl_allow_on_mobile_sum"
android:defaultValue="false"/>
<de.danoeh.antennapod.preferences.SwitchCompatPreference
android:key="prefEnableAutoDownloadWifiFilter"
android:title="@string/pref_autodl_wifi_filter_title"

View File

@ -84,6 +84,7 @@ public class UserPreferences {
public static final String PREF_ENABLE_AUTODL = "prefEnableAutoDl";
public static final String PREF_ENABLE_AUTODL_ON_BATTERY = "prefEnableAutoDownloadOnBattery";
public static final String PREF_ENABLE_AUTODL_WIFI_FILTER = "prefEnableAutoDownloadWifiFilter";
public static final String PREF_ENABLE_AUTODL_ON_MOBILE = "prefEnableAutoDownloadOnMobile";
public static final String PREF_AUTODL_SELECTED_NETWORKS = "prefAutodownloadSelectedNetworks";
public static final String PREF_PROXY_TYPE = "prefProxyType";
public static final String PREF_PROXY_HOST = "prefProxyHost";
@ -401,6 +402,11 @@ public class UserPreferences {
return prefs.getBoolean(PREF_ENABLE_AUTODL_WIFI_FILTER, false);
}
public static boolean isEnableAutodownloadOnMobile() {
return prefs.getBoolean(PREF_ENABLE_AUTODL_ON_MOBILE, false);
}
public static int getImageCacheSize() {
String cacheSizeString = prefs.getString(PREF_IMAGE_CACHE_SIZE, IMAGE_CACHE_DEFAULT_VALUE);
int cacheSizeInt = Integer.parseInt(cacheSizeString);

View File

@ -66,6 +66,16 @@ public class NetworkUtils {
}
}
}
} else {
if (!UserPreferences.isEnableAutodownloadOnMobile()) {
Log.d(TAG, "Auto Download not enabled on Mobile");
return false;
}
if (networkInfo.isRoaming()) {
Log.d(TAG, "Roaming on foreign network");
return false;
}
return true;
}
}
Log.d(TAG, "Network for auto-dl is not available");

View File

@ -365,6 +365,8 @@
<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_autodl_allow_on_mobile_title">Download on mobile connection</string>
<string name="pref_autodl_allow_on_mobile_sum">Allow automatic download over the mobile data connection.</string>
<string name="pref_automatic_download_on_battery_title">Download when not charging</string>
<string name="pref_automatic_download_on_battery_sum">Allow automatic download when the battery is not charging</string>
<string name="pref_parallel_downloads_title">Parallel Downloads</string>