diff options
Diffstat (limited to 'src')
5 files changed, 45 insertions, 12 deletions
diff --git a/src/android/app/src/main/AndroidManifest.xml b/src/android/app/src/main/AndroidManifest.xml index 933244140..832c08e15 100644 --- a/src/android/app/src/main/AndroidManifest.xml +++ b/src/android/app/src/main/AndroidManifest.xml | |||
| @@ -66,6 +66,14 @@ SPDX-License-Identifier: GPL-3.0-or-later | |||
| 66 | <data android:mimeType="application/octet-stream" /> | 66 | <data android:mimeType="application/octet-stream" /> |
| 67 | </intent-filter> | 67 | </intent-filter> |
| 68 | 68 | ||
| 69 | <intent-filter> | ||
| 70 | <action android:name="android.intent.action.VIEW" /> | ||
| 71 | <category android:name="android.intent.category.DEFAULT" /> | ||
| 72 | <data | ||
| 73 | android:mimeType="application/octet-stream" | ||
| 74 | android:scheme="content"/> | ||
| 75 | </intent-filter> | ||
| 76 | |||
| 69 | <meta-data | 77 | <meta-data |
| 70 | android:name="android.nfc.action.TECH_DISCOVERED" | 78 | android:name="android.nfc.action.TECH_DISCOVERED" |
| 71 | android:resource="@xml/nfc_tech_filter" /> | 79 | android:resource="@xml/nfc_tech_filter" /> |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt index 09e93a017..956c35c0a 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt | |||
| @@ -11,6 +11,7 @@ import android.content.SharedPreferences | |||
| 11 | import android.content.pm.ActivityInfo | 11 | import android.content.pm.ActivityInfo |
| 12 | import android.content.res.Configuration | 12 | import android.content.res.Configuration |
| 13 | import android.graphics.Color | 13 | import android.graphics.Color |
| 14 | import android.net.Uri | ||
| 14 | import android.os.Bundle | 15 | import android.os.Bundle |
| 15 | import android.os.Handler | 16 | import android.os.Handler |
| 16 | import android.os.Looper | 17 | import android.os.Looper |
| @@ -47,6 +48,7 @@ import org.yuzu.yuzu_emu.features.settings.model.IntSetting | |||
| 47 | import org.yuzu.yuzu_emu.features.settings.model.Settings | 48 | import org.yuzu.yuzu_emu.features.settings.model.Settings |
| 48 | import org.yuzu.yuzu_emu.features.settings.ui.SettingsActivity | 49 | import org.yuzu.yuzu_emu.features.settings.ui.SettingsActivity |
| 49 | import org.yuzu.yuzu_emu.features.settings.utils.SettingsFile | 50 | import org.yuzu.yuzu_emu.features.settings.utils.SettingsFile |
| 51 | import org.yuzu.yuzu_emu.model.Game | ||
| 50 | import org.yuzu.yuzu_emu.overlay.InputOverlay | 52 | import org.yuzu.yuzu_emu.overlay.InputOverlay |
| 51 | import org.yuzu.yuzu_emu.utils.* | 53 | import org.yuzu.yuzu_emu.utils.* |
| 52 | 54 | ||
| @@ -59,7 +61,9 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { | |||
| 59 | private var _binding: FragmentEmulationBinding? = null | 61 | private var _binding: FragmentEmulationBinding? = null |
| 60 | private val binding get() = _binding!! | 62 | private val binding get() = _binding!! |
| 61 | 63 | ||
| 62 | val args by navArgs<EmulationFragmentArgs>() | 64 | private val args by navArgs<EmulationFragmentArgs>() |
| 65 | |||
| 66 | private lateinit var game: Game | ||
| 63 | 67 | ||
| 64 | private var isInFoldableLayout = false | 68 | private var isInFoldableLayout = false |
| 65 | 69 | ||
| @@ -87,10 +91,25 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { | |||
| 87 | override fun onCreate(savedInstanceState: Bundle?) { | 91 | override fun onCreate(savedInstanceState: Bundle?) { |
| 88 | super.onCreate(savedInstanceState) | 92 | super.onCreate(savedInstanceState) |
| 89 | 93 | ||
| 94 | val intentUri: Uri? = requireActivity().intent.data | ||
| 95 | var intentGame: Game? = null | ||
| 96 | if (intentUri != null) { | ||
| 97 | intentGame = if (Game.extensions.contains(FileUtil.getExtension(intentUri))) { | ||
| 98 | GameHelper.getGame(requireActivity().intent.data!!, false) | ||
| 99 | } else { | ||
| 100 | null | ||
| 101 | } | ||
| 102 | } | ||
| 103 | game = if (args.game != null) { | ||
| 104 | args.game!! | ||
| 105 | } else { | ||
| 106 | intentGame ?: error("[EmulationFragment] No bootable game present!") | ||
| 107 | } | ||
| 108 | |||
| 90 | // So this fragment doesn't restart on configuration changes; i.e. rotation. | 109 | // So this fragment doesn't restart on configuration changes; i.e. rotation. |
| 91 | retainInstance = true | 110 | retainInstance = true |
| 92 | preferences = PreferenceManager.getDefaultSharedPreferences(YuzuApplication.appContext) | 111 | preferences = PreferenceManager.getDefaultSharedPreferences(YuzuApplication.appContext) |
| 93 | emulationState = EmulationState(args.game.path) | 112 | emulationState = EmulationState(game.path) |
| 94 | } | 113 | } |
| 95 | 114 | ||
| 96 | /** | 115 | /** |
| @@ -114,7 +133,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { | |||
| 114 | updateShowFpsOverlay() | 133 | updateShowFpsOverlay() |
| 115 | 134 | ||
| 116 | binding.inGameMenu.getHeaderView(0).findViewById<TextView>(R.id.text_game_title).text = | 135 | binding.inGameMenu.getHeaderView(0).findViewById<TextView>(R.id.text_game_title).text = |
| 117 | args.game.title | 136 | game.title |
| 118 | binding.inGameMenu.setNavigationItemSelectedListener { | 137 | binding.inGameMenu.setNavigationItemSelectedListener { |
| 119 | when (it.itemId) { | 138 | when (it.itemId) { |
| 120 | R.id.menu_pause_emulation -> { | 139 | R.id.menu_pause_emulation -> { |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GameHelper.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GameHelper.kt index f71d0a098..e0ee29c9b 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GameHelper.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GameHelper.kt | |||
| @@ -63,13 +63,13 @@ object GameHelper { | |||
| 63 | ) | 63 | ) |
| 64 | } else { | 64 | } else { |
| 65 | if (Game.extensions.contains(FileUtil.getExtension(it.uri))) { | 65 | if (Game.extensions.contains(FileUtil.getExtension(it.uri))) { |
| 66 | games.add(getGame(it.uri)) | 66 | games.add(getGame(it.uri, true)) |
| 67 | } | 67 | } |
| 68 | } | 68 | } |
| 69 | } | 69 | } |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | private fun getGame(uri: Uri): Game { | 72 | fun getGame(uri: Uri, addedToLibrary: Boolean): Game { |
| 73 | val filePath = uri.toString() | 73 | val filePath = uri.toString() |
| 74 | var name = NativeLibrary.getTitle(filePath) | 74 | var name = NativeLibrary.getTitle(filePath) |
| 75 | 75 | ||
| @@ -94,11 +94,13 @@ object GameHelper { | |||
| 94 | NativeLibrary.isHomebrew(filePath) | 94 | NativeLibrary.isHomebrew(filePath) |
| 95 | ) | 95 | ) |
| 96 | 96 | ||
| 97 | val addedTime = preferences.getLong(newGame.keyAddedToLibraryTime, 0L) | 97 | if (addedToLibrary) { |
| 98 | if (addedTime == 0L) { | 98 | val addedTime = preferences.getLong(newGame.keyAddedToLibraryTime, 0L) |
| 99 | preferences.edit() | 99 | if (addedTime == 0L) { |
| 100 | .putLong(newGame.keyAddedToLibraryTime, System.currentTimeMillis()) | 100 | preferences.edit() |
| 101 | .apply() | 101 | .putLong(newGame.keyAddedToLibraryTime, System.currentTimeMillis()) |
| 102 | .apply() | ||
| 103 | } | ||
| 102 | } | 104 | } |
| 103 | 105 | ||
| 104 | return newGame | 106 | return newGame |
diff --git a/src/android/app/src/main/res/navigation/emulation_navigation.xml b/src/android/app/src/main/res/navigation/emulation_navigation.xml index 8208f4c2c..cd1d36a12 100644 --- a/src/android/app/src/main/res/navigation/emulation_navigation.xml +++ b/src/android/app/src/main/res/navigation/emulation_navigation.xml | |||
| @@ -12,7 +12,9 @@ | |||
| 12 | tools:layout="@layout/fragment_emulation" > | 12 | tools:layout="@layout/fragment_emulation" > |
| 13 | <argument | 13 | <argument |
| 14 | android:name="game" | 14 | android:name="game" |
| 15 | app:argType="org.yuzu.yuzu_emu.model.Game" /> | 15 | app:argType="org.yuzu.yuzu_emu.model.Game" |
| 16 | app:nullable="true" | ||
| 17 | android:defaultValue="@null" /> | ||
| 16 | </fragment> | 18 | </fragment> |
| 17 | 19 | ||
| 18 | </navigation> | 20 | </navigation> |
diff --git a/src/android/app/src/main/res/navigation/home_navigation.xml b/src/android/app/src/main/res/navigation/home_navigation.xml index fcebba726..42f987fed 100644 --- a/src/android/app/src/main/res/navigation/home_navigation.xml +++ b/src/android/app/src/main/res/navigation/home_navigation.xml | |||
| @@ -62,7 +62,9 @@ | |||
| 62 | android:label="EmulationActivity"> | 62 | android:label="EmulationActivity"> |
| 63 | <argument | 63 | <argument |
| 64 | android:name="game" | 64 | android:name="game" |
| 65 | app:argType="org.yuzu.yuzu_emu.model.Game" /> | 65 | app:argType="org.yuzu.yuzu_emu.model.Game" |
| 66 | app:nullable="true" | ||
| 67 | android:defaultValue="@null" /> | ||
| 66 | </activity> | 68 | </activity> |
| 67 | 69 | ||
| 68 | <action | 70 | <action |