diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2012-07-09 12:05:09 +0200 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2012-07-09 12:05:09 +0200 |
commit | fcbb28981f28263c6659d8b225fa5166b7d13e5a (patch) | |
tree | 9c582e4e5cd53048fbd4872e4bba8c0bbd790db4 /src | |
parent | a05edcb0a468f93c46a642b9e5e6220b1e82e1c1 (diff) | |
download | AntennaPod-fcbb28981f28263c6659d8b225fa5166b7d13e5a.zip |
Added preference to block updates over mobile internet
Diffstat (limited to 'src')
-rw-r--r-- | src/de/podfetcher/PodcastApp.java | 1 | ||||
-rw-r--r-- | src/de/podfetcher/receiver/FeedUpdateReceiver.java | 24 |
2 files changed, 23 insertions, 2 deletions
diff --git a/src/de/podfetcher/PodcastApp.java b/src/de/podfetcher/PodcastApp.java index 0b2da0e99..4ecc553ba 100644 --- a/src/de/podfetcher/PodcastApp.java +++ b/src/de/podfetcher/PodcastApp.java @@ -24,6 +24,7 @@ public class PodcastApp extends Application implements public static final String PREF_FOLLOW_QUEUE = "prefFollowQueue"; public static final String PREF_DOWNLOAD_MEDIA_ON_WIFI_ONLY = "prefDownloadMediaOnWifiOnly"; public static final String PREF_UPDATE_INTERVALL = "prefAutoUpdateIntervall"; + public static final String PREF_MOBILE_UPDATE = "prefMobileUpdate"; private static PodcastApp singleton; diff --git a/src/de/podfetcher/receiver/FeedUpdateReceiver.java b/src/de/podfetcher/receiver/FeedUpdateReceiver.java index 1556a33ef..50b2b0ab5 100644 --- a/src/de/podfetcher/receiver/FeedUpdateReceiver.java +++ b/src/de/podfetcher/receiver/FeedUpdateReceiver.java @@ -1,22 +1,42 @@ package de.podfetcher.receiver; +import de.podfetcher.PodcastApp; import de.podfetcher.feed.FeedManager; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; +import android.net.ConnectivityManager; +import android.net.NetworkInfo; +import android.preference.PreferenceManager; import android.util.Log; /** Refreshes all feeds when it receives an intent */ public class FeedUpdateReceiver extends BroadcastReceiver { private static final String TAG = "FeedUpdateReceiver"; public static final String ACTION_REFRESH_FEEDS = "de.podfetcher.feedupdatereceiver.refreshFeeds"; - + @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(ACTION_REFRESH_FEEDS)) { Log.d(TAG, "Received intent"); - FeedManager.getInstance().refreshAllFeeds(context); + boolean mobileUpdate = PreferenceManager + .getDefaultSharedPreferences( + context.getApplicationContext()).getBoolean( + PodcastApp.PREF_MOBILE_UPDATE, false); + if (mobileUpdate || connectedToWifi(context)) { + FeedManager.getInstance().refreshAllFeeds(context); + } else { + 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(); + } + } |