Enable separate functions for Previous and Rewind hardware buttons.

Added prefHardwarePreviousButtonRestarts preference.
This commit is contained in:
Daniel 2016-08-26 12:26:12 -04:00
parent da063d5e81
commit e7cc0ffe05
4 changed files with 21 additions and 0 deletions

View File

@ -109,6 +109,12 @@
android:key="prefHardwareForwardButtonSkips"
android:summary="@string/pref_hardwareForwardButtonSkips_sum"
android:title="@string/pref_hardwareForwardButtonSkips_title"/>
<de.danoeh.antennapod.preferences.SwitchCompatPreference
android:defaultValue="false"
android:enabled="true"
android:key="prefHardwarePreviousButtonRestarts"
android:summary="@string/pref_hardwarePreviousButtonRestarts_sum"
android:title="@string/pref_hardwarePreviousButtonRestarts_title"/>
<de.danoeh.antennapod.preferences.SwitchCompatPreference
android:defaultValue="true"
android:enabled="true"

View File

@ -65,6 +65,7 @@ public class UserPreferences {
public static final String PREF_UNPAUSE_ON_HEADSET_RECONNECT = "prefUnpauseOnHeadsetReconnect";
public static final String PREF_UNPAUSE_ON_BLUETOOTH_RECONNECT = "prefUnpauseOnBluetoothReconnect";
public static final String PREF_HARDWARE_FOWARD_BUTTON_SKIPS = "prefHardwareForwardButtonSkips";
public static final String PREF_HARDWARE_PREVIOUS_BUTTON_RESTARTS = "prefHardwarePreviousButtonRestarts";
public static final String PREF_FOLLOW_QUEUE = "prefFollowQueue";
public static final String PREF_SKIP_KEEPS_EPISODE = "prefSkipKeepsEpisode";
public static final String PREF_AUTO_DELETE = "prefAutoDelete";
@ -282,6 +283,10 @@ public class UserPreferences {
return prefs.getBoolean(PREF_HARDWARE_FOWARD_BUTTON_SKIPS, false);
}
public static boolean shouldHardwarePreviousButtonRestart() {
return prefs.getBoolean(PREF_HARDWARE_PREVIOUS_BUTTON_RESTARTS, false);
}
public static boolean isFollowQueue() {
return prefs.getBoolean(PREF_FOLLOW_QUEUE, true);

View File

@ -478,6 +478,14 @@ public class PlaybackService extends MediaBrowserServiceCompat {
mediaPlayer.seekDelta(UserPreferences.getFastFowardSecs() * 1000);
break;
case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
if(UserPreferences.shouldHardwarePreviousButtonRestart()) {
// user wants to restart current episode
mediaPlayer.seekTo(0);
} else {
// user wants to rewind current episode
mediaPlayer.seekDelta(-UserPreferences.getRewindSecs() * 1000);
}
break;
case KeyEvent.KEYCODE_MEDIA_REWIND:
mediaPlayer.seekDelta(-UserPreferences.getRewindSecs() * 1000);
break;

View File

@ -298,6 +298,8 @@
<string name="pref_unpauseOnBluetoothReconnect_sum">Resume playback when bluetooth reconnects</string>
<string name="pref_hardwareForwardButtonSkips_title">Forward button skips</string>
<string name="pref_hardwareForwardButtonSkips_sum">When pressing a hardware forward button skip to the next episode instead of fast-forwarding</string>
<string name="pref_hardwarePreviousButtonRestarts_title">Previous button restarts</string>
<string name="pref_hardwarePreviousButtonRestarts_sum">When pressing a hardware previous button restart playing the current episode instead of rewinding</string>
<string name="pref_followQueue_sum">Jump to next queue item when playback completes</string>
<string name="pref_auto_delete_sum">Delete episode when playback completes</string>
<string name="pref_auto_delete_title">Auto Delete</string>