close activity after handling View intent

This commit is contained in:
tibbi 2022-02-28 22:46:46 +01:00
parent 173b6f73c7
commit 83fec3db4e
2 changed files with 6 additions and 2 deletions

View file

@ -371,7 +371,7 @@ class MainActivity : SimpleActivity() {
}
if (!File(data.path!!).isDirectory) {
tryOpenPathIntent(data.path!!, false)
tryOpenPathIntent(data.path!!, false, finishActivity = true)
}
} else {
openPath(config.homeFolder)

View file

@ -16,7 +16,7 @@ fun Activity.sharePaths(paths: ArrayList<String>) {
sharePathsIntent(paths, BuildConfig.APPLICATION_ID)
}
fun Activity.tryOpenPathIntent(path: String, forceChooser: Boolean, openAsType: Int = OPEN_AS_DEFAULT) {
fun Activity.tryOpenPathIntent(path: String, forceChooser: Boolean, openAsType: Int = OPEN_AS_DEFAULT, finishActivity: Boolean = false) {
if (!forceChooser && path.endsWith(".apk", true)) {
val uri = if (isNougatPlus()) {
FileProvider.getUriForFile(this, "${BuildConfig.APPLICATION_ID}.provider", File(path))
@ -32,6 +32,10 @@ fun Activity.tryOpenPathIntent(path: String, forceChooser: Boolean, openAsType:
}
} else {
openPath(path, forceChooser, openAsType)
if (finishActivity) {
finish()
}
}
}