diff options
author | Petar Kukolj <petarkukolj3@yahoo.com> | 2018-11-14 16:18:58 +0100 |
---|---|---|
committer | Petar Kukolj <petarkukolj3@yahoo.com> | 2018-11-14 16:40:59 +0100 |
commit | b3fbb0ec7574cf1090bfb410589753ba8ef51bbb (patch) | |
tree | 740faa9df0b769deca7e4d7f3c78c43657413a62 /core | |
parent | 68b245701e2ff11f23d2bdf1145e8189dc3709ac (diff) | |
download | AntennaPod-b3fbb0ec7574cf1090bfb410589753ba8ef51bbb.zip |
Add configurable behavior of the back button
This PR allows users to change how the back button functions. Closes #2196
Possible choices are following:
- **Default** - back button functions how it currently functions (closes the app if there is nowhere to go back to)
- **Open navigation drawer** - back button always opens the navigation drawer instead of closing the app
- **Double tap to exit** - like default, but requires two taps to close the app
- **Confirm to exit** - like default, but prompts user if they really want to exit
Diffstat (limited to 'core')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java | 15 | ||||
-rw-r--r-- | core/src/main/res/values/arrays.xml | 14 | ||||
-rw-r--r-- | core/src/main/res/values/strings.xml | 9 |
3 files changed, 38 insertions, 0 deletions
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 e6b5f9e1b..c80cfacba 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 @@ -52,6 +52,7 @@ public class UserPreferences { public static final String PREF_COMPACT_NOTIFICATION_BUTTONS = "prefCompactNotificationButtons"; public static final String PREF_LOCKSCREEN_BACKGROUND = "prefLockscreenBackground"; private static final String PREF_SHOW_DOWNLOAD_REPORT = "prefShowDownloadReport"; + private static final String PREF_BACK_BUTTON_BEHAVIOR = "prefBackButtonBehavior"; // Queue private static final String PREF_QUEUE_ADD_TO_FRONT = "prefQueueAddToFront"; @@ -809,4 +810,18 @@ public class UserPreferences { public enum VideoBackgroundBehavior { STOP, PICTURE_IN_PICTURE, CONTINUE_PLAYING } + + public enum BackButtonBehavior { + DEFAULT, OPEN_DRAWER, DOUBLE_TAP, SHOW_PROMPT + } + + public static BackButtonBehavior getBackButtonBehavior() { + switch (prefs.getString(PREF_BACK_BUTTON_BEHAVIOR, "default")) { + case "default": return BackButtonBehavior.DEFAULT; + case "drawer": return BackButtonBehavior.OPEN_DRAWER; + case "doubletap": return BackButtonBehavior.DOUBLE_TAP; + case "prompt": return BackButtonBehavior.SHOW_PROMPT; + default: return BackButtonBehavior.DEFAULT; + } + } } diff --git a/core/src/main/res/values/arrays.xml b/core/src/main/res/values/arrays.xml index 7e2fed054..2d84cbd70 100644 --- a/core/src/main/res/values/arrays.xml +++ b/core/src/main/res/values/arrays.xml @@ -277,4 +277,18 @@ <item>@string/select_all_above</item> <item>@string/select_all_below</item> </string-array> + + <string-array name="back_button_behavior_options"> + <item>@string/back_button_default</item> + <item>@string/back_button_open_drawer</item> + <item>@string/back_button_double_tap</item> + <item>@string/back_button_show_prompt</item> + </string-array> + + <string-array name="back_button_behavior_values"> + <item>default</item> + <item>drawer</item> + <item>doubletap</item> + <item>prompt</item> + </string-array> </resources> diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index ad91ecc76..fd5535462 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -470,6 +470,15 @@ <string name="pref_videoBehavior_sum">Behavior when leaving video playback</string> <string name="stop_playback">Stop playback</string> <string name="continue_playback">Continue audio playback</string> + <string name="behavior">Behavior</string> + <string name="pref_back_button_behavior_title">Back button behavior</string> + <string name="pref_back_button_behavior_sum">Change behavior of the back button.</string> + <string name="back_button_default">Default</string> + <string name="back_button_open_drawer">Open navigation drawer</string> + <string name="back_button_double_tap">Double tap to exit</string> + <string name="back_button_show_prompt">Confirm to exit</string> + <string name="close_prompt">Are you sure you want to close AntennaPod?</string> + <string name="double_tap_toast">Tap back button again to exit</string> <!-- Auto-Flattr dialog --> <string name="auto_flattr_enable">Enable automatic flattring</string> |