android/source/AndroidManifest_quest.xml | 18 ++++++++ android/source/build.gradle | 8 +++ android/source/src/java/org/libreoffice/ToolbarController.java | 22 ++-------- 3 files changed, 31 insertions(+), 17 deletions(-)
New commits: commit 494e3ed0c106ad0c6659b9ca570e4cd4f5511aa8 Author: Michael Weghorn <[email protected]> AuthorDate: Tue Nov 25 23:06:02 2025 +0100 Commit: Xisco Fauli <[email protected]> CommitDate: Wed Nov 26 12:59:07 2025 +0100 android: Have a single method for menu item (de)activation Instead of having one method that enables/disables a menu item and one that shows/hides it, let ToolbarController.setItemVisible take care of both. Use that method also where ToolbarController.enableMenuItem was used before and drop that now unused method. The way that hiding/disabling menu items was and is used is to do that when they are not applicable, in which case it seems reasonable to consistently both hide and disable them at the same time. Quoting from the MenuItem.setVisible doc [1]: > Sets the visibility of the menu item. Even if a menu item is not > visible, it may still be invoked via its shortcut (to completely disable > an item, set it to invisible and disabled). [1] https://developer.android.com/reference/android/view/MenuItem#setVisible(boolean) Change-Id: I5d05f5324a1fb5c69e38302b59b2ad56a45342ff Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194533 Tested-by: Jenkins Code-Style: Michael Weghorn <[email protected]> Reviewed-by: Michael Weghorn <[email protected]> (cherry picked from commit 8d015346d0ac21da7a4908ea35d2f736e9a0cc97) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194540 Reviewed-by: Xisco Fauli <[email protected]> Code-Style: Xisco Fauli <[email protected]> diff --git a/android/source/src/java/org/libreoffice/ToolbarController.java b/android/source/src/java/org/libreoffice/ToolbarController.java index 6e88d90aa7ca..466de485489e 100644 --- a/android/source/src/java/org/libreoffice/ToolbarController.java +++ b/android/source/src/java/org/libreoffice/ToolbarController.java @@ -46,19 +46,6 @@ public class ToolbarController implements Toolbar.OnMenuItemClickListener { clipboardManager = (ClipboardManager)mContext.getSystemService(Context.CLIPBOARD_SERVICE); } - private void enableMenuItem(final int menuItemId, final boolean enabled) { - LOKitShell.getMainHandler().post(new Runnable() { - public void run() { - MenuItem menuItem = mMainMenu.findItem(menuItemId); - if (menuItem != null) { - menuItem.setEnabled(enabled); - } else { - Log.e(LOGTAG, "MenuItem not found."); - } - } - }); - } - public void setEditModeOn(boolean enabled) { isEditModeOn = enabled; } @@ -240,7 +227,7 @@ public class ToolbarController implements Toolbar.OnMenuItemClickListener { void setupToolbars() { if (LibreOfficeMainActivity.isExperimentalMode()) { boolean enableSaveEntry = !LibreOfficeMainActivity.isReadOnlyMode() && mContext.hasLocationForSave(); - enableMenuItem(R.id.action_save, enableSaveEntry); + setItemVisible(R.id.action_save, enableSaveEntry); if (LibreOfficeMainActivity.isReadOnlyMode()) { // show message in case experimental mode is enabled (i.e. editing is supported in general), // but current document is readonly @@ -252,15 +239,16 @@ public class ToolbarController implements Toolbar.OnMenuItemClickListener { setItemVisible(R.id.action_parts, mContext.isDrawerEnabled()); final boolean enablePrint = mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_PRINTING); - enableMenuItem(R.id.action_print, enablePrint); setItemVisible(R.id.action_print, enablePrint); } - public void setItemVisible(final int item, boolean visible){ + public void setItemVisible(final int item, boolean visible) { LOKitShell.getMainHandler().post(new Runnable() { @Override public void run() { - mMainMenu.findItem(item).setVisible(visible); + final MenuItem menuItem = mMainMenu.findItem(item); + menuItem.setEnabled(visible); + menuItem.setVisible(visible); } }); } commit 4e5e23c995f7aaa13d90e036e6a7843def5f9edc Author: Michael Weghorn <[email protected]> AuthorDate: Tue Nov 25 20:53:40 2025 +0100 Commit: Xisco Fauli <[email protected]> CommitDate: Wed Nov 26 12:58:54 2025 +0100 android: Set activity size for Meta Quest in new product flavor For Meta Quest devices running Horizon OS, it is required that the default activity size is set to 1024x640, see also [1]. Add a new product flavor "quest" with an additional AndroidManifest_quest.xml that sets the corresponding attributes for the 2 main activities. Due to the manifest merge logic as described at [2], it is sufficient to only specify those extra attributes. The rest is taken from the main AndroidManifest.xml used for all build flavors. This makes the LibreOffice Viewer app on a Meta Quest 3 VR headset open in the specified size in landscape mode, while it was previously opening in a smaller window in portrait mode. Also, disable the experimental editing mode for that product flavor, as it seems to be even more experimental when tested on a Meta Quest than on another Android device. (Document UI doesn't update while typing.) The build flavor can either manually be selected in Android Studio ("Build" -> "Select Build Variant") or specified for the gradle target, e.g. ./gradlew assembleQuestRelease [1] https://developers.meta.com/horizon/documentation/android-apps/panel-sizing [2] https://developer.android.com/build/manage-manifests#merge-manifests Change-Id: Ia2b234f50694553d2b3458e4c57e8bb1b1a5baa8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194532 Code-Style: Michael Weghorn <[email protected]> Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> (cherry picked from commit b39da4be6fef36090f94ad5a6b19f602f65bfa9f) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194539 Code-Style: Xisco Fauli <[email protected]> Reviewed-by: Xisco Fauli <[email protected]> diff --git a/android/source/AndroidManifest_quest.xml b/android/source/AndroidManifest_quest.xml new file mode 100644 index 000000000000..f96b6494a1ab --- /dev/null +++ b/android/source/AndroidManifest_quest.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android"> + <application> + <!-- set a default activity size of 1024x640, + see https://developers.meta.com/horizon/documentation/android-apps/panel-sizing --> + <activity + android:name=".LibreOfficeMainActivity"> + <layout + android:defaultHeight="640dp" + android:defaultWidth="1024dp" /> + </activity> + <activity android:name="org.libreoffice.ui.LibreOfficeUIActivity"> + <layout + android:defaultHeight="640dp" + android:defaultWidth="1024dp" /> + </activity> + </application> +</manifest> diff --git a/android/source/build.gradle b/android/source/build.gradle index 85b76eeee62f..8a1666ff0df9 100644 --- a/android/source/build.gradle +++ b/android/source/build.gradle @@ -56,6 +56,7 @@ android { main.java.srcDirs = ['../Bootstrap/src', 'src/java'] main.jniLibs.srcDirs = ["${liboJniLibsdir}"] main.assets.srcDirs 'assets_strippedUI' + quest.manifest.srcFile 'AndroidManifest_quest.xml' } defaultConfig { // minSdkVersion is set in liboSettings.gradle @@ -84,6 +85,13 @@ android { dimension "default" buildConfigField 'boolean', 'ALLOW_EDITING', 'true' } + + // product flavor for Meta Quest devices (Horizon OS) + quest { + dimension "default" + buildConfigField 'boolean', 'ALLOW_EDITING', 'false' + } + } lint { warningsAsErrors true
