mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2025-01-28 01:19:23 +01:00
Added preference to block updates over mobile internet
This commit is contained in:
parent
a05edcb0a4
commit
fcbb28981f
@ -86,8 +86,10 @@
|
||||
<string name="pref_autoUpdateIntervall_title">Update intervall</string>
|
||||
<string name="pref_autoUpdateIntervall_sum">Specify an intervall in which the feeds are refreshed automatically or disable it</string>
|
||||
<string name="pref_downloadMediaOnWifiOnly_sum">Download media files only over WiFi</string>
|
||||
<string name="pref_followQueue_title">Follow queue</string>
|
||||
<string name="pref_followQueue_title">Continuous playback</string>
|
||||
<string name="pref_downloadMediaOnWifiOnly_title">WiFi media download</string>
|
||||
<string name="pref_pauseOnHeadsetDisconnect_title">Headset disconnect</string>
|
||||
<string name="pref_mobileUpdate_title">Mobile Updates</string>
|
||||
<string name="pref_mobileUpdate_sum">Allow updates over the mobile data connection</string>
|
||||
|
||||
</resources>
|
@ -30,6 +30,13 @@
|
||||
android:key="prefAutoUpdateIntervall"
|
||||
android:summary="@string/pref_autoUpdateIntervall_sum"
|
||||
android:title="@string/pref_autoUpdateIntervall_title" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:enabled="true"
|
||||
android:key="prefMobileUpdate"
|
||||
android:summary="@string/pref_mobileUpdate_sum"
|
||||
android:title="@string/pref_mobileUpdate_title" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/other_pref" >
|
||||
<Preference android:title="@string/version_pref" />
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user