aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ui
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2020-03-25 21:01:02 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2020-03-25 21:02:02 +0530
commit1ad0ef3f6106be116db3f82763a8776a86057d08 (patch)
tree83923229873631976bd49a6cd627cc5803b30731 /ui
parentstrings: Explicit indexing for 'import_partial_success' (diff)
downloadwireguard-android-1ad0ef3f6106be116db3f82763a8776a86057d08.tar.xz
wireguard-android-1ad0ef3f6106be116db3f82763a8776a86057d08.zip
LogExporterPreference: Don't ask for storage permissions on Android 10 and above
We use the proper MediaStore implementation on Android 10 which makes it unnecessary. Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'ui')
-rw-r--r--ui/src/main/java/com/wireguard/android/preference/LogExporterPreference.kt18
1 files changed, 12 insertions, 6 deletions
diff --git a/ui/src/main/java/com/wireguard/android/preference/LogExporterPreference.kt b/ui/src/main/java/com/wireguard/android/preference/LogExporterPreference.kt
index 1b907530..ede4b661 100644
--- a/ui/src/main/java/com/wireguard/android/preference/LogExporterPreference.kt
+++ b/ui/src/main/java/com/wireguard/android/preference/LogExporterPreference.kt
@@ -7,6 +7,7 @@ package com.wireguard.android.preference
import android.Manifest
import android.content.Context
import android.content.pm.PackageManager
+import android.os.Build
import android.util.AttributeSet
import android.util.Log
import androidx.preference.Preference
@@ -80,13 +81,18 @@ class LogExporterPreference(context: Context, attrs: AttributeSet?) : Preference
override fun getTitle() = context.getString(R.string.log_export_title)
override fun onClick() {
- FragmentUtils.getPrefActivity(this)
- .ensurePermissions(arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE)) { _, grantResults ->
- if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
- isEnabled = false
- exportLog()
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
+ FragmentUtils.getPrefActivity(this)
+ .ensurePermissions(arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE)) { _, grantResults ->
+ if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
+ isEnabled = false
+ exportLog()
+ }
}
- }
+ } else {
+ isEnabled = false
+ exportLog()
+ }
}
companion object {