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>
This commit is contained in:
parent
90bf46e8d3
commit
1ad0ef3f61
@ -7,6 +7,7 @@ package com.wireguard.android.preference
|
|||||||
import android.Manifest
|
import android.Manifest
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
|
import android.os.Build
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.preference.Preference
|
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 getTitle() = context.getString(R.string.log_export_title)
|
||||||
|
|
||||||
override fun onClick() {
|
override fun onClick() {
|
||||||
FragmentUtils.getPrefActivity(this)
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
|
||||||
.ensurePermissions(arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE)) { _, grantResults ->
|
FragmentUtils.getPrefActivity(this)
|
||||||
if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
.ensurePermissions(arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE)) { _, grantResults ->
|
||||||
isEnabled = false
|
if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||||
exportLog()
|
isEnabled = false
|
||||||
|
exportLog()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
isEnabled = false
|
||||||
|
exportLog()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
Loading…
Reference in New Issue
Block a user