Respect the existing "mute" user preference

This commit is contained in:
Abandoned Cart 2023-02-15 02:54:17 -05:00 committed by Billy Laws
parent bdc368e039
commit a1143ee5de

View File

@ -272,11 +272,14 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
binding.onScreenControllerToggle.setOnApplyWindowInsetsListener(insetsOrMarginHandler) binding.onScreenControllerToggle.setOnApplyWindowInsetsListener(insetsOrMarginHandler)
} }
pictureInPictureParamsBuilder = PictureInPictureParams.Builder()
if (!emulationSettings.isAudioOutputDisabled) {
val muteIcon = Icon.createWithResource(this, R.drawable.ic_volume_mute) val muteIcon = Icon.createWithResource(this, R.drawable.ic_volume_mute)
val mutePendingIntent = PendingIntent.getBroadcast(this, R.drawable.ic_volume_mute, Intent(muteIntentAction), PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) val mutePendingIntent = PendingIntent.getBroadcast(this, R.drawable.ic_volume_mute, Intent(muteIntentAction), PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
val muteRemoteAction = RemoteAction(muteIcon, getString(R.string.mute), getString(R.string.disable_audio_output), mutePendingIntent) val muteRemoteAction = RemoteAction(muteIcon, getString(R.string.mute), getString(R.string.disable_audio_output), mutePendingIntent)
pictureInPictureParamsBuilder.setActions(mutableListOf(muteRemoteAction))
pictureInPictureParamsBuilder = PictureInPictureParams.Builder().setActions(mutableListOf(muteRemoteAction)) }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S)
pictureInPictureParamsBuilder.setAutoEnterEnabled(true) pictureInPictureParamsBuilder.setAutoEnterEnabled(true)
@ -368,6 +371,7 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean, newConfig: Configuration) { override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean, newConfig: Configuration) {
super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig) super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig)
if (isInPictureInPictureMode) { if (isInPictureInPictureMode) {
if (!emulationSettings.isAudioOutputDisabled) {
muteReceiver = object : BroadcastReceiver() { muteReceiver = object : BroadcastReceiver() {
override fun onReceive(context : Context?, intent : Intent) { override fun onReceive(context : Context?, intent : Intent) {
if (intent.action == muteIntentAction) if (intent.action == muteIntentAction)
@ -378,17 +382,13 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
IntentFilter(muteIntentAction).also { IntentFilter(muteIntentAction).also {
registerReceiver(muteReceiver, it) registerReceiver(muteReceiver, it)
} }
}
binding.onScreenControllerView.isGone = true binding.onScreenControllerView.isGone = true
binding.onScreenControllerToggle.isGone = true binding.onScreenControllerToggle.isGone = true
} else { } else {
binding.onScreenControllerView.apply { if (!emulationSettings.isAudioOutputDisabled) {
controllerType = inputHandler.getFirstControllerType() changeAudioStatus(true)
isGone = controllerType == ControllerType.None || !appSettings.onScreenControl
}
binding.onScreenControllerToggle.apply {
isGone = binding.onScreenControllerView.isGone
}
try { try {
if (this::muteReceiver.isInitialized) if (this::muteReceiver.isInitialized)
@ -397,6 +397,15 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
// Perfectly acceptable and should be ignored // Perfectly acceptable and should be ignored
} }
} }
binding.onScreenControllerView.apply {
controllerType = inputHandler.getFirstControllerType()
isGone = controllerType == ControllerType.None || !appSettings.onScreenControl
}
binding.onScreenControllerToggle.apply {
isGone = binding.onScreenControllerView.isGone
}
}
} }
/** /**