summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorJacobo Aragunde Pérez <jaragunde@igalia.com>2015-06-11 20:22:52 +0200
committerJacobo Aragunde Pérez <jaragunde@igalia.com>2015-06-12 11:23:27 +0000
commitaa3cdfc8b61f8ef543a13741caf8cf88e3969a79 (patch)
tree134157888c1a5e7ad49c3714ffe043c1dd26f966 /android
parent371cecff13c1ba8d2ace97695c7ede6d90440736 (diff)
Android: show drawer ("hamburger") icon on root directory
When browsing the root directory, the application home button (on the top left corner) becomes a drawer icon. When not in the root dir, the icon is an arrow as usual. This will increase the visibility of the document providers feature. Also, modified the behavior of the system back key to close the drawer in case it is open. Change-Id: Id0ce932907bcec4b8601029482eda0c1c1f0df35 Reviewed-on: https://gerrit.libreoffice.org/16246 Reviewed-by: Jacobo Aragunde Pérez <jaragunde@igalia.com> Tested-by: Jacobo Aragunde Pérez <jaragunde@igalia.com>
Diffstat (limited to 'android')
-rw-r--r--android/source/res/values/strings.xml2
-rw-r--r--android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java43
2 files changed, 42 insertions, 3 deletions
diff --git a/android/source/res/values/strings.xml b/android/source/res/values/strings.xml
index e2afccaf9f85..5e2dd9b62521 100644
--- a/android/source/res/values/strings.xml
+++ b/android/source/res/values/strings.xml
@@ -46,6 +46,8 @@
<string name="share_via">Share via</string>
<!-- Document provider names -->
+ <string name="document_locations">Document locations</string>
+ <string name="close_document_locations">Close document locations</string>
<string name="local_documents">Local documents</string>
<string name="local_file_system">Local file system</string>
<string name="owncloud">ownCloud</string>
diff --git a/android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java b/android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
index 8ceca05938c2..dbc309de7aba 100644
--- a/android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
+++ b/android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
@@ -25,6 +25,7 @@ import android.preference.PreferenceManager;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
+import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.ContextMenu;
@@ -93,6 +94,7 @@ public class LibreOfficeUIActivity extends ActionBarActivity implements ActionBa
private DrawerLayout drawerLayout;
private ListView drawerList;
+ private ActionBarDrawerToggle drawerToggle;
GridView gv;
ListView lv;
@@ -128,6 +130,7 @@ public class LibreOfficeUIActivity extends ActionBarActivity implements ActionBa
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayShowTitleEnabled(false); //This should show current directory if anything
+ actionBar.setDisplayHomeAsUpEnabled(true);
//make the navigation spinner
Context context = actionBar.getThemedContext();
@@ -163,6 +166,25 @@ public class LibreOfficeUIActivity extends ActionBarActivity implements ActionBa
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
drawerList = (ListView) findViewById(R.id.left_drawer);
+ drawerToggle = new ActionBarDrawerToggle(this, drawerLayout,
+ R.string.document_locations, R.string.close_document_locations) {
+
+ @Override
+ public void onDrawerOpened(View drawerView) {
+ super.onDrawerOpened(drawerView);
+ supportInvalidateOptionsMenu();
+ drawerList.requestFocus(); // Make keypad navigation easier
+ }
+
+ @Override
+ public void onDrawerClosed(View drawerView) {
+ super.onDrawerClosed(drawerView);
+ supportInvalidateOptionsMenu();
+ }
+ };
+ drawerToggle.setDrawerIndicatorEnabled(true);
+ drawerLayout.setDrawerListener(drawerToggle);
+ drawerToggle.syncState();
// Set the adapter for the list view
drawerList.setAdapter(new ArrayAdapter<String>(this,
@@ -178,12 +200,19 @@ public class LibreOfficeUIActivity extends ActionBarActivity implements ActionBa
});
}
+ @Override
+ protected void onPostCreate(Bundle savedInstanceState) {
+ super.onPostCreate(savedInstanceState);
+
+ drawerToggle.syncState();
+ }
+
private void refreshView() {
// enable home icon as "up" if required
if (!currentDirectory.equals(homeDirectory)) {
- getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ drawerToggle.setDrawerIndicatorEnabled(false);
} else {
- getSupportActionBar().setDisplayHomeAsUpEnabled(false);
+ drawerToggle.setDrawerIndicatorEnabled(true);
}
FileUtilities.sortFiles(filePaths, sortMode);
@@ -201,7 +230,9 @@ public class LibreOfficeUIActivity extends ActionBarActivity implements ActionBa
@Override
public void onBackPressed() {
- if (!currentDirectory.equals(homeDirectory)) {
+ if (drawerLayout.isDrawerOpen(drawerList)) {
+ drawerLayout.closeDrawer(drawerList);
+ } else if (!currentDirectory.equals(homeDirectory)) {
// navigate upwards in directory hierarchy
openParentDirectory();
} else {
@@ -459,7 +490,13 @@ public class LibreOfficeUIActivity extends ActionBarActivity implements ActionBa
return true;
}
+ @Override
public boolean onOptionsItemSelected(MenuItem item) {
+ // Will close the drawer if the home button is pressed
+ if (drawerToggle.onOptionsItemSelected(item)) {
+ return true;
+ }
+
switch (item.getItemId()) {
case android.R.id.home:
if (!currentDirectory.equals(homeDirectory)){