diff options
Diffstat (limited to 'android/source/src')
-rw-r--r-- | android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java | 4 | ||||
-rw-r--r-- | android/source/src/java/org/libreoffice/ui/FileUtilities.java | 5 |
2 files changed, 9 insertions, 0 deletions
diff --git a/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java b/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java index b21ad02383d7..ba371bfd9c8a 100644 --- a/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java +++ b/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java @@ -350,7 +350,11 @@ public class LibreOfficeMainActivity extends AppCompatActivity implements Settin Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType(FileUtilities.MIMETYPE_PDF); + // suggest directory and file name based on the doc intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, mDocumentUri); + final String displayName = toolbarTop.getTitle().toString(); + final String suggestedFileName = FileUtilities.stripExtensionFromFileName(displayName) + ".pdf"; + intent.putExtra(Intent.EXTRA_TITLE, suggestedFileName); startActivityForResult(intent, REQUEST_CODE_EXPORT_TO_PDF); } diff --git a/android/source/src/java/org/libreoffice/ui/FileUtilities.java b/android/source/src/java/org/libreoffice/ui/FileUtilities.java index 902b30ed7794..7fc8c3c84eb1 100644 --- a/android/source/src/java/org/libreoffice/ui/FileUtilities.java +++ b/android/source/src/java/org/libreoffice/ui/FileUtilities.java @@ -124,6 +124,11 @@ public class FileUtilities { return mimeType != null && mimeType.endsWith("template"); } + public static String stripExtensionFromFileName(final String fileName) + { + return fileName.split("\\.[A-Za-z0-9]*$")[0]; + } + /** * Tries to retrieve the display (which should be the document name) * for the given URI using the given resolver. |