diff options
-rw-r--r-- | subsonic-android/res/values/strings.xml | 1 | ||||
-rw-r--r-- | subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java | 18 |
2 files changed, 8 insertions, 11 deletions
diff --git a/subsonic-android/res/values/strings.xml b/subsonic-android/res/values/strings.xml index 839a3e49..4e96ad5a 100644 --- a/subsonic-android/res/values/strings.xml +++ b/subsonic-android/res/values/strings.xml @@ -50,6 +50,7 @@ <string name="main.albums_highest">Top rated</string>
<string name="main.albums_starred">Starred</string>
<string name="main.albums_random">Random</string>
+ <string name="main.back_confirm">Press back again to exit</string>
<string name="menu.search">Search</string>
<string name="menu.shuffle">Shuffle</string>
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java index 5342f367..9930d2b0 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java @@ -37,6 +37,7 @@ public class MainActivity extends SubsonicActivity { private TextView trackView;
private TextView artistView;
private ImageButton startButton;
+ private long lastBackPressTime = 0;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -184,17 +185,12 @@ public class MainActivity extends SubsonicActivity { @Override
public void onBackPressed() {
if(pagerAdapter.onBackPressed()) {
- AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
- builder.setTitle(R.string.menu_exit)
- .setPositiveButton(R.string.common_ok, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int id) {
- MainActivity.super.onBackPressed();
- }
- })
- .setNegativeButton(R.string.common_cancel, null);
- AlertDialog dialog = builder.create();
- dialog.show();
+ if(lastBackPressTime < (System.currentTimeMillis() - 4000)) {
+ lastBackPressTime = System.currentTimeMillis();
+ Util.toast(this, R.string.main_back_confirm);
+ } else {
+ super.onBackPressed();
+ }
}
}
|