android: Refactor native and corresponding variables
This commit is contained in:
parent
e35371e50c
commit
cfc6ef42d9
6 changed files with 25 additions and 22 deletions
|
@ -286,7 +286,7 @@ object NativeLibrary {
|
||||||
/**
|
/**
|
||||||
* Unpauses emulation from a paused state.
|
* Unpauses emulation from a paused state.
|
||||||
*/
|
*/
|
||||||
external fun unPauseEmulation()
|
external fun unpauseEmulation()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pauses emulation.
|
* Pauses emulation.
|
||||||
|
@ -321,7 +321,7 @@ object NativeLibrary {
|
||||||
/**
|
/**
|
||||||
* Unmutes emulation sound
|
* Unmutes emulation sound
|
||||||
*/
|
*/
|
||||||
external fun unMuteAudio(): Boolean
|
external fun unmuteAudio(): Boolean
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if emulation audio is muted.
|
* Returns true if emulation audio is muted.
|
||||||
|
|
|
@ -64,7 +64,7 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
|
||||||
private val actionPause = "ACTION_EMULATOR_PAUSE"
|
private val actionPause = "ACTION_EMULATOR_PAUSE"
|
||||||
private val actionPlay = "ACTION_EMULATOR_PLAY"
|
private val actionPlay = "ACTION_EMULATOR_PLAY"
|
||||||
private val actionMute = "ACTION_EMULATOR_MUTE"
|
private val actionMute = "ACTION_EMULATOR_MUTE"
|
||||||
private val actionSound = "ACTION_EMULATOR_SOUND"
|
private val actionUnmute = "ACTION_EMULATOR_UNMUTE"
|
||||||
|
|
||||||
private val settingsViewModel: SettingsViewModel by viewModels()
|
private val settingsViewModel: SettingsViewModel by viewModels()
|
||||||
|
|
||||||
|
@ -308,20 +308,23 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NativeLibrary.isMuted()) {
|
if (NativeLibrary.isMuted()) {
|
||||||
val soundIcon = Icon.createWithResource(this@EmulationActivity, R.drawable.ic_pip_sound)
|
val unmuteIcon = Icon.createWithResource(
|
||||||
val soundPendingIntent = PendingIntent.getBroadcast(
|
|
||||||
this@EmulationActivity,
|
this@EmulationActivity,
|
||||||
R.drawable.ic_pip_sound,
|
R.drawable.ic_pip_unmute
|
||||||
Intent(actionSound),
|
)
|
||||||
|
val unmutePendingIntent = PendingIntent.getBroadcast(
|
||||||
|
this@EmulationActivity,
|
||||||
|
R.drawable.ic_pip_unmute,
|
||||||
|
Intent(actionUnmute),
|
||||||
pendingFlags
|
pendingFlags
|
||||||
)
|
)
|
||||||
val soundRemoteAction = RemoteAction(
|
val unmuteRemoteAction = RemoteAction(
|
||||||
soundIcon,
|
unmuteIcon,
|
||||||
getString(R.string.sound),
|
getString(R.string.unmute),
|
||||||
getString(R.string.sound),
|
getString(R.string.unmute),
|
||||||
soundPendingIntent
|
unmutePendingIntent
|
||||||
)
|
)
|
||||||
pictureInPictureActions.add(soundRemoteAction)
|
pictureInPictureActions.add(unmuteRemoteAction)
|
||||||
} else {
|
} else {
|
||||||
val muteIcon = Icon.createWithResource(this@EmulationActivity, R.drawable.ic_pip_mute)
|
val muteIcon = Icon.createWithResource(this@EmulationActivity, R.drawable.ic_pip_mute)
|
||||||
val mutePendingIntent = PendingIntent.getBroadcast(
|
val mutePendingIntent = PendingIntent.getBroadcast(
|
||||||
|
@ -356,12 +359,12 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
|
||||||
private var pictureInPictureReceiver = object : BroadcastReceiver() {
|
private var pictureInPictureReceiver = object : BroadcastReceiver() {
|
||||||
override fun onReceive(context: Context?, intent: Intent) {
|
override fun onReceive(context: Context?, intent: Intent) {
|
||||||
if (intent.action == actionPlay) {
|
if (intent.action == actionPlay) {
|
||||||
if (NativeLibrary.isPaused()) NativeLibrary.unPauseEmulation()
|
if (NativeLibrary.isPaused()) NativeLibrary.unpauseEmulation()
|
||||||
} else if (intent.action == actionPause) {
|
} else if (intent.action == actionPause) {
|
||||||
if (!NativeLibrary.isPaused()) NativeLibrary.pauseEmulation()
|
if (!NativeLibrary.isPaused()) NativeLibrary.pauseEmulation()
|
||||||
}
|
}
|
||||||
if (intent.action == actionSound) {
|
if (intent.action == actionUnmute) {
|
||||||
if (NativeLibrary.isMuted()) NativeLibrary.unMuteAudio()
|
if (NativeLibrary.isMuted()) NativeLibrary.unmuteAudio()
|
||||||
} else if (intent.action == actionMute) {
|
} else if (intent.action == actionMute) {
|
||||||
if (!NativeLibrary.isMuted()) NativeLibrary.muteAudio()
|
if (!NativeLibrary.isMuted()) NativeLibrary.muteAudio()
|
||||||
}
|
}
|
||||||
|
@ -379,7 +382,7 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
|
||||||
addAction(actionPause)
|
addAction(actionPause)
|
||||||
addAction(actionPlay)
|
addAction(actionPlay)
|
||||||
addAction(actionMute)
|
addAction(actionMute)
|
||||||
addAction(actionSound)
|
addAction(actionUnmute)
|
||||||
}.also {
|
}.also {
|
||||||
registerReceiver(pictureInPictureReceiver, it)
|
registerReceiver(pictureInPictureReceiver, it)
|
||||||
}
|
}
|
||||||
|
@ -389,7 +392,7 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
|
||||||
} catch (ignored: Exception) {
|
} catch (ignored: Exception) {
|
||||||
}
|
}
|
||||||
// Always resume audio, since there is no UI button
|
// Always resume audio, since there is no UI button
|
||||||
if (NativeLibrary.isMuted()) NativeLibrary.unMuteAudio()
|
if (NativeLibrary.isMuted()) NativeLibrary.unmuteAudio()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -714,7 +714,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
|
||||||
State.PAUSED -> {
|
State.PAUSED -> {
|
||||||
Log.debug("[EmulationFragment] Resuming emulation.")
|
Log.debug("[EmulationFragment] Resuming emulation.")
|
||||||
NativeLibrary.surfaceChanged(surface)
|
NativeLibrary.surfaceChanged(surface)
|
||||||
NativeLibrary.unPauseEmulation()
|
NativeLibrary.unpauseEmulation()
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> Log.debug("[EmulationFragment] Bug, run called while already running.")
|
else -> Log.debug("[EmulationFragment] Bug, run called while already running.")
|
||||||
|
|
|
@ -583,7 +583,7 @@ jboolean Java_org_yuzu_yuzu_1emu_NativeLibrary_reloadKeys(JNIEnv* env, jclass cl
|
||||||
return static_cast<jboolean>(Core::Crypto::KeyManager::Instance().AreKeysLoaded());
|
return static_cast<jboolean>(Core::Crypto::KeyManager::Instance().AreKeysLoaded());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Java_org_yuzu_yuzu_1emu_NativeLibrary_unPauseEmulation(JNIEnv* env, jclass clazz) {
|
void Java_org_yuzu_yuzu_1emu_NativeLibrary_unpauseEmulation(JNIEnv* env, jclass clazz) {
|
||||||
EmulationSession::GetInstance().UnPauseEmulation();
|
EmulationSession::GetInstance().UnPauseEmulation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -611,7 +611,7 @@ void Java_org_yuzu_yuzu_1emu_NativeLibrary_muteAduio(JNIEnv* env, jclass clazz)
|
||||||
Settings::values.audio_muted = true;
|
Settings::values.audio_muted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Java_org_yuzu_yuzu_1emu_NativeLibrary_unMuteAudio(JNIEnv* env, jclass clazz) {
|
void Java_org_yuzu_yuzu_1emu_NativeLibrary_unmuteAudio(JNIEnv* env, jclass clazz) {
|
||||||
Settings::values.audio_muted = false;
|
Settings::values.audio_muted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -388,7 +388,7 @@
|
||||||
<string name="pause">Pause</string>
|
<string name="pause">Pause</string>
|
||||||
<string name="play">Play</string>
|
<string name="play">Play</string>
|
||||||
<string name="mute">Mute</string>
|
<string name="mute">Mute</string>
|
||||||
<string name="sound">Sound</string>
|
<string name="unmute">Unmute</string>
|
||||||
|
|
||||||
<!-- Licenses screen strings -->
|
<!-- Licenses screen strings -->
|
||||||
<string name="licenses">Licenses</string>
|
<string name="licenses">Licenses</string>
|
||||||
|
|
Loading…
Reference in a new issue