diff options
author | Tom Hennen <TomHennen@users.noreply.github.com> | 2015-05-08 17:44:47 -0400 |
---|---|---|
committer | Tom Hennen <TomHennen@users.noreply.github.com> | 2015-05-08 17:44:47 -0400 |
commit | b32fa4ec71343aa443e01c5e5c3526b387ccefc5 (patch) | |
tree | 665f9eaa88b22c842a86d8dd123d2fe07a5c547a /core/src | |
parent | 9c6c218aa170d6e6939cfd0b7ac7ee0cc02e819b (diff) | |
parent | 615723bc982cd5132c4bb975641d24c2af6ea9e9 (diff) | |
download | AntennaPod-b32fa4ec71343aa443e01c5e5c3526b387ccefc5.zip |
Merge pull request #789 from mfietz/feature/confirm-download-mobile
Confirm download on mobile data connection
This seems to work well. We may want to tweak the workflow further, but we'll figure that out as we use it an in Alpha testing.
Diffstat (limited to 'core/src')
3 files changed, 28 insertions, 22 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/receiver/FeedUpdateReceiver.java b/core/src/main/java/de/danoeh/antennapod/core/receiver/FeedUpdateReceiver.java index 95dc4fb07..d37f97a5f 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/receiver/FeedUpdateReceiver.java +++ b/core/src/main/java/de/danoeh/antennapod/core/receiver/FeedUpdateReceiver.java @@ -3,41 +3,26 @@ package de.danoeh.antennapod.core.receiver; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; -import android.net.ConnectivityManager; -import android.net.NetworkInfo; import android.util.Log; -import de.danoeh.antennapod.core.BuildConfig; -import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.storage.DBTasks; +import de.danoeh.antennapod.core.util.NetworkUtils; /** * Refreshes all feeds when it receives an intent */ public class FeedUpdateReceiver extends BroadcastReceiver { + private static final String TAG = "FeedUpdateReceiver"; @Override public void onReceive(Context context, Intent intent) { - if (BuildConfig.DEBUG) - Log.d(TAG, "Received intent"); - boolean mobileUpdate = UserPreferences.isAllowMobileUpdate(); - if (mobileUpdate || connectedToWifi(context)) { + Log.d(TAG, "Received intent"); + if (NetworkUtils.isDownloadAllowed(context)) { DBTasks.refreshExpiredFeeds(context); } else { - if (BuildConfig.DEBUG) - Log.d(TAG, - "Blocking automatic update: no wifi available / no mobile updates allowed"); + Log.d(TAG, "Blocking automatic update: no wifi available / no mobile updates allowed"); } } - private boolean connectedToWifi(Context context) { - ConnectivityManager connManager = (ConnectivityManager) context - .getSystemService(Context.CONNECTIVITY_SERVICE); - NetworkInfo mWifi = connManager - .getNetworkInfo(ConnectivityManager.TYPE_WIFI); - - return mWifi.isConnected(); - } - } diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/NetworkUtils.java b/core/src/main/java/de/danoeh/antennapod/core/util/NetworkUtils.java index b321536a3..3a349e221 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/NetworkUtils.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/NetworkUtils.java @@ -6,12 +6,13 @@ import android.net.NetworkInfo; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.util.Log; -import de.danoeh.antennapod.core.BuildConfig; -import de.danoeh.antennapod.core.preferences.UserPreferences; import java.util.Arrays; import java.util.List; +import de.danoeh.antennapod.core.BuildConfig; +import de.danoeh.antennapod.core.preferences.UserPreferences; + public class NetworkUtils { private static final String TAG = "NetworkUtils"; @@ -66,4 +67,18 @@ public class NetworkUtils { NetworkInfo info = cm.getActiveNetworkInfo(); return info != null && info.isConnected(); } + + public static boolean isDownloadAllowed(Context context) { + return UserPreferences.isAllowMobileUpdate() || NetworkUtils.connectedToWifi(context); + } + + public static boolean connectedToWifi(Context context) { + ConnectivityManager connManager = (ConnectivityManager) context + .getSystemService(Context.CONNECTIVITY_SERVICE); + NetworkInfo mWifi = connManager + .getNetworkInfo(ConnectivityManager.TYPE_WIFI); + + return mWifi.isConnected(); + } + } diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index 3421d3c52..f01d60f22 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -104,6 +104,7 @@ <string name="mark_unread_label">Mark as unplayed</string> <string name="marked_as_read_label">Marked as played</string> <string name="add_to_queue_label">Add to Queue</string> + <string name="added_to_queue_label">Added to Queue</string> <string name="remove_from_queue_label">Remove from Queue</string> <string name="visit_website_label">Visit Website</string> <string name="support_label">Flattr this</string> @@ -145,6 +146,11 @@ <string name="download_request_error_dialog_message_prefix">An error occurred when trying to download the file:\u0020</string> <string name="authentication_notification_title">Authentication required</string> <string name="authentication_notification_msg">The resource you requested requires a username and a password</string> + <string name="confirm_mobile_download_dialog_title">Confirm Mobile Download</string> + <string name="confirm_mobile_download_dialog_message_not_in_queue">Downloading over mobile data connection is disabled in the settings.\n\nEnable temporarily or just add to queue?\n\n<small>Your choice will be remember for 10 minutes.</small></string> + <string name="confirm_mobile_download_dialog_message">Downloading over mobile data connection is disabled in the settings.\n\nEnable temporarily?\n\n<small>Your choice will be remember for 10 minutes.</small></string> + <string name="confirm_mobile_download_dialog_only_add_to_queue">Only add to Queue</string> + <string name="confirm_mobile_download_dialog_enable_temporarily">Enable temporarily</string> <!-- Mediaplayer messages --> <string name="player_error_msg">Error!</string> |