Merge pull request #11413 from t895/intents
android: Support intents to emulation activity
This commit is contained in:
commit
2f03fac9a0
|
@ -66,6 +66,14 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
<data android:mimeType="application/octet-stream" />
|
<data android:mimeType="application/octet-stream" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<data
|
||||||
|
android:mimeType="application/octet-stream"
|
||||||
|
android:scheme="content"/>
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.nfc.action.TECH_DISCOVERED"
|
android:name="android.nfc.action.TECH_DISCOVERED"
|
||||||
android:resource="@xml/nfc_tech_filter" />
|
android:resource="@xml/nfc_tech_filter" />
|
||||||
|
|
|
@ -11,6 +11,7 @@ import android.content.SharedPreferences
|
||||||
import android.content.pm.ActivityInfo
|
import android.content.pm.ActivityInfo
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
|
@ -47,6 +48,7 @@ import org.yuzu.yuzu_emu.features.settings.model.IntSetting
|
||||||
import org.yuzu.yuzu_emu.features.settings.model.Settings
|
import org.yuzu.yuzu_emu.features.settings.model.Settings
|
||||||
import org.yuzu.yuzu_emu.features.settings.ui.SettingsActivity
|
import org.yuzu.yuzu_emu.features.settings.ui.SettingsActivity
|
||||||
import org.yuzu.yuzu_emu.features.settings.utils.SettingsFile
|
import org.yuzu.yuzu_emu.features.settings.utils.SettingsFile
|
||||||
|
import org.yuzu.yuzu_emu.model.Game
|
||||||
import org.yuzu.yuzu_emu.overlay.InputOverlay
|
import org.yuzu.yuzu_emu.overlay.InputOverlay
|
||||||
import org.yuzu.yuzu_emu.utils.*
|
import org.yuzu.yuzu_emu.utils.*
|
||||||
|
|
||||||
|
@ -59,7 +61,9 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
|
||||||
private var _binding: FragmentEmulationBinding? = null
|
private var _binding: FragmentEmulationBinding? = null
|
||||||
private val binding get() = _binding!!
|
private val binding get() = _binding!!
|
||||||
|
|
||||||
val args by navArgs<EmulationFragmentArgs>()
|
private val args by navArgs<EmulationFragmentArgs>()
|
||||||
|
|
||||||
|
private lateinit var game: Game
|
||||||
|
|
||||||
private var isInFoldableLayout = false
|
private var isInFoldableLayout = false
|
||||||
|
|
||||||
|
@ -87,10 +91,25 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
val intentUri: Uri? = requireActivity().intent.data
|
||||||
|
var intentGame: Game? = null
|
||||||
|
if (intentUri != null) {
|
||||||
|
intentGame = if (Game.extensions.contains(FileUtil.getExtension(intentUri))) {
|
||||||
|
GameHelper.getGame(requireActivity().intent.data!!, false)
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
game = if (args.game != null) {
|
||||||
|
args.game!!
|
||||||
|
} else {
|
||||||
|
intentGame ?: error("[EmulationFragment] No bootable game present!")
|
||||||
|
}
|
||||||
|
|
||||||
// So this fragment doesn't restart on configuration changes; i.e. rotation.
|
// So this fragment doesn't restart on configuration changes; i.e. rotation.
|
||||||
retainInstance = true
|
retainInstance = true
|
||||||
preferences = PreferenceManager.getDefaultSharedPreferences(YuzuApplication.appContext)
|
preferences = PreferenceManager.getDefaultSharedPreferences(YuzuApplication.appContext)
|
||||||
emulationState = EmulationState(args.game.path)
|
emulationState = EmulationState(game.path)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -114,7 +133,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
|
||||||
updateShowFpsOverlay()
|
updateShowFpsOverlay()
|
||||||
|
|
||||||
binding.inGameMenu.getHeaderView(0).findViewById<TextView>(R.id.text_game_title).text =
|
binding.inGameMenu.getHeaderView(0).findViewById<TextView>(R.id.text_game_title).text =
|
||||||
args.game.title
|
game.title
|
||||||
binding.inGameMenu.setNavigationItemSelectedListener {
|
binding.inGameMenu.setNavigationItemSelectedListener {
|
||||||
when (it.itemId) {
|
when (it.itemId) {
|
||||||
R.id.menu_pause_emulation -> {
|
R.id.menu_pause_emulation -> {
|
||||||
|
|
|
@ -63,13 +63,13 @@ object GameHelper {
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
if (Game.extensions.contains(FileUtil.getExtension(it.uri))) {
|
if (Game.extensions.contains(FileUtil.getExtension(it.uri))) {
|
||||||
games.add(getGame(it.uri))
|
games.add(getGame(it.uri, true))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getGame(uri: Uri): Game {
|
fun getGame(uri: Uri, addedToLibrary: Boolean): Game {
|
||||||
val filePath = uri.toString()
|
val filePath = uri.toString()
|
||||||
var name = NativeLibrary.getTitle(filePath)
|
var name = NativeLibrary.getTitle(filePath)
|
||||||
|
|
||||||
|
@ -94,11 +94,13 @@ object GameHelper {
|
||||||
NativeLibrary.isHomebrew(filePath)
|
NativeLibrary.isHomebrew(filePath)
|
||||||
)
|
)
|
||||||
|
|
||||||
val addedTime = preferences.getLong(newGame.keyAddedToLibraryTime, 0L)
|
if (addedToLibrary) {
|
||||||
if (addedTime == 0L) {
|
val addedTime = preferences.getLong(newGame.keyAddedToLibraryTime, 0L)
|
||||||
preferences.edit()
|
if (addedTime == 0L) {
|
||||||
.putLong(newGame.keyAddedToLibraryTime, System.currentTimeMillis())
|
preferences.edit()
|
||||||
.apply()
|
.putLong(newGame.keyAddedToLibraryTime, System.currentTimeMillis())
|
||||||
|
.apply()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return newGame
|
return newGame
|
||||||
|
|
|
@ -12,7 +12,9 @@
|
||||||
tools:layout="@layout/fragment_emulation" >
|
tools:layout="@layout/fragment_emulation" >
|
||||||
<argument
|
<argument
|
||||||
android:name="game"
|
android:name="game"
|
||||||
app:argType="org.yuzu.yuzu_emu.model.Game" />
|
app:argType="org.yuzu.yuzu_emu.model.Game"
|
||||||
|
app:nullable="true"
|
||||||
|
android:defaultValue="@null" />
|
||||||
</fragment>
|
</fragment>
|
||||||
|
|
||||||
</navigation>
|
</navigation>
|
||||||
|
|
|
@ -62,7 +62,9 @@
|
||||||
android:label="EmulationActivity">
|
android:label="EmulationActivity">
|
||||||
<argument
|
<argument
|
||||||
android:name="game"
|
android:name="game"
|
||||||
app:argType="org.yuzu.yuzu_emu.model.Game" />
|
app:argType="org.yuzu.yuzu_emu.model.Game"
|
||||||
|
app:nullable="true"
|
||||||
|
android:defaultValue="@null" />
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<action
|
<action
|
||||||
|
|
Loading…
Reference in New Issue