move the OTG permissions dialog showing in an own function

This commit is contained in:
tibbi 2019-03-25 19:05:04 +01:00
parent 3ff3c84f97
commit b0137dd1e8
2 changed files with 20 additions and 16 deletions

View file

@ -7,7 +7,7 @@ buildscript {
propMinSdkVersion = 21
propTargetSdkVersion = propCompileSdkVersion
propVersionCode = 1
propVersionName = '5.10.15'
propVersionName = '5.10.16'
kotlin_version = '1.3.21'
}

View file

@ -114,26 +114,30 @@ fun Activity.isShowingSAFDialog(path: String): Boolean {
fun BaseSimpleActivity.isShowingOTGDialog(path: String): Boolean {
return if (isPathOnOTG(path) && (baseConfig.OTGTreeUri.isEmpty() || !hasProperStoredTreeUri(true))) {
runOnUiThread {
if (!isDestroyed && !isFinishing) {
WritePermissionDialog(this, true) {
Intent(Intent.ACTION_OPEN_DOCUMENT_TREE).apply {
if (resolveActivity(packageManager) == null) {
type = "*/*"
}
showOTGPermissionDialog()
true
} else {
false
}
}
if (resolveActivity(packageManager) != null) {
startActivityForResult(this, OPEN_DOCUMENT_TREE_OTG)
} else {
toast(R.string.unknown_error_occurred)
}
fun Activity.showOTGPermissionDialog() {
runOnUiThread {
if (!isDestroyed && !isFinishing) {
WritePermissionDialog(this, true) {
Intent(Intent.ACTION_OPEN_DOCUMENT_TREE).apply {
if (resolveActivity(packageManager) == null) {
type = "*/*"
}
if (resolveActivity(packageManager) != null) {
startActivityForResult(this, OPEN_DOCUMENT_TREE_OTG)
} else {
toast(R.string.unknown_error_occurred)
}
}
}
}
true
} else {
false
}
}