diff options
author | Martin Fietz <Martin.Fietz@gmail.com> | 2016-10-02 23:38:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-02 23:38:05 +0200 |
commit | 3fa6c1bc200b161801a8e9dbd328e2da08d32522 (patch) | |
tree | 585c38d7750d247b2e2945ec148c3f74e051aa13 | |
parent | 7c028dd3e58f9116a36f337622de60feb23a79cb (diff) | |
parent | e7cc0ffe05cd568c784431333df56ecae9a03762 (diff) | |
download | AntennaPod-3fa6c1bc200b161801a8e9dbd328e2da08d32522.zip |
Merge pull request #2109 from danielm5/enable-previous-button
Set current position to the begining on 'Previous' button
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 490dff94f..d5a1007af 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 eca3d1bb9..e67dc9d0a 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> |