mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-24 23:36:04 +00:00
fix(session): a fixed portrait resolution applies when landscape is set to Follow screen (#3124)
This commit is contained in:
1 parent
7630173b24
commit
a573f8b14f
4 files changed
+45
-12
No files matched your search
@@ -875,9 +875,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
cornerTap = SessionPrefs.drawerCornerTap(this)
|
||||
applyOutputPacing()
|
||||
if (!SessionState.running) {
|
||||
SessionState.followScreen = followChoice()
|
||||
SessionState.followScale = followScale()
|
||||
SessionState.followScales = SessionPrefs.followScales(this, displayMode(),
|
||||
com.droiddeck.launcher.session.SessionDisplay.panelSize(this))
|
||||
}
|
||||
applyFollowChoice()
|
||||
applyFollowOrientation(resources.configuration)
|
||||
goFullscreen()
|
||||
volumeControlStream = android.media.AudioManager.STREAM_MUSIC
|
||||
@@ -2995,16 +2996,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
|
||||
private fun followPortrait(): Boolean = glassesScreen == null && SessionPrefs.portrait(this)
|
||||
|
||||
private fun followScale(): Float {
|
||||
val mode = displayMode()
|
||||
val choice = SessionPrefs.resolutionChoice(this, mode, com.droiddeck.launcher.session.SessionDisplay.panelSize(this), followPortrait())
|
||||
return com.droiddeck.launcher.session.SessionDisplay.followScale(choice) ?: 1f
|
||||
}
|
||||
|
||||
private fun followChoice(): Boolean {
|
||||
val mode = displayMode()
|
||||
return com.droiddeck.launcher.session.SessionDisplay.isFollow(
|
||||
SessionPrefs.resolutionChoice(this, mode, com.droiddeck.launcher.session.SessionDisplay.panelSize(this), followPortrait()))
|
||||
private fun applyFollowChoice() {
|
||||
val scale = SessionState.followScales.let { if (followPortrait()) it.second else it.first }
|
||||
SessionState.followScreen = scale != null
|
||||
SessionState.followScale = scale ?: 1f
|
||||
}
|
||||
|
||||
private fun applyFollowOrientation(config: android.content.res.Configuration) {
|
||||
@@ -3018,6 +3013,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
SessionService.setActivityDisplay(this, sessionActivityDisplayId)
|
||||
}
|
||||
cancelTouchGestures()
|
||||
applyFollowChoice()
|
||||
applyFollowOrientation(newConfig)
|
||||
applyNotchInset()
|
||||
applyUnfoldedControls()
|
||||
|
||||
@@ -1343,6 +1343,10 @@ object SessionPrefs {
|
||||
SessionDisplay.effectiveChoice(
|
||||
resolutionStored(context, mode, panel, false), resolutionStored(context, mode, panel, true), portrait)
|
||||
|
||||
fun followScales(context: Context, mode: String, panel: Pair<Int, Int>): Pair<Float?, Float?> =
|
||||
SessionDisplay.followScale(resolutionChoice(context, mode, panel, false)) to
|
||||
SessionDisplay.followScale(resolutionChoice(context, mode, panel, true))
|
||||
|
||||
fun resolutionStored(context: Context, mode: String, panel: Pair<Int, Int>, portrait: Boolean): String {
|
||||
if (!portrait) return landscapeResolutionStored(context, mode, panel)
|
||||
val value = prefs(context).getString("displayResolution.portrait.$mode", null) ?: return SessionDisplay.LINK_LANDSCAPE
|
||||
|
||||
@@ -148,6 +148,9 @@ object SessionState {
|
||||
@Volatile
|
||||
var outputSize: Pair<Int, Int> = Pair(1920, 1080)
|
||||
|
||||
@Volatile
|
||||
var followScales: Pair<Float?, Float?> = null to null
|
||||
|
||||
@Volatile
|
||||
var followScreen = false
|
||||
var followScale = 1f
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import android.content.Context
|
||||
import android.content.pm.ActivityInfo
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
@@ -74,6 +75,35 @@ class PortraitResolutionTest {
|
||||
assertEquals("1440x2560", SessionPrefs.resolutionStored(app, "steam", panel, true))
|
||||
}
|
||||
|
||||
@Test fun followScreenInLandscapeLeavesAFixedPortraitSizeFixed() {
|
||||
SessionPrefs.setResolutionChoice(app, "steam", SessionDisplay.FOLLOW_SCREEN)
|
||||
SessionPrefs.setResolutionChoice(app, "steam", "1024x768", portrait = true)
|
||||
assertEquals(1f to null, SessionPrefs.followScales(app, "steam", panel))
|
||||
}
|
||||
|
||||
@Test fun followScreenInPortraitLeavesAFixedLandscapeSizeFixed() {
|
||||
SessionPrefs.setResolutionChoice(app, "steam", "1080p")
|
||||
SessionPrefs.setResolutionChoice(app, "steam", SessionDisplay.followScaled(2f), portrait = true)
|
||||
assertEquals(null to 2f, SessionPrefs.followScales(app, "steam", panel))
|
||||
}
|
||||
|
||||
@Test fun followScalesKeepLinkedAndFixedChoices() {
|
||||
SessionPrefs.setResolutionChoice(app, "steam", SessionDisplay.followScaled(1.5f))
|
||||
assertEquals(1.5f to 1.5f, SessionPrefs.followScales(app, "steam", panel))
|
||||
SessionPrefs.setResolutionChoice(app, "steam", "1024x768", portrait = true)
|
||||
SessionPrefs.setResolutionChoice(app, "steam", SessionDisplay.LINK_PORTRAIT)
|
||||
assertEquals(null to null, SessionPrefs.followScales(app, "steam", panel))
|
||||
app.getSharedPreferences("session", Context.MODE_PRIVATE).edit().clear().commit()
|
||||
assertEquals(null to null, SessionPrefs.followScales(app, "steam", panel))
|
||||
}
|
||||
|
||||
@Test fun anAutoOrientationIsNotChangedByFollowScreen() {
|
||||
assertFalse(SessionPrefs.portrait(app))
|
||||
SessionPrefs.setOrientation(app, ActivityInfo.SCREEN_ORIENTATION_USER)
|
||||
assertEquals(ActivityInfo.SCREEN_ORIENTATION_USER, SessionPrefs.windowOrientation(app, true, 700))
|
||||
assertEquals(ActivityInfo.SCREEN_ORIENTATION_USER, SessionPrefs.windowOrientation(app, false, 700))
|
||||
}
|
||||
|
||||
@Test fun modesKeepSeparateChoices() {
|
||||
SessionPrefs.setResolutionChoice(app, "steam", "1080p", portrait = true)
|
||||
assertEquals(SessionDisplay.LINK_LANDSCAPE, SessionPrefs.resolutionStored(app, "lxqt", panel, true))
|
||||
|
||||
Reference in new issue
Block a user