mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-24 23:36:04 +00:00
feat(session): split the display resolution into landscape and portrait (#2990)
## Summary Splits the session resolution setting into two: **Landscape resolution** and **Portrait resolution**. Each has the same options as the old Resolution row, plus a Follow option so one orientation can mirror the other. ## Why A single resolution has to serve both orientations. Presets and Match screen flip automatically in portrait, but a custom size is used exactly as typed, so a landscape size in a portrait session is wrong. Users who play in both orientations couldn't pick a good size for each. ## Behavior - The Display tab shows **Landscape resolution** and, underneath it, **Portrait resolution**. Both offer the full existing list: presets, Match screen, Follow screen, scaled follow options and Custom. - Each row has an extra option at the top. **Follow portrait** (on the landscape row) and **Follow landscape** (on the portrait row) use the other orientation's choice, so someone can set one resolution and let the other mirror it. The label shows the size it resolves to. - A session picks the landscape or portrait choice from its orientation. This uses the same orientation check as the output size, so the unfolded-controls layout still counts as landscape. - Custom WxH sizes are flipped to match the target orientation when followed, e.g. portrait following 1280x720 uses 720x1280. - If both rows would follow each other, the other row is set to the concrete size it currently resolves to, so there is never a loop and nothing visibly changes. - The glasses output keeps using the landscape resolution. - Applies to the Steam and Desktop Display tabs, which share the same row. ## Compatibility - The existing saved choice (`displayResolution.<mode>`) is now the landscape resolution, so existing users keep their setting. - The portrait choice is stored as `displayResolution.portrait.<mode>` and defaults to Follow landscape, so portrait sessions behave as before until it is changed. The settings reset covers it through the existing `displayResolution.` prefix. - One visible difference: a typed landscape custom size, used as typed in portrait before, now flips to portrait while portrait follows landscape. ## Known limitation "Follow screen" is still decided once when the session starts, not on every rotation. Re-evaluating it on rotation could make the window orientation flip repeatedly when no orientation is pinned. ## Changes - `SessionDisplay`: `LINK_LANDSCAPE` / `LINK_PORTRAIT`, `isLink`, `orientCustom`, `effectiveChoice` - `SessionPrefs`: `resolutionStored` (raw value per orientation), `resolutionChoice(..., portrait)`, `setResolutionChoice(..., portrait)` with the loop guard, `resolutionChosen(..., portrait)` - `SessionActivity`: `portraitOutput()` drives the output size, follow-screen choice and follow scale; the Match-screen default for programs that draw at the panel size checks the matching orientation - `ResolutionRow`, `ModeSettingsDialog`, `FrontEndActivity`: two rows, the Follow option, state and actions - `DeviceReport`: logs landscape and portrait separately - Strings: `display_resolution_landscape`, `display_resolution_portrait`, `display_follow_landscape`, `display_follow_portrait` in all 33 locales; the unused `display_resolution` is removed - Tests: `PortraitResolutionTest` ## Testing - Unit tests added for the preference logic, follow resolution, loop guard and reset.
This commit is contained in:
42 files changed
+388
-103
No files matched your search
@@ -0,0 +1,97 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import android.content.Context
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.RuntimeEnvironment
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [28], manifest = Config.NONE)
|
||||
class PortraitResolutionTest {
|
||||
private val app get() = RuntimeEnvironment.getApplication()
|
||||
private val panel = 2400 to 1080
|
||||
|
||||
@Before fun clear() {
|
||||
app.getSharedPreferences("session", Context.MODE_PRIVATE).edit().clear().commit()
|
||||
}
|
||||
|
||||
@Test fun portraitFollowsLandscapeUntilItIsSet() {
|
||||
assertEquals(SessionDisplay.LINK_LANDSCAPE, SessionPrefs.resolutionStored(app, "steam", panel, true))
|
||||
SessionPrefs.setResolutionChoice(app, "steam", "900p")
|
||||
assertEquals("900p", SessionPrefs.resolutionChoice(app, "steam", panel, false))
|
||||
assertEquals("900p", SessionPrefs.resolutionChoice(app, "steam", panel, true))
|
||||
}
|
||||
|
||||
@Test fun eachOrientationKeepsItsOwnResolution() {
|
||||
SessionPrefs.setResolutionChoice(app, "steam", "1600x720")
|
||||
SessionPrefs.setResolutionChoice(app, "steam", "1080p", portrait = true)
|
||||
assertEquals("1600x720", SessionPrefs.resolutionChoice(app, "steam", panel, false))
|
||||
assertEquals("1080p", SessionPrefs.resolutionChoice(app, "steam", panel, true))
|
||||
assertEquals("1080p", SessionPrefs.resolutionStored(app, "steam", panel, true))
|
||||
}
|
||||
|
||||
@Test fun landscapeCanFollowPortrait() {
|
||||
SessionPrefs.setResolutionChoice(app, "steam", "720x1280", portrait = true)
|
||||
SessionPrefs.setResolutionChoice(app, "steam", SessionDisplay.LINK_PORTRAIT)
|
||||
assertEquals(SessionDisplay.LINK_PORTRAIT, SessionPrefs.resolutionStored(app, "steam", panel, false))
|
||||
assertEquals("1280x720", SessionPrefs.resolutionChoice(app, "steam", panel, false))
|
||||
assertEquals("720x1280", SessionPrefs.resolutionChoice(app, "steam", panel, true))
|
||||
}
|
||||
|
||||
@Test fun followingEachOtherNeverLoops() {
|
||||
SessionPrefs.setResolutionChoice(app, "steam", "900p")
|
||||
SessionPrefs.setResolutionChoice(app, "steam", SessionDisplay.LINK_PORTRAIT)
|
||||
assertEquals("900p", SessionPrefs.resolutionChoice(app, "steam", panel, false))
|
||||
assertEquals("900p", SessionPrefs.resolutionChoice(app, "steam", panel, true))
|
||||
assertFalse(SessionDisplay.isLink(SessionPrefs.resolutionStored(app, "steam", panel, true)))
|
||||
}
|
||||
|
||||
@Test fun aGeneratedPortraitSizeSurvivesAReload() {
|
||||
SessionPrefs.setResolutionChoice(app, "steam", "2560x1440")
|
||||
SessionPrefs.setResolutionChoice(app, "steam", SessionDisplay.LINK_PORTRAIT)
|
||||
assertEquals("1440x2560", SessionPrefs.resolutionStored(app, "steam", panel, true))
|
||||
assertEquals("2560x1440", SessionPrefs.resolutionChoice(app, "steam", panel, false))
|
||||
assertEquals("1440x2560", SessionPrefs.resolutionChoice(app, "steam", panel, true))
|
||||
}
|
||||
|
||||
@Test fun aSavedDesktopResolutionInEitherOrientationCountsAsChosen() {
|
||||
SessionPrefs.setResolutionChoice(app, SessionService.MODE_DESKTOP, "1080p", portrait = true)
|
||||
assertTrue(SessionPrefs.resolutionChosen(app, SessionService.MODE_DESKTOP, true))
|
||||
assertEquals(SessionService.MODE_DESKTOP,
|
||||
SessionPrefs.displayMode(app, SessionService.MODE_RUN, com.droiddeck.launcher.runtime.UserApps.SCRIPT_LAUNCHER))
|
||||
}
|
||||
|
||||
@Test fun portraitInputAcceptsTallSizesLandscapeInputDoesNot() {
|
||||
assertNull(SessionPrefs.parseResolution("1440x2560"))
|
||||
assertEquals(1440 to 2560, SessionPrefs.parseOrientedResolution("1440x2560"))
|
||||
assertEquals(1280 to 720, SessionPrefs.parseOrientedResolution("1280x720"))
|
||||
assertNull(SessionPrefs.parseOrientedResolution("100x100"))
|
||||
SessionPrefs.setResolutionChoice(app, "steam", "1440x2560", portrait = true)
|
||||
assertEquals("1440x2560", SessionPrefs.resolutionStored(app, "steam", panel, true))
|
||||
}
|
||||
|
||||
@Test fun modesKeepSeparateChoices() {
|
||||
SessionPrefs.setResolutionChoice(app, "steam", "1080p", portrait = true)
|
||||
assertEquals(SessionDisplay.LINK_LANDSCAPE, SessionPrefs.resolutionStored(app, "lxqt", panel, true))
|
||||
}
|
||||
|
||||
@Test fun resettingSettingsClearsThePortraitChoice() {
|
||||
SessionPrefs.setResolutionChoice(app, "steam", "1080p", portrait = true)
|
||||
assertTrue(SettingsReset.isSessionSetting("displayResolution.portrait.steam"))
|
||||
}
|
||||
|
||||
@Test fun effectiveChoiceFollowsTheOtherOrientation() {
|
||||
val d = SessionDisplay
|
||||
assertEquals("900p", d.effectiveChoice("900p", d.LINK_LANDSCAPE, true))
|
||||
assertEquals("1600x720", d.effectiveChoice("1600x720", "1080p", false))
|
||||
assertEquals("720x1600", d.effectiveChoice("1600x720", d.LINK_LANDSCAPE, true))
|
||||
assertEquals("1600x720", d.effectiveChoice(d.LINK_PORTRAIT, "720x1600", false))
|
||||
assertEquals(d.DEFAULT_RESOLUTION, d.effectiveChoice(d.LINK_PORTRAIT, d.LINK_LANDSCAPE, true))
|
||||
assertEquals("follow/2", d.effectiveChoice("follow/2", d.LINK_LANDSCAPE, true))
|
||||
assertEquals(d.MATCH_SCREEN, d.effectiveChoice(d.LINK_PORTRAIT, d.MATCH_SCREEN, false))
|
||||
}
|
||||
}
|
||||
@@ -55,6 +55,11 @@ class SessionDisplayTest {
|
||||
|
||||
@Test fun unfoldedControlsKeepTheGameSixteenByNineAcrossTheWidth() {
|
||||
assertEquals(606, SessionDisplay.unfoldedGameHeight(1080, 1920))
|
||||
assertEquals(606, SessionDisplay.unfoldedGameHeight(1080, 1920, 0, 16f / 9f))
|
||||
assertEquals(606, SessionDisplay.unfoldedGameHeight(1080, 1920, 0, 2.2f))
|
||||
assertEquals(1080, SessionDisplay.unfoldedGameHeight(1440, 3039, 192, 4f / 3f))
|
||||
assertEquals(1080, SessionDisplay.unfoldedGameHeight(1440, 3039, 0, 4f / 3f))
|
||||
assertEquals(2430, SessionDisplay.unfoldedGameHeight(1440, 3039, 0, 0.5f))
|
||||
assertEquals(1376, SessionDisplay.unfoldedGameHeight(2448, 1848))
|
||||
assertEquals(1038, SessionDisplay.unfoldedGameHeight(1848, 2448))
|
||||
assertEquals(864, SessionDisplay.unfoldedGameHeight(1920, 1080))
|
||||
|
||||
Reference in new issue
Block a user