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>
This commit is contained in:
@@ -14,6 +14,7 @@
|
|||||||
<string name="about_license">Show License</string>
|
<string name="about_license">Show License</string>
|
||||||
<string name="about_notice">Show Notice</string>
|
<string name="about_notice">Show Notice</string>
|
||||||
<string name="about_moreinfo">More Info</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="browser_app_name">LibreOffice Browser</string>
|
||||||
<string name="menu_search">Search</string>
|
<string name="menu_search">Search</string>
|
||||||
|
@@ -20,6 +20,7 @@ import android.graphics.drawable.BitmapDrawable;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v4.widget.DrawerLayout;
|
import android.support.v4.widget.DrawerLayout;
|
||||||
import android.support.v7.app.ActionBar;
|
import android.support.v7.app.ActionBar;
|
||||||
@@ -96,6 +97,7 @@ public class LibreOfficeUIActivity extends ActionBarActivity implements ActionBa
|
|||||||
ListView lv;
|
ListView lv;
|
||||||
|
|
||||||
private final LOAbout mAbout;
|
private final LOAbout mAbout;
|
||||||
|
private boolean canQuit = false;
|
||||||
|
|
||||||
public LibreOfficeUIActivity() {
|
public LibreOfficeUIActivity() {
|
||||||
mAbout = new LOAbout(this, true);
|
mAbout = new LOAbout(this, true);
|
||||||
@@ -197,6 +199,31 @@ public class LibreOfficeUIActivity extends ActionBarActivity implements ActionBa
|
|||||||
drawerLayout.closeDrawer(drawerList);
|
drawerLayout.closeDrawer(drawerList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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
|
@Override
|
||||||
public void onCreateContextMenu(ContextMenu menu, View v,
|
public void onCreateContextMenu(ContextMenu menu, View v,
|
||||||
ContextMenuInfo menuInfo) {
|
ContextMenuInfo menuInfo) {
|
||||||
|
Reference in New Issue
Block a user