aboutsummaryrefslogtreecommitdiff
path: root/subsonic-android/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2013-05-20 19:22:33 -0700
committerScott Jackson <daneren2005@gmail.com>2013-05-20 19:22:33 -0700
commitdf2b3c4504754b7b64475c442d0b77e25543be4b (patch)
tree0a6273c266b711e93f161015d3976d29a3bcde0f /subsonic-android/src
parentec670db9b3e71af2a644e8c7cbc8e1565c3cf0a8 (diff)
downloaddsub-df2b3c4504754b7b64475c442d0b77e25543be4b.tar.gz
dsub-df2b3c4504754b7b64475c442d0b77e25543be4b.tar.bz2
dsub-df2b3c4504754b7b64475c442d0b77e25543be4b.zip
Added separate setting for preload count for wifi/mobile
Diffstat (limited to 'subsonic-android/src')
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/activity/SettingsActivity.java9
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/util/Constants.java3
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/util/Util.java9
3 files changed, 16 insertions, 5 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SettingsActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SettingsActivity.java
index 18d7e6b4..dc39e2f6 100644
--- a/subsonic-android/src/github/daneren2005/dsub/activity/SettingsActivity.java
+++ b/subsonic-android/src/github/daneren2005/dsub/activity/SettingsActivity.java
@@ -57,7 +57,8 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer
private ListPreference networkTimeout;
private EditTextPreference cacheSize;
private EditTextPreference cacheLocation;
- private ListPreference preloadCount;
+ private ListPreference preloadCountWifi;
+ private ListPreference preloadCountMobile;
private EditTextPreference randomSize;
private ListPreference tempLoss;
private EditTextPreference bufferLength;
@@ -75,7 +76,8 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer
networkTimeout = (ListPreference) findPreference(Constants.PREFERENCES_KEY_NETWORK_TIMEOUT);
cacheSize = (EditTextPreference) findPreference(Constants.PREFERENCES_KEY_CACHE_SIZE);
cacheLocation = (EditTextPreference) findPreference(Constants.PREFERENCES_KEY_CACHE_LOCATION);
- preloadCount = (ListPreference) findPreference(Constants.PREFERENCES_KEY_PRELOAD_COUNT);
+ preloadCountWifi = (ListPreference) findPreference(Constants.PREFERENCES_KEY_PRELOAD_COUNT_WIFI);
+ preloadCountMobile = (ListPreference) findPreference(Constants.PREFERENCES_KEY_PRELOAD_COUNT_MOBILE);
randomSize = (EditTextPreference) findPreference(Constants.PREFERENCES_KEY_RANDOM_SIZE);
tempLoss = (ListPreference) findPreference(Constants.PREFERENCES_KEY_TEMP_LOSS);
bufferLength = (EditTextPreference) findPreference(Constants.PREFERENCES_KEY_BUFFER_LENGTH);
@@ -166,7 +168,8 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer
networkTimeout.setSummary(networkTimeout.getEntry());
cacheSize.setSummary(cacheSize.getText());
cacheLocation.setSummary(cacheLocation.getText());
- preloadCount.setSummary(preloadCount.getEntry());
+ preloadCountWifi.setSummary(preloadCountWifi.getEntry());
+ preloadCountMobile.setSummary(preloadCountMobile.getEntry());
randomSize.setSummary(randomSize.getText());
tempLoss.setSummary(tempLoss.getEntry());
bufferLength.setSummary(bufferLength.getText() + " seconds");
diff --git a/subsonic-android/src/github/daneren2005/dsub/util/Constants.java b/subsonic-android/src/github/daneren2005/dsub/util/Constants.java
index 302ececf..7ab9dd80 100644
--- a/subsonic-android/src/github/daneren2005/dsub/util/Constants.java
+++ b/subsonic-android/src/github/daneren2005/dsub/util/Constants.java
@@ -72,7 +72,8 @@ public final class Constants {
public static final String PREFERENCES_KEY_NETWORK_TIMEOUT = "networkTimeout";
public static final String PREFERENCES_KEY_CACHE_SIZE = "cacheSize";
public static final String PREFERENCES_KEY_CACHE_LOCATION = "cacheLocation";
- public static final String PREFERENCES_KEY_PRELOAD_COUNT = "preloadCount";
+ public static final String PREFERENCES_KEY_PRELOAD_COUNT_WIFI = "preloadCountWifi";
+ public static final String PREFERENCES_KEY_PRELOAD_COUNT_MOBILE = "preloadCountMobile";
public static final String PREFERENCES_KEY_HIDE_MEDIA = "hideMedia";
public static final String PREFERENCES_KEY_MEDIA_BUTTONS = "mediaButtons";
public static final String PREFERENCES_KEY_SCREEN_LIT_ON_DOWNLOAD = "screenLitOnDownload";
diff --git a/subsonic-android/src/github/daneren2005/dsub/util/Util.java b/subsonic-android/src/github/daneren2005/dsub/util/Util.java
index 43aad67b..aafed8da 100644
--- a/subsonic-android/src/github/daneren2005/dsub/util/Util.java
+++ b/subsonic-android/src/github/daneren2005/dsub/util/Util.java
@@ -223,8 +223,15 @@ public final class Util {
}
public static int getPreloadCount(Context context) {
+ ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+ NetworkInfo networkInfo = manager.getActiveNetworkInfo();
+ if (networkInfo == null) {
+ return 3;
+ }
+
SharedPreferences prefs = getPreferences(context);
- int preloadCount = Integer.parseInt(prefs.getString(Constants.PREFERENCES_KEY_PRELOAD_COUNT, "-1"));
+ boolean wifi = networkInfo.getType() == ConnectivityManager.TYPE_WIFI;
+ int preloadCount = Integer.parseInt(prefs.getString(wifi ? Constants.PREFERENCES_KEY_PRELOAD_COUNT_WIFI : Constants.PREFERENCES_KEY_PRELOAD_COUNT_MOBILE, "-1"));
return preloadCount == -1 ? Integer.MAX_VALUE : preloadCount;
}