From 83fec3db4e01378db43c1e5429d445d19bc1ee1a Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 28 Feb 2022 22:46:46 +0100 Subject: [PATCH] close activity after handling View intent --- .../filemanager/pro/activities/MainActivity.kt | 2 +- .../filemanager/pro/extensions/Activity.kt | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MainActivity.kt index 5b1c591e..33be19e4 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MainActivity.kt @@ -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) diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/extensions/Activity.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/extensions/Activity.kt index 3014823b..6dd00a83 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/extensions/Activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/extensions/Activity.kt @@ -16,7 +16,7 @@ fun Activity.sharePaths(paths: ArrayList) { 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() + } } }