Kaydet (Commit) 450647a8 authored tarafından Miklos Vajna's avatar Miklos Vajna

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
üst ca9a81b2
...@@ -71,7 +71,8 @@ public class LOKitTileProvider implements TileProvider { ...@@ -71,7 +71,8 @@ public class LOKitTileProvider implements TileProvider {
LibreOfficeMainActivity.mAppContext.getDocumentPartView().clear(); 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++) { for (int i = 0; i < parts; i++) {
String partName = mDocument.getPartName(i); String partName = mDocument.getPartName(i);
if (partName.isEmpty()) { if (partName.isEmpty()) {
...@@ -84,6 +85,8 @@ public class LOKitTileProvider implements TileProvider { ...@@ -84,6 +85,8 @@ public class LOKitTileProvider implements TileProvider {
final DocumentPartView partView = new DocumentPartView(i, partName, thumbnail(128)); final DocumentPartView partView = new DocumentPartView(i, partName, thumbnail(128));
LibreOfficeMainActivity.mAppContext.getDocumentPartView().add(partView); LibreOfficeMainActivity.mAppContext.getDocumentPartView().add(partView);
} }
} else {
LibreOfficeMainActivity.mAppContext.disableNavigationDrawer();
} }
mDocument.setPart(0); mDocument.setPart(0);
......
...@@ -72,7 +72,9 @@ public class LibreOfficeMainActivity extends Activity { ...@@ -72,7 +72,9 @@ public class LibreOfficeMainActivity extends Activity {
public boolean onPrepareOptionsMenu(Menu menu) { public boolean onPrepareOptionsMenu(Menu menu) {
// If the nav drawer is open, hide action items related to the content view // If the nav drawer is open, hide action items related to the content view
boolean isDrawerOpen = mDrawerLayout.isDrawerOpen(mDrawerList); 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); return super.onPrepareOptionsMenu(menu);
} }
...@@ -169,6 +171,16 @@ public class LibreOfficeMainActivity extends Activity { ...@@ -169,6 +171,16 @@ public class LibreOfficeMainActivity extends Activity {
return mDocumentPartView; 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() { public DocumentPartViewListAdapter getDocumentPartViewListAdapter() {
return mDocumentPartViewListAdapter; return mDocumentPartViewListAdapter;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment