summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacobo Aragunde Pérez <jaragunde@igalia.com>2015-06-10 19:04:22 +0200
committerJacobo Aragunde Pérez <jaragunde@igalia.com>2015-06-12 09:32:12 +0000
commitd1f671e053864d0bf54d04a855761b43a7f5a9c4 (patch)
tree3e786e5e8beb06472322e116d51da73648d4653b
parentcafae25b04d4c7cdb930a053472d6b11c1943716 (diff)
tdf#87434: android: system back key to go one level up
Added an additional check so back has to be pressed twice on the root folder to actually leave the application. It's a check seen in many other apps. Change-Id: I26827113a41070aa8188fa616ba8fe53742329b3 Reviewed-on: https://gerrit.libreoffice.org/16245 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Jacobo Aragunde Pérez <jaragunde@igalia.com>
-rw-r--r--android/source/res/values/strings.xml1
-rw-r--r--android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java27
2 files changed, 28 insertions, 0 deletions
diff --git a/android/source/res/values/strings.xml b/android/source/res/values/strings.xml
index 94ba49f7b148..e2afccaf9f85 100644
--- a/android/source/res/values/strings.xml
+++ b/android/source/res/values/strings.xml
@@ -14,6 +14,7 @@
<string name="about_license">Show License</string>
<string name="about_notice">Show Notice</string>
<string name="about_moreinfo">More Info</string>
+ <string name="back_again_to_quit">Press back again to quit</string>
<string name="browser_app_name">LibreOffice Browser</string>
<string name="menu_search">Search</string>
diff --git a/android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java b/android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
index a8f42765a873..8ceca05938c2 100644
--- a/android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
+++ b/android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
@@ -20,6 +20,7 @@ import android.graphics.drawable.BitmapDrawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
+import android.os.Handler;
import android.preference.PreferenceManager;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBar;
@@ -96,6 +97,7 @@ public class LibreOfficeUIActivity extends ActionBarActivity implements ActionBa
ListView lv;
private final LOAbout mAbout;
+ private boolean canQuit = false;
public LibreOfficeUIActivity() {
mAbout = new LOAbout(this, true);
@@ -198,6 +200,31 @@ public class LibreOfficeUIActivity extends ActionBarActivity implements ActionBa
}
@Override
+ public void onBackPressed() {
+ if (!currentDirectory.equals(homeDirectory)) {
+ // navigate upwards in directory hierarchy
+ openParentDirectory();
+ } else {
+ // only exit if warning has been shown
+ if (canQuit) {
+ super.onBackPressed();
+ return;
+ }
+
+ // show warning about leaving the app and set a timer
+ Toast.makeText(this, R.string.back_again_to_quit,
+ Toast.LENGTH_SHORT).show();
+ canQuit = true;
+ new Handler().postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ canQuit = false;
+ }
+ }, 3000);
+ }
+ }
+
+ @Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);