From e9a4a2839b205c4351cc2ade00f4e4b5efb7dc29 Mon Sep 17 00:00:00 2001 From: Mark Adamson Date: Fri, 20 Mar 2015 13:57:33 +0000 Subject: Add option to disable 'Press back again to exit' prompt --- src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java | 2 +- src/github/daneren2005/dsub/util/Constants.java | 1 + src/github/daneren2005/dsub/util/Util.java | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src/github/daneren2005') diff --git a/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java b/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java index 791fa1c6..74329dd0 100644 --- a/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java +++ b/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java @@ -362,7 +362,7 @@ public class SubsonicFragmentActivity extends SubsonicActivity { @Override public void onBackPressed() { if(onBackPressedSupport()) { - if(lastBackPressTime < (System.currentTimeMillis() - 4000)) { + if(!Util.disableExitPrompt(this) && lastBackPressTime < (System.currentTimeMillis() - 4000)) { lastBackPressTime = System.currentTimeMillis(); Util.toast(this, R.string.main_back_confirm); } else { diff --git a/src/github/daneren2005/dsub/util/Constants.java b/src/github/daneren2005/dsub/util/Constants.java index b0bbfe31..0102aba1 100644 --- a/src/github/daneren2005/dsub/util/Constants.java +++ b/src/github/daneren2005/dsub/util/Constants.java @@ -153,6 +153,7 @@ public final class Constants { public static final String PREFERENCES_KEY_REPLAY_GAIN_TYPE= "replayGainType"; public static final String PREFERENCES_KEY_ALBUMS_PER_FOLDER = "albumsPerFolder"; public static final String PREFERENCES_KEY_CAST_PROXY = "castProxy"; + public static final String PREFERENCES_KEY_DISABLE_EXIT_PROMPT = "disableExitPrompt"; public static final String OFFLINE_SCROBBLE_COUNT = "scrobbleCount"; public static final String OFFLINE_SCROBBLE_ID = "scrobbleID"; diff --git a/src/github/daneren2005/dsub/util/Util.java b/src/github/daneren2005/dsub/util/Util.java index d23d7300..4d2a9a1a 100644 --- a/src/github/daneren2005/dsub/util/Util.java +++ b/src/github/daneren2005/dsub/util/Util.java @@ -424,6 +424,11 @@ public final class Util { return prefs.getString(Constants.PREFERENCES_KEY_OPEN_TO_TAB, null); } + public static boolean disableExitPrompt(Context context) { + SharedPreferences prefs = getPreferences(context); + return prefs.getBoolean(Constants.PREFERENCES_KEY_DISABLE_EXIT_PROMPT, false); + } + public static String getVideoPlayerType(Context context) { SharedPreferences prefs = getPreferences(context); return prefs.getString(Constants.PREFERENCES_KEY_VIDEO_PLAYER, "raw"); -- cgit v1.2.3