From 1a0dc9bec6a2163b2219c841235173119168e7c8 Mon Sep 17 00:00:00 2001 From: Maxime Gervais Date: Mon, 27 May 2024 13:14:36 +0200 Subject: [PATCH] Android GUI: Open files fixes - Disable native file picker for android 4.4 (19) - Replace ACTION_OPEN_DOCUMENT by ACTION_GET_CONTENT Signed-off-by: Maxime Gervais --- Source/GUI/Android/app/build.gradle | 2 +- .../GUI/Android/app/src/main/AndroidManifest.xml | 4 ---- .../mediaarea/mediainfo/ReportListActivity.kt | 16 +++------------- 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/Source/GUI/Android/app/build.gradle b/Source/GUI/Android/app/build.gradle index 77e167901..d9d21b007 100644 --- a/Source/GUI/Android/app/build.gradle +++ b/Source/GUI/Android/app/build.gradle @@ -16,7 +16,7 @@ android { defaultConfig { applicationId "net.mediaarea.mediainfo" multiDexEnabled = true - minSdkVersion 14 + minSdkVersion 19 versionCode 42 versionName "24.04" targetSdkVersion 34 diff --git a/Source/GUI/Android/app/src/main/AndroidManifest.xml b/Source/GUI/Android/app/src/main/AndroidManifest.xml index ee8de6b57..68ad53cdc 100644 --- a/Source/GUI/Android/app/src/main/AndroidManifest.xml +++ b/Source/GUI/Android/app/src/main/AndroidManifest.xml @@ -8,9 +8,6 @@ - - - @@ -27,7 +24,6 @@ android:name=".ReportListActivity" android:label="@string/app_name" android:theme="@style/AppTheme.NoActionBar" - android:launchMode="singleInstance" android:configChanges="locale|layoutDirection" android:exported="true"> diff --git a/Source/GUI/Android/app/src/main/java/net/mediaarea/mediainfo/ReportListActivity.kt b/Source/GUI/Android/app/src/main/java/net/mediaarea/mediainfo/ReportListActivity.kt index f400454c1..2cebd8714 100644 --- a/Source/GUI/Android/app/src/main/java/net/mediaarea/mediainfo/ReportListActivity.kt +++ b/Source/GUI/Android/app/src/main/java/net/mediaarea/mediainfo/ReportListActivity.kt @@ -189,17 +189,7 @@ class ReportListActivity : AppCompatActivity(), ReportActivityListener { private fun handleUri(uri: Uri) { if (uri.scheme == "file") { - if (Build.VERSION.SDK_INT >= 33) { - if (checkSelfPermission(android.Manifest.permission.READ_MEDIA_IMAGES) != PackageManager.PERMISSION_GRANTED || - checkSelfPermission(android.Manifest.permission.READ_MEDIA_VIDEO) != PackageManager.PERMISSION_GRANTED || - checkSelfPermission(android.Manifest.permission.READ_MEDIA_AUDIO) != PackageManager.PERMISSION_GRANTED) { - pendingFileUris.add(uri) - ActivityCompat.requestPermissions(this@ReportListActivity, - arrayOf(android.Manifest.permission.READ_MEDIA_IMAGES, android.Manifest.permission.READ_MEDIA_VIDEO, android.Manifest.permission.READ_MEDIA_AUDIO), - READ_EXTERNAL_STORAGE_PERMISSION_REQUEST) - return - } - } else if (Build.VERSION.SDK_INT >= 23) { + if (Build.VERSION.SDK_INT >= 23) { if (checkSelfPermission(android.Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { pendingFileUris.add(uri) ActivityCompat.requestPermissions(this@ReportListActivity, @@ -555,8 +545,8 @@ class ReportListActivity : AppCompatActivity(), ReportActivityListener { reportModel = ViewModelProvider(this, viewModelFactory)[ReportViewModel::class.java] activityReportListBinding.addButton.setOnClickListener { - if (Build.VERSION.SDK_INT >= 19) { - val intent = Intent(Intent.ACTION_OPEN_DOCUMENT) + if (Build.VERSION.SDK_INT >= 20) { // Official Android FileChooser is buggy on Android 4.4 (19) + val intent = Intent(Intent.ACTION_GET_CONTENT) intent.addCategory(Intent.CATEGORY_OPENABLE) intent.type = "*/*"