Created a user preference to enable the headphone resume feature
This commit is contained in:
parent
d4a3095512
commit
58f071e763
|
@ -41,6 +41,7 @@ public class PlaybackTest extends ActivityInstrumentationTestCase2<MainActivity>
|
|||
adapter.open();
|
||||
adapter.close();
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getInstrumentation().getTargetContext());
|
||||
prefs.edit().putBoolean(UserPreferences.PREF_UNPAUSE_ON_HEADSET_RECONNECT, false).commit();
|
||||
prefs.edit().putBoolean(UserPreferences.PREF_PAUSE_ON_HEADSET_DISCONNECT, false).commit();
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,13 @@
|
|||
android:key="prefPauseOnHeadsetDisconnect"
|
||||
android:summary="@string/pref_pauseOnHeadsetDisconnect_sum"
|
||||
android:title="@string/pref_pauseOnHeadsetDisconnect_title"/>
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:enabled="true"
|
||||
android:dependency="prefPauseOnHeadsetDisconnect"
|
||||
android:key="prefUnpauseOnHeadsetReconnect"
|
||||
android:summary="@string/pref_unpauseOnHeadsetReconnect_sum"
|
||||
android:title="@string/pref_unpauseOnHeadsetReconnect_title"/>
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:enabled="true"
|
||||
|
|
|
@ -37,6 +37,7 @@ public class UserPreferences implements
|
|||
private static final String TAG = "UserPreferences";
|
||||
|
||||
public static final String PREF_PAUSE_ON_HEADSET_DISCONNECT = "prefPauseOnHeadsetDisconnect";
|
||||
public static final String PREF_UNPAUSE_ON_HEADSET_RECONNECT = "prefUnpauseOnHeadsetReconnect";
|
||||
public static final String PREF_FOLLOW_QUEUE = "prefFollowQueue";
|
||||
public static final String PREF_DOWNLOAD_MEDIA_ON_WIFI_ONLY = "prefDownloadMediaOnWifiOnly";
|
||||
public static final String PREF_UPDATE_INTERVAL = "prefAutoUpdateIntervall";
|
||||
|
@ -68,6 +69,7 @@ public class UserPreferences implements
|
|||
|
||||
// Preferences
|
||||
private boolean pauseOnHeadsetDisconnect;
|
||||
private boolean unpauseOnHeadsetReconnect;
|
||||
private boolean followQueue;
|
||||
private boolean downloadMediaOnWifiOnly;
|
||||
private long updateInterval;
|
||||
|
@ -120,6 +122,8 @@ public class UserPreferences implements
|
|||
R.integer.episode_cache_size_unlimited);
|
||||
pauseOnHeadsetDisconnect = sp.getBoolean(
|
||||
PREF_PAUSE_ON_HEADSET_DISCONNECT, true);
|
||||
unpauseOnHeadsetReconnect = sp.getBoolean(
|
||||
PREF_UNPAUSE_ON_HEADSET_RECONNECT, true);
|
||||
followQueue = sp.getBoolean(PREF_FOLLOW_QUEUE, false);
|
||||
downloadMediaOnWifiOnly = sp.getBoolean(
|
||||
PREF_DOWNLOAD_MEDIA_ON_WIFI_ONLY, true);
|
||||
|
@ -220,6 +224,11 @@ public class UserPreferences implements
|
|||
return instance.pauseOnHeadsetDisconnect;
|
||||
}
|
||||
|
||||
public static boolean isUnpauseOnHeadsetReconnect() {
|
||||
instanceAvailable();
|
||||
return instance.unpauseOnHeadsetReconnect;
|
||||
}
|
||||
|
||||
public static boolean isFollowQueue() {
|
||||
instanceAvailable();
|
||||
return instance.followQueue;
|
||||
|
@ -387,6 +396,8 @@ public class UserPreferences implements
|
|||
seekDeltaSecs = Integer.valueOf(sp.getString(PREF_SEEK_DELTA_SECS, "30"));
|
||||
} else if (key.equals(PREF_PAUSE_ON_HEADSET_DISCONNECT)) {
|
||||
pauseOnHeadsetDisconnect = sp.getBoolean(PREF_PAUSE_ON_HEADSET_DISCONNECT, true);
|
||||
} else if (key.equals(PREF_UNPAUSE_ON_HEADSET_RECONNECT)) {
|
||||
unpauseOnHeadsetReconnect = sp.getBoolean(PREF_UNPAUSE_ON_HEADSET_RECONNECT, true);
|
||||
} else if (key.equals(PREF_AUTO_FLATTR_PLAYED_DURATION_THRESHOLD)) {
|
||||
autoFlattrPlayedDurationThreshold = sp.getFloat(PREF_AUTO_FLATTR_PLAYED_DURATION_THRESHOLD,
|
||||
PREF_AUTO_FLATTR_PLAYED_DURATION_THRESHOLD_DEFAULT);
|
||||
|
|
|
@ -1042,9 +1042,11 @@ public class PlaybackService extends Service {
|
|||
}
|
||||
|
||||
private void unpauseIfPauseOnDisconnect() {
|
||||
if (UserPreferences.isPauseOnHeadsetDisconnect() && transientPause) {
|
||||
if (transientPause) {
|
||||
transientPause = false;
|
||||
mediaPlayer.resume();
|
||||
if (UserPreferences.isPauseOnHeadsetDisconnect() && UserPreferences.isUnpauseOnHeadsetReconnect()) {
|
||||
mediaPlayer.resume();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -205,6 +205,7 @@
|
|||
<string name="services_label">Services</string>
|
||||
<string name="flattr_label">Flattr</string>
|
||||
<string name="pref_pauseOnHeadsetDisconnect_sum">Pause playback when the headphones are disconnected</string>
|
||||
<string name="pref_unpauseOnHeadsetReconnect_sum">Resume playback when the headphones are reconnected</string>
|
||||
<string name="pref_followQueue_sum">Jump to next queue item when playback completes</string>
|
||||
<string name="playback_pref">Playback</string>
|
||||
<string name="network_pref">Network</string>
|
||||
|
@ -214,6 +215,7 @@
|
|||
<string name="pref_followQueue_title">Continuous playback</string>
|
||||
<string name="pref_downloadMediaOnWifiOnly_title">WiFi media download</string>
|
||||
<string name="pref_pauseOnHeadsetDisconnect_title">Headphones disconnect</string>
|
||||
<string name="pref_unpauseOnHeadsetReconnect_title">Headphones reconnect</string>
|
||||
<string name="pref_mobileUpdate_title">Mobile updates</string>
|
||||
<string name="pref_mobileUpdate_sum">Allow updates over the mobile data connection</string>
|
||||
<string name="refreshing_label">Refreshing</string>
|
||||
|
|
Loading…
Reference in New Issue