1
0
mirror of https://github.com/etesync/android synced 2024-11-21 23:48:11 +00:00

Fix no permission to import from file (#254)

* Fix no permission to import from file for Android 13+

* Made changes and successfully tested fixing no permission to import from file for Android 13+
This commit is contained in:
jahway603 2024-03-01 18:08:24 -05:00 committed by GitHub
parent 425c637ead
commit 00425eb281
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 3 deletions

View File

@ -36,8 +36,9 @@
--> -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18"/>
<!-- Used for external log and vcf import. --> <!-- Used for external log and vcf import. Permissions changed for SDK >= 33. -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32"/>
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
<!-- other permissions --> <!-- other permissions -->
<!-- android.permission-group.CONTACTS --> <!-- android.permission-group.CONTACTS -->

View File

@ -10,6 +10,7 @@ import android.content.ActivityNotFoundException
import android.content.Intent import android.content.Intent
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.os.Build import android.os.Build
import android.os.Build.VERSION.SDK_INT
import android.os.Bundle import android.os.Bundle
import android.provider.CalendarContract import android.provider.CalendarContract
import android.provider.ContactsContract import android.provider.ContactsContract
@ -63,7 +64,11 @@ class ImportFragment : DialogFragment() {
@TargetApi(Build.VERSION_CODES.M) @TargetApi(Build.VERSION_CODES.M)
private fun requestPermissions() { private fun requestPermissions() {
requestPermissions(arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE), 0) if (SDK_INT <= 32) {
requestPermissions(kotlin.arrayOf(android.Manifest.permission.READ_EXTERNAL_STORAGE), 0)
} else {
requestPermissions(arrayOf(Manifest.permission.READ_MEDIA_IMAGES), 0)
}
} }
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {