Some users never use WiFi, check for that state on first run
Lots of people complain that the graphics aren't being downloaded. That's because they never use F-Droid while on WiFi and the default prefs do not allow downloading graphics while on Data. This sets the preference to allow downloading graphics while on Data if only Data is enabled, and not WiFi, when the user first starts F-Droid. closes #1592
This commit is contained in:
parent
aebf7efc10
commit
57b587dfe3
@ -454,6 +454,7 @@ public class FDroidApp extends Application {
|
||||
ImageLoader.getInstance().init(config);
|
||||
|
||||
if (preferences.isIndexNeverUpdated()) {
|
||||
preferences.setDefaultForDataOnlyConnection(this);
|
||||
// force this check to ensure it starts fetching the index on initial runs
|
||||
networkState = ConnectivityMonitorService.getNetworkState(this);
|
||||
}
|
||||
|
@ -25,6 +25,8 @@ package org.fdroid.fdroid;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Build;
|
||||
import android.support.v7.preference.PreferenceManager;
|
||||
import android.text.format.DateUtils;
|
||||
@ -443,6 +445,26 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
|
||||
return preferences.getInt(PREF_OVER_DATA, IGNORED_I);
|
||||
}
|
||||
|
||||
/**
|
||||
* Some users never use WiFi, this lets us check for that state on first run.
|
||||
*/
|
||||
public void setDefaultForDataOnlyConnection(Context context) {
|
||||
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
if (cm == null) {
|
||||
return;
|
||||
}
|
||||
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
|
||||
if (activeNetwork == null || !activeNetwork.isConnectedOrConnecting()) {
|
||||
return;
|
||||
}
|
||||
if (activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE) {
|
||||
NetworkInfo wifiNetwork = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
|
||||
if (!wifiNetwork.isConnectedOrConnecting()) {
|
||||
preferences.edit().putInt(PREF_OVER_DATA, OVER_NETWORK_ALWAYS).apply();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This preference's default is set dynamically based on whether Orbot is
|
||||
* installed. If Orbot is installed, default to using Tor, the user can still override
|
||||
|
Loading…
x
Reference in New Issue
Block a user