diff options
author | Mert Tumer <merttumer@outlook.com> | 2018-07-29 09:04:14 -0700 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2018-07-31 13:38:03 +0200 |
commit | cc61683a0e1dd67e838538a432b961322e5832be (patch) | |
tree | 3f24d6283d83fd0d43b083487f53ccec7de7dddf /android | |
parent | baac334dd2a8425714b0706ab764b6f00e83a65c (diff) |
Setting visibility of menu items instead of disabling or enabling them
On Android Viewer
Signed-off-by: Mert Tumer <merttumer@outlook.com>
Change-Id: I1fc21f84f5063afe3b91bf26401f9fcacc66b6c8
Reviewed-on: https://gerrit.libreoffice.org/58285
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'android')
-rw-r--r-- | android/source/res/menu/main.xml | 6 | ||||
-rw-r--r-- | android/source/src/java/org/libreoffice/LOKitTileProvider.java | 8 | ||||
-rw-r--r-- | android/source/src/java/org/libreoffice/ToolbarController.java | 20 |
3 files changed, 27 insertions, 7 deletions
diff --git a/android/source/res/menu/main.xml b/android/source/res/menu/main.xml index 92b40c250aaa..764e6e7f97c8 100644 --- a/android/source/res/menu/main.xml +++ b/android/source/res/menu/main.xml @@ -43,12 +43,12 @@ <item android:id="@+id/action_add_slide" android:title="@string/action_add_slide" android:orderInCategory="100" - android:enabled="false" /> + android:visible="false" /> <item android:id="@+id/action_add_worksheet" android:title="@string/action_add_worksheet" android:orderInCategory="100" - android:enabled="false" /> + android:visible="false" /> </group> <group android:id="@+id/group_edit_clipboard" @@ -90,7 +90,7 @@ <item android:id="@+id/action_presentation" android:title="@string/action_presentation" android:orderInCategory="100" - android:enabled="false" /> + android:visible="false" /> <item android:id="@+id/action_parts" android:title="@string/action_parts" diff --git a/android/source/src/java/org/libreoffice/LOKitTileProvider.java b/android/source/src/java/org/libreoffice/LOKitTileProvider.java index f094e49f5a8f..e5c32dee64ed 100644 --- a/android/source/src/java/org/libreoffice/LOKitTileProvider.java +++ b/android/source/src/java/org/libreoffice/LOKitTileProvider.java @@ -123,11 +123,11 @@ class LOKitTileProvider implements TileProvider { mContext.getDocumentPartView().clear(); if (mDocument.getDocumentType() == Document.DOCTYPE_PRESENTATION) { - mContext.getToolbarController().disableMenuItem(R.id.action_presentation, false); - mContext.getToolbarController().disableMenuItem(R.id.action_add_slide, false); + mContext.getToolbarController().showItem(R.id.action_presentation); + mContext.getToolbarController().showItem(R.id.action_add_slide); } if (mDocument.getDocumentType() == Document.DOCTYPE_SPREADSHEET) { - mContext.getToolbarController().disableMenuItem(R.id.action_add_worksheet, false); + mContext.getToolbarController().showItem(R.id.action_add_worksheet); } // Writer documents always have one part, so hide the navigation drawer. @@ -146,7 +146,7 @@ class LOKitTileProvider implements TileProvider { } } else { mContext.disableNavigationDrawer(); - mContext.getToolbarController().disableMenuItem(R.id.action_parts, true); + mContext.getToolbarController().hideItem(R.id.action_parts); } // Enable headers for Calc documents diff --git a/android/source/src/java/org/libreoffice/ToolbarController.java b/android/source/src/java/org/libreoffice/ToolbarController.java index 146be9fdfd7c..204664d80004 100644 --- a/android/source/src/java/org/libreoffice/ToolbarController.java +++ b/android/source/src/java/org/libreoffice/ToolbarController.java @@ -227,6 +227,26 @@ public class ToolbarController implements Toolbar.OnMenuItemClickListener { mMainMenu.findItem(R.id.action_parts).setVisible(mContext.isDrawerEnabled()); } + public void showItem(final int item){ + LOKitShell.getMainHandler().post(new Runnable() { + @Override + public void run() { + mMainMenu.findItem(item).setVisible(true); + + } + }); + } + + public void hideItem(final int item){ + LOKitShell.getMainHandler().post(new Runnable() { + @Override + public void run() { + mMainMenu.findItem(item).setVisible(false); + + } + }); + } + } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |