diff options
| author | 2023-06-16 18:50:36 -0400 | |
|---|---|---|
| committer | 2023-06-21 17:21:36 -0400 | |
| commit | e31152ee347c2dddeba847ca08bd101ef53d1cce (patch) | |
| tree | 57f63a26945549c5e9fedbd2d3d9fe8c8c2de9b2 | |
| parent | Merge pull request #10864 from t895/disable-mali-driver (diff) | |
| download | yuzu-e31152ee347c2dddeba847ca08bd101ef53d1cce.tar.gz yuzu-e31152ee347c2dddeba847ca08bd101ef53d1cce.tar.xz yuzu-e31152ee347c2dddeba847ca08bd101ef53d1cce.zip | |
android: Add a PiP interface to mute / unmute
Diffstat (limited to '')
4 files changed, 68 insertions, 0 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt index f0a6753a9..8a071f4da 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt | |||
| @@ -63,6 +63,10 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener { | |||
| 63 | 63 | ||
| 64 | private val actionPause = "ACTION_EMULATOR_PAUSE" | 64 | private val actionPause = "ACTION_EMULATOR_PAUSE" |
| 65 | private val actionPlay = "ACTION_EMULATOR_PLAY" | 65 | private val actionPlay = "ACTION_EMULATOR_PLAY" |
| 66 | private val actionMute = "ACTION_EMULATOR_MUTE" | ||
| 67 | private val actionAudio = "ACTION_EMULATOR_AUDIO" | ||
| 68 | private var isAudioMuted = false | ||
| 69 | private var userAudio = IntSetting.AUDIO_VOLUME.int | ||
| 66 | 70 | ||
| 67 | private val settingsViewModel: SettingsViewModel by viewModels() | 71 | private val settingsViewModel: SettingsViewModel by viewModels() |
| 68 | 72 | ||
| @@ -305,6 +309,38 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener { | |||
| 305 | pictureInPictureActions.add(pauseRemoteAction) | 309 | pictureInPictureActions.add(pauseRemoteAction) |
| 306 | } | 310 | } |
| 307 | 311 | ||
| 312 | if (isAudioMuted) { | ||
| 313 | val audioIcon = Icon.createWithResource(this@EmulationActivity, R.drawable.ic_pip_audio) | ||
| 314 | val audioPendingIntent = PendingIntent.getBroadcast( | ||
| 315 | this@EmulationActivity, | ||
| 316 | R.drawable.ic_pip_audio, | ||
| 317 | Intent(actionAudio), | ||
| 318 | pendingFlags | ||
| 319 | ) | ||
| 320 | val audioRemoteAction = RemoteAction( | ||
| 321 | audioIcon, | ||
| 322 | getString(R.string.audio), | ||
| 323 | getString(R.string.audio), | ||
| 324 | audioPendingIntent | ||
| 325 | ) | ||
| 326 | pictureInPictureActions.add(audioRemoteAction) | ||
| 327 | } else { | ||
| 328 | val muteIcon = Icon.createWithResource(this@EmulationActivity, R.drawable.ic_pip_mute) | ||
| 329 | val mutePendingIntent = PendingIntent.getBroadcast( | ||
| 330 | this@EmulationActivity, | ||
| 331 | R.drawable.ic_pip_mute, | ||
| 332 | Intent(actionMute), | ||
| 333 | pendingFlags | ||
| 334 | ) | ||
| 335 | val muteRemoteAction = RemoteAction( | ||
| 336 | muteIcon, | ||
| 337 | getString(R.string.mute), | ||
| 338 | getString(R.string.mute), | ||
| 339 | mutePendingIntent | ||
| 340 | ) | ||
| 341 | pictureInPictureActions.add(muteRemoteAction) | ||
| 342 | } | ||
| 343 | |||
| 308 | return this.apply { setActions(pictureInPictureActions) } | 344 | return this.apply { setActions(pictureInPictureActions) } |
| 309 | } | 345 | } |
| 310 | 346 | ||
| @@ -326,6 +362,18 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener { | |||
| 326 | } else if (intent.action == actionPause) { | 362 | } else if (intent.action == actionPause) { |
| 327 | if (!NativeLibrary.isPaused()) NativeLibrary.pauseEmulation() | 363 | if (!NativeLibrary.isPaused()) NativeLibrary.pauseEmulation() |
| 328 | } | 364 | } |
| 365 | if (intent.action == actionAudio) { | ||
| 366 | if (isAudioMuted) { | ||
| 367 | IntSetting.AUDIO_VOLUME.int = userAudio | ||
| 368 | isAudioMuted = false | ||
| 369 | } | ||
| 370 | } else if (intent.action == actionMute) { | ||
| 371 | if (!isAudioMuted) { | ||
| 372 | isAudioMuted = true | ||
| 373 | userAudio = IntSetting.AUDIO_VOLUME.int | ||
| 374 | IntSetting.AUDIO_VOLUME.int = 0 | ||
| 375 | } | ||
| 376 | } | ||
| 329 | buildPictureInPictureParams() | 377 | buildPictureInPictureParams() |
| 330 | } | 378 | } |
| 331 | } | 379 | } |
diff --git a/src/android/app/src/main/res/drawable/ic_pip_audio.xml b/src/android/app/src/main/res/drawable/ic_pip_audio.xml new file mode 100644 index 000000000..f7ed0862e --- /dev/null +++ b/src/android/app/src/main/res/drawable/ic_pip_audio.xml | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 2 | android:width="24dp" | ||
| 3 | android:height="24dp" | ||
| 4 | android:viewportHeight="24" | ||
| 5 | android:viewportWidth="24"> | ||
| 6 | <path | ||
| 7 | android:fillColor="@android:color/white" | ||
| 8 | android:pathData="M3,9v6h4l5,5L12,4L7,9L3,9zM16.5,12c0,-1.77 -1.02,-3.29 -2.5,-4.03v8.05c1.48,-0.73 2.5,-2.25 2.5,-4.02zM14,3.23v2.06c2.89,0.86 5,3.54 5,6.71s-2.11,5.85 -5,6.71v2.06c4.01,-0.91 7,-4.49 7,-8.77s-2.99,-7.86 -7,-8.77z" /> | ||
| 9 | </vector> | ||
diff --git a/src/android/app/src/main/res/drawable/ic_pip_mute.xml b/src/android/app/src/main/res/drawable/ic_pip_mute.xml new file mode 100644 index 000000000..a271c5fe8 --- /dev/null +++ b/src/android/app/src/main/res/drawable/ic_pip_mute.xml | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 2 | android:width="24dp" | ||
| 3 | android:height="24dp" | ||
| 4 | android:viewportHeight="24" | ||
| 5 | android:viewportWidth="24"> | ||
| 6 | <path | ||
| 7 | android:fillColor="@android:color/white" | ||
| 8 | android:pathData="M7,9v6h4l5,5V4l-5,5H7z" /> | ||
| 9 | </vector> | ||
diff --git a/src/android/app/src/main/res/values/strings.xml b/src/android/app/src/main/res/values/strings.xml index cc1d8c39d..d4f089c7f 100644 --- a/src/android/app/src/main/res/values/strings.xml +++ b/src/android/app/src/main/res/values/strings.xml | |||
| @@ -387,6 +387,8 @@ | |||
| 387 | <string name="picture_in_picture_description">Minimize window when placed in the background</string> | 387 | <string name="picture_in_picture_description">Minimize window when placed in the background</string> |
| 388 | <string name="pause">Pause</string> | 388 | <string name="pause">Pause</string> |
| 389 | <string name="play">Play</string> | 389 | <string name="play">Play</string> |
| 390 | <string name="mute">Mute</string> | ||
| 391 | <string name="audio">Audio</string> | ||
| 390 | 392 | ||
| 391 | <!-- Licenses screen strings --> | 393 | <!-- Licenses screen strings --> |
| 392 | <string name="licenses">Licenses</string> | 394 | <string name="licenses">Licenses</string> |