diff --git a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java
index f506921d2..fffd751c9 100644
--- a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java
+++ b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java
@@ -27,6 +27,7 @@ import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
+import android.widget.Toast;
import com.bumptech.glide.Glide;
@@ -123,6 +124,8 @@ public class MainActivity extends CastEnabledActivity implements NavDrawerActivi
private Subscription subscription;
+ private long lastBackButtonPressTime = 0;
+
@Override
public void onCreate(Bundle savedInstanceState) {
setTheme(UserPreferences.getNoTitleTheme());
@@ -646,7 +649,33 @@ public class MainActivity extends CastEnabledActivity implements NavDrawerActivi
if(isDrawerOpen()) {
drawerLayout.closeDrawer(navDrawer);
} else {
- super.onBackPressed();
+ switch (UserPreferences.getBackButtonBehavior()) {
+ case OPEN_DRAWER:
+ drawerLayout.openDrawer(navDrawer);
+ break;
+ case SHOW_PROMPT:
+ new AlertDialog.Builder(this)
+ .setMessage(R.string.close_prompt)
+ .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int i) {
+ MainActivity.super.onBackPressed();
+ }
+ })
+ .setNegativeButton(R.string.no, null)
+ .setCancelable(false)
+ .show();
+ break;
+ case DOUBLE_TAP:
+ if(lastBackButtonPressTime < System.currentTimeMillis() - 2000) {
+ Toast.makeText(this, R.string.double_tap_toast, Toast.LENGTH_SHORT).show();
+ lastBackButtonPressTime = System.currentTimeMillis();
+ } else {
+ super.onBackPressed();
+ }
+ break;
+ default: super.onBackPressed();
+ }
}
}
diff --git a/app/src/main/res/xml/preferences_user_interface.xml b/app/src/main/res/xml/preferences_user_interface.xml
index da694b844..1d970a5f7 100644
--- a/app/src/main/res/xml/preferences_user_interface.xml
+++ b/app/src/main/res/xml/preferences_user_interface.xml
@@ -57,4 +57,14 @@
android:summary="@string/pref_lockscreen_background_sum"
android:title="@string/pref_lockscreen_background_title"/>
+
+
+
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 @@
- @string/select_all_above
- @string/select_all_below
+
+
+ - @string/back_button_default
+ - @string/back_button_open_drawer
+ - @string/back_button_double_tap
+ - @string/back_button_show_prompt
+
+
+
+ - default
+ - drawer
+ - doubletap
+ - prompt
+
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 @@
Behavior when leaving video playback
Stop playback
Continue audio playback
+ Behavior
+ Back button behavior
+ Change behavior of the back button.
+ Default
+ Open navigation drawer
+ Double tap to exit
+ Confirm to exit
+ Are you sure you want to close AntennaPod?
+ Tap back button again to exit
Enable automatic flattring