summaryrefslogtreecommitdiff
path: root/android/source/src/java/org/libreoffice/ui/FileUtilities.java
AgeCommit message (Collapse)Author
2021-04-16tdf#95615 android: Don't offer "Save" after opening templatedistro/lhm/libreoffice-7-1+backportsMichael Weghorn
When the input document in Android Viewer is a template, a new doc is created and a plain '.uno:Save' (which 'LibreOfficeMainActivity#saveDocument' triggers when the "Save" menu entry is selected) will therefore fail. A proper URI to save to (rather than overwriting the template itself) is only known after a "Save As" anyway, so don't set the 'mDocument' member until then, which leads to the "Save" menu entry becoming disabled, just as is the case when explicitly choosing to create a new document in the start activity. For now, the check whether the document is a template checks whether the MIME type detected for the URI ends with "template", which is the case for ODF and OOXML types (like "application/vnd.oasis.opendocument.text-template" or "application/vnd.openxmlformats-officedocument.wordprocessingml.template"). This can be refined further as needed, e.g. by explicitly adding more MIME types to check. (Editing the actual template instead of creating a new doc from it would be a different use case that remains unsupported also with this change in place.) Change-Id: I81ff957de27f620a026dbc01097b8061886293a1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114157 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> (cherry picked from commit 01521db61eb41447113c4bb671ac828a583c0cd1)
2021-04-16android: Show file picker for new docs on "Save As"Michael Weghorn
When creating a new document in Android Viewer, don't show a file picker to choose where to save the file at once, but create a new document and only ask where to save the file once "Save As" has been selected. The plain "Save" entry is disabled until then, since no URI to save to is known at this time. The handling for the temporary local file, which is used for all of the "actual work" remains unchanged. While at it, rename 'ToolbarController#disableMenuItem' to 'ToolbarController#enableMenuItem' and invert the meaning of the boolean parameter since I find that more straightforward and it also better matches the naming of the underlying 'MenuItem' method as well. Change-Id: I3eefada5531bfb2202aca25f2c9f170a463f87f6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114152 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> (cherry picked from commit 5ce43b2b4e79c51f0d8922caf77fa6492c05c2a7)
2021-04-16android: Drop unused 'FileUtilities#doAccept'Michael Weghorn
Change-Id: I8b7f268862c3800012548376b3e60ac1f7dca9e3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114151 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> (cherry picked from commit 865ec16158b04cf98efae4309b40244a7e41eb59)
2021-04-16android: Ask where to save PDF file on exportMichael Weghorn
In Android Viewer, show a file picker to select where to save the PDF file on PDF export, rather than unconditionally trying to save in the "Documents" directory. This also means that permission 'android.PERMISSION_WRITE_EXTERNAL_STORAGE' is now no longer needed for this task, s. commit message from commit 7d9db806d65cb814af1e99a1e79c3db5aa7c17d5 Date: Fri Apr 9 11:24:16 2021 +0200 android: Request PERMISSION_WRITE_EXTERNAL_STORAGE again for more details. Also, adapt the 'TileKitProvider#saveDocumentAs' methods to return a boolean value indicating whether the save operation was successful, and trigger showing the message right into 'LibreOfficeMainActivity#exportToPDF'. Rename 'LOKitTileProvider#exportToPDF(boolean print)' to just 'LOKitTileProvider#printDocument()', since the only remaining use case for which it is used is printing now. Change-Id: I779d782813ca01640811690a388a4b7fd3db4b2a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114143 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> (cherry picked from commit 9ebcb80e2e4335fca1e137d015fe4d84631e282a)
2021-04-16android: Add a "Save As..." menu entryMichael Weghorn
This adds a "Save As..." menu entry to Android Viewer in order to save the currently opened file to a different location. Currently, the file is always saved in the corresponding ODF format, regardless of the original file type, i.e. that e.g. a DOCX file is saved in ODT format. (This could be extended to allow a selection of the target format as needed.) Like "Save As" (and as compared to "Save a Copy") in the desktop version, the app remembers the new document URI and subsequent save operations will overwrite the newly saved file, not the originally opened one. (There is no need to create a new temporary local file to use, though.) The directory of the currently used file is preselected in the file chooser used to specify where to save the new file. Make sure to copy the file in a non-main thread, since the destination URI might be handled by a DocumentsProvider that does network access. However, for now the main thread just waits for the separate thread to finish, just like commit 7f838b73e85eb6f0a1dce4647650a5cf5f34ccd2 Date: Fri Mar 19 15:46:36 2021 +0100 tdf#129833 android: Move reading file to separate thread implemented it for copying from the URI to the temporary file when opening a file. This also adds a 'TileProvider#isDrawing' method (like the already existing 'isTextDocument', 'isSpreadsheet' and 'isPresentation' ones). Change-Id: I6f56b71763431b89a6c74be35cc1e81fad136cd0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114058 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> (cherry picked from commit d16e569209fe40c2cb5776f7b9415e273d5b2387)
2021-04-07android: Drop custom file abstraction + UIMichael Weghorn
Android Viewer had its own file abstraction layer. From the (now deleted) IFile.java: > An abstraction of the File class, intended to be implemented by different > Document Providers. > > It represents a file or a directory in the context of a certain Document > Provider. It wraps the file-related operations and provides access to the > final document as a local File, downloading it if necessary. However, Android already provides such an abstraction by what is called "documents provider" there as well, s. [1]. Android Viewer has previously been adapted to support and make use of that. Therefore, drop the custom implementation to avoid duplication and having to reimplement functionality already provided otherwise. Also, drop the custom UI elements to display and select files implemented on top of the custom file abstraction. Support for using the system file picker (via the corresponding Intents) has been added earlier and is now the only available option to open files from within the app. [1] https://developer.android.com/training/data-storage/shared/documents-files Change-Id: Ide529e836a32fd7e880e5a72d971af9f9c7e74bf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113667 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> (cherry picked from commit a23bd42e9b2f6401c710ac95afcc3aa8f360d65c)
2021-04-01android: Move code to get doc's display name from URI to static helperMichael Weghorn
Will be used in LibreOfficeUIActivity as well. Change-Id: Ie1b99f0d31dba1be263459d135ee7fcb36613a7b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113457 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> (cherry picked from commit af56d15d6bbe92c7df0248ec72dc4d759580c378)
2021-03-22tdf#129833 android: Allow opening files using system file pickerMichael Weghorn
Extend Android Viewer with the possibility to select a file to open using the "system file picker", which can be opened by an Intent that has the action 'Intent.ACTION_OPEN_DOCUMENT' (or 'Intent.ACTION_GET_CONTENT' for API level < 19) set. This way, all locations supported by currently installed and set up DocumentsProviders [1] are generally supported. In a test, opening local files worked just fine, but trying to open a file located in a NextCloud share failed (with the corresponding app [2] installed), showing this in ADB log: I DownloadFileOperation: Download of /Documents/five_pages.odt to /storage/emulated/0/Android/media/com.nextcloud.client/nextcloud/<USERNAME>@demo2.nextcloud.com/Documents/five_pages.odt: Unexpected exception E DocumentsStorageProvider: RemoteOperationResult(mSuccess=false, mHttpCode=-1, mHttpPhrase=null, mException=android.os.NetworkOnMainThreadException, mCode=HOST_NOT_AVAILABLE, message=null, getLogMessage=Unexpected exception) This will be dealt with in a separate commit. For now, this way to open files (and a corresponding menu entry) is added in addition to the existing ones, but since that method should in general be able to cover all of the other use cases as well, the other options may be dropped in the future. [1] https://developer.android.com/reference/android/provider/DocumentsProvider [2] https://github.com/nextcloud/android Change-Id: I684a4aa770c0df7cc9fc35ff92445230405885f5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112768 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> (cherry picked from commit d678ee309b02b4cc8af29a097bf5053b8b1b4e06)
2018-11-02[Pardus] removed ignore hidden files on AndroidMert Tumer
ignore hidden files statment is obsolete because we put option on settings whether they are shown or not This patch is sponsored by ULAKBIM/Pardus project. Signed-off-by: Mert Tumer <merttumer@outlook.com> Change-Id: Ibba7ed76c20a189cff04e330a4493b3e84e5dba2 Reviewed-on: https://gerrit.libreoffice.org/62754 Tested-by: Jenkins Reviewed-by: Gülşah Köse <gulsah.1004@gmail.com>
2018-04-19tdf#96795: Use locale-sensitive sorting in Android viewerMert Tümer
Change-Id: I98edec9f57f1bf0576e16a1ba3c0e023d6d0b6ed Signed-off-by: Mert Tümer <merttumer7@gmail.com> Reviewed-on: https://gerrit.libreoffice.org/52494 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
2017-04-18Discard StorageAccessFramework for creating new documentsbrainbreaker
This commit adds the ability to create a new document using existing file system browsing in the app. Usage of StorageAccessFramework to create new document has been ditched as it is not backward compatible. Change-Id: I852c3de337613cb01e689d532476d2c5f932c1b3 Reviewed-on: https://gerrit.libreoffice.org/36195 Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Tested-by: Tomaž Vajngerl <quikee@gmail.com>
2017-04-05android: simplify some if statements, remove redundant variablesChristian Lohmaier
Change-Id: I55a866ac66ffeab5fe2ebb45d86f68558b468650
2017-03-30tdf#106325 - No way to create a new Documentbrainbreaker
This commit will add the ability to create a new document. A FAB is used in home screen which on expansion gives four options namely new writer document, new impress, new Sheet or new Draw. Two new events loadNewDocument and saveDocumentAs have been added. Another major change includes the use of constraint layout in LOUIActivity layout as it decreases nesting of views and improves the app performance. This was needed because of the new FAB layouts being added. Support for vector drawables has been enabled. Change-Id: Ia3ea17f73c0d8514f8ddb7b9a1cbd2ce7de6ac08 Reviewed-on: https://gerrit.libreoffice.org/35183 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
2015-11-17android: don't crash on empty filelistCaolán McNamara
Change-Id: I46caceed3fdf0ad0aa51c8a8ede1177ca3d1855e
2015-10-15android: show flat ODS files in the doc browserMiklos Vajna
I forgot about this when I enabled other Calc file types in 07997cba7745997d7e2ed908a8764ba1f0777f1e (android: adapt doc browser to updated manifest that accepts Calc documents, 2015-01-19). Change-Id: Iabacffbfc09d806f09bc7e0f9307830bda8ebbe1
2015-10-03compare strings using equals, not with ==Christian Lohmaier
Change-Id: I8869980198123bbe9e86e12638e3316be24588c3
2015-10-03android: remove unused imports, call static methods the static wayChristian Lohmaier
and remove some redundant casts Change-Id: If58a395227e4b9d54b0d757032d4a55c25315019
2015-06-11java:regulatize the order of 'final' and public/privateNoel Grandin
Make the order be 'public static' or 'private static' Just makes the code nicer to read. Change-Id: I182424bda45a2d68642e5d04c6091d268ace1fe2 Reviewed-on: https://gerrit.libreoffice.org/16202 Reviewed-by: Noel Grandin <noelgrandin@gmail.com> Tested-by: Noel Grandin <noelgrandin@gmail.com>
2015-05-21Let's simplify the paths and be less 'experimental'Tor Lillqvist