Provide the "Save As..." menu entry in Android
Viewer also if read-only mode is used, either
because the experimental editing mode is disabled
or there is no write access to the document.
This way, a copy of the original document
can be saved elsewhere.
In case experimental mode is enabled, editing
is allowed after saving the document.
Call 'ToolbarController#setEditMode' in
'ToolbarController#switchToEditMode' right away instead
of posting it to the main handler in a Runnable along
with the other commands (that change the UI), so the new state
is already taken into account in
'LibreOfficeMainActivity#onResume' and the toolbar
isn't switched back to view mode there right away.
Change-Id: I321e42d0833463b31c7b39336d66b29bd51d9890
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114539
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Don't only enable the "Export To PDF" and "Print" menu
items if the experimental editing mode is enabled, but
always offer them, since they should be sufficiently stable
and don't require any editing of the document.
To do so, move them into a new menu group
"group_misc_actions", and move the entry for sending
UNO commands up, so it remains in the
"group_edit_actions" menu group whose entries are
hidden unless editing mode is enabled.
Change-Id: I425cf6d0a45306ff48b45dad6fd0e804b87a2546
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114147
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
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>
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>
Move the view that opens the system file picker when tapped
above the "Recent files" view in the Android Viewer start
activity.
Change-Id: I63ee0ea7fb784a3405877fcf5ed587ce06e8e093
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113674
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
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>
Drop the "Press back again to quit" info shown when pressing
"Back" in the file selection dialog in Android Viewer and
just quit the app right away.
It was originally added in
commit d1f671e053864d0bf54d04a855761b43a7f5a9c4
Date: Wed Jun 10 19:04:22 2015 +0200
tdf#87434: android: system back key to go one level up
Added an additional check so back has to be pressed twice on the root
folder to actually leave the application. It's a check seen in many
other apps.
but I don't really see any need to bother the user
about pressing "Back" again. Nothing is lost at
this stage when quitting the app, and I haven't
seen anything similar in many current apps myself
(but have rather seen some extra confirmation dialogs
disappear from desktop applications over the last
years).
The original request in tdf#87434 to go one level up
in the directory hierarchy is unaffected by this,
though this only applies for the custom widgets
to browse the file system, which will potentially be
dropped in the future anyway, now that support
for the system file picker has been added in
commit d678ee309b02b4cc8af29a097bf5053b8b1b4e06
Author: Michael Weghorn <m.weghorn@posteo.de>
Date: Fri Mar 19 14:29:36 2021 +0100
tdf#129833 android: Allow opening files using system file picker
Change-Id: Ib324b7f0b82427b04c7708665ff7492a758eec9b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113413
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Similar to the way that existing documents can be
opened from within the Android Viewer app
using the system file picker by using
'Intent.ACTION_OPEN_DOCUMENT', use the system file picker
via 'Intent.ACTION_CREATE_DOCUMENT' to create new docs
as well, instead of providing a custom dialog to
insert a file name.
As described at [1], this allows to save files
in locations supported by any existing
DocumentsProvider (e.g. a Nextcloud share,
if the Nextcloud app is installed and set up),
not just locally.
This also allows to further unify the handling in
LOMainActivity. Just like for the cases where an
existing document is opened using the system file
picker or a document is passed from a third-party app,
the document URI is now set in the Intent, a
temporary file is used and writing back to the
actual URI happens on save.
Drop LibreOfficeMainActivity's method 'showSaveStatusMessage',
which was only meant to be used when a new file was created, but
was called from the more generic 'LOKitTileProvider::saveDocumentAs'.
Change that to show a more general error message when saving fails.
Since the actual file is now created by the DocumentsProvider,
LOKitTileProvider only operates on the temporary copy anyway.
Side note: With this change in place, overwriting
existing files also no longer just happens silently,
as used to be the case when typing the name of an existing
file in the custom dialog for creating new files
earlier.
Since 'Intent.ACTION_OPEN_DOCUMENT' was introduced
in SDK version 19 (Android 4.4), restrict creating
new docs to corresponding devices.
[1] https://developer.android.com/training/data-storage/shared/documents-files
Change-Id: I8932cb892ca8ac97a04d15cbd1540d0ee68350da
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113408
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
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>
When a document is passed by an Intent in Android
Viewer, allow editing if the Intent has flag
'Intent.FLAG_GRANT_WRITE_URI_PERMISSION' set.
Since LibreOffice operates on a temporary copy
in this case, write the content of the
temporary file back to the original URI
when saving.
This in particular allows editing documents
passed from third-party apps, e.g. opened from
Android's "Files" app or the NextCloud app.
The online-based Android app already does
something similar.
Change-Id: Icf252a95dd9a8089ca8610ccf3edfbeee2682e1a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112767
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Missing escaping became apparent after a local
gradle update, after which the build failed with
> Android resource compilation failed
.../android/source/res/values-tr/strings.xml:231:5-73: AAPT: error: unescaped apostrophe in string
.../android/source/res/values-tr/strings.xml:231:5-73: AAPT: error: not a valid string.
.../android/source/build/intermediates/incremental/mergeStrippedUIReleaseResources/merged.dir/values-tr/values-tr.xml: AAPT: error: file failed to compile.
Change-Id: Iaffabfe82ce1a1255919e48dc15bd40ad89d1f90
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90098
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
This fits better than the "File Explorer Settings" one.
The whole "General" section was hidden before when editing
mode was disabled for the build ('!BuildConfig.ALLOW_EDITING').
Since the language setting is unrelated to this, no longer
do so, but explicitly remove the two other entries in this group,
namely "ENABLE_DEVELOPER" and "ENABLE_EXPERIMENTAL".
Change-Id: I64d1abef38d7669fc1072b380f497ca83e23f265
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90096
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
... instead of "Enter" key that inserted a newline when clicked.
Instead, start a search in downward direction when the search button
is clicked, which makes using the search feature more intuitive.
I quickly tested with both, Writer and Calc.
Change-Id: Iffc9f6115e558721b34d8fb4ae2ed4a36c4a7aa5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90092
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
The naming for the directions UP and DOWN were used the wrong way
around, which was also apparent when looking at
'android/source/res/layout/toolbar_bottom.xml', where icon
'"@drawable/ic_search_direction_down"' was assigned to the
button with ID "@+id/button_search_up" (and vice versa).
Adapt the naming to avoid confusion.
Change-Id: I5cf59f1789f2c12651ce6a5638d559658d9d4deb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90091
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Instead of hard-coding the use of English as default
locale and allowing manually selecting another language,
this now makes the system's default locale to be used
by default in the Android Viewer. It's still possible to
explicitly select another language to override that.
In case there is no localization for the system locale,
an automatic fallback to English happens anyway, so there
should be no need to explicitly set the locale to English
in that case either.
Change-Id: I0b8cfafea6a4659c3657522cfd5895c00f25f054
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/85583
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
More hardcoded strings extrated to the resource file
Few Turkish language improvements
This patch is sponsored by ULAKBIM/Pardus project.
Signed-off-by: Mert Tumer <merttumer@outlook.com>
Change-Id: I9c49d1b8ec3dfc88a19832a2cdea2c7cbaf2be42
Reviewed-on: https://gerrit.libreoffice.org/62757
Tested-by: Jenkins
Reviewed-by: Gülşah Köse <gulsah.1004@gmail.com>
Added an settings option to enable Developer
Mode, in which you can send UNO commands
from the Viewer. You can also add properties
to the command.
Change-Id: I76cbb55771cdd5cea89da65ddf67e48e12745b41
Reviewed-on: https://gerrit.libreoffice.org/37045
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
This is a base change, further implementations may be added
Change-Id: I8aa5b5314f2b1e93821baf3da3e44803904f57fa
Reviewed-on: https://gerrit.libreoffice.org/57249
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
This patch prevents document browsing and creating
a new document from happening when write external
storage permission is denied by the user.
Signed-off-by: Mert Tümer <merttumer7@gmail.com>
Change-Id: Idf39a291a15a9dac023f4318329baed1baa90e14
Reviewed-on: https://gerrit.libreoffice.org/52868
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Also adjust to dynamic permissions after bumping target-SDK.
There still is some confusion about the concept of "external storage" in
the code. LocalDocuments already is "external storage" - clean that up a
little and use AppCompat function instead of using a legacy class for
ExternalDocuments provider.
Doesn't help for broken ROMs though, that would need guessing pathname
for a mounted SD (in addition to separate storage partition of builtin
storage).
Also c6e8c96d50fc2082a3c4b9553196a42bbdd6df37 incorrectly changed the
conditional around, making the whole ExternalDocumentsProvider useless/a
copy of the Local one (i.e. the primary, first returned by the system).
Real fix for tdf#99539 likely was 66be4feef7e0d3661f01fbb2372700de5eeea070
Change-Id: I88ca7742c0f2e89d63c338c8852ad88be0a46e4b
Reviewed-on: https://gerrit.libreoffice.org/45572
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>