diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2021-04-01 09:38:55 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2021-04-01 18:07:57 +0200 |
commit | b49d07a99109b8978e3af9292404e768378076ba (patch) | |
tree | 76487559f325f796ecba20b05dd40f1cddfa4d30 | |
parent | 2d2e8414cbc0e52359d9b0440f06d4c99135a227 (diff) |
android: Extract opening of file to separate method 'openDocument'
The method will also be used from elsewhere in a follow-up commit.
Change-Id: I94cbdfa9faf54fcb655233f43d13ced8740b88a0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113456
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
(cherry picked from commit 40115df50102bd5314a93f54042ae6d035c1f685)
-rw-r--r-- | android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java b/android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java index 539b355cc932..f9afa9578d56 100644 --- a/android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java +++ b/android/source/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java @@ -467,15 +467,7 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements Settings protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_CODE_OPEN_FILECHOOSER && resultCode == RESULT_OK) { final Uri fileUri = data.getData(); - - // "forward" to LibreOfficeMainActivity to open the file - Intent intent = new Intent(Intent.ACTION_VIEW, fileUri); - intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); - String packageName = getApplicationContext().getPackageName(); - ComponentName componentName = new ComponentName(packageName, - LibreOfficeMainActivity.class.getName()); - intent.setComponent(componentName); - startActivity(intent); + openDocument(fileUri); } else if (requestCode == REQUEST_CODE_CREATE_NEW_DOCUMENT) { // "forward" to LibreOfficeMainActivity to create + open the file final Uri fileUri = data.getData(); @@ -667,6 +659,17 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements Settings }.execute(document); } + private void openDocument(final Uri documentUri) { + // "forward" to LibreOfficeMainActivity to open the file + Intent intent = new Intent(Intent.ACTION_VIEW, documentUri); + intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); + String packageName = getApplicationContext().getPackageName(); + ComponentName componentName = new ComponentName(packageName, + LibreOfficeMainActivity.class.getName()); + intent.setComponent(componentName); + startActivity(intent); + } + private void createNewFileDialog() { final String extension; if (newDocType == DocumentType.WRITER) { |