Added option to only download artist images on wifi
This commit is contained in:
parent
2e5b17be38
commit
585fd1013c
9 changed files with 78 additions and 10 deletions
|
|
@ -63,6 +63,8 @@ public final class PreferenceUtil {
|
|||
public static final String LAST_CHANGELOG_VERSION = "last_changelog_version";
|
||||
public static final String INTRO_SHOWN = "intro_shown";
|
||||
|
||||
public static final String AUTO_DOWNLOAD_IMAGES_POLICY = "auto_download_images_policy";
|
||||
|
||||
private static PreferenceUtil sInstance;
|
||||
|
||||
private final SharedPreferences mPreferences;
|
||||
|
|
@ -371,4 +373,8 @@ public final class PreferenceUtil {
|
|||
public final boolean introShown() {
|
||||
return mPreferences.getBoolean(INTRO_SHOWN, false);
|
||||
}
|
||||
|
||||
public final String autoDownloadImagesPolicy() {
|
||||
return mPreferences.getString(AUTO_DOWNLOAD_IMAGES_POLICY, "only_wifi");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ import android.content.res.TypedArray;
|
|||
import android.graphics.Point;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.AttrRes;
|
||||
import android.support.annotation.DrawableRes;
|
||||
|
|
@ -114,4 +116,19 @@ public class Util {
|
|||
return config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
|
||||
} else return false;
|
||||
}
|
||||
|
||||
public static boolean isAllowedToAutoDownload(final Context context) {
|
||||
switch (PreferenceUtil.getInstance(context).autoDownloadImagesPolicy()) {
|
||||
case "always":
|
||||
return true;
|
||||
case "only_wifi":
|
||||
final ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo netInfo = connectivityManager.getActiveNetworkInfo();
|
||||
return netInfo != null && netInfo.getType() == ConnectivityManager.TYPE_WIFI && netInfo.isConnectedOrConnecting();
|
||||
case "never":
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue