[Libreoffice-commits] core.git: android/experimental

Miklos Vajna vmiklos at collabora.co.uk
Tue Dec 16 07:17:05 PST 2014


 android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java       |    5 ++-
 android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java |   14 +++++++++-
 2 files changed, 17 insertions(+), 2 deletions(-)

New commits:
commit 450647a8a2e6f1e9f7474e1a5d82834e0d6cb594
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Dec 16 16:14:54 2014 +0100

    android: disable navigation drawer for Writer
    
    Writer documents currently always have one part, so it's not possible to
    switch to an other part anyway. Also hide the matching menu item
    accordingly.
    
    Change-Id: Ic634d46c4ff307416b2878e5bc8a590b22a827a0

diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
index 82908e1..848ec7b 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
@@ -71,7 +71,8 @@ public class LOKitTileProvider implements TileProvider {
 
         LibreOfficeMainActivity.mAppContext.getDocumentPartView().clear();
 
-        if (parts > 1) {
+        // Writer documents always have one part, so hide the navigation drawer.
+        if (mDocument.getDocumentType() != Document.DOCTYPE_TEXT) {
             for (int i = 0; i < parts; i++) {
                 String partName = mDocument.getPartName(i);
                 if (partName.isEmpty()) {
@@ -84,6 +85,8 @@ public class LOKitTileProvider implements TileProvider {
                 final DocumentPartView partView = new DocumentPartView(i, partName, thumbnail(128));
                 LibreOfficeMainActivity.mAppContext.getDocumentPartView().add(partView);
             }
+        } else {
+            LibreOfficeMainActivity.mAppContext.disableNavigationDrawer();
         }
 
         mDocument.setPart(0);
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
index ccb864b..16d0edf 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
@@ -72,7 +72,9 @@ public class LibreOfficeMainActivity extends Activity {
     public boolean onPrepareOptionsMenu(Menu menu) {
         // If the nav drawer is open, hide action items related to the content view
         boolean isDrawerOpen = mDrawerLayout.isDrawerOpen(mDrawerList);
-        menu.findItem(R.id.action_parts).setVisible(!isDrawerOpen);
+        // Do the same in case the drawer is locked.
+        boolean isDrawerLocked = mDrawerLayout.getDrawerLockMode(mDrawerList) != DrawerLayout.LOCK_MODE_UNLOCKED;
+        menu.findItem(R.id.action_parts).setVisible(!isDrawerOpen && !isDrawerLocked);
         return super.onPrepareOptionsMenu(menu);
     }
 
@@ -169,6 +171,16 @@ public class LibreOfficeMainActivity extends Activity {
         return mDocumentPartView;
     }
 
+    public void disableNavigationDrawer() {
+        // Only the original thread that created mDrawerLayout should touch its views.
+        LOKitShell.getMainHandler().post(new Runnable() {
+            @Override
+            public void run() {
+                mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, mDrawerList);
+            }
+        });
+    }
+
     public DocumentPartViewListAdapter getDocumentPartViewListAdapter() {
         return mDocumentPartViewListAdapter;
     }


More information about the Libreoffice-commits mailing list