android/app/src/main/java/org/libreoffice/androidapp/ui/LibreOfficeUIActivity.java | 115 +++++----- 1 file changed, 64 insertions(+), 51 deletions(-)
New commits: commit 74ec8892419753e4181b2cd5157bab1565f5cad4 Author: Jan Holesovsky <ke...@collabora.com> AuthorDate: Tue Jun 30 11:55:47 2020 +0200 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Thu Jul 2 10:11:55 2020 +0200 android: Intent.EXTRA_MIME_TYPES does not work on ChromeOS. From some reason, when we limit the mime types the same way as on normal Android, the ChromeOS file picker shows no files by default; the user has to use the dropdown in the bottom left to switch to All files, and then they can choose something to open. [Interestingly, the only other working choice is SVGZ/SVG; but the rest of the mime types are empty in the dropdown.] I haven't found any advice anywhere, so just disabled this for ChromeOS. Change-Id: I95195077ab936670050d980f4180d4b22bfa35d7 Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97483 Tested-by: Jenkins Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Jan Holesovsky <ke...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97715 Tested-by: Andras Timar <andras.ti...@collabora.com> Reviewed-by: Andras Timar <andras.ti...@collabora.com> diff --git a/android/app/src/main/java/org/libreoffice/androidapp/ui/LibreOfficeUIActivity.java b/android/app/src/main/java/org/libreoffice/androidapp/ui/LibreOfficeUIActivity.java index c1d9df818..f44723861 100644 --- a/android/app/src/main/java/org/libreoffice/androidapp/ui/LibreOfficeUIActivity.java +++ b/android/app/src/main/java/org/libreoffice/androidapp/ui/LibreOfficeUIActivity.java @@ -678,6 +678,11 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements Settings return true; } + /** True if the App is running under ChromeOS. */ + private boolean isChromeOS() { + return getPackageManager().hasSystemFeature("org.chromium.arc.device_management"); + } + /** Start an ACTION_OPEN_DOCUMENT Intent to trigger opening a document. */ private void openDocument() { collapseFabMenu(); @@ -689,57 +694,65 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements Settings // NOTE: If updating the list here, also check the AndroidManifest.xml, // I didn't find a way how to do it from one central place :-( i.setType("*/*"); - final String[] mimeTypes = new String[] { - // ODF - "application/vnd.oasis.opendocument.text", - "application/vnd.oasis.opendocument.graphics", - "application/vnd.oasis.opendocument.presentation", - "application/vnd.oasis.opendocument.spreadsheet", - "application/vnd.oasis.opendocument.text-flat-xml", - "application/vnd.oasis.opendocument.graphics-flat-xml", - "application/vnd.oasis.opendocument.presentation-flat-xml", - "application/vnd.oasis.opendocument.spreadsheet-flat-xml", - - // ODF templates - "application/vnd.oasis.opendocument.text-template", - "application/vnd.oasis.opendocument.spreadsheet-template", - "application/vnd.oasis.opendocument.graphics-template", - "application/vnd.oasis.opendocument.presentation-template", - - // MS - "application/rtf", - "text/rtf", - "application/msword", - "application/vnd.ms-powerpoint", - "application/vnd.ms-excel", - "application/vnd.visio", - "application/vnd.visio.xml", - "application/x-mspublisher", - - // OOXML - "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", - "application/vnd.openxmlformats-officedocument.presentationml.presentation", - "application/vnd.openxmlformats-officedocument.presentationml.slideshow", - "application/vnd.openxmlformats-officedocument.wordprocessingml.document", - - // OOXML templates - "application/vnd.openxmlformats-officedocument.wordprocessingml.template", - "application/vnd.openxmlformats-officedocument.spreadsheetml.template", - "application/vnd.openxmlformats-officedocument.presentationml.template", - - // other - "text/csv", - "text/comma-separated-values", - "application/vnd.ms-works", - "application/vnd.apple.keynote", - "application/x-abiword", - "application/x-pagemaker", - "image/x-emf", - "image/x-svm", - "image/x-wmf", - "image/svg+xml" - }; - i.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes); + + // from some reason, the file picker on ChromeOS is confused when it + // gets the EXTRA_MIME_TYPES; to the user it looks like it is + // impossible to choose any files, unless they notice the dropdown in + // the bottom left and choose "All files". Interestingly, SVG / SVGZ + // are shown there as an option, the other mime types are just blank + if (!isChromeOS()) { + final String[] mimeTypes = new String[] { + // ODF + "application/vnd.oasis.opendocument.text", + "application/vnd.oasis.opendocument.graphics", + "application/vnd.oasis.opendocument.presentation", + "application/vnd.oasis.opendocument.spreadsheet", + "application/vnd.oasis.opendocument.text-flat-xml", + "application/vnd.oasis.opendocument.graphics-flat-xml", + "application/vnd.oasis.opendocument.presentation-flat-xml", + "application/vnd.oasis.opendocument.spreadsheet-flat-xml", + + // ODF templates + "application/vnd.oasis.opendocument.text-template", + "application/vnd.oasis.opendocument.spreadsheet-template", + "application/vnd.oasis.opendocument.graphics-template", + "application/vnd.oasis.opendocument.presentation-template", + + // MS + "application/rtf", + "text/rtf", + "application/msword", + "application/vnd.ms-powerpoint", + "application/vnd.ms-excel", + "application/vnd.visio", + "application/vnd.visio.xml", + "application/x-mspublisher", + + // OOXML + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + "application/vnd.openxmlformats-officedocument.presentationml.presentation", + "application/vnd.openxmlformats-officedocument.presentationml.slideshow", + "application/vnd.openxmlformats-officedocument.wordprocessingml.document", + + // OOXML templates + "application/vnd.openxmlformats-officedocument.wordprocessingml.template", + "application/vnd.openxmlformats-officedocument.spreadsheetml.template", + "application/vnd.openxmlformats-officedocument.presentationml.template", + + // other + "text/csv", + "text/comma-separated-values", + "application/vnd.ms-works", + "application/vnd.apple.keynote", + "application/x-abiword", + "application/x-pagemaker", + "image/x-emf", + "image/x-svm", + "image/x-wmf", + "image/svg+xml" + }; + i.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes); + } // TODO remember where the user picked the file the last time // TODO and that should default to Context.getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits