aboutsummaryrefslogtreecommitdiff
path: root/subsonic-android
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2012-11-14 18:43:27 -0800
committerScott Jackson <daneren2005@gmail.com>2012-11-14 18:43:27 -0800
commitb4fecfc08b05d4a8c95443405f104e32556508f2 (patch)
tree4a56aed940c74b2f3225018bace03d6f832c5594 /subsonic-android
parent3a64650fa51b5caf330bcd8b0fa6d8e514397e6f (diff)
downloaddsub-b4fecfc08b05d4a8c95443405f104e32556508f2.tar.gz
dsub-b4fecfc08b05d4a8c95443405f104e32556508f2.tar.bz2
dsub-b4fecfc08b05d4a8c95443405f104e32556508f2.zip
Updated temp focus loss options
Diffstat (limited to 'subsonic-android')
-rw-r--r--subsonic-android/res/values/arrays.xml8
-rw-r--r--subsonic-android/res/values/strings.xml7
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/util/Util.java25
3 files changed, 21 insertions, 19 deletions
diff --git a/subsonic-android/res/values/arrays.xml b/subsonic-android/res/values/arrays.xml
index dcec441f..493239e9 100644
--- a/subsonic-android/res/values/arrays.xml
+++ b/subsonic-android/res/values/arrays.xml
@@ -94,13 +94,15 @@
<string-array name="tempLossValues">
<item>0</item>
+ <item>1</item>
<item>2</item>
- <item>4</item>
+ <item>3</item>
</string-array>
<string-array name="tempLossNames">
<item>@string/settings.temp_loss_pause</item>
- <item>@string/settings.temp_loss_half</item>
- <item>@string/settings.temp_loss_fourth</item>
+ <item>@string/settings.temp_loss_pause_lower</item>
+ <item>@string/settings.temp_loss_lower</item>
+ <item>@string/settings.temp_loss_nothing</item>
</string-array>
</resources> \ No newline at end of file
diff --git a/subsonic-android/res/values/strings.xml b/subsonic-android/res/values/strings.xml
index 074d9686..feb1bf9e 100644
--- a/subsonic-android/res/values/strings.xml
+++ b/subsonic-android/res/values/strings.xml
@@ -226,9 +226,10 @@
<string name="settings.sleep_timer_on">On</string>
<string name="settings.sleep_timer_always_on">Always On</string>
<string name="settings.temp_loss_title">Temperary Loss of Focus</string>
- <string name="settings.temp_loss_pause">Pause Playback</string>
- <string name="settings.temp_loss_half">Half volume</string>
- <string name="settings.temp_loss_fourth">Fourth Volume</string>
+ <string name="settings.temp_loss_pause">Always Pause</string>
+ <string name="settings.temp_loss_pause_lower">Pause, lower volume when requested</string>
+ <string name="settings.temp_loss_lower">Always lower volume</string>
+ <string name="settings.temp_loss_nothing">Do Nothing</string>
<string name="music_service.retry">A network error occurred. Retrying %1$d of %2$d.</string>
diff --git a/subsonic-android/src/github/daneren2005/dsub/util/Util.java b/subsonic-android/src/github/daneren2005/dsub/util/Util.java
index 53bc54c4..7616964b 100644
--- a/subsonic-android/src/github/daneren2005/dsub/util/Util.java
+++ b/subsonic-android/src/github/daneren2005/dsub/util/Util.java
@@ -99,8 +99,8 @@ public final class Util {
public static final String EVENT_PLAYSTATE_CHANGED = "github.daneren2005.dsub.EVENT_PLAYSTATE_CHANGED";
private static boolean pauseFocus = false;
+ private static boolean lowerFocus = false;
private static int currentVolume = 0;
- private static int lossPref = 0;
private static final Map<Integer, Version> SERVER_REST_VERSIONS = new ConcurrentHashMap<Integer, Version>();
@@ -754,26 +754,25 @@ public final class Util {
public void onAudioFocusChange(int focusChange) {
DownloadServiceImpl downloadService = (DownloadServiceImpl)context;
if(focusChange == AudioManager.AUDIOFOCUS_LOSS_TRANSIENT || focusChange == AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK) {
- if(downloadService.getPlayerState() == PlayerState.STARTED) {
- pauseFocus = true;
-
+ if(downloadService.getPlayerState() == PlayerState.STARTED) {
SharedPreferences prefs = getPreferences(context);
- lossPref = Integer.parseInt(prefs.getString(Constants.PREFERENCES_KEY_TEMP_LOSS, "0"));
- if(lossPref > 0) {
+ int lossPref = Integer.parseInt(prefs.getString(Constants.PREFERENCES_KEY_TEMP_LOSS, "0"));
+ if(lossPref == 2 || (lossPref == 1 && focusChange == AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK)) {
+ lowerFocus = true;
currentVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
- audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, (int)Math.ceil(currentVolume / (double)lossPref), 0);
- } else {
+ audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, (int)Math.ceil(currentVolume / 4.0), 0);
+ } else if(lossPref == 0 || (lossPref == 1 && focusChange == AudioManager.AUDIOFOCUS_LOSS_TRANSIENT)) {
+ pauseFocus = true;
downloadService.pause();
}
}
} else if (focusChange == AudioManager.AUDIOFOCUS_GAIN) {
if(pauseFocus) {
pauseFocus = false;
- if(lossPref > 0) {
- audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, currentVolume, 0);
- } else {
- downloadService.start();
- }
+ downloadService.start();
+ } else if(lowerFocus) {
+ lowerFocus = false;
+ audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, currentVolume, 0);
}
}
}