Skip to content

Commit c8fc3eb

Browse files
Improve Shortcut Handling (Now shortcuts works even with MiceWine Already Opened)
1 parent 085fd65 commit c8fc3eb

File tree

1 file changed

+39
-31
lines changed

1 file changed

+39
-31
lines changed

app/src/main/java/com/micewine/emu/activities/MainActivity.kt

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -306,37 +306,7 @@ class MainActivity : AppCompatActivity() {
306306
}
307307
})
308308

309-
val exePath = intent.getStringExtra("exePath")
310-
311-
if (exePath != null) {
312-
val intent = Intent(this, EmulationActivity::class.java).apply {
313-
flags = Intent.FLAG_ACTIVITY_REORDER_TO_FRONT
314-
}
315-
316-
sendBroadcast(
317-
Intent(ACTION_RUN_WINE).apply {
318-
putExtra("exePath", exePath)
319-
}
320-
)
321-
322-
startActivityIfNeeded(intent, 0)
323-
}
324-
325-
intent?.data?.let { uri ->
326-
val filePath = FilePathResolver.resolvePath(this, uri)
327-
328-
val runWineIntent = Intent(ACTION_RUN_WINE).apply {
329-
putExtra("exePath", filePath)
330-
}
331-
332-
sendBroadcast(runWineIntent)
333-
334-
val emulationActivityIntent = Intent(this@MainActivity, EmulationActivity::class.java).apply {
335-
flags = Intent.FLAG_ACTIVITY_REORDER_TO_FRONT
336-
}
337-
338-
startActivityIfNeeded(emulationActivityIntent, 0)
339-
}
309+
onNewIntent(intent)
340310
}
341311

342312
override fun onPostCreate(savedInstanceState: Bundle?) {
@@ -768,6 +738,44 @@ class MainActivity : AppCompatActivity() {
768738
}
769739
}
770740

741+
override fun onNewIntent(intent: Intent) {
742+
val exePath = intent.getStringExtra("exePath")
743+
744+
val emulationActivityIntent = Intent(this, EmulationActivity::class.java).apply {
745+
flags = Intent.FLAG_ACTIVITY_REORDER_TO_FRONT
746+
}
747+
748+
if (exePath != null) {
749+
if (File(exePath).exists()) {
750+
sendBroadcast(
751+
Intent(ACTION_RUN_WINE).apply {
752+
putExtra("exePath", exePath)
753+
}
754+
)
755+
756+
startActivityIfNeeded(emulationActivityIntent, 0)
757+
}
758+
}
759+
760+
intent.data?.let { uri ->
761+
val filePath = FilePathResolver.resolvePath(this, uri)
762+
763+
if (filePath != null) {
764+
if (File(filePath).exists()) {
765+
sendBroadcast(
766+
Intent(ACTION_RUN_WINE).apply {
767+
putExtra("exePath", filePath)
768+
}
769+
)
770+
}
771+
}
772+
773+
startActivityIfNeeded(emulationActivityIntent, 0)
774+
}
775+
776+
super.onNewIntent(intent)
777+
}
778+
771779
companion object {
772780
@SuppressLint("SdCardPath")
773781
val appRootDir = File("/data/data/com.micewine.emu/files")

0 commit comments

Comments
 (0)