tdf#173650 android: Support opening Markdown files
Declare support for the Markdown MIME type
"text/markdown" for LibreOffice Viewer for Android.
Similar to CSV, make sure that the temporary file
passed to LibreOffice has a file name ending on
".md", otherwise it is imported as a plain text
file instead of a Markdown document.
This allows opening Markdown files from the Android
file manager ("Files" app) as tested successfully
on an Android AVD with API level 37 (Android 17).
However, when trying to open the file from within
the LibreOffice app ("Select file to open"), the
file is still grayed out and cannot be selected.
This will be addressed separately in upcoming commit
Change-Id: Ie071ce8770155b97dd3a70d26620560a39a7e356
Author: Michael Weghorn <m.weghorn@posteo.de>
Date: Mon Sep 21 14:51:38 2026 +0200
tdf#173650 android: Resolve MIME type if not passed in intent
Change-Id: I6a81dd65e7ef9a233ee9b507c9e133d419cf985c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/211291
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
This commit is contained in:
@@ -74,6 +74,7 @@
|
||||
<!-- OTHER -->
|
||||
<data android:mimeType="text/csv"/>
|
||||
<data android:mimeType="text/comma-separated-values"/>
|
||||
<data android:mimeType="text/markdown"/>
|
||||
<data android:mimeType="application/vnd.ms-works" />
|
||||
<data android:mimeType="application/vnd.apple.keynote" />
|
||||
<data android:mimeType="application/x-abiword" />
|
||||
|
||||
@@ -330,11 +330,14 @@ public class LibreOfficeMainActivity extends AppCompatActivity implements Shared
|
||||
|
||||
private boolean copyFileToTemp(Uri documentUri) {
|
||||
// CSV files need a .csv suffix to be opened in Calc.
|
||||
// Markdown files need an .md suffix to be imported as Markdown and not plain text
|
||||
String suffix = null;
|
||||
String intentType = getIntent().getType();
|
||||
// K-9 mail uses the first, GMail uses the second variant.
|
||||
if ("text/comma-separated-values".equals(intentType) || "text/csv".equals(intentType))
|
||||
suffix = ".csv";
|
||||
else if ("text/markdown".equals(intentType))
|
||||
suffix = ".md";
|
||||
|
||||
try {
|
||||
mTempFile = File.createTempFile("LibreOffice", suffix, this.getCacheDir());
|
||||
|
||||
@@ -85,6 +85,7 @@ public class FileUtilities {
|
||||
|
||||
// Other
|
||||
mExtnMap.put(".csv", CALC);
|
||||
mExtnMap.put(".md", DOC);
|
||||
mExtnMap.put(".wps", DOC);
|
||||
mExtnMap.put(".key", IMPRESS);
|
||||
mExtnMap.put(".abw", DOC);
|
||||
|
||||
@@ -111,6 +111,7 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements View.OnC
|
||||
"application/vnd.openxmlformats-officedocument.presentationml.template",
|
||||
"text/csv",
|
||||
"text/comma-separated-values",
|
||||
"text/markdown",
|
||||
"application/vnd.ms-works",
|
||||
"application/vnd.apple.keynote",
|
||||
"application/x-abiword",
|
||||
|
||||
Reference in New Issue
Block a user