diff options
author | Daniel <moreno.daniel@gmail.com> | 2016-08-26 12:26:12 -0400 |
---|---|---|
committer | Daniel <moreno.daniel@gmail.com> | 2016-09-03 15:36:03 -0400 |
commit | e7cc0ffe05cd568c784431333df56ecae9a03762 (patch) | |
tree | 2c04d8276819eb50da75bf7df1f5ce0e3bf0dd69 | |
parent | da063d5e812777666615cafe98a2edf8fab3059c (diff) | |
download | AntennaPod-e7cc0ffe05cd568c784431333df56ecae9a03762.zip |
Enable separate functions for Previous and Rewind hardware buttons.
Added prefHardwarePreviousButtonRestarts preference.
4 files changed, 21 insertions, 0 deletions
diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index d907cee12..350e2e2ee 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -110,6 +110,12 @@ 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" android:key="prefFollowQueue" diff --git a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java index 0772597a2..7c01b7fef 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java +++ b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java @@ -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); diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java index 04b5b676d..15656de3b 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java @@ -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; diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index e243776f5..29fa7797f 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -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> |