aboutsummaryrefslogtreecommitdiff
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
parentec670db9b3e71af2a644e8c7cbc8e1565c3cf0a8 (diff)
downloaddsub-df2b3c4504754b7b64475c442d0b77e25543be4b.tar.gz
dsub-df2b3c4504754b7b64475c442d0b77e25543be4b.tar.bz2
dsub-df2b3c4504754b7b64475c442d0b77e25543be4b.zip
Added separate setting for preload count for wifi/mobile
-rw-r--r--subsonic-android/res/values/strings.xml3
-rw-r--r--subsonic-android/res/xml/settings.xml11
-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
5 files changed, 27 insertions, 8 deletions
diff --git a/subsonic-android/res/values/strings.xml b/subsonic-android/res/values/strings.xml
index 21dd4b88..e494aef0 100644
--- a/subsonic-android/res/values/strings.xml
+++ b/subsonic-android/res/values/strings.xml
@@ -183,7 +183,8 @@
<string name="settings.server_username">Username</string>
<string name="settings.server_password">Password</string>
<string name="settings.cache_title">Music cache</string>
- <string name="settings.preload">Songs to preload</string>
+ <string name="settings.preload_wifi">Songs to preload (Wifi)</string>
+ <string name="settings.preload_mobile">Songs to preload (Mobile)</string>
<string name="settings.cache_size">Cache size (MB)</string>
<string name="settings.cache_location">Cache location</string>
<string name="settings.cache_location_error">Invalid cache location. Using default.</string>
diff --git a/subsonic-android/res/xml/settings.xml b/subsonic-android/res/xml/settings.xml
index d21f928f..89ec5699 100644
--- a/subsonic-android/res/xml/settings.xml
+++ b/subsonic-android/res/xml/settings.xml
@@ -204,8 +204,15 @@
android:key="cacheLocation"/>
<ListPreference
- android:title="@string/settings.preload"
- android:key="preloadCount"
+ android:title="@string/settings.preload_wifi"
+ android:key="preloadCountWifi"
+ android:defaultValue="3"
+ android:entryValues="@array/preloadCountValues"
+ android:entries="@array/preloadCountNames"/>
+
+ <ListPreference
+ android:title="@string/settings.preload_mobile"
+ android:key="preloadCountMobile"
android:defaultValue="3"
android:entryValues="@array/preloadCountValues"
android:entries="@array/preloadCountNames"/>
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;
}