adding an activity check at showing SAF dialog
This commit is contained in:
parent
097bb4e703
commit
368479b96b
2 changed files with 13 additions and 11 deletions
|
@ -7,7 +7,7 @@ buildscript {
|
||||||
propMinSdkVersion = 21
|
propMinSdkVersion = 21
|
||||||
propTargetSdkVersion = propCompileSdkVersion
|
propTargetSdkVersion = propCompileSdkVersion
|
||||||
propVersionCode = 1
|
propVersionCode = 1
|
||||||
propVersionName = '5.7.6'
|
propVersionName = '5.7.7'
|
||||||
kotlin_version = '1.3.21'
|
kotlin_version = '1.3.21'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,17 +91,19 @@ fun Activity.isAppInstalledOnSDCard(): Boolean = try {
|
||||||
fun Activity.isShowingSAFDialog(path: String, treeUri: String, requestCode: Int): Boolean {
|
fun Activity.isShowingSAFDialog(path: String, treeUri: String, requestCode: Int): Boolean {
|
||||||
return if (needsStupidWritePermissions(path) && (treeUri.isEmpty() || !hasProperStoredTreeUri())) {
|
return if (needsStupidWritePermissions(path) && (treeUri.isEmpty() || !hasProperStoredTreeUri())) {
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
WritePermissionDialog(this, false) {
|
if (!isDestroyed) {
|
||||||
Intent(Intent.ACTION_OPEN_DOCUMENT_TREE).apply {
|
WritePermissionDialog(this, false) {
|
||||||
putExtra("android.content.extra.SHOW_ADVANCED", true)
|
Intent(Intent.ACTION_OPEN_DOCUMENT_TREE).apply {
|
||||||
if (resolveActivity(packageManager) == null) {
|
putExtra("android.content.extra.SHOW_ADVANCED", true)
|
||||||
type = "*/*"
|
if (resolveActivity(packageManager) == null) {
|
||||||
}
|
type = "*/*"
|
||||||
|
}
|
||||||
|
|
||||||
if (resolveActivity(packageManager) != null) {
|
if (resolveActivity(packageManager) != null) {
|
||||||
startActivityForResult(this, requestCode)
|
startActivityForResult(this, requestCode)
|
||||||
} else {
|
} else {
|
||||||
toast(R.string.unknown_error_occurred)
|
toast(R.string.unknown_error_occurred)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue