From 4b91bf48f5ab827d8c694b0e6ce4d8947410072a Mon Sep 17 00:00:00 2001 From: Minh Truong Date: Fri, 1 Dec 2023 13:05:24 -0600 Subject: [PATCH] Finish parent activity after directory initializer completes Add frontIntent flag to control activity.finish() Moved parent activity finish inside of performLaunchChecks --- .../dolphinemu/activities/EmulationActivity.kt | 15 +++++++++------ .../dolphinemu/utils/StartupHandler.java | 3 +-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.kt index def62eb7ec..47921ce401 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.kt +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.kt @@ -1066,16 +1066,16 @@ class EmulationActivity : AppCompatActivity(), ThemeProvider { } @JvmStatic - fun launch(activity: FragmentActivity, filePaths: Array, riivolution: Boolean) { + fun launch(activity: FragmentActivity, filePaths: Array, riivolution: Boolean, fromIntent: Boolean = false) { if (ignoreLaunchRequests) return - performLaunchChecks(activity) { launchWithoutChecks(activity, filePaths, riivolution) } + performLaunchChecks(activity, fromIntent) { launchWithoutChecks(activity, filePaths, riivolution) } } @JvmStatic - fun launch(activity: FragmentActivity, filePath: String, riivolution: Boolean) = - launch(activity, arrayOf(filePath), riivolution) + fun launch(activity: FragmentActivity, filePath: String, riivolution: Boolean, fromIntent: Boolean = false) = + launch(activity, arrayOf(filePath), riivolution, fromIntent) private fun launchWithoutChecks( activity: FragmentActivity, @@ -1089,8 +1089,11 @@ class EmulationActivity : AppCompatActivity(), ThemeProvider { activity.startActivity(launcher) } - private fun performLaunchChecks(activity: FragmentActivity, continueCallback: Runnable) { + private fun performLaunchChecks(activity: FragmentActivity, fromIntent: Boolean, continueCallback: Runnable) { AfterDirectoryInitializationRunner().runWithLifecycle(activity) { + if (fromIntent) { + activity.finish() + } if (!FileBrowserHelper.isPathEmptyOrValid(StringSetting.MAIN_DEFAULT_ISO) || !FileBrowserHelper.isPathEmptyOrValid(StringSetting.MAIN_FS_PATH) || !FileBrowserHelper.isPathEmptyOrValid(StringSetting.MAIN_DUMP_PATH) || @@ -1129,7 +1132,7 @@ class EmulationActivity : AppCompatActivity(), ThemeProvider { if (ignoreLaunchRequests) return - performLaunchChecks(activity) { launchSystemMenuWithoutChecks(activity) } + performLaunchChecks(activity, false) { launchSystemMenuWithoutChecks(activity) } } private fun launchSystemMenuWithoutChecks(activity: FragmentActivity) { diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/StartupHandler.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/StartupHandler.java index 1cb332636e..63b8657f83 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/StartupHandler.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/StartupHandler.java @@ -37,8 +37,7 @@ public final class StartupHandler if (gamesToLaunch != null && gamesToLaunch.length > 0) { // Start the emulation activity, send the ISO passed in and finish the main activity - EmulationActivity.launch(parent, gamesToLaunch, false); - parent.finish(); + EmulationActivity.launch(parent, gamesToLaunch, false, true); } }