mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-25 07:46:01 +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)
|
cornerTap = SessionPrefs.drawerCornerTap(this)
|
||||||
applyOutputPacing()
|
applyOutputPacing()
|
||||||
if (!SessionState.running) {
|
if (!SessionState.running) {
|
||||||
SessionState.followScreen = followChoice()
|
SessionState.followScales = SessionPrefs.followScales(this, displayMode(),
|
||||||
SessionState.followScale = followScale()
|
com.droiddeck.launcher.session.SessionDisplay.panelSize(this))
|
||||||
}
|
}
|
||||||
|
applyFollowChoice()
|
||||||
applyFollowOrientation(resources.configuration)
|
applyFollowOrientation(resources.configuration)
|
||||||
goFullscreen()
|
goFullscreen()
|
||||||
volumeControlStream = android.media.AudioManager.STREAM_MUSIC
|
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 followPortrait(): Boolean = glassesScreen == null && SessionPrefs.portrait(this)
|
||||||
|
|
||||||
private fun followScale(): Float {
|
private fun applyFollowChoice() {
|
||||||
val mode = displayMode()
|
val scale = SessionState.followScales.let { if (followPortrait()) it.second else it.first }
|
||||||
val choice = SessionPrefs.resolutionChoice(this, mode, com.droiddeck.launcher.session.SessionDisplay.panelSize(this), followPortrait())
|
SessionState.followScreen = scale != null
|
||||||
return com.droiddeck.launcher.session.SessionDisplay.followScale(choice) ?: 1f
|
SessionState.followScale = scale ?: 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 applyFollowOrientation(config: android.content.res.Configuration) {
|
private fun applyFollowOrientation(config: android.content.res.Configuration) {
|
||||||
@@ -3018,6 +3013,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
|||||||
SessionService.setActivityDisplay(this, sessionActivityDisplayId)
|
SessionService.setActivityDisplay(this, sessionActivityDisplayId)
|
||||||
}
|
}
|
||||||
cancelTouchGestures()
|
cancelTouchGestures()
|
||||||
|
applyFollowChoice()
|
||||||
applyFollowOrientation(newConfig)
|
applyFollowOrientation(newConfig)
|
||||||
applyNotchInset()
|
applyNotchInset()
|
||||||
applyUnfoldedControls()
|
applyUnfoldedControls()
|
||||||
|
|||||||
@@ -1343,6 +1343,10 @@ object SessionPrefs {
|
|||||||
SessionDisplay.effectiveChoice(
|
SessionDisplay.effectiveChoice(
|
||||||
resolutionStored(context, mode, panel, false), resolutionStored(context, mode, panel, true), portrait)
|
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 {
|
fun resolutionStored(context: Context, mode: String, panel: Pair<Int, Int>, portrait: Boolean): String {
|
||||||
if (!portrait) return landscapeResolutionStored(context, mode, panel)
|
if (!portrait) return landscapeResolutionStored(context, mode, panel)
|
||||||
val value = prefs(context).getString("displayResolution.portrait.$mode", null) ?: return SessionDisplay.LINK_LANDSCAPE
|
val value = prefs(context).getString("displayResolution.portrait.$mode", null) ?: return SessionDisplay.LINK_LANDSCAPE
|
||||||
|
|||||||
@@ -148,6 +148,9 @@ object SessionState {
|
|||||||
@Volatile
|
@Volatile
|
||||||
var outputSize: Pair<Int, Int> = Pair(1920, 1080)
|
var outputSize: Pair<Int, Int> = Pair(1920, 1080)
|
||||||
|
|
||||||
|
@Volatile
|
||||||
|
var followScales: Pair<Float?, Float?> = null to null
|
||||||
|
|
||||||
@Volatile
|
@Volatile
|
||||||
var followScreen = false
|
var followScreen = false
|
||||||
var followScale = 1f
|
var followScale = 1f
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.droiddeck.launcher.session
|
package com.droiddeck.launcher.session
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.pm.ActivityInfo
|
||||||
import org.junit.Assert.*
|
import org.junit.Assert.*
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
@@ -74,6 +75,35 @@ class PortraitResolutionTest {
|
|||||||
assertEquals("1440x2560", SessionPrefs.resolutionStored(app, "steam", panel, true))
|
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() {
|
@Test fun modesKeepSeparateChoices() {
|
||||||
SessionPrefs.setResolutionChoice(app, "steam", "1080p", portrait = true)
|
SessionPrefs.setResolutionChoice(app, "steam", "1080p", portrait = true)
|
||||||
assertEquals(SessionDisplay.LINK_LANDSCAPE, SessionPrefs.resolutionStored(app, "lxqt", panel, true))
|
assertEquals(SessionDisplay.LINK_LANDSCAPE, SessionPrefs.resolutionStored(app, "lxqt", panel, true))
|
||||||
|
|||||||
Reference in new issue
Block a user