From 3e560496b7951cda1724fa2580ee0601dbe5b88c Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Sat, 7 Jul 2012 11:23:48 -0700 Subject: Basic Network Timeout setting --- subsonic-android/res/values/arrays.xml | 15 +++++++++++++++ subsonic-android/res/values/strings.xml | 7 +++++++ subsonic-android/res/xml/settings.xml | 7 +++++++ .../daneren2005/subphonic/activity/SettingsActivity.java | 3 +++ .../daneren2005/subphonic/service/RESTMusicService.java | 3 +++ .../src/github/daneren2005/subphonic/util/Constants.java | 1 + 6 files changed, 36 insertions(+) diff --git a/subsonic-android/res/values/arrays.xml b/subsonic-android/res/values/arrays.xml index 087206a9..17ea4b6a 100644 --- a/subsonic-android/res/values/arrays.xml +++ b/subsonic-android/res/values/arrays.xml @@ -58,5 +58,20 @@ @string/settings.max_bitrate_320 @string/settings.max_bitrate_unlimited + + + 10000 + 15000 + 30000 + 45000 + 60000 + + + @string/settings.network_timeout_10000 + @string/settings.network_timeout_15000 + @string/settings.network_timeout_30000 + @string/settings.network_timeout_45000 + @string/settings.network_timeout_60000 + \ No newline at end of file diff --git a/subsonic-android/res/values/strings.xml b/subsonic-android/res/values/strings.xml index 6acfed87..47487e43 100644 --- a/subsonic-android/res/values/strings.xml +++ b/subsonic-android/res/values/strings.xml @@ -157,11 +157,18 @@ Unlimited Wi-Fi streaming only Only stream media if connected to Wi-Fi + Network Timeout + 10 seconds + 15 seconds + 30 seconds + 45 seconds + 60 seconds 1 song 2 songs 3 songs 5 songs 10 songs + Unlimited Clear search history Search history cleared Other settings diff --git a/subsonic-android/res/xml/settings.xml b/subsonic-android/res/xml/settings.xml index 4e4cd7dd..21d0568a 100644 --- a/subsonic-android/res/xml/settings.xml +++ b/subsonic-android/res/xml/settings.xml @@ -137,6 +137,13 @@ android:summary="@string/settings.wifi_required_summary" android:key="wifiRequiredForDownload" android:defaultValue="false"/> + + diff --git a/subsonic-android/src/github/daneren2005/subphonic/activity/SettingsActivity.java b/subsonic-android/src/github/daneren2005/subphonic/activity/SettingsActivity.java index bb8fdd35..5cc70d14 100644 --- a/subsonic-android/src/github/daneren2005/subphonic/activity/SettingsActivity.java +++ b/subsonic-android/src/github/daneren2005/subphonic/activity/SettingsActivity.java @@ -52,6 +52,7 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer private ListPreference theme; private ListPreference maxBitrateWifi; private ListPreference maxBitrateMobile; + private ListPreference networkTimeout; private EditTextPreference cacheSize; private EditTextPreference cacheLocation; private ListPreference preloadCount; @@ -64,6 +65,7 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer theme = (ListPreference) findPreference(Constants.PREFERENCES_KEY_THEME); maxBitrateWifi = (ListPreference) findPreference(Constants.PREFERENCES_KEY_MAX_BITRATE_WIFI); maxBitrateMobile = (ListPreference) findPreference(Constants.PREFERENCES_KEY_MAX_BITRATE_MOBILE); + 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); @@ -145,6 +147,7 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer theme.setSummary(theme.getEntry()); maxBitrateWifi.setSummary(maxBitrateWifi.getEntry()); maxBitrateMobile.setSummary(maxBitrateMobile.getEntry()); + networkTimeout.setSummary(networkTimeout.getEntry()); cacheSize.setSummary(cacheSize.getText()); cacheLocation.setSummary(cacheLocation.getText()); preloadCount.setSummary(preloadCount.getEntry()); diff --git a/subsonic-android/src/github/daneren2005/subphonic/service/RESTMusicService.java b/subsonic-android/src/github/daneren2005/subphonic/service/RESTMusicService.java index 7a7d1415..b9da4c1a 100644 --- a/subsonic-android/src/github/daneren2005/subphonic/service/RESTMusicService.java +++ b/subsonic-android/src/github/daneren2005/subphonic/service/RESTMusicService.java @@ -711,6 +711,9 @@ public class RESTMusicService implements MusicService { String password = prefs.getString(Constants.PREFERENCES_KEY_PASSWORD + instance, null); httpClient.getCredentialsProvider().setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), new UsernamePasswordCredentials(username, password)); + + int networkTimeout = Integer.parseInt(prefs.getString(Constants.PREFERENCES_KEY_NETWORK_TIMEOUT, "10000")); + httpClient.getParams().setParameter("http.socket.timeout", networkTimeout); try { HttpResponse response = httpClient.execute(request, httpContext); diff --git a/subsonic-android/src/github/daneren2005/subphonic/util/Constants.java b/subsonic-android/src/github/daneren2005/subphonic/util/Constants.java index c9b339d6..532ef81f 100644 --- a/subsonic-android/src/github/daneren2005/subphonic/util/Constants.java +++ b/subsonic-android/src/github/daneren2005/subphonic/util/Constants.java @@ -65,6 +65,7 @@ public final class Constants { public static final String PREFERENCES_KEY_THEME = "theme"; public static final String PREFERENCES_KEY_MAX_BITRATE_WIFI = "maxBitrateWifi"; public static final String PREFERENCES_KEY_MAX_BITRATE_MOBILE = "maxBitrateMobile"; + 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"; -- cgit v1.2.3