Fix requesting write permissions on Q and above

Requesting WRITE_EXTERNAL_STORAGE is only required before Android Q.
This commit is contained in:
Markus Fisch
2021-12-10 19:45:50 +01:00
parent 10e02b3164
commit 47c252ab18
3 changed files with 9 additions and 3 deletions
@@ -152,7 +152,7 @@ class BarcodeFragment : Fragment() {
@SuppressLint("InflateParams")
private fun askForFileNameAndSave(fileType: FileType) {
val ac = activity ?: return
// write permission is only required before Android Q
// Write permission is only required before Android Q.
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q &&
!hasWritePermission(ac) { askForFileNameAndSave(fileType) }
) {
@@ -344,7 +344,10 @@ class DecodeFragment : Fragment() {
private fun askForFileNameAndSave(raw: ByteArray) {
val ac = activity ?: return
if (!hasWritePermission(ac) { askForFileNameAndSave(raw) }) {
// Write permission is only required before Android Q.
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q &&
!hasWritePermission(ac) { askForFileNameAndSave(raw) }
) {
return
}
scope.launch(Dispatchers.Main) {
@@ -364,7 +364,10 @@ class HistoryFragment : Fragment() {
scope.launch {
val ac = activity ?: return@launch
progressView.useVisibility {
if (!hasWritePermission(ac) { askToExportToFile() }) {
// Write permission is only required before Android Q.
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q &&
!hasWritePermission(ac) { askToExportToFile() }
) {
return@useVisibility
}
val options = context.resources.getStringArray(