Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix no permission to import from file #254

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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 -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down