android: Add a picture in picture setting
This commit is contained in:
parent
fa58cbe0d2
commit
b03052843b
4 changed files with 23 additions and 5 deletions
|
@ -42,6 +42,7 @@ import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.yuzu.yuzu_emu.NativeLibrary
|
import org.yuzu.yuzu_emu.NativeLibrary
|
||||||
import org.yuzu.yuzu_emu.R
|
import org.yuzu.yuzu_emu.R
|
||||||
|
import org.yuzu.yuzu_emu.features.settings.model.BooleanSetting
|
||||||
import org.yuzu.yuzu_emu.features.settings.model.SettingsViewModel
|
import org.yuzu.yuzu_emu.features.settings.model.SettingsViewModel
|
||||||
import org.yuzu.yuzu_emu.fragments.EmulationFragment
|
import org.yuzu.yuzu_emu.fragments.EmulationFragment
|
||||||
import org.yuzu.yuzu_emu.model.Game
|
import org.yuzu.yuzu_emu.model.Game
|
||||||
|
@ -99,9 +100,6 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
|
||||||
// Set these options now so that the SurfaceView the game renders into is the right size.
|
// Set these options now so that the SurfaceView the game renders into is the right size.
|
||||||
enableFullscreenImmersive()
|
enableFullscreenImmersive()
|
||||||
|
|
||||||
pictureInPictureParamsBuilder = getPictureInPictureBuilder()
|
|
||||||
setPictureInPictureParams(pictureInPictureParamsBuilder.build())
|
|
||||||
|
|
||||||
setContentView(R.layout.activity_emulation)
|
setContentView(R.layout.activity_emulation)
|
||||||
window.decorView.setBackgroundColor(getColor(android.R.color.black))
|
window.decorView.setBackgroundColor(getColor(android.R.color.black))
|
||||||
|
|
||||||
|
@ -167,6 +165,11 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
|
||||||
EmulationMenuSettings.landscapeScreenLayout,
|
EmulationMenuSettings.landscapeScreenLayout,
|
||||||
getAdjustedRotation()
|
getAdjustedRotation()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (BooleanSetting.PICTURE_IN_PICTURE.boolean) {
|
||||||
|
pictureInPictureParamsBuilder = getPictureInPictureBuilder()
|
||||||
|
setPictureInPictureParams(pictureInPictureParamsBuilder.build())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
|
@ -176,8 +179,10 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUserLeaveHint() {
|
override fun onUserLeaveHint() {
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S && !isInPictureInPictureMode) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
|
||||||
enterPictureInPictureMode(pictureInPictureParamsBuilder.build())
|
if (BooleanSetting.PICTURE_IN_PICTURE.boolean && !isInPictureInPictureMode) {
|
||||||
|
enterPictureInPictureMode(pictureInPictureParamsBuilder.build())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ enum class BooleanSetting(
|
||||||
override val section: String,
|
override val section: String,
|
||||||
override val defaultValue: Boolean
|
override val defaultValue: Boolean
|
||||||
) : AbstractBooleanSetting {
|
) : AbstractBooleanSetting {
|
||||||
|
PICTURE_IN_PICTURE("picture_in_picture", Settings.SECTION_GENERAL, true),
|
||||||
USE_CUSTOM_RTC("custom_rtc_enabled", Settings.SECTION_SYSTEM, false);
|
USE_CUSTOM_RTC("custom_rtc_enabled", Settings.SECTION_SYSTEM, false);
|
||||||
|
|
||||||
override var boolean: Boolean = defaultValue
|
override var boolean: Boolean = defaultValue
|
||||||
|
@ -27,6 +28,7 @@ enum class BooleanSetting(
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val NOT_RUNTIME_EDITABLE = listOf(
|
private val NOT_RUNTIME_EDITABLE = listOf(
|
||||||
|
PICTURE_IN_PICTURE,
|
||||||
USE_CUSTOM_RTC
|
USE_CUSTOM_RTC
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -166,6 +166,15 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView)
|
||||||
IntSetting.CPU_ACCURACY.defaultValue
|
IntSetting.CPU_ACCURACY.defaultValue
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
add(
|
||||||
|
SwitchSetting(
|
||||||
|
BooleanSetting.PICTURE_IN_PICTURE,
|
||||||
|
R.string.picture_in_picture,
|
||||||
|
R.string.picture_in_picture_description,
|
||||||
|
BooleanSetting.PICTURE_IN_PICTURE.key,
|
||||||
|
BooleanSetting.PICTURE_IN_PICTURE.defaultValue
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -357,6 +357,8 @@
|
||||||
<string name="use_black_backgrounds_description">When using the dark theme, apply black backgrounds.</string>
|
<string name="use_black_backgrounds_description">When using the dark theme, apply black backgrounds.</string>
|
||||||
|
|
||||||
<!-- Picture-In-Picture -->
|
<!-- Picture-In-Picture -->
|
||||||
|
<string name="picture_in_picture">Picture in Picture</string>
|
||||||
|
<string name="picture_in_picture_description">Minimize window when placed in the background</string>
|
||||||
<string name="pause">Pause</string>
|
<string name="pause">Pause</string>
|
||||||
<string name="play">Play</string>
|
<string name="play">Play</string>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue