From 4bba7fbc22f13d579e57b36e8c8e302d987e01f0 Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Fri, 8 Dec 2023 16:34:19 +0100 Subject: android lint: Add API level check for EXTRA_INITIAL_URI `DocumentsContract.EXTRA_INITIAL_URI` was added in API level 26, so only set it conditionally when that API level is avaible. Change-Id: I6783e89f50354c017968b74cc45fb1a3b6faab83 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160468 Tested-by: Jenkins Reviewed-by: Christian Lohmaier --- .../source/src/java/org/libreoffice/LibreOfficeMainActivity.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'android') diff --git a/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java b/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java index 23bf8d27b6c3..cf60ff37c5da 100644 --- a/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java +++ b/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java @@ -324,7 +324,9 @@ public class LibreOfficeMainActivity extends AppCompatActivity implements Settin intent.addCategory(Intent.CATEGORY_OPENABLE); String mimeType = getODFMimeTypeForDocument(); intent.setType(mimeType); - intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, mDocumentUri); + if (Build.VERSION.SDK_INT >= 26) { + intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, mDocumentUri); + } startActivityForResult(intent, REQUEST_CODE_SAVEAS); } @@ -351,7 +353,9 @@ public class LibreOfficeMainActivity extends AppCompatActivity implements Settin 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); + if (Build.VERSION.SDK_INT >= 26) { + 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); -- cgit