1
0
mirror of https://github.com/etesync/android synced 2024-11-24 17:08: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"/>
<!-- Used for external log and vcf import. -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<!-- Used for external log and vcf import. Permissions changed for SDK >= 33. -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32"/>
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
<!-- other permissions -->
<!-- android.permission-group.CONTACTS -->

View File

@ -10,6 +10,7 @@ import android.content.ActivityNotFoundException
import android.content.Intent
import android.content.pm.PackageManager
import android.os.Build
import android.os.Build.VERSION.SDK_INT
import android.os.Bundle
import android.provider.CalendarContract
import android.provider.ContactsContract
@ -63,7 +64,11 @@ class ImportFragment : DialogFragment() {
@TargetApi(Build.VERSION_CODES.M)
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 {