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 17:18:23 +0200 |
commit | 40115df50102bd5314a93f54042ae6d035c1f685 (patch) | |
tree | 77badc9a9e7d5c81d1d2c1005b1791b0e54920e5 /android/source/src | |
parent | f02095fd225f0d2ea52ccc0c482a16dcb20a3fe8 (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>
Diffstat (limited to 'android/source/src')
-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) { |