mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-05 12:35:42 +00:00
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3f4405931a | ||
|
|
d41424170a | ||
|
|
f4678935c4 | ||
|
|
416eb41d8d | ||
|
|
6e0d456dd7 | ||
|
|
a1078cb12f |
No files matched your search
@@ -488,6 +488,30 @@ jobs:
|
||||
- name: Unit tests
|
||||
run: ./gradlew testReleaseUnitTest --console=plain -PndkVersion="$NDK_VERSION"
|
||||
|
||||
- name: Render Compose previews
|
||||
run: ./gradlew testDebugUnitTest --tests '*PreviewRenderTest' --console=plain -PndkVersion="$NDK_VERSION"
|
||||
|
||||
- name: Check the native dependency closure
|
||||
run: |
|
||||
set -euo pipefail
|
||||
APK=$(find app/build/outputs/apk -name '*.apk' | head -1)
|
||||
WORK=$(mktemp -d)
|
||||
unzip -q "$APK" 'lib/arm64-v8a/*' -d "$WORK"
|
||||
cd "$WORK/lib/arm64-v8a"
|
||||
SYSTEM="libc.so libm.so libdl.so liblog.so libandroid.so libz.so libvulkan.so libstdc++.so
|
||||
libGLESv2.so libEGL.so libnativewindow.so libjnigraphics.so libaaudio.so
|
||||
libOpenSLES.so libmediandk.so libcamera2ndk.so libsync.so libneuralnetworks.so"
|
||||
fail=0
|
||||
for so in *.so; do
|
||||
for need in $(readelf -d "$so" | sed -n 's/.*NEEDED.*\[\(.*\)\]/\1/p'); do
|
||||
[ -f "$need" ] && continue
|
||||
case " $(echo $SYSTEM) " in *" $need "*) continue ;; esac
|
||||
echo "::error::$so needs $need, which is neither in the apk nor a platform library"
|
||||
fail=1
|
||||
done
|
||||
done
|
||||
exit $fail
|
||||
|
||||
- name: Sign with the testkey (v1 + v2 + v3)
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
@@ -65,6 +65,13 @@ def commitTime = (gitValue(['show', '-s', '--format=%ct', 'HEAD']) ?: '0').with
|
||||
def desktopKde = rootProject.file('tools/desktop-kde/release.env').readLines()
|
||||
.findAll { it.contains('=') && !it.startsWith('#') }
|
||||
.collectEntries { def kv = it.split('=', 2); [(kv[0].trim()): kv[1].trim()] }
|
||||
def desktopRemovalSources = new groovy.json.JsonSlurper().parse(file('src/main/assets/desktop-removal/sources.json'))
|
||||
if (desktopRemovalSources.archives[desktopKde.DESKTOP_KDE_TAG] != desktopKde.DESKTOP_KDE_SHA256) {
|
||||
throw new GradleException('Desktop removal inventories do not match the pinned archive')
|
||||
}
|
||||
if (!file('src/main/assets/desktop-removal/versions.txt').readLines().contains(desktopKde.DESKTOP_KDE_TAG)) {
|
||||
throw new GradleException('Regenerate desktop removal inventories for ' + desktopKde.DESKTOP_KDE_TAG)
|
||||
}
|
||||
// tools/release/variants.txt as "package=suffix;...", so the updater picks the apk of the package it runs as.
|
||||
def variantSuffixes = rootProject.file('tools/release/variants.txt').readLines()
|
||||
.findAll { it.trim() && !it.startsWith('#') }
|
||||
@@ -279,6 +286,10 @@ dependencies {
|
||||
// on-screen pad are Views underneath it, which is what they are in every Compose app.
|
||||
implementation platform('androidx.compose:compose-bom:2024.02.00')
|
||||
implementation 'androidx.compose.ui:ui'
|
||||
debugImplementation 'androidx.compose.ui:ui-tooling-preview'
|
||||
debugImplementation 'androidx.compose.ui:ui-tooling'
|
||||
debugImplementation 'androidx.compose.ui:ui-test-manifest'
|
||||
testImplementation 'androidx.compose.ui:ui-test-junit4'
|
||||
implementation 'androidx.compose.material3:material3'
|
||||
implementation 'androidx.activity:activity-compose:1.8.2'
|
||||
// The File Manager, Bannerlator's: its icon set, image thumbnails and the coroutines it
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.droiddeck.launcher.files
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import com.droiddeck.launcher.ui.DroidDeckPreviews
|
||||
import com.droiddeck.launcher.ui.PreviewCase
|
||||
import com.droiddeck.launcher.ui.PreviewHost
|
||||
import java.io.File
|
||||
|
||||
/** File metadata only: no files are created and no real directory is enumerated. */
|
||||
private class SampleFile(path: String, private val directory: Boolean = false, private val bytes: Long = 0) : File(path) {
|
||||
override fun isDirectory() = directory
|
||||
override fun isFile() = !directory
|
||||
override fun exists() = true
|
||||
override fun canRead() = true
|
||||
override fun canWrite() = false
|
||||
override fun length() = bytes
|
||||
override fun getUsableSpace() = 32_000_000_000L
|
||||
override fun getFreeSpace() = 32_000_000_000L
|
||||
override fun lastModified() = 1_791_331_200_000L
|
||||
override fun getCanonicalPath() = absolutePath
|
||||
override fun getCanonicalFile() = this
|
||||
override fun listFiles(): Array<File> = emptyArray()
|
||||
}
|
||||
|
||||
private val directory = SampleFile("/storage/emulated/0", directory = true)
|
||||
private val entries = listOf(
|
||||
SampleFile("/storage/emulated/0/Games", directory = true),
|
||||
SampleFile("/storage/emulated/0/ROMs", directory = true),
|
||||
SampleFile("/storage/emulated/0/Downloads", directory = true),
|
||||
SampleFile("/storage/emulated/0/Portal 2.exe", bytes = 4_200_000),
|
||||
SampleFile("/storage/emulated/0/session.log", bytes = 32_000),
|
||||
SampleFile("/storage/emulated/0/save.zip", bytes = 12_000_000),
|
||||
)
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun FileGridPreview() = PreviewHost {
|
||||
FileManagerScreen(preview = FileManagerPreviewState(directory, entries))
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun FileListPreview() = PreviewHost {
|
||||
FileManagerScreen(preview = FileManagerPreviewState(directory, entries, grid = false))
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun FileEmptyPreview() = PreviewHost {
|
||||
FileManagerScreen(preview = FileManagerPreviewState(directory, emptyList()))
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun FilePickerPreview() = PreviewHost {
|
||||
FileManagerScreen(pickMode = true, pickExtensions = listOf("exe"), pickerTitle = "Choose executable", onPick = {},
|
||||
preview = FileManagerPreviewState(directory, entries.filter { it.isDirectory || it.extension == "exe" }))
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun FolderPickerPreview() = PreviewHost {
|
||||
FileManagerScreen(pickMode = true, pickDirMode = true, onPick = {},
|
||||
preview = FileManagerPreviewState(directory, entries.filter { it.isDirectory }))
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun FilePropertiesPreview() = PreviewHost {
|
||||
FilePropertiesDialog(entries.last(), {}, {})
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun FavoritesPreview() = PreviewHost {
|
||||
FileManagerScreen(preview = FileManagerPreviewState(directory, entries, favorites = true))
|
||||
}
|
||||
|
||||
internal val filePreviewCases = listOf(
|
||||
PreviewCase("Favorites") { FavoritesPreview() },
|
||||
PreviewCase("FileGrid") { FileGridPreview() },
|
||||
PreviewCase("FileList") { FileListPreview() },
|
||||
PreviewCase("FileEmpty") { FileEmptyPreview() },
|
||||
PreviewCase("FilePicker") { FilePickerPreview() },
|
||||
PreviewCase("FolderPicker") { FolderPickerPreview() },
|
||||
PreviewCase("FileProperties") { FilePropertiesPreview() },
|
||||
)
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import com.droiddeck.launcher.core.PhantomProcessStatus
|
||||
import com.droiddeck.launcher.runtime.UserApps
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun WirelessAdbPreview() {
|
||||
PreviewHost {
|
||||
WirelessAdbFixPage({}, true, {}, { _, _, _, done -> done("Preview only") }, { _, done -> done(null) }, { _, _, _, done -> done("Preview only") })
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun ProcessLimitPreview() {
|
||||
PreviewHost {
|
||||
PhantomProcessGatePage(PhantomProcessStatus.ENABLED, {}, {}, {}, {}, {}, {})
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun AddAppPreview() {
|
||||
PreviewHost {
|
||||
AddAppDialog(true, {}) { _, _ -> }
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun EditAppPreview() {
|
||||
PreviewHost {
|
||||
EditAppDialog(UserApps.App("sample", UserApps.Kind.APPIMAGE, "Example app", null, "AppImage", "/preview/example.AppImage", emptyList()), {}) { _, _, _ -> }
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun ConfirmationPreview() {
|
||||
PreviewHost {
|
||||
ConfirmDialog("Remove runtime?", "Remove the installed Linux runtime.", "Remove", {}, {})
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun CustomResolutionPreview() {
|
||||
PreviewHost {
|
||||
CustomResolutionDialog(1280 to 720, {}, {})
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun RomsFolderPreview() {
|
||||
PreviewHost {
|
||||
RomsDialog("/preview/ROMs", {}, {}, {})
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun GameEnvironmentPreview() {
|
||||
PreviewHost {
|
||||
GameEnvironmentEditor(false, com.droiddeck.launcher.core.GameEnvironment.Config(shared = mapOf("DXVK_HUD" to "fps", "MANGOHUD" to "1"))) {}
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun WindowsComponentsPreview() {
|
||||
PreviewHost {
|
||||
WinComponentsDialog("100", "Portal 2", null, false, onClose = {}, previewComponents = listOf(
|
||||
com.droiddeck.launcher.session.WinComponents.Component("vcrun2022", "Visual C++ runtime", "Microsoft", "ready", emptyList(), emptyList()),
|
||||
com.droiddeck.launcher.session.WinComponents.Component("d3dcompiler_47", "DirectX shader compiler", "Microsoft", "ready", emptyList(), emptyList()),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun DeveloperDisplayPreview() = PreviewHost {
|
||||
DeveloperDisplayChoiceDialog(listOf(2 to "Secondary screen"), {}, {}, {})
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun AppDisplayPreview() = PreviewHost {
|
||||
ChooseAppDisplayDialog(com.droiddeck.launcher.HomeApp.LaunchableApp("Files", "preview.files", "preview.files.Main", null),
|
||||
com.droiddeck.launcher.input.SecondScreenDisplay(2, "Secondary screen"), {}, {}, {})
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun LauncherPreview() {
|
||||
PreviewHost {
|
||||
FrontEndScreen(PreviewData.front(), PreviewData.frontActions)
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun RuntimeMissingPreview() {
|
||||
PreviewHost {
|
||||
FrontEndScreen(PreviewData.front(ready = false), PreviewData.frontActions)
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun RuntimeDownloadingPreview() {
|
||||
PreviewHost {
|
||||
FrontEndScreen(PreviewData.front(ready = false, busy = true), PreviewData.frontActions)
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun LibraryPreview() {
|
||||
PreviewHost {
|
||||
FrontEndScreen(PreviewData.front(), PreviewData.frontActions, initialSelection = "games")
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun EmptyLibraryPreview() {
|
||||
PreviewHost {
|
||||
FrontEndScreen(PreviewData.front(empty = true), PreviewData.frontActions, initialSelection = "games")
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun GameDetailsPreview() {
|
||||
PreviewHost {
|
||||
FrontEndScreen(PreviewData.front(), PreviewData.frontActions, initialSelection = "app:100")
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun DesktopPreview() {
|
||||
PreviewHost {
|
||||
FrontEndScreen(PreviewData.front(), PreviewData.frontActions, initialSelection = "desktop")
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun EmulatorPreview() {
|
||||
PreviewHost {
|
||||
FrontEndScreen(PreviewData.front(), PreviewData.frontActions, initialSelection = "emu:dolphin")
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun ArtPreview() {
|
||||
PreviewHost {
|
||||
Column(Modifier.fillMaxSize().padding(24.dp)) {
|
||||
ArtGrid(PreviewData.games.map { Tile(it.name, "Installed", null, it.gameIdString, onClick = {}) })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun UpdatesPreview() {
|
||||
PreviewHost {
|
||||
UpdatesPage(PreviewData.front(updates = UpdatesState(catalog = PreviewData.updatesCatalog)), PreviewData.frontActions, Modifier.fillMaxSize().padding(24.dp), installed = PreviewData.installed)
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun UpdatesDownloadingPreview() {
|
||||
PreviewHost {
|
||||
UpdatesPage(PreviewData.front(updates = UpdatesState(catalog = PreviewData.updatesCatalog, stage = "Downloading", percent = 42)), PreviewData.frontActions, Modifier.fillMaxSize().padding(24.dp), installed = PreviewData.installed)
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun UpdatesErrorPreview() {
|
||||
PreviewHost {
|
||||
UpdatesPage(PreviewData.front(updates = UpdatesState(error = "Could not check for updates")), PreviewData.frontActions, Modifier.fillMaxSize().padding(24.dp), installed = PreviewData.installed)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview(name = "Paper theme", widthDp = 960, heightDp = 540, apiLevel = 34)
|
||||
@Composable
|
||||
internal fun AlternateThemePreview() {
|
||||
PreviewHost(theme = Themes.PAPER) { FrontEndScreen(PreviewData.front(), PreviewData.frontActions) }
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun StorePreview() = PreviewHost {
|
||||
val apps = listOf(
|
||||
com.droiddeck.launcher.store.FlathubApi.AppSummary("org.videolan.VLC", "VLC", "Media player", null, "VideoLAN", true, 100_000),
|
||||
com.droiddeck.launcher.store.FlathubApi.AppSummary("org.mozilla.firefox", "Firefox", "Web browser", null, "Mozilla", true, 100_000),
|
||||
)
|
||||
StorePage(PreviewData.front(), PreviewData.frontActions, Modifier.fillMaxSize(), previewSections = mapOf("popular" to apps, "trending" to apps))
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun AndroidAppsPreview() = PreviewHost {
|
||||
FrontEndScreen(PreviewData.front(home = true), PreviewData.frontActions, initialSelection = "android-apps")
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
|
||||
internal class PreviewCase(val name: String, val content: @Composable () -> Unit) {
|
||||
override fun toString() = name
|
||||
}
|
||||
|
||||
internal val screenPreviewCases = listOf(
|
||||
PreviewCase("AlternateTheme") { AlternateThemePreview() },
|
||||
PreviewCase("Launcher") { LauncherPreview() },
|
||||
PreviewCase("RuntimeMissing") { RuntimeMissingPreview() },
|
||||
PreviewCase("RuntimeDownloading") { RuntimeDownloadingPreview() },
|
||||
PreviewCase("Library") { LibraryPreview() },
|
||||
PreviewCase("EmptyLibrary") { EmptyLibraryPreview() },
|
||||
PreviewCase("GameDetails") { GameDetailsPreview() },
|
||||
PreviewCase("Desktop") { DesktopPreview() },
|
||||
PreviewCase("Emulator") { EmulatorPreview() },
|
||||
PreviewCase("Setup") { SetupPreview() },
|
||||
PreviewCase("ControllerMapping") { ControllerMappingPreview() },
|
||||
PreviewCase("GpuDrivers") { GpuDriversPreview() },
|
||||
PreviewCase("Protons") { ProtonsPreview() },
|
||||
PreviewCase("ProtonDownload") { ProtonDownloadPreview() },
|
||||
PreviewCase("ProtonsEmpty") { ProtonsEmptyPreview() },
|
||||
PreviewCase("Drivers") { DriversPreview() },
|
||||
PreviewCase("Loading") { LoadingPreview() },
|
||||
PreviewCase("SessionStarting") { SessionStartingPreview() },
|
||||
PreviewCase("SessionError") { SessionErrorPreview() },
|
||||
PreviewCase("Keyboard") { KeyboardPreview() },
|
||||
PreviewCase("Hud") { HudPreview() },
|
||||
PreviewCase("WirelessAdb") { WirelessAdbPreview() },
|
||||
PreviewCase("ProcessLimit") { ProcessLimitPreview() },
|
||||
PreviewCase("AddApp") { AddAppPreview() },
|
||||
PreviewCase("EditApp") { EditAppPreview() },
|
||||
PreviewCase("Confirmation") { ConfirmationPreview() },
|
||||
PreviewCase("CustomResolution") { CustomResolutionPreview() },
|
||||
PreviewCase("RomsFolder") { RomsFolderPreview() },
|
||||
PreviewCase("GameEnvironment") { GameEnvironmentPreview() },
|
||||
PreviewCase("WindowsComponents") { WindowsComponentsPreview() },
|
||||
PreviewCase("Controls") { ControlsPreview() },
|
||||
PreviewCase("Widgets") { WidgetsPreview() },
|
||||
PreviewCase("Art") { ArtPreview() },
|
||||
PreviewCase("Cursor") { CursorPreview() },
|
||||
PreviewCase("SteamDisplay") { SteamDisplayPreview() },
|
||||
PreviewCase("SteamControls") { SteamControlsPreview() },
|
||||
PreviewCase("SteamGames") { SteamGamesPreview() },
|
||||
PreviewCase("SteamAudio") { SteamAudioPreview() },
|
||||
PreviewCase("SteamSession") { SteamSessionPreview() },
|
||||
PreviewCase("SteamSteam") { SteamSteamPreview() },
|
||||
PreviewCase("DesktopSettings") { DesktopSettingsPreview() },
|
||||
PreviewCase("DrawerController") { DrawerControllerPreview() },
|
||||
PreviewCase("DrawerSecondScreen") { DrawerSecondScreenPreview() },
|
||||
PreviewCase("DrawerDisplay") { DrawerDisplayPreview() },
|
||||
PreviewCase("DrawerEffects") { DrawerEffectsPreview() },
|
||||
PreviewCase("DrawerGames") { DrawerGamesPreview() },
|
||||
PreviewCase("DrawerSession") { DrawerSessionPreview() },
|
||||
PreviewCase("Performance") { PerformancePreview() },
|
||||
PreviewCase("Components") { ComponentsPreview() },
|
||||
PreviewCase("ComponentsLoading") { ComponentsLoadingPreview() },
|
||||
PreviewCase("GpuComponents") { GpuComponentsPreview() },
|
||||
PreviewCase("Updates") { UpdatesPreview() },
|
||||
PreviewCase("UpdatesDownloading") { UpdatesDownloadingPreview() },
|
||||
PreviewCase("UpdatesError") { UpdatesErrorPreview() },
|
||||
PreviewCase("Store") { StorePreview() },
|
||||
PreviewCase("DeveloperDisplay") { DeveloperDisplayPreview() },
|
||||
PreviewCase("AppDisplay") { AppDisplayPreview() },
|
||||
PreviewCase("AndroidApps") { AndroidAppsPreview() },
|
||||
PreviewCase("SetupController") { SetupControllerPreview() },
|
||||
PreviewCase("SetupSession") { SetupSessionPreview() },
|
||||
PreviewCase("SetupLauncher") { SetupLauncherPreview() },
|
||||
)
|
||||
@@ -0,0 +1,143 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import com.droiddeck.launcher.frontend.Library
|
||||
import com.droiddeck.launcher.gpu.FrameGen
|
||||
import com.droiddeck.launcher.gpu.Lossless
|
||||
import com.droiddeck.launcher.input.ControllerPrefs
|
||||
import com.droiddeck.launcher.input.SecondScreenMode
|
||||
import com.droiddeck.launcher.input.SecondScreenDisplay
|
||||
import com.droiddeck.launcher.session.ComponentsManager
|
||||
import com.droiddeck.launcher.session.SessionPrefs
|
||||
import com.droiddeck.launcher.session.SessionService
|
||||
import com.droiddeck.launcher.update.AppUpdates
|
||||
import java.io.File
|
||||
|
||||
/** Deterministic fixtures shared by Studio previews and the render smoke tests. */
|
||||
internal object PreviewData {
|
||||
val games = listOf("Portal 2", "Celeste", "Stardew Valley", "Hollow Knight", "A Short Hike", "Dead Cells")
|
||||
.mapIndexed { i, name -> Library.SteamGame(100 + i, name, null, "/preview/steam") }
|
||||
val controller = ControllerPrefs.Settings(0xFF1A9FFF.toInt(), 80, 100, true, true, true, true, true, true, false, emptyMap())
|
||||
fun front(empty: Boolean = false, busy: Boolean = false, ready: Boolean = true, home: Boolean = false, updates: UpdatesState = UpdatesState()) = FrontEndState(
|
||||
installed = if (ready) "2026.10.07" else null, ready = ready, available = "2026.10.07",
|
||||
busy = busy, stage = if (busy) "Downloading runtime" else "", percent = if (busy) 42 else -1,
|
||||
desktopInstalled = ready, offlineAccount = "Player", offline = false, frameGenLabel = "Off", romsDir = "/preview/ROMs", logsEnabled = true,
|
||||
steamGames = if (empty) emptyList() else games,
|
||||
emulators = listOf(Library.Emulator("dolphin", "Dolphin", "GameCube / Wii", "dolphin-emu", true, listOf(
|
||||
Library.Rom("Wind Waker", File("/preview/ROMs/Wind Waker.iso"), "/root/ROMs/Wind Waker.iso", "dolphin"),
|
||||
))), running = null, controller = controller, animationsEnabled = false, storeEnabled = true,
|
||||
buildLabel = "Design preview", updates = updates, isHomeApp = home, homeScreenEnabled = home,
|
||||
androidApps = if (home) listOf(com.droiddeck.launcher.HomeApp.LaunchableApp("Files", "preview.files", "preview.files.Main", null),
|
||||
com.droiddeck.launcher.HomeApp.LaunchableApp("Settings", "preview.settings", "preview.settings.Main", null)) else emptyList(),
|
||||
)
|
||||
val frontActions = FrontEndActions(
|
||||
onPlay = {},
|
||||
onPlayDesktopUi = {},
|
||||
onSteamGame = {},
|
||||
onDesktop = {},
|
||||
onEmulator = {},
|
||||
onRom = {},
|
||||
onResume = {},
|
||||
onSteamSettings = {},
|
||||
onDesktopSettings = {},
|
||||
onInstallPackage = {},
|
||||
onRemovePackage = {},
|
||||
onRuntime = {},
|
||||
onFrameGenPick = {},
|
||||
onImportLossless = {},
|
||||
onProtons = {},
|
||||
onComponents = {},
|
||||
onPerformance = {},
|
||||
onRoms = {},
|
||||
onFiles = {},
|
||||
onLogs = {},
|
||||
onOffline = {},
|
||||
onWirelessAdbPair = { _, _, _, done -> done("Preview only") },
|
||||
onWirelessAdbApply = { _, _, _, done -> done("Preview only") },
|
||||
onSetPhantomProcessLimit = { _, done -> done("Preview only") },
|
||||
controller = ControllerActions(
|
||||
onOsc = {},
|
||||
onTint = {},
|
||||
onOpacity = {},
|
||||
onSize = {},
|
||||
onStickClick = {},
|
||||
onAdaptiveSticks = {},
|
||||
onRumble = {},
|
||||
onSteamButton = {},
|
||||
onQamButton = {},
|
||||
onKeyboardButton = {},
|
||||
onEditLayout = {},
|
||||
onResetLayout = {},
|
||||
onMapping = {},
|
||||
onResetAll = {},
|
||||
),
|
||||
)
|
||||
fun mode(steam: Boolean = true) = ModeSettings(
|
||||
mode = if (steam) SessionService.MODE_STEAM else SessionService.MODE_DESKTOP, resolution = "1280x720",
|
||||
hdr = false, hdrReason = "HDR is unavailable on this display", touchMode = SessionPrefs.TOUCH_AUTO,
|
||||
suspendPolicy = SessionPrefs.SUSPEND_AUTO, oscMode = SessionPrefs.OSC_AUTO,
|
||||
directAudio = true, mic = false, renderer = "vulkan", stretch16x9 = false,
|
||||
pipSupported = true, syncBackend = "auto", steamChannel = "stable", steamController = "deck",
|
||||
addedGamesDirs = listOf("/preview/Games"), deckyInstalled = "3.0.0", deckyEnabled = true,
|
||||
)
|
||||
val modeActions = ModeSettingsActions(
|
||||
onResolution = {},
|
||||
onHdr = {},
|
||||
onTouch = {},
|
||||
onSuspendPolicy = {},
|
||||
onOsc = {},
|
||||
onDirectAudio = {},
|
||||
onMic = {},
|
||||
onRenderer = {},
|
||||
onDismiss = {},
|
||||
)
|
||||
val components = ComponentsManager.Snapshot(
|
||||
protons = listOf(ComponentsManager.ProtonView(
|
||||
ComponentsManager.Proton("ge-proton", "GE-Proton", File("/preview/proton"), "/opt/proton", "10-20", false),
|
||||
mapOf("fex" to ComponentsManager.Component("FEX-2609", "FEX-2609", "Original", null, null),
|
||||
"dxvk" to ComponentsManager.Component("2.7", "DXVK 2.7", "Original", null, null),
|
||||
"vkd3d" to ComponentsManager.Component("2.14", "VKD3D-Proton 2.14", "Original", null, null)),
|
||||
emptyList(), false,
|
||||
)),
|
||||
packages = listOf(ComponentsManager.Package("dxvk-2.7.tzst", "dxvk", "2.7", "DXVK 2.7", 24_000_000)),
|
||||
)
|
||||
val catalog = listOf(ComponentsManager.CatalogItem("dxvk-2.7.tzst", "dxvk", "2.7", "", 24_000_000, ""))
|
||||
val drivers = listOf(DriverRow("auto", "Auto", "Recommended for this device", false),
|
||||
DriverRow("turnip", "Turnip 25.3", "Android and Linux", true, DriverRow.BUNDLE))
|
||||
val gpu = GpuDriversState(gpuName = "Adreno 740", gpuFamily = "Adreno 7xx", soc = "Snapdragon 8 Gen 2",
|
||||
supportText = "Turnip supported", autoStatus = "Turnip 25.3", activeBundle = "Turnip 25.3",
|
||||
pairs = listOf(PairRow("turnip", "Turnip", "25.3", "Android and Linux", true, true, true, true, true)),
|
||||
androidRows = drivers, linuxRows = drivers)
|
||||
val drawerActions = DrawerActions(
|
||||
steam = true, isHomeApp = false, androidApps = emptyList(), hudOn = true,
|
||||
frameGen = FrameGen.Mode.OFF, lossless = Lossless.State.NONE, oscMode = SessionPrefs.OSC_AUTO,
|
||||
onScreenButtonsVisible = true, suspendPolicy = SessionPrefs.SUSPEND_AUTO, backActionsInverted = false,
|
||||
touchMode = SessionPrefs.TOUCH_AUTO, touchAuto = "Touchpad", fexPreset = "balanced",
|
||||
secondScreenMode = SecondScreenMode.NONE, secondScreenDisplays = listOf(SecondScreenDisplay(2, "Secondary screen")),
|
||||
selectedSecondScreenDisplay = 2, controller = controller, components = components, pipSupported = true,
|
||||
onHud = {},
|
||||
onFrameGenPick = {},
|
||||
onImportLossless = {},
|
||||
onKeyboard = {},
|
||||
onHardwareKeyboard = {},
|
||||
onSteamMenu = {},
|
||||
onQam = {},
|
||||
onOsc = {},
|
||||
onSuspendPolicy = {},
|
||||
onBackActionsInverted = {},
|
||||
onTouch = {},
|
||||
onFexPreset = {},
|
||||
onSecondScreenMode = {},
|
||||
onSecondScreenDisplay = {},
|
||||
onLaunchAndroidApp = { _, _ -> },
|
||||
onBackground = {},
|
||||
onShareLogs = {},
|
||||
onStop = {},
|
||||
onClose = {},
|
||||
)
|
||||
const val TIME = 1_791_331_200_000L
|
||||
val installed = AppUpdates.Installed("preview-old", 0, "0.3.0", 10, true, TIME - 86_400_000, true)
|
||||
val release = AppUpdates.Release("v0.3.1", "Improve handheld layouts", "Settings and library improvements.", "preview-new", 0, "0.3.1", 11, TIME,
|
||||
"", AppUpdates.Apk("DroidDeck.apk", "", 200_000_000, "", "com.droiddeck.launcher", 11, com.droiddeck.launcher.BuildConfig.RELEASE_SIGNER))
|
||||
val updatesCatalog = AppUpdates.Catalog(release, release, emptyList(), TIME,
|
||||
listOf(AppUpdates.PreviewChange("preview-new", "Improve handheld layouts", "Settings and library improvements.", TIME)))
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import androidx.activity.OnBackPressedDispatcher
|
||||
import androidx.activity.OnBackPressedDispatcherOwner
|
||||
import androidx.activity.compose.LocalActivityResultRegistryOwner
|
||||
import androidx.activity.compose.LocalOnBackPressedDispatcherOwner
|
||||
import androidx.activity.result.ActivityResultRegistry
|
||||
import androidx.activity.result.ActivityResultRegistryOwner
|
||||
import androidx.activity.result.contract.ActivityResultContract
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalInspectionMode
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.core.app.ActivityOptionsCompat
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.lifecycle.LifecycleRegistry
|
||||
|
||||
@Preview(name = "Handheld", widthDp = 960, heightDp = 540, apiLevel = 34)
|
||||
@Preview(name = "Compact", widthDp = 480, heightDp = 360, apiLevel = 34)
|
||||
@Preview(name = "Portrait", widthDp = 400, heightDp = 700, apiLevel = 34)
|
||||
@Preview(name = "Large text", widthDp = 960, heightDp = 540, fontScale = 1.3f, apiLevel = 34)
|
||||
@Target(AnnotationTarget.FUNCTION)
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
annotation class DroidDeckPreviews
|
||||
|
||||
/** Every preview uses the production theme and inert Android navigation/picker owners. */
|
||||
@Composable
|
||||
internal fun PreviewHost(theme: String = Themes.GRAPHITE, content: @Composable () -> Unit) {
|
||||
val owner = remember { PreviewOwner() }
|
||||
CompositionLocalProvider(
|
||||
LocalInspectionMode provides true,
|
||||
LocalOnBackPressedDispatcherOwner provides owner,
|
||||
LocalActivityResultRegistryOwner provides owner,
|
||||
) {
|
||||
DroidDeckTheme(theme = theme) {
|
||||
Box(Modifier.fillMaxSize().background(MaterialTheme.colorScheme.background)) { content() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class PreviewOwner : OnBackPressedDispatcherOwner, ActivityResultRegistryOwner, LifecycleOwner {
|
||||
override val lifecycle: Lifecycle = LifecycleRegistry(this).apply { currentState = Lifecycle.State.RESUMED }
|
||||
override val onBackPressedDispatcher = OnBackPressedDispatcher()
|
||||
override val activityResultRegistry = object : ActivityResultRegistry() {
|
||||
override fun <I, O> onLaunch(requestCode: Int, contract: ActivityResultContract<I, O>, input: I, options: ActivityOptionsCompat?) = Unit
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun GpuDriversPreview() {
|
||||
PreviewHost {
|
||||
GpuDriversPanel(PreviewData.gpu, GpuDriversActions()) {}
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun ProtonsPreview() {
|
||||
PreviewHost {
|
||||
ProtonPage(listOf(ProtonRow("ge-proton", "GE-Proton 10-20", "10-20", false), ProtonRow("proton", "Proton Experimental", null, false)), null, null, -1, true, false, {}, {}, {}, {})
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun ProtonDownloadPreview() {
|
||||
PreviewHost {
|
||||
ProtonPage(listOf(ProtonRow("ge-proton", "GE-Proton 10-20", null, false)), "ge-proton", "Downloading", 42, true, false, {}, {}, {}, {})
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun ProtonsEmptyPreview() {
|
||||
PreviewHost {
|
||||
ProtonPage(emptyList(), null, null, -1, false, false, {}, {}, {}, {})
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun DriversPreview() {
|
||||
PreviewHost {
|
||||
DriverPage("GPU drivers", "Choose a driver", PreviewData.drivers, "auto",
|
||||
listOf(DownloadRow("turnip", "Turnip 25.3", "Adreno 7xx", 42)), "Downloading", false, "Import driver", true,
|
||||
{}, {}, {}, {}, {}, {}, {})
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun ComponentsPreview() {
|
||||
PreviewHost {
|
||||
ComponentsPage(PreviewData.components, PreviewData.catalog, PreviewData.TIME, "ge-proton", "dxvk", false, null, emptyMap(),
|
||||
{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, requestInitialFocus = false, gpu = PreviewData.gpu)
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun ComponentsLoadingPreview() {
|
||||
PreviewHost {
|
||||
ComponentsPage(null, PreviewData.catalog, PreviewData.TIME, "ge-proton", "dxvk", true, null, emptyMap(),
|
||||
{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, requestInitialFocus = false, gpu = PreviewData.gpu)
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun GpuComponentsPreview() {
|
||||
PreviewHost {
|
||||
ComponentsPage(PreviewData.components, PreviewData.catalog, PreviewData.TIME, "ge-proton", GPU_TAB, false, null, emptyMap(),
|
||||
{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, requestInitialFocus = false, gpu = PreviewData.gpu)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import com.droiddeck.launcher.session.LoadingState
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun LoadingPreview() {
|
||||
PreviewHost {
|
||||
LoadingOverlay("Downloading runtime", 42, "00:32", "", false, LoadingState.Topic.RUNTIME, true, onCancel = {})
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun SessionStartingPreview() {
|
||||
PreviewHost {
|
||||
LoadingOverlay("Starting Steam", -1, "00:08", "", false, LoadingState.Topic.STEAM_STARTING, true, onCancel = {})
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun SessionErrorPreview() {
|
||||
PreviewHost {
|
||||
LoadingOverlay("Steam stopped", -1, "00:08", "Try starting Steam again.", true, LoadingState.Topic.STEAM, true, endedDetail = "Exit code 1", onRetry = {}, onShareLogs = {}, onClose = {})
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun KeyboardPreview() {
|
||||
PreviewHost {
|
||||
PcKeyboard({ _, _ -> }, {}, {})
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun HudPreview() {
|
||||
PreviewHost {
|
||||
HudText("60 FPS • GPU 72% • CPU 38%")
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun CursorPreview() {
|
||||
PreviewHost {
|
||||
CursorOverlay(Offset(220f, 180f), true, 2f)
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun DrawerControllerPreview() {
|
||||
PreviewHost {
|
||||
SessionDrawer(true, SessionDrawerPage.CONTROLLER, false, {}, PreviewData.drawerActions)
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun DrawerSecondScreenPreview() {
|
||||
PreviewHost {
|
||||
SessionDrawer(true, SessionDrawerPage.SECOND_SCREEN, false, {}, PreviewData.drawerActions)
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun DrawerDisplayPreview() {
|
||||
PreviewHost {
|
||||
SessionDrawer(true, SessionDrawerPage.DISPLAY, false, {}, PreviewData.drawerActions)
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun DrawerEffectsPreview() {
|
||||
PreviewHost {
|
||||
SessionDrawer(true, SessionDrawerPage.EFFECTS, false, {}, PreviewData.drawerActions)
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun DrawerGamesPreview() {
|
||||
PreviewHost {
|
||||
SessionDrawer(true, SessionDrawerPage.GAMES, false, {}, PreviewData.drawerActions)
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun DrawerSessionPreview() {
|
||||
PreviewHost {
|
||||
SessionDrawer(true, SessionDrawerPage.SESSION, false, {}, PreviewData.drawerActions)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.runtime.Composable
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun SetupPreview() {
|
||||
PreviewHost {
|
||||
FrontEndScreen(PreviewData.front(), PreviewData.frontActions, initialSelection = "setup")
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun ControllerMappingPreview() {
|
||||
PreviewHost {
|
||||
ControllerMappingPage(mapOf("a" to "b"), { _, _ -> }, {}, {})
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun ControlsPreview() {
|
||||
PreviewHost {
|
||||
val host = rememberMenuHost()
|
||||
SettingsPage(host, "Controller", {}, scroll = rememberScrollState()) {
|
||||
ControllerRows(host, "auto", PreviewData.controller, PreviewData.frontActions.controller!!)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun WidgetsPreview() {
|
||||
PreviewHost {
|
||||
val host = rememberMenuHost()
|
||||
SettingsPage(host, "Settings controls", {}, scroll = rememberScrollState()) {
|
||||
SettingsGroup("Display") {
|
||||
ChoiceRow(host, "resolution", "Resolution", "Virtual screen size", listOf("720p" to "1280 × 720", "1080p" to "1920 × 1080"), "720p") {}
|
||||
ToggleRow(host, "hdr", "HDR", "High dynamic range", true) {}
|
||||
SliderRow("Sharpness", null, 75, 0..100) {}
|
||||
ActionRow("GPU driver", null, "Manage", {})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun SteamDisplayPreview() {
|
||||
PreviewHost {
|
||||
ModeSettingsPage(PreviewData.mode(), PreviewData.modeActions, initialTab = 0)
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun SteamControlsPreview() {
|
||||
PreviewHost {
|
||||
ModeSettingsPage(PreviewData.mode(), PreviewData.modeActions, initialTab = 1)
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun SteamGamesPreview() {
|
||||
PreviewHost {
|
||||
ModeSettingsPage(PreviewData.mode(), PreviewData.modeActions, initialTab = 2)
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun SteamAudioPreview() {
|
||||
PreviewHost {
|
||||
ModeSettingsPage(PreviewData.mode(), PreviewData.modeActions, initialTab = 3)
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun SteamSessionPreview() {
|
||||
PreviewHost {
|
||||
ModeSettingsPage(PreviewData.mode(), PreviewData.modeActions, initialTab = 4)
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun SteamSteamPreview() {
|
||||
PreviewHost {
|
||||
ModeSettingsPage(PreviewData.mode(), PreviewData.modeActions, initialTab = 5)
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun DesktopSettingsPreview() {
|
||||
PreviewHost {
|
||||
ModeSettingsPage(PreviewData.mode(steam = false), PreviewData.modeActions)
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun PerformancePreview() {
|
||||
PreviewHost {
|
||||
PerformancePage(
|
||||
cores = List(8) { CoreRow(it, if (it < 4) "Efficiency" else "Performance") },
|
||||
clientOverride = false,
|
||||
clientCores = setOf(0, 1, 2, 3),
|
||||
gameCores = (0..7).toSet(),
|
||||
tuSysmem = false,
|
||||
zinkLazy = false,
|
||||
glThread = false,
|
||||
noGlError = false,
|
||||
noXalia = false,
|
||||
fastSync = false,
|
||||
syncFallback = false,
|
||||
fsyncFirst = false,
|
||||
gamescopeRealtime = false,
|
||||
gpuClockPin = false,
|
||||
prootNoSeccomp = false,
|
||||
prootFastPath = false,
|
||||
guestHostname = "droiddeck",
|
||||
phantomWarning = null,
|
||||
onClientOverride = {},
|
||||
onTuSysmem = {},
|
||||
onZinkLazy = {},
|
||||
onGlThread = {},
|
||||
onNoGlError = {},
|
||||
onNoXalia = {},
|
||||
onFastSync = {},
|
||||
onSyncFallback = {},
|
||||
onFsyncFirst = {},
|
||||
onGamescopeRealtime = {},
|
||||
onGpuClockPin = {},
|
||||
onProotNoSeccomp = {},
|
||||
onProotFastPath = {},
|
||||
onGuestHostname = {},
|
||||
onClientCore = { _, _ -> },
|
||||
onGameCore = { _, _ -> },
|
||||
onDismiss = {},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun SetupControllerPreview() = PreviewHost {
|
||||
SetupPanel(PreviewData.front(), PreviewData.frontActions, {}, {}, initialTab = 1)
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun SetupSessionPreview() = PreviewHost {
|
||||
SetupPanel(PreviewData.front(), PreviewData.frontActions, {}, {}, initialTab = 2)
|
||||
}
|
||||
|
||||
@DroidDeckPreviews
|
||||
@Composable
|
||||
internal fun SetupLauncherPreview() = PreviewHost {
|
||||
SetupPanel(PreviewData.front(), PreviewData.frontActions, {}, {}, initialTab = 3)
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,49 @@
|
||||
{
|
||||
"archives": {
|
||||
"lxqt-r1": "c2bb860b3b1688287451e2495be5db313ec07f8c8af501dfac2768a9f417bc86",
|
||||
"desktop-kde-r1": "55747e75d0ec055ab7ea1e92a757f3be227cc3205bb9101f5b53cadef6318579",
|
||||
"desktop-kde-r2": "9ba832677b498654136c69d8c8330434d17e4d53cd099acac9bde3ba429b35bf",
|
||||
"emulators-r1": "a1f4806a9663d28f424b4cab1277e0ede80a92e69de5bc063cdc8b45af220164"
|
||||
},
|
||||
"desktopApplications": {
|
||||
"ark-26.08.1-1-aarch64.pkg.tar.xz": "93e2c2b75ff20cd29b4f312ed1979ef6f27255b93232b93bfcdb31239903c1d4",
|
||||
"breeze-6.7.5-1-aarch64.pkg.tar.xz": "1d7f4eb9d8d234caaea23621909f5233d19462c2f058afeeb54bed7b81bd03bd",
|
||||
"breeze-gtk-6.7.5-1-any.pkg.tar.xz": "a0f59bc4fc426879c8f8a97f6dcc707fb7d1b52913da5eb7e9db83777b6957b7",
|
||||
"breeze-icons-6.30.0-1-aarch64.pkg.tar.xz": "4bae4689032501156687a227024e56554820747644953c67fc8d2e2b6b0b045a",
|
||||
"dolphin-26.08.1-1-aarch64.pkg.tar.xz": "fef738ab8132d3eba1156b98c116699ce0a5efcb4cb462efbacdcf4c47f79a23",
|
||||
"firefox-157.0.1-1-aarch64.pkg.tar.xz": "d142fdb8a339a65eca7cea6a2bba5b29202386166abd9d59851d6757c9eb2163",
|
||||
"gwenview-26.08.1-1-aarch64.pkg.tar.xz": "a9dc7d5ab73fa677905d5a57248b1b9b404b6b16e862958cc7443d387f684a47",
|
||||
"kate-26.08.1-1-aarch64.pkg.tar.xz": "acf50710042746f243a3b219a1ae0f788e338f3dd9d75093e8bb671a618b83b6",
|
||||
"kde-cli-tools-6.7.5-1-aarch64.pkg.tar.xz": "af466398a912a994a97fadfe46aff401d88a90d7fdce7e843dc4218098fa38ac",
|
||||
"kde-gtk-config-6.7.5-1-aarch64.pkg.tar.xz": "ba6cb4cb01dbb3f2c247f2f6973ede3b64c0849f89340217b51dfbf11cb8cb5c",
|
||||
"kinfocenter-6.7.5-1-aarch64.pkg.tar.xz": "f3d5416db96b50f9a5b8a284d82ae21d834a8cce646010abdd7087491c399b0b",
|
||||
"konsole-26.08.1-1-aarch64.pkg.tar.xz": "1ecf87c0d11d620ebe4aeafb02788e0d5f4fe9019ad9c5d9f1011c43237dd5ec",
|
||||
"kscreen-6.7.5-1-aarch64.pkg.tar.xz": "8fbaa6fedf93edeba021a5416b551663654919b27c2ee237d696ec0b0ce7d5b7",
|
||||
"kwin-6.7.5-1-aarch64.pkg.tar.xz": "a7535710c74b90359f80306134b2b7581132cbac508dc84b7e07ef275cc8c3fe",
|
||||
"mpv-1:0.41.0-6-aarch64.pkg.tar.xz": "6c89d00736820210a3c7f32af4cf95d155191d463f9df8bd22137c45f30a554a",
|
||||
"plasma-desktop-6.7.5-1-aarch64.pkg.tar.xz": "b266dd42cea965b5ab1cc1ae600877e9d3bc83ec642c61fe1669c4457e641a55",
|
||||
"plasma-integration-6.7.5-1-aarch64.pkg.tar.xz": "daa96da14d9a4d12c0d9c0341e1be6836a9a437c469d61da5e9844d51e2606cf",
|
||||
"plasma-pa-6.7.5-1-aarch64.pkg.tar.xz": "02dbefe9d3e0069b2bb37cac2a6be18b8f0a1887c87704a0716e7a9268eadcd8",
|
||||
"plasma-workspace-6.7.5-1-aarch64.pkg.tar.xz": "3a1455857afaa9ccf342ab6167f0f15794ee9d248b0925398ea6f62f12730a86",
|
||||
"spectacle-1:6.7.5-1-aarch64.pkg.tar.xz": "0c9837412ea6119edef18bcb0a8fceb74634cb35be0ca78b3e1dd1ff2443866e",
|
||||
"systemsettings-6.7.5-1-aarch64.pkg.tar.xz": "b02b6a726857d5125c92d1ec95379216c7a3bc1f187a3b46e88c0d056b29ce70",
|
||||
"xdg-desktop-portal-kde-6.7.5-1-aarch64.pkg.tar.xz": "2c57d17d34d577023eb9cd7b0fca1ba9163549afe60450f6271aa148af099ef2"
|
||||
},
|
||||
"legacyApplications": {
|
||||
"featherpad-1.6.3-1-aarch64.pkg.tar.xz": "fcac55215815c0b712453f9bcc09abfe4b518e36025a111a7a7598ef04913f3d",
|
||||
"labwc-0.20.2-1-aarch64.pkg.tar.xz": "bcd4cc3945165b0fdd33c0117cd7b9dfd05cf8c327326c37f3c3a27ef23ee5ca",
|
||||
"lximage-qt-2.4.0-1-aarch64.pkg.tar.xz": "5d6bdd5472ea6bcb4b993b36df3ab7010bb2e62b36a78a649708fc9a52cb0928",
|
||||
"lxqt-config-2.4.0-1-aarch64.pkg.tar.xz": "4b601d798fc7689ee76787dbef8c8958c02429ee60248cd99d950c919dbefba5",
|
||||
"lxqt-panel-2.4.1-1-aarch64.pkg.tar.xz": "a141e0f8049e73f859d843510c6f45d6ed9087c990bcebf44f5f2430621024c4",
|
||||
"lxqt-qtplugin-2.4.0-3-aarch64.pkg.tar.xz": "61c8f828be73111ee0bd5e3163b0d64c2098dd0189710a190f42be11137695cf",
|
||||
"lxqt-runner-2.4.0-1-aarch64.pkg.tar.xz": "5afa74652a37366ea4e7774cf33379977582fbdca599cef1005ebf637cbcae4b",
|
||||
"lxqt-session-2.4.0-2-aarch64.pkg.tar.xz": "e9c7c8a0011859029622ad202e0d3826e4e5bc8d64659031f6efa211456ff6eb",
|
||||
"lxqt-themes-2.4.0-1-any.pkg.tar.xz": "7ea16c62a1fa70cdac13cb3f8fdcdaad299ae1f5bd514acfda671484755787bf",
|
||||
"lxqt-wayland-session-0.4.1-1-any.pkg.tar.xz": "cd8dc11f5035469d23b6bbd937a90593402428c43de37517412aa43fe1fc6b10",
|
||||
"papirus-icon-theme-20260801-1-any.pkg.tar.xz": "4aae3f47b800a60d6fd360e55adc581408ceaafc481c5a420a681741a3966510",
|
||||
"pcmanfm-qt-2.4.1-1-aarch64.pkg.tar.xz": "7ec1a6b39dd0e4055b39f0e2c0549ea263d83004e1b821fb9e42f1d7f5fff0f9",
|
||||
"qterminal-2.4.0-1-aarch64.pkg.tar.xz": "aa4adc9c9d47641b9452ec8d879038a9cb4762c3b6b5299045fac968fd0ed22d",
|
||||
"swaybg-1.2.2-1-aarch64.pkg.tar.xz": "a26caa16ca7d581b5ca05758677058b4b60af10dc8d83e447ad6824b762b48b8",
|
||||
"wlr-randr-0.5.0-1-aarch64.pkg.tar.xz": "58c3651c6a15dc8f95a310c7e225f759aa766be2fb3c0981a9a8b567854675b3"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
desktop-kde-r1
|
||||
desktop-kde-r2
|
||||
@@ -139,6 +139,7 @@ class MainActivity : ComponentActivity() {
|
||||
private var pkgStage by mutableStateOf<String?>(null)
|
||||
private var pkgPercent by mutableIntStateOf(-1)
|
||||
private var desktopInstalled by mutableStateOf(false)
|
||||
private var desktopPresent by mutableStateOf(false)
|
||||
private var offlineAccount by mutableStateOf<String?>(null)
|
||||
private var offline by mutableStateOf(false)
|
||||
private var showPerformance by mutableStateOf(false)
|
||||
@@ -560,7 +561,7 @@ class MainActivity : ComponentActivity() {
|
||||
shortcutLibraryScanning = shortcutLibraryScanning,
|
||||
gameSyncFolder = gameSyncFolder,
|
||||
busy = busy, stage = stage, percent = percent,
|
||||
desktopInstalled = desktopInstalled,
|
||||
desktopInstalled = desktopInstalled, desktopPresent = desktopPresent,
|
||||
offlineAccount = offlineAccount, offline = offline,
|
||||
frameGenLabel = frameGenLabel, romsDir = romsDir, logsEnabled = logsEnabled, agentCommands = agentCommands,
|
||||
steamGames = steamGames, emulators = emulatorList, running = runningLabel,
|
||||
@@ -669,6 +670,7 @@ class MainActivity : ComponentActivity() {
|
||||
// The activity re-attaches to the session that is running; nothing restarts.
|
||||
onResume = { startActivity(Intent(this, SessionActivity::class.java)) },
|
||||
onSteamSettings = { openModeSettings(SessionService.MODE_STEAM) },
|
||||
onRemoveDesktop = { removeDesktop() },
|
||||
onDesktopSettings = { openModeSettings(SessionService.MODE_DESKTOP) },
|
||||
onInstallPackage = { id -> installPackage(id) },
|
||||
onRemovePackage = { id -> removePackage(id) },
|
||||
@@ -1198,6 +1200,7 @@ class MainActivity : ComponentActivity() {
|
||||
private fun refreshPackages() {
|
||||
packageRows = catalog?.map { PackageRow(it.id, it.kind, it.notes) }
|
||||
desktopInstalled = DesktopCatalog.desktopInstalled(this)
|
||||
desktopPresent = DesktopCatalog.desktopPresent(this)
|
||||
}
|
||||
|
||||
private fun launchProgram(path: String) {
|
||||
@@ -1556,6 +1559,7 @@ class MainActivity : ComponentActivity() {
|
||||
if (!busy && LinuxRuntimeInstaller.isBusy()) followRuntimeOperation { LinuxRuntimeInstaller.attach(it) }
|
||||
addedGamesArt = SessionPrefs.addedGamesArt(this)
|
||||
desktopInstalled = DesktopCatalog.desktopInstalled(this)
|
||||
desktopPresent = DesktopCatalog.desktopPresent(this)
|
||||
offlineAccount = OfflineMode.account(this)
|
||||
offline = OfflineMode.enabled(this)
|
||||
installed = LinuxRuntimeInstaller.installedVersion(this)
|
||||
@@ -1668,6 +1672,15 @@ class MainActivity : ComponentActivity() {
|
||||
protons.protonBusyId != null || ProtonExtras.installInProgress || pkgStage != null ||
|
||||
components.compBusy != null || saveBusy != null || com.droiddeck.launcher.store.UserAppsState.working != null
|
||||
|
||||
private fun removeDesktop() {
|
||||
if (runtimeChangesBlocked()) return
|
||||
val operation = LinuxRuntimeInstaller.beginMaintenance(this, getString(R.string.desktop_removing)) ?: return
|
||||
com.droiddeck.launcher.runtime.RuntimeInstallService.keepRemovalAlive(this)
|
||||
followRuntimeOperation { listener ->
|
||||
operation.run(listener) { progress -> DesktopCatalog.removeDesktop(this, progress) }
|
||||
}
|
||||
}
|
||||
|
||||
private fun removeRuntime() {
|
||||
if (runtimeChangesBlocked()) return
|
||||
val removal = LinuxRuntimeInstaller.beginUninstall(this) ?: return
|
||||
@@ -1690,7 +1703,7 @@ class MainActivity : ComponentActivity() {
|
||||
private fun followRuntimeOperation(run: (LinuxRuntimeInstaller.ProgressListener) -> Boolean?) {
|
||||
busy = true
|
||||
failed = false
|
||||
stage = getString(if (LinuxRuntimeInstaller.isRemoving()) R.string.main_removing_runtime else R.string.store_starting)
|
||||
stage = getString(if (LinuxRuntimeInstaller.isMaintaining()) R.string.desktop_removing else if (LinuxRuntimeInstaller.isRemoving()) R.string.main_removing_runtime else R.string.store_starting)
|
||||
percent = -1
|
||||
Thread({
|
||||
val ok = run(LinuxRuntimeInstaller.ProgressListener { s, p ->
|
||||
|
||||
@@ -315,7 +315,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
if (com.droiddeck.launcher.runtime.LinuxRuntimeInstaller.isRemoving()) {
|
||||
if (com.droiddeck.launcher.runtime.LinuxRuntimeInstaller.isRemoving() ||
|
||||
com.droiddeck.launcher.runtime.LinuxRuntimeInstaller.isMaintaining()) {
|
||||
runtimeRemovalBlocked = true
|
||||
android.widget.Toast.makeText(this, R.string.session_wait_removal, android.widget.Toast.LENGTH_SHORT).show()
|
||||
finish()
|
||||
|
||||
@@ -23,4 +23,8 @@ object DeviceSupport {
|
||||
val soc = if (Build.VERSION.SDK_INT >= 31) Build.SOC_MODEL.takeIf { it.isNotBlank() && it != Build.UNKNOWN } else null
|
||||
return soc?.let { "$it (${Build.HARDWARE})" } ?: Build.HARDWARE.ifBlank { context.getString(R.string.gpu_this_gpu) }
|
||||
}
|
||||
|
||||
/** False on the Odin 3 (CQ8725S): a low-latency Wi-Fi lock makes its WLAN firmware hang, and
|
||||
* that firmware reboots the whole device instead of restarting Wi-Fi. */
|
||||
fun lowLatencyWifiSafe(): Boolean = Build.VERSION.SDK_INT < 31 || Build.SOC_MODEL != "CQ8725S"
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.droiddeck.launcher.files
|
||||
|
||||
import androidx.compose.ui.platform.LocalInspectionMode
|
||||
import android.content.res.Configuration
|
||||
import androidx.compose.animation.core.animateDpAsState
|
||||
import androidx.compose.foundation.background
|
||||
@@ -122,7 +123,8 @@ class RailState internal constructor(
|
||||
fun rememberRailState(screenKey: String): RailState {
|
||||
val context = LocalContext.current
|
||||
// The same file the File Manager keeps its own browse settings in (no androidx.preference here).
|
||||
val prefs = remember { context.getSharedPreferences("file_manager", android.content.Context.MODE_PRIVATE) }
|
||||
val inspecting = LocalInspectionMode.current
|
||||
val prefs = remember { if (inspecting) null else context.getSharedPreferences("file_manager", android.content.Context.MODE_PRIVATE) }
|
||||
val isLandscape = LocalConfiguration.current.orientation == Configuration.ORIENTATION_LANDSCAPE
|
||||
|
||||
val choseKey = "rail_${screenKey}_userChose"
|
||||
@@ -130,9 +132,9 @@ fun rememberRailState(screenKey: String): RailState {
|
||||
|
||||
// Keep the landscape choice in saveable state regardless of orientation so portrait→landscape
|
||||
// restores it. In portrait we simply report collapsed+locked and ignore it.
|
||||
var userChose by rememberSaveable(screenKey) { mutableStateOf(prefs.getBoolean(choseKey, false)) }
|
||||
var userChose by rememberSaveable(screenKey) { mutableStateOf((prefs?.getBoolean(choseKey, false) ?: false)) }
|
||||
var landscapeCollapsed by rememberSaveable(screenKey) {
|
||||
mutableStateOf(if (prefs.getBoolean(choseKey, false)) prefs.getBoolean(collapsedKey, false) else false)
|
||||
mutableStateOf(if ((prefs?.getBoolean(choseKey, false) ?: false)) (prefs?.getBoolean(collapsedKey, false) ?: false) else false)
|
||||
}
|
||||
|
||||
if (!isLandscape) {
|
||||
@@ -144,10 +146,7 @@ fun rememberRailState(screenKey: String): RailState {
|
||||
onToggle = {
|
||||
landscapeCollapsed = !landscapeCollapsed
|
||||
userChose = true
|
||||
prefs.edit()
|
||||
.putBoolean(choseKey, true)
|
||||
.putBoolean(collapsedKey, landscapeCollapsed)
|
||||
.apply()
|
||||
prefs?.edit()?.putBoolean(choseKey, true)?.putBoolean(collapsedKey, landscapeCollapsed)?.apply()
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.compose.ui.platform.LocalInspectionMode
|
||||
import com.droiddeck.launcher.R
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
@@ -187,6 +188,7 @@ internal fun FileItemRow(
|
||||
) {
|
||||
val dateFormat = remember { SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.getDefault()) }
|
||||
val context = LocalContext.current
|
||||
val inspecting = LocalInspectionMode.current
|
||||
val isDir = file.isDirectory
|
||||
val isExe = !isDir && file.name.lowercase().let { it.endsWith(".exe") || it.endsWith(".bat") || it.endsWith(".msi") || it.endsWith(".sh") }
|
||||
// Image files show a real thumbnail instead of the generic file icon (handy when picking a
|
||||
@@ -195,7 +197,7 @@ internal fun FileItemRow(
|
||||
|
||||
// For real PE executables, try to pull out the embedded application icon (async, off the main thread).
|
||||
var exeIcon by remember(file.absolutePath) { mutableStateOf<ImageBitmap?>(null) }
|
||||
if (!isDir && file.name.lowercase().endsWith(".exe")) {
|
||||
if (!inspecting && !isDir && file.name.lowercase().endsWith(".exe")) {
|
||||
LaunchedEffect(file.absolutePath) {
|
||||
val bmp = withContext(Dispatchers.IO) { PeIconExtractor.extract(file) }
|
||||
if (bmp != null) exeIcon = bmp.asImageBitmap()
|
||||
@@ -364,13 +366,15 @@ internal fun FavoritesList(
|
||||
onJump: (File) -> Unit,
|
||||
onUnpin: (File) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
previewFavorites: List<File> = emptyList(),
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
val inspecting = LocalInspectionMode.current
|
||||
val favorites = remember(favTick) {
|
||||
FavoritesStore.list(context).map(::File).filter { it.exists() }
|
||||
if (inspecting) previewFavorites else FavoritesStore.list(context).map(::File).filter { it.exists() }
|
||||
}
|
||||
val currentAlreadyPinned = remember(favTick, currentDir.absolutePath) {
|
||||
FavoritesStore.isFavorite(context, currentDir.absolutePath)
|
||||
if (inspecting) currentDir in previewFavorites else FavoritesStore.isFavorite(context, currentDir.absolutePath)
|
||||
}
|
||||
|
||||
LazyColumn(modifier = modifier) {
|
||||
@@ -545,10 +549,11 @@ internal fun FileGridTile(
|
||||
onToggleFavorite: () -> Unit = {},
|
||||
onProperties: () -> Unit = {},
|
||||
) {
|
||||
val inspecting = LocalInspectionMode.current
|
||||
val isDir = file.isDirectory
|
||||
val isImage = !isDir && file.extension.lowercase() in IMAGE_THUMB_EXTS
|
||||
var exeIcon by remember(file.absolutePath) { mutableStateOf<ImageBitmap?>(null) }
|
||||
if (!isDir && file.name.lowercase().endsWith(".exe")) {
|
||||
if (!inspecting && !isDir && file.name.lowercase().endsWith(".exe")) {
|
||||
LaunchedEffect(file.absolutePath) {
|
||||
val bmp = withContext(Dispatchers.IO) { PeIconExtractor.extract(file) }
|
||||
if (bmp != null) exeIcon = bmp.asImageBitmap()
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.droiddeck.launcher.files
|
||||
|
||||
import java.io.File
|
||||
|
||||
/** Metadata for design previews. [FileManagerScreen] ignores it outside inspection mode. */
|
||||
class FileManagerPreviewState(val directory: File, val entries: List<File>, val grid: Boolean = true, val favorites: Boolean = false)
|
||||
@@ -80,6 +80,7 @@ import androidx.compose.ui.platform.LocalConfiguration
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.pluralStringResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.platform.LocalInspectionMode
|
||||
import com.droiddeck.launcher.R
|
||||
import androidx.compose.ui.platform.LocalLifecycleOwner
|
||||
import androidx.lifecycle.Lifecycle
|
||||
@@ -109,8 +110,11 @@ fun FileManagerScreen(
|
||||
initialDir: File? = null,
|
||||
pickerTitle: String? = null,
|
||||
onPick: ((File) -> Unit)? = null,
|
||||
preview: FileManagerPreviewState? = null,
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
val inspecting = LocalInspectionMode.current
|
||||
val sample = preview.takeIf { inspecting }
|
||||
val scope = rememberCoroutineScope()
|
||||
|
||||
// Only matching files are shown in pick mode (directories are always shown). Empty = all files.
|
||||
@@ -121,14 +125,15 @@ fun FileManagerScreen(
|
||||
return lowerExts.any { name.endsWith(".$it") }
|
||||
}
|
||||
|
||||
val pickPrefs = remember { context.getSharedPreferences("file_manager", android.content.Context.MODE_PRIVATE) }
|
||||
val pickPrefs = remember { if (inspecting) null else context.getSharedPreferences("file_manager", android.content.Context.MODE_PRIVATE) }
|
||||
val browsePrefs = pickPrefs
|
||||
val rootDir = remember {
|
||||
// Both modes: honour an explicit caller-supplied start dir (e.g. Log Manager's game-log
|
||||
// folder), else open at the INTERNAL STORAGE ROOT. Selection screens (drive-folder pick,
|
||||
// local component pick, imports) previously defaulted to Download which - combined with the
|
||||
// currentRoot floor below - trapped users in Download with no way up (reported bug).
|
||||
initialDir?.takeIf { it.isDirectory } ?: File("/storage/emulated/0")
|
||||
if (inspecting) sample?.directory ?: File("/storage/emulated/0")
|
||||
else initialDir?.takeIf { it.isDirectory } ?: File("/storage/emulated/0")
|
||||
}
|
||||
|
||||
var currentDir by remember { mutableStateOf(rootDir) }
|
||||
@@ -156,7 +161,7 @@ fun FileManagerScreen(
|
||||
}
|
||||
mutableStateOf(vol)
|
||||
}
|
||||
var entries by remember { mutableStateOf(listOf<File>()) }
|
||||
var entries by remember { mutableStateOf(sample?.entries.orEmpty()) }
|
||||
var selectedEntry by remember { mutableStateOf<File?>(null) }
|
||||
var showMenuFor by remember { mutableStateOf<File?>(null) }
|
||||
// Clipboard holds a LIST so one paste can carry a whole selection. Cut/copy semantics are a
|
||||
@@ -177,9 +182,9 @@ fun FileManagerScreen(
|
||||
// Browse controls. Persisted so the list doesn't reset its order every time you open a folder.
|
||||
var searchQuery by remember { mutableStateOf("") }
|
||||
var showSearch by remember { mutableStateOf(false) }
|
||||
var sortBy by remember { mutableStateOf(browsePrefs.getString("fmSortBy", "name") ?: "name") }
|
||||
var sortDesc by remember { mutableStateOf(browsePrefs.getBoolean("fmSortDesc", false)) }
|
||||
var showHidden by remember { mutableStateOf(browsePrefs.getBoolean("fmShowHidden", true)) }
|
||||
var sortBy by remember { mutableStateOf(browsePrefs?.getString("fmSortBy", "name") ?: "name") }
|
||||
var sortDesc by remember { mutableStateOf(browsePrefs?.getBoolean("fmSortDesc", false) ?: false) }
|
||||
var showHidden by remember { mutableStateOf(browsePrefs?.getBoolean("fmShowHidden", true) ?: true) }
|
||||
var showSortMenu by remember { mutableStateOf(false) }
|
||||
// View mode: list of cards (default) or a thumbnail grid. Density applies to the list only -
|
||||
// a grid tile has no second line to compact.
|
||||
@@ -187,9 +192,9 @@ fun FileManagerScreen(
|
||||
// choice persists across rotation). Grid is the default - most useful in landscape, and in
|
||||
// portrait GridCells.Adaptive naturally renders fewer columns (~2). Do NOT force portrait to list:
|
||||
// that broke the toggle on-device (tapping it did nothing in portrait).
|
||||
var gridView by remember { mutableStateOf(browsePrefs.getBoolean("fmGridView", true)) }
|
||||
var gridView by remember { mutableStateOf(sample?.grid ?: (browsePrefs?.getBoolean("fmGridView", true) ?: true)) }
|
||||
val showGrid = gridView
|
||||
var compactRows by remember { mutableStateOf(browsePrefs.getBoolean("fmCompactRows", false)) }
|
||||
var compactRows by remember { mutableStateOf(browsePrefs?.getBoolean("fmCompactRows", false) ?: false) }
|
||||
var showNewFolderDialog by remember { mutableStateOf(false) }
|
||||
var renameTarget by remember { mutableStateOf<File?>(null) }
|
||||
// Properties sheet (basic info + Read-only / Hidden toggles) target; null when closed.
|
||||
@@ -203,7 +208,7 @@ fun FileManagerScreen(
|
||||
|
||||
// Favorites view: when on, a dedicated bookmarks list replaces the file list.
|
||||
// favTick is bumped on any add/remove/toggle so the favorites view + per-row star recompute.
|
||||
var showFavorites by remember { mutableStateOf(false) }
|
||||
var showFavorites by remember { mutableStateOf(sample?.favorites == true) }
|
||||
var favTick by remember { mutableIntStateOf(0) }
|
||||
|
||||
// resetScroll: jump to the top of the list (true for navigation; false for in-place reloads
|
||||
@@ -211,7 +216,8 @@ fun FileManagerScreen(
|
||||
fun loadDirectory(dir: File, resetScroll: Boolean = true) {
|
||||
currentDir = dir
|
||||
// Remember the browsed directory so the next pick resumes here.
|
||||
if (pickMode) pickPrefs.edit().putString("lastFilePickerDir", dir.absolutePath).apply()
|
||||
if (inspecting) return
|
||||
if (pickMode) pickPrefs?.edit()?.putString("lastFilePickerDir", dir.absolutePath)?.apply()
|
||||
scope.launch {
|
||||
val list = withContext(Dispatchers.IO) {
|
||||
dir.listFiles()?.toList()
|
||||
@@ -281,6 +287,7 @@ fun FileManagerScreen(
|
||||
}
|
||||
|
||||
fun performDelete(file: File) {
|
||||
if (inspecting) return
|
||||
scope.launch {
|
||||
isOperationRunning = true
|
||||
operationLabel = context.getString(R.string.fm_op_deleting)
|
||||
@@ -302,6 +309,7 @@ fun FileManagerScreen(
|
||||
}
|
||||
|
||||
fun performPaste() {
|
||||
if (inspecting) return
|
||||
val sources = clipboardFiles
|
||||
if (sources.isEmpty()) return
|
||||
val dstDir = currentDir
|
||||
@@ -387,6 +395,7 @@ fun FileManagerScreen(
|
||||
}
|
||||
|
||||
fun performRename(file: File, newName: String) {
|
||||
if (inspecting) return
|
||||
val target = File(file.parentFile, newName)
|
||||
if (target.exists()) {
|
||||
Toast.makeText(context, context.getString(R.string.fm_already_exists, newName), Toast.LENGTH_SHORT).show()
|
||||
@@ -403,6 +412,7 @@ fun FileManagerScreen(
|
||||
}
|
||||
|
||||
fun createFolder(parent: File, name: String) {
|
||||
if (inspecting) return
|
||||
val target = File(parent, name)
|
||||
if (target.exists()) {
|
||||
Toast.makeText(context, context.getString(R.string.fm_already_exists, name), Toast.LENGTH_SHORT).show()
|
||||
@@ -430,9 +440,9 @@ fun FileManagerScreen(
|
||||
lifecycleOwner.lifecycle.addObserver(observer)
|
||||
onDispose { lifecycleOwner.lifecycle.removeObserver(observer) }
|
||||
}
|
||||
val drives = remember(storageTick) { StorageRoots.list(context) }
|
||||
val drives = remember(storageTick) { if (inspecting) emptyList() else StorageRoots.list(context) }
|
||||
val linuxRoot = remember(storageTick) {
|
||||
com.droiddeck.launcher.runtime.LinuxRuntime.rootDir(context).takeIf { File(it, "usr").isDirectory }
|
||||
if (inspecting) null else com.droiddeck.launcher.runtime.LinuxRuntime.rootDir(context).takeIf { File(it, "usr").isDirectory }
|
||||
}
|
||||
|
||||
// ── Dialogs ──
|
||||
@@ -537,6 +547,7 @@ fun FileManagerScreen(
|
||||
pendingBulkDelete = emptyList()
|
||||
selectionMode = false
|
||||
selectedPaths = emptySet()
|
||||
if (inspecting) return@TextButton
|
||||
operationJob = scope.launch {
|
||||
isOperationRunning = true
|
||||
var failed = 0
|
||||
@@ -754,7 +765,7 @@ fun FileManagerScreen(
|
||||
}
|
||||
IconButton(onClick = {
|
||||
gridView = !gridView
|
||||
browsePrefs.edit().putBoolean("fmGridView", gridView).apply()
|
||||
browsePrefs?.edit()?.putBoolean("fmGridView", gridView)?.apply()
|
||||
}) {
|
||||
Icon(
|
||||
if (gridView) Icons.Filled.ViewList else Icons.Filled.GridView,
|
||||
@@ -780,8 +791,8 @@ fun FileManagerScreen(
|
||||
// Tapping the active field flips direction; a different
|
||||
// field switches to it ascending.
|
||||
if (sortBy == key) sortDesc = !sortDesc else { sortBy = key; sortDesc = false }
|
||||
browsePrefs.edit().putString("fmSortBy", sortBy)
|
||||
.putBoolean("fmSortDesc", sortDesc).apply()
|
||||
browsePrefs?.edit()?.putString("fmSortBy", sortBy)
|
||||
?.putBoolean("fmSortDesc", sortDesc)?.apply()
|
||||
showSortMenu = false
|
||||
loadDirectory(currentDir, resetScroll = false)
|
||||
},
|
||||
@@ -792,7 +803,7 @@ fun FileManagerScreen(
|
||||
text = { Text(if (compactRows) stringResource(R.string.fm_rows_comfortable) else stringResource(R.string.fm_rows_compact)) },
|
||||
onClick = {
|
||||
compactRows = !compactRows
|
||||
browsePrefs.edit().putBoolean("fmCompactRows", compactRows).apply()
|
||||
browsePrefs?.edit()?.putBoolean("fmCompactRows", compactRows)?.apply()
|
||||
showSortMenu = false
|
||||
},
|
||||
)
|
||||
@@ -800,7 +811,7 @@ fun FileManagerScreen(
|
||||
text = { Text(if (showHidden) stringResource(R.string.fm_hide_hidden) else stringResource(R.string.fm_show_hidden)) },
|
||||
onClick = {
|
||||
showHidden = !showHidden
|
||||
browsePrefs.edit().putBoolean("fmShowHidden", showHidden).apply()
|
||||
browsePrefs?.edit()?.putBoolean("fmShowHidden", showHidden)?.apply()
|
||||
showSortMenu = false
|
||||
loadDirectory(currentDir, resetScroll = false)
|
||||
},
|
||||
@@ -1016,15 +1027,15 @@ fun FileManagerScreen(
|
||||
linuxRoot?.let { add(locItem(stringResource(R.string.fm_drive_linux), Icons.Filled.Terminal, it)) }
|
||||
}
|
||||
val quickItems = buildList {
|
||||
File("/storage/emulated/0/Download").takeIf { it.isDirectory }?.let { add(locItem(stringResource(R.string.fm_rail_downloads), Icons.Filled.Download, it, stringResource(R.string.fm_rail_downloads_short))) }
|
||||
File("/storage/emulated/0/Download").takeIf { !inspecting && it.isDirectory }?.let { add(locItem(stringResource(R.string.fm_rail_downloads), Icons.Filled.Download, it, stringResource(R.string.fm_rail_downloads_short))) }
|
||||
// The ROMs folder chosen on the main screen: what the session shows as /root/ROMs.
|
||||
SessionPrefs.romsDir(context).takeIf { it.isNotEmpty() }?.let(::File)?.takeIf { it.isDirectory }
|
||||
(if (inspecting) "" else SessionPrefs.romsDir(context)).takeIf { it.isNotEmpty() }?.let(::File)?.takeIf { it.isDirectory }
|
||||
?.let { add(locItem(stringResource(R.string.fm_rail_roms), Icons.Filled.SportsEsports, it)) }
|
||||
// The app's own logs folder: private, which this file manager (the app itself) can read.
|
||||
com.droiddeck.launcher.runtime.LinuxRuntime.logDir(context).takeIf { it.isDirectory }?.let { add(locItem(stringResource(R.string.fm_rail_session_logs), Icons.Filled.Description, it)) }
|
||||
File("/storage/emulated/0/Pictures").takeIf { it.isDirectory }?.let { add(locItem(stringResource(R.string.fm_rail_pictures), Icons.Filled.Image, it)) }
|
||||
com.droiddeck.launcher.runtime.LinuxRuntime.logDir(context).takeIf { !inspecting && it.isDirectory }?.let { add(locItem(stringResource(R.string.fm_rail_session_logs), Icons.Filled.Description, it)) }
|
||||
File("/storage/emulated/0/Pictures").takeIf { !inspecting && it.isDirectory }?.let { add(locItem(stringResource(R.string.fm_rail_pictures), Icons.Filled.Image, it)) }
|
||||
}
|
||||
val favItems = remember(favTick) { FavoritesStore.list(context).map(::File).filter { it.exists() } }
|
||||
val favItems = remember(favTick) { if (inspecting) sample?.entries.orEmpty().filter { it.isDirectory } else FavoritesStore.list(context).map(::File).filter { it.exists() } }
|
||||
.map { d -> RailItem(d.name, Icons.Filled.Star, false) { showFavorites = false; openDrive(d) } }
|
||||
val locationSections = buildList {
|
||||
add(RailSection(stringResource(R.string.fm_rail_storage), storageItems))
|
||||
@@ -1043,8 +1054,9 @@ fun FileManagerScreen(
|
||||
FavoritesList(
|
||||
currentDir = currentDir,
|
||||
favTick = favTick,
|
||||
previewFavorites = sample?.entries.orEmpty().filter { it.isDirectory },
|
||||
onPinCurrent = {
|
||||
FavoritesStore.add(context, currentDir.absolutePath)
|
||||
if (!inspecting) FavoritesStore.add(context, currentDir.absolutePath)
|
||||
favTick++
|
||||
Toast.makeText(context, context.getString(R.string.fm_favorite_added, currentDir.name), Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
@@ -1053,7 +1065,7 @@ fun FileManagerScreen(
|
||||
openDrive(dir)
|
||||
},
|
||||
onUnpin = { dir ->
|
||||
FavoritesStore.remove(context, dir.absolutePath)
|
||||
if (!inspecting) FavoritesStore.remove(context, dir.absolutePath)
|
||||
favTick++
|
||||
Toast.makeText(context, context.getString(R.string.fm_favorite_removed, dir.name), Toast.LENGTH_SHORT).show()
|
||||
},
|
||||
@@ -1080,7 +1092,7 @@ fun FileManagerScreen(
|
||||
}
|
||||
items(shownEntries, key = { it.absolutePath }) { file ->
|
||||
val isFav = remember(file.absolutePath, favTick) {
|
||||
FavoritesStore.isFavorite(context, file.absolutePath)
|
||||
(!inspecting && FavoritesStore.isFavorite(context, file.absolutePath))
|
||||
}
|
||||
FileGridTile(
|
||||
file = file,
|
||||
@@ -1108,7 +1120,7 @@ fun FileManagerScreen(
|
||||
if (file.isDirectory) loadDirectory(file)
|
||||
else if (pickMode) {
|
||||
if (matchesPickExt(file)) {
|
||||
pickPrefs.edit().putString("lastFilePickerDir", currentDir.absolutePath).apply()
|
||||
pickPrefs?.edit()?.putString("lastFilePickerDir", currentDir.absolutePath)?.apply()
|
||||
onPick?.invoke(file)
|
||||
}
|
||||
}
|
||||
@@ -1127,7 +1139,7 @@ fun FileManagerScreen(
|
||||
onCut = { clipboardFiles = listOf(file); isCutOperation = true; showMenuFor = null },
|
||||
onDelete = { selectedEntry = file; showMenuFor = null },
|
||||
onToggleFavorite = {
|
||||
val nowFav = FavoritesStore.toggle(context, file.absolutePath)
|
||||
val nowFav = if (inspecting) false else FavoritesStore.toggle(context, file.absolutePath)
|
||||
favTick++
|
||||
showMenuFor = null
|
||||
Toast.makeText(
|
||||
@@ -1159,7 +1171,7 @@ fun FileManagerScreen(
|
||||
val shown = shownEntries
|
||||
items(shown, key = { it.absolutePath }) { file ->
|
||||
val isFav = remember(file.absolutePath, favTick) {
|
||||
FavoritesStore.isFavorite(context, file.absolutePath)
|
||||
(!inspecting && FavoritesStore.isFavorite(context, file.absolutePath))
|
||||
}
|
||||
FileItemRow(
|
||||
file = file,
|
||||
@@ -1189,7 +1201,7 @@ fun FileManagerScreen(
|
||||
if (file.isDirectory) loadDirectory(file)
|
||||
else if (pickMode) {
|
||||
if (matchesPickExt(file)) {
|
||||
pickPrefs.edit().putString("lastFilePickerDir", currentDir.absolutePath).apply()
|
||||
pickPrefs?.edit()?.putString("lastFilePickerDir", currentDir.absolutePath)?.apply()
|
||||
onPick?.invoke(file)
|
||||
}
|
||||
}
|
||||
@@ -1208,7 +1220,7 @@ fun FileManagerScreen(
|
||||
onRename = { renameTarget = file; showMenuFor = null },
|
||||
isFavorite = isFav,
|
||||
onToggleFavorite = {
|
||||
val nowFav = FavoritesStore.toggle(context, file.absolutePath)
|
||||
val nowFav = if (inspecting) false else FavoritesStore.toggle(context, file.absolutePath)
|
||||
favTick++
|
||||
showMenuFor = null
|
||||
Toast.makeText(
|
||||
|
||||
@@ -26,6 +26,7 @@ import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.platform.LocalInspectionMode
|
||||
import com.droiddeck.launcher.R
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
@@ -58,11 +59,13 @@ internal fun FilePropertiesDialog(
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
val scope = rememberCoroutineScope()
|
||||
val inspecting = LocalInspectionMode.current
|
||||
val dateFormat = remember { SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.getDefault()) }
|
||||
var attrs by remember(file.absolutePath) { mutableStateOf<FileAttrState?>(null) }
|
||||
var attrs by remember(file.absolutePath) { mutableStateOf<FileAttrState?>(if (inspecting) FileAttrState(false, false, false) else null) }
|
||||
// Guards against a second toggle landing while the first is still being applied off-thread.
|
||||
var busy by remember(file.absolutePath) { mutableStateOf(false) }
|
||||
LaunchedEffect(file.absolutePath) {
|
||||
if (inspecting) return@LaunchedEffect
|
||||
attrs = withContext(Dispatchers.IO) { readFileAttrs(file) }
|
||||
}
|
||||
|
||||
@@ -101,7 +104,11 @@ internal fun FilePropertiesDialog(
|
||||
description = stringResource(R.string.fm_read_only_hint),
|
||||
checked = state?.readOnly == true,
|
||||
enabled = state != null && !busy,
|
||||
onToggle = { want ->
|
||||
onToggle = toggle@{ want ->
|
||||
if (inspecting) {
|
||||
attrs = attrs?.copy(readOnly = want)
|
||||
return@toggle
|
||||
}
|
||||
busy = true
|
||||
scope.launch {
|
||||
val ok = withContext(Dispatchers.IO) { setReadOnly(file, want) }
|
||||
@@ -125,7 +132,11 @@ internal fun FilePropertiesDialog(
|
||||
else stringResource(R.string.fm_hidden_hint),
|
||||
checked = state?.hidden == true,
|
||||
enabled = state != null && hiddenSupported && !busy,
|
||||
onToggle = { want ->
|
||||
onToggle = toggle@{ want ->
|
||||
if (inspecting) {
|
||||
attrs = attrs?.copy(hidden = want)
|
||||
return@toggle
|
||||
}
|
||||
busy = true
|
||||
scope.launch {
|
||||
val ok = withContext(Dispatchers.IO) { setHidden(file, want) }
|
||||
|
||||
@@ -10,16 +10,23 @@ import androidx.activity.ComponentActivity
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.selection.toggleable
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.semantics.Role
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.platform.ComposeView
|
||||
import androidx.compose.ui.unit.dp
|
||||
@@ -48,19 +55,27 @@ class ControllerEditorActivity : ComponentActivity() {
|
||||
val bar = ComposeView(this).apply {
|
||||
setContent {
|
||||
DroidDeckTheme {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(6.dp),
|
||||
var snap by remember { mutableStateOf(ControllerPrefs.read(context).snap) }
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.spacedBy(5.dp),
|
||||
modifier = Modifier
|
||||
.background(MaterialTheme.colorScheme.surface.copy(alpha = 0.9f), RoundedCornerShape(50))
|
||||
.padding(start = 14.dp, end = 5.dp, top = 5.dp, bottom = 5.dp),
|
||||
.background(MaterialTheme.colorScheme.surface.copy(alpha = 0.9f), RoundedCornerShape(20.dp))
|
||||
.padding(start = 5.dp, end = 5.dp, top = 8.dp, bottom = 5.dp),
|
||||
) {
|
||||
Text(stringResource(R.string.ctrl_editor_drag), fontSize = 12.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.padding(end = 4.dp))
|
||||
EditorButton(stringResource(R.string.ctrl_reset), false) { controls.resetLayout() }
|
||||
EditorButton(stringResource(R.string.common_cancel), false) { finish() }
|
||||
EditorButton(stringResource(R.string.ctrl_editor_save), true) {
|
||||
controls.saveLayout()
|
||||
finish()
|
||||
Text(stringResource(R.string.ctrl_editor_drag), fontSize = 12.sp, color = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
EditorButton(stringResource(R.string.ctrl_editor_snap), false, selected = snap) {
|
||||
snap = !snap
|
||||
ControllerPrefs.setSnap(context, snap)
|
||||
controls.setSnap(snap)
|
||||
}
|
||||
EditorButton(stringResource(R.string.ctrl_reset), false) { controls.resetLayout() }
|
||||
EditorButton(stringResource(R.string.common_cancel), false) { finish() }
|
||||
EditorButton(stringResource(R.string.ctrl_editor_save), true) {
|
||||
controls.saveLayout()
|
||||
finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -71,14 +86,27 @@ class ControllerEditorActivity : ComponentActivity() {
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun EditorButton(label: String, primary: Boolean, onClick: () -> Unit) {
|
||||
private fun EditorButton(label: String, primary: Boolean, selected: Boolean? = null, onClick: () -> Unit) {
|
||||
val pal = LocalPalette.current
|
||||
Text(
|
||||
label, fontSize = 12.sp, fontWeight = FontWeight.SemiBold,
|
||||
color = if (primary) pal.onSignal else MaterialTheme.colorScheme.onBackground,
|
||||
color = when {
|
||||
primary -> pal.onSignal
|
||||
selected == true -> pal.signal
|
||||
else -> MaterialTheme.colorScheme.onBackground
|
||||
},
|
||||
modifier = Modifier.clip(RoundedCornerShape(50))
|
||||
.background(if (primary) pal.signal else Color.White.copy(alpha = 0.06f))
|
||||
.clickable(onClick = onClick)
|
||||
.background(
|
||||
when {
|
||||
primary -> pal.signal
|
||||
selected == true -> pal.signal.copy(alpha = 0.18f)
|
||||
else -> Color.White.copy(alpha = 0.06f)
|
||||
},
|
||||
)
|
||||
.then(
|
||||
if (selected == null) Modifier.clickable(onClick = onClick)
|
||||
else Modifier.toggleable(value = selected, role = Role.Switch, onValueChange = { onClick() }),
|
||||
)
|
||||
.padding(horizontal = 12.dp, vertical = 6.dp),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ object ControllerPrefs {
|
||||
val steamButton: Boolean,
|
||||
val qamButton: Boolean,
|
||||
val keyboardButton: Boolean,
|
||||
val snap: Boolean,
|
||||
val customLayout: Boolean,
|
||||
val mapping: Map<String, String>,
|
||||
)
|
||||
@@ -64,6 +65,7 @@ object ControllerPrefs {
|
||||
steamButton = p.getBoolean("steamButton", true),
|
||||
qamButton = p.getBoolean("qamButton", true),
|
||||
keyboardButton = p.getBoolean("keyboardButton", true),
|
||||
snap = p.getBoolean("snap", true),
|
||||
customLayout = p.all.keys.any { it.startsWith("layout.") },
|
||||
mapping = mappable.associate { (id, _) -> id to target(context, id) },
|
||||
)
|
||||
@@ -119,6 +121,10 @@ object ControllerPrefs {
|
||||
prefs(context).edit().putBoolean("keyboardButton", on).apply()
|
||||
}
|
||||
|
||||
fun setSnap(context: Context, on: Boolean) {
|
||||
prefs(context).edit().putBoolean("snap", on).apply()
|
||||
}
|
||||
|
||||
fun layout(context: Context, width: Int, height: Int): Map<String, Pair<Float, Float>> {
|
||||
val raw = prefs(context).getString("layout.${width}x$height", null) ?: return emptyMap()
|
||||
return raw.split(';').mapNotNull { entry ->
|
||||
|
||||
@@ -9,6 +9,7 @@ import android.graphics.Path
|
||||
import android.graphics.Rect
|
||||
import android.graphics.RectF
|
||||
import android.os.Build
|
||||
import android.view.HapticFeedbackConstants
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.view.WindowInsets
|
||||
@@ -95,8 +96,11 @@ class OnScreenControls(
|
||||
private var quickPressedBy = -1
|
||||
private var keyboardPressedBy = -1
|
||||
private var settings = ControllerPrefs.read(context)
|
||||
private var snap = settings.snap
|
||||
private var safe = Rect()
|
||||
private var selected: String? = null
|
||||
private var snapX: Float? = null
|
||||
private var snapY: Float? = null
|
||||
private var grabX = 0f
|
||||
private var grabY = 0f
|
||||
private var ignoreSaved = false
|
||||
@@ -138,10 +142,18 @@ class OnScreenControls(
|
||||
fun reload() {
|
||||
releaseAll()
|
||||
settings = ControllerPrefs.read(context)
|
||||
setSnap(settings.snap)
|
||||
applySettings()
|
||||
relayout()
|
||||
}
|
||||
|
||||
private fun clearSnapGuides() {
|
||||
if (snapX == null && snapY == null) return
|
||||
snapX = null
|
||||
snapY = null
|
||||
invalidate()
|
||||
}
|
||||
|
||||
private fun applySettings() {
|
||||
for (control in controls) control.target = settings.mapping[control.id] ?: control.id
|
||||
val tint = settings.tint
|
||||
@@ -179,6 +191,11 @@ class OnScreenControls(
|
||||
invalidate()
|
||||
}
|
||||
|
||||
fun setSnap(on: Boolean) {
|
||||
snap = on
|
||||
if (!on) clearSnapGuides()
|
||||
}
|
||||
|
||||
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
|
||||
super.onSizeChanged(w, h, oldw, oldh)
|
||||
relayout()
|
||||
@@ -412,15 +429,18 @@ class OnScreenControls(
|
||||
}
|
||||
}
|
||||
if (editing) {
|
||||
val group = selected ?: return
|
||||
val (x, y) = centre(group)
|
||||
stroke.color = heldStroke
|
||||
val single = members(group).singleOrNull()
|
||||
if (single?.wide == true) {
|
||||
val pad = dp(6f)
|
||||
box.set(x - single.halfW - pad, y - single.halfH - pad, x + single.halfW + pad, y + single.halfH + pad)
|
||||
canvas.drawRoundRect(box, single.halfH, single.halfH, stroke)
|
||||
} else canvas.drawCircle(x, y, extent(group) + dp(6f), stroke)
|
||||
snapX?.let { canvas.drawLine(it, safe.top.toFloat(), it, (height - safe.bottom).toFloat(), stroke) }
|
||||
snapY?.let { canvas.drawLine(safe.left.toFloat(), it, (width - safe.right).toFloat(), it, stroke) }
|
||||
selected?.let { group ->
|
||||
val (x, y) = centre(group)
|
||||
val single = members(group).singleOrNull()
|
||||
if (single?.wide == true) {
|
||||
val pad = dp(6f)
|
||||
box.set(x - single.halfW - pad, y - single.halfH - pad, x + single.halfW + pad, y + single.halfH + pad)
|
||||
canvas.drawRoundRect(box, single.halfH, single.halfH, stroke)
|
||||
} else canvas.drawCircle(x, y, extent(group) + dp(6f), stroke)
|
||||
}
|
||||
} else if (!buttonsOnly) {
|
||||
val (x, y) = quickCenter()
|
||||
val radius = dp(18f)
|
||||
@@ -587,6 +607,7 @@ class OnScreenControls(
|
||||
private fun onEditTouch(event: MotionEvent): Boolean {
|
||||
when (event.actionMasked) {
|
||||
MotionEvent.ACTION_DOWN -> {
|
||||
clearSnapGuides()
|
||||
val control = controlAt(event.x, event.y)
|
||||
selected = control?.group
|
||||
val group = selected ?: run { invalidate(); return false }
|
||||
@@ -598,14 +619,29 @@ class OnScreenControls(
|
||||
MotionEvent.ACTION_MOVE -> {
|
||||
val group = selected ?: return true
|
||||
ignoreSaved = false
|
||||
put(group, event.x + grabX, event.y + grabY)
|
||||
val rawX = event.x + grabX
|
||||
val rawY = event.y + grabY
|
||||
val others = groups.filter { it != group && members(it).any(::isVisible) }.map { centre(it) }
|
||||
val nextX = if (snap) closestSnap(rawX, others.map { it.first } + width / 2f) else null
|
||||
val nextY = if (snap) closestSnap(rawY, others.map { it.second }) else null
|
||||
put(group, nextX ?: rawX, nextY ?: rawY)
|
||||
clamp(group)
|
||||
val (x, y) = centre(group)
|
||||
val visibleX = nextX?.takeIf { abs(x - it) <= SNAP_TOLERANCE_PX }
|
||||
val visibleY = nextY?.takeIf { abs(y - it) <= SNAP_TOLERANCE_PX }
|
||||
if ((visibleX != null && visibleX != snapX) || (visibleY != null && visibleY != snapY)) performHapticFeedback(HapticFeedbackConstants.CLOCK_TICK)
|
||||
snapX = visibleX
|
||||
snapY = visibleY
|
||||
invalidate()
|
||||
}
|
||||
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> clearSnapGuides()
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
private fun closestSnap(position: Float, targets: List<Float>): Float? =
|
||||
targets.minByOrNull { abs(position - it) }?.takeIf { abs(position - it) <= dp(SNAP_DP) }
|
||||
|
||||
private fun controlAt(x: Float, y: Float): Control? =
|
||||
controls.firstOrNull {
|
||||
!quickHidden && isVisible(it) && (editing || !settings.adaptiveSticks || it.stick < 0) && it.contains(x, y, it.radius)
|
||||
@@ -715,6 +751,8 @@ class OnScreenControls(
|
||||
const val PHONE_MAX_HEIGHT_MM = 90f
|
||||
const val SHOULDER_WIDTH = 1.45f
|
||||
const val SHOULDER_HEIGHT = 0.8f
|
||||
const val SNAP_DP = 9f
|
||||
const val SNAP_TOLERANCE_PX = 1f
|
||||
val shoulderIds = setOf("lb", "rb", "lt", "rt")
|
||||
val directions = listOf("up", "right", "down", "left")
|
||||
}
|
||||
|
||||
@@ -101,9 +101,21 @@ object DesktopCatalog {
|
||||
fun desktopInstalled(context: Context): Boolean = desktopInstalled(LinuxRuntime.rootDir(context))
|
||||
|
||||
fun desktopInstalled(root: File): Boolean =
|
||||
!File(root, DesktopRemoval.PENDING).exists() &&
|
||||
File(root, "usr/bin/kwin_wayland").isFile &&
|
||||
FileUtils.readString(File(root, ".droiddeck-pkg-$DESKTOP_ID"))?.trim() == BuildConfig.DESKTOP_KDE_TAG
|
||||
|
||||
fun desktopPresent(context: Context): Boolean {
|
||||
val root = LinuxRuntime.rootDir(context)
|
||||
return File(root, DesktopRemoval.PENDING).exists() || marker(context, DESKTOP_ID).exists()
|
||||
}
|
||||
|
||||
fun cleanLegacy(context: Context, listener: LinuxRuntimeInstaller.ProgressListener? = null) =
|
||||
DesktopRemoval.cleanLegacy(context, listener)
|
||||
|
||||
fun removeDesktop(context: Context, listener: LinuxRuntimeInstaller.ProgressListener): String? =
|
||||
DesktopRemoval.remove(context, listener)
|
||||
|
||||
/** Downloads, verifies and installs one package. Returns null on success, else a message. */
|
||||
fun install(context: Context, entry: Entry, listener: LinuxRuntimeInstaller.ProgressListener?): String? {
|
||||
val root = LinuxRuntime.rootDir(context)
|
||||
@@ -143,7 +155,13 @@ object DesktopCatalog {
|
||||
if (!LinuxRuntimeInstaller.extract(context, download, root, listener)) return context.getString(R.string.deskpkg_extract_failed)
|
||||
}
|
||||
}
|
||||
if (entry.id == DESKTOP_ID) {
|
||||
cleanLegacy(context, listener)
|
||||
val pending = File(root, DesktopRemoval.PENDING)
|
||||
check(!pending.exists() || pending.delete()) { "Could not finish desktop installation" }
|
||||
}
|
||||
FileUtils.writeString(marker(context, entry.id), entry.version)
|
||||
check(installed(context, entry.id) == entry.version) { "Could not finish package installation" }
|
||||
return null
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "install ${entry.id}", e)
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.droiddeck.launcher.runtime
|
||||
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.LinkOption.NOFOLLOW_LINKS
|
||||
import java.nio.file.attribute.BasicFileAttributes
|
||||
import java.security.MessageDigest
|
||||
|
||||
/** Removes only unchanged, recorded package files. Never visits home or follows a symlink. */
|
||||
internal object DesktopFileRemoval {
|
||||
data class Entry(val kind: String, val size: Long, val identity: String, val path: String) {
|
||||
companion object {
|
||||
fun parse(line: String): Entry {
|
||||
val parts = line.split('\t', limit = 4)
|
||||
require(parts.size == 4 && parts[0] in setOf("F", "L")) { "Invalid removal inventory" }
|
||||
return Entry(parts[0], parts[1].toLong(), parts[2], parts[3])
|
||||
}
|
||||
}
|
||||
}
|
||||
data class Result(val removed: Int, val bytes: Long, val kept: Int)
|
||||
|
||||
fun remove(root: File, entries: Iterable<Entry>, protected: Set<String>, progress: (Int) -> Unit = {}): Result {
|
||||
var removed = 0
|
||||
var bytes = 0L
|
||||
var kept = 0
|
||||
val buffer = ByteArray(65536)
|
||||
val total = (entries as? Collection<*>)?.size ?: 0
|
||||
val directories = mutableSetOf<File>()
|
||||
for ((index, entry) in entries.withIndex()) {
|
||||
val file = safeFile(root, entry.path)
|
||||
if (file == null || entry.path in protected) { kept++; continue }
|
||||
val attrs = try { Files.readAttributes(file.toPath(), BasicFileAttributes::class.java, NOFOLLOW_LINKS) }
|
||||
catch (_: java.nio.file.NoSuchFileException) { continue }
|
||||
val matches = when (entry.kind) {
|
||||
"L" -> attrs.isSymbolicLink && Files.readSymbolicLink(file.toPath()).toString() == entry.identity
|
||||
else -> attrs.isRegularFile && attrs.size() == entry.size && sha(file, buffer) == entry.identity
|
||||
}
|
||||
if (!matches) { kept++; continue }
|
||||
Files.delete(file.toPath()) // A failure propagates; the pending marker makes retry possible.
|
||||
removed++
|
||||
bytes += if (attrs.isRegularFile) attrs.size() else 0
|
||||
var parent = file.parentFile
|
||||
while (parent != root && parent != null) { directories.add(parent); parent = parent.parentFile }
|
||||
if (index % 200 == 0) progress(if (total > 0) index * 99 / total else -1)
|
||||
}
|
||||
// Only now-empty parents of removed files, never a recursive delete of a package directory.
|
||||
for (dir in directories.sortedByDescending { it.path.length }) {
|
||||
if (dir.list()?.isEmpty() == true && !dir.delete()) throw IOException("Cannot remove $dir")
|
||||
}
|
||||
progress(99)
|
||||
return Result(removed, bytes, kept)
|
||||
}
|
||||
|
||||
internal fun safeFile(root: File, name: String): File? {
|
||||
if (Files.isSymbolicLink(root.toPath())) return null
|
||||
val parts = name.split('/')
|
||||
if (parts.firstOrNull() !in setOf("usr", "etc") || parts.any { it.isEmpty() || it == "." || it == ".." }) return null
|
||||
// Even an in-root symlink in a parent can redirect deletion into a user's data.
|
||||
var parent = root
|
||||
for (part in parts.dropLast(1)) {
|
||||
parent = File(parent, part)
|
||||
if (Files.isSymbolicLink(parent.toPath())) return null
|
||||
}
|
||||
return File(root, name)
|
||||
}
|
||||
|
||||
internal fun sha(file: File, buffer: ByteArray = ByteArray(65536)): String {
|
||||
val digest = MessageDigest.getInstance("SHA-256")
|
||||
file.inputStream().buffered().use { input ->
|
||||
while (true) { val n = input.read(buffer); if (n < 0) break; digest.update(buffer, 0, n) }
|
||||
}
|
||||
val digits = "0123456789abcdef"
|
||||
return buildString(64) {
|
||||
for (byte in digest.digest()) { val b = byte.toInt() and 255; append(digits[b ushr 4]); append(digits[b and 15]) }
|
||||
}
|
||||
}
|
||||
|
||||
/** The base runtime's pacman database is still present: desktop archives never replace it. */
|
||||
fun runtimeFiles(root: File): Set<String> = buildSet {
|
||||
val database = File(root, "var/lib/pacman/local")
|
||||
if (!database.isDirectory || Files.isSymbolicLink(database.toPath())) throw IOException("Runtime package database missing")
|
||||
for (pkg in database.listFiles().orEmpty()) {
|
||||
val files = File(pkg, "files")
|
||||
if (!pkg.isDirectory || Files.isSymbolicLink(pkg.toPath()) || !files.isFile || Files.isSymbolicLink(files.toPath())) continue
|
||||
var inFiles = false
|
||||
files.forEachLine { line ->
|
||||
when {
|
||||
line == "%FILES%" -> inFiles = true
|
||||
line.startsWith('%') -> inFiles = false
|
||||
inFiles && line.isNotEmpty() && !line.endsWith('/') -> add(line)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isEmpty()) throw IOException("Runtime package inventory missing")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.droiddeck.launcher.runtime
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.core.FileUtils
|
||||
import java.io.File
|
||||
import java.util.zip.GZIPInputStream
|
||||
|
||||
/** Inventories are generated from pinned archives by tools/desktop-kde/removal-manifests.py. */
|
||||
internal object DesktopRemoval {
|
||||
const val PENDING = ".droiddeck-desktop-removing"
|
||||
private const val CLEANING = ".droiddeck-lxqt-cleaning-v1"
|
||||
private const val CLEANED = ".droiddeck-lxqt-cleaned-v1"
|
||||
|
||||
private fun lines(context: Context, name: String) =
|
||||
GZIPInputStream(context.assets.open("desktop-removal/$name")).bufferedReader().use { it.readLines() }
|
||||
|
||||
private fun protected(context: Context, root: File) =
|
||||
DesktopFileRemoval.runtimeFiles(root) + lines(context, "emulators-keep.txt.gzip")
|
||||
|
||||
/** Called before a guest starts or just after KDE extraction; retries after a process death. */
|
||||
fun cleanLegacy(context: Context, listener: LinuxRuntimeInstaller.ProgressListener? = null) {
|
||||
val root = LinuxRuntime.rootDir(context)
|
||||
if (FileUtils.readString(File(root, CLEANED))?.trim() == "1") return
|
||||
if (!File(root, CLEANING).exists() && !File(root, ".droiddeck-pkg-desktop").exists() && !File(root, "usr/bin/lxqt-session").exists()) return
|
||||
listener?.onProgress(context.getString(R.string.desktop_cleaning_legacy), -1)
|
||||
val keep = protected(context, root) + lines(context, "kde-keep.txt.gzip")
|
||||
val pending = File(root, CLEANING)
|
||||
FileUtils.writeString(pending, "1")
|
||||
check(FileUtils.readString(pending)?.trim() == "1") { "Could not reserve LXQt cleanup" }
|
||||
val result = GZIPInputStream(context.assets.open("desktop-removal/lxqt-r1.tsv.gzip")).bufferedReader().use { reader ->
|
||||
DesktopFileRemoval.remove(root, reader.lineSequence().map(DesktopFileRemoval.Entry::parse).asIterable(), keep)
|
||||
}
|
||||
FileUtils.writeString(File(root, CLEANED), "1")
|
||||
check(FileUtils.readString(File(root, CLEANED))?.trim() == "1") { "Could not finish LXQt cleanup" }
|
||||
File(root, ".droiddeck-pkg-desktop").delete()
|
||||
pending.delete()
|
||||
Log.i("DesktopRemoval", "LXQt: $result")
|
||||
}
|
||||
|
||||
fun remove(context: Context, listener: LinuxRuntimeInstaller.ProgressListener): String? = try {
|
||||
val root = LinuxRuntime.rootDir(context)
|
||||
val pending = File(root, PENDING)
|
||||
val marker = File(root, ".droiddeck-pkg-${DesktopCatalog.DESKTOP_ID}")
|
||||
val version = FileUtils.readString(pending)?.trim() ?: FileUtils.readString(marker)?.trim()
|
||||
val versions = context.assets.open("desktop-removal/versions.txt").bufferedReader().use { it.readLines() }
|
||||
check(version in versions) { context.getString(R.string.desktop_removal_unknown) }
|
||||
// Validate all inventories and the runtime database before dropping the installed marker.
|
||||
val entries = lines(context, "kde-remove.tsv.gzip").map(DesktopFileRemoval.Entry::parse)
|
||||
val keep = protected(context, root)
|
||||
cleanLegacy(context, listener)
|
||||
FileUtils.writeString(pending, version!!)
|
||||
check(FileUtils.readString(pending)?.trim() == version) { "Could not reserve desktop removal" }
|
||||
if (marker.exists() && !marker.delete()) error("Could not clear desktop marker")
|
||||
val removing = context.getString(R.string.desktop_removing)
|
||||
val result = DesktopFileRemoval.remove(root, entries, keep) { listener.onProgress(removing, it) }
|
||||
// APK-staged desktop files are matched against the APK too; keep user-modified copies.
|
||||
for ((asset, path) in com.droiddeck.launcher.session.SessionFiles.DESKTOP_FILES) {
|
||||
val target = DesktopFileRemoval.safeFile(root, path) ?: continue
|
||||
if (!isRegularFile(target)) continue
|
||||
val content = context.assets.open("linuxfs/$asset").use { it.readBytes() }
|
||||
if (target.length() == content.size.toLong() && target.inputStream().use { it.readBytes() }.contentEquals(content)) {
|
||||
if (!target.delete()) error("Could not remove $path")
|
||||
}
|
||||
}
|
||||
if (!pending.delete()) error("Could not finish desktop removal")
|
||||
Log.i("DesktopRemoval", "KDE: $result")
|
||||
listener.onProgress(context.getString(R.string.desktop_removed), 100)
|
||||
null
|
||||
} catch (e: Exception) {
|
||||
Log.e("DesktopRemoval", "remove", e)
|
||||
e.message ?: context.getString(R.string.deskpkg_install_failed)
|
||||
}
|
||||
|
||||
private fun isRegularFile(file: File) = java.nio.file.Files.isRegularFile(file.toPath(), java.nio.file.LinkOption.NOFOLLOW_LINKS)
|
||||
}
|
||||
@@ -85,6 +85,7 @@ public final class LinuxRuntimeInstaller {
|
||||
volatile int percent = -1;
|
||||
volatile boolean ok;
|
||||
final boolean removal;
|
||||
boolean maintenance;
|
||||
Job(boolean removal, String stage) { this.removal = removal; this.stage = stage; }
|
||||
}
|
||||
|
||||
@@ -139,7 +140,7 @@ public final class LinuxRuntimeInstaller {
|
||||
Job job;
|
||||
boolean owner;
|
||||
synchronized (JOB_LOCK) {
|
||||
if (running != null && running.removal) return false;
|
||||
if (running != null && (running.removal || running.maintenance)) return false;
|
||||
owner = running == null;
|
||||
if (owner) { running = new Job(false, context.getString(R.string.user_apps_starting)); removalError = null; }
|
||||
job = running;
|
||||
@@ -171,7 +172,7 @@ public final class LinuxRuntimeInstaller {
|
||||
/** True while an install is running in this process, whoever started it. */
|
||||
public static boolean isInstalling() {
|
||||
synchronized (JOB_LOCK) {
|
||||
return running != null && !running.removal;
|
||||
return running != null && !running.removal && !running.maintenance;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,6 +184,53 @@ public final class LinuxRuntimeInstaller {
|
||||
synchronized (JOB_LOCK) { return running != null && running.removal; }
|
||||
}
|
||||
|
||||
public static boolean isMaintaining() {
|
||||
synchronized (JOB_LOCK) { return running != null && running.maintenance; }
|
||||
}
|
||||
|
||||
/** Reserve an in-place package operation with the same exclusion/progress as runtime installs. */
|
||||
public static Maintenance beginMaintenance(Context context, String stage) {
|
||||
if (com.droiddeck.launcher.session.SessionState.INSTANCE.getRunning()) return null;
|
||||
com.droiddeck.launcher.session.SessionPhase phase = com.droiddeck.launcher.session.SessionState.INSTANCE.getPhase();
|
||||
if (phase != com.droiddeck.launcher.session.SessionPhase.IDLE && phase != com.droiddeck.launcher.session.SessionPhase.FAILED) return null;
|
||||
synchronized (JOB_LOCK) {
|
||||
if (running != null) return null;
|
||||
removalError = null;
|
||||
running = new Job(false, stage);
|
||||
running.maintenance = true;
|
||||
return new Maintenance(running);
|
||||
}
|
||||
}
|
||||
|
||||
public interface MaintenanceWork { String run(ProgressListener listener); }
|
||||
|
||||
public static final class Maintenance {
|
||||
private final Job job;
|
||||
private final java.util.concurrent.atomic.AtomicBoolean started = new java.util.concurrent.atomic.AtomicBoolean();
|
||||
private Maintenance(Job job) { this.job = job; }
|
||||
public boolean run(ProgressListener listener, MaintenanceWork work) {
|
||||
if (!started.compareAndSet(false, true)) return join(job, listener);
|
||||
if (listener != null) job.listeners.add(listener);
|
||||
try {
|
||||
removalError = work.run((stage, percent) -> {
|
||||
job.stage = stage;
|
||||
job.percent = percent;
|
||||
for (ProgressListener l : job.listeners) l.onProgress(stage, percent);
|
||||
});
|
||||
job.ok = removalError == null;
|
||||
return job.ok;
|
||||
} catch (Exception e) {
|
||||
removalError = e.getMessage();
|
||||
Log.e(TAG, "maintenance", e);
|
||||
return false;
|
||||
} finally {
|
||||
synchronized (JOB_LOCK) { running = null; }
|
||||
job.done.countDown();
|
||||
if (listener != null) job.listeners.remove(listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String removalError() { return removalError; }
|
||||
|
||||
public static boolean hasRemovalPending(Context context) {
|
||||
|
||||
@@ -30,7 +30,7 @@ class RuntimeInstallService : Service() {
|
||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||
val removal = intent?.action == ACTION_REMOVE
|
||||
val release = intent?.let(::releaseFrom)
|
||||
startForeground(NOTIFICATION_ID, notification(getString(if (removal) R.string.rtinst_removing else R.string.user_apps_starting), -1))
|
||||
startForeground(NOTIFICATION_ID, notification(getString(if (LinuxRuntimeInstaller.isMaintaining()) R.string.desktop_removing else if (removal) R.string.rtinst_removing else R.string.user_apps_starting), -1))
|
||||
if (release == null && !removal) {
|
||||
stopSelf(startId)
|
||||
return START_NOT_STICKY
|
||||
@@ -68,7 +68,7 @@ class RuntimeInstallService : Service() {
|
||||
PendingIntent.FLAG_IMMUTABLE)
|
||||
return Notification.Builder(this, CHANNEL_ID)
|
||||
.setSmallIcon(R.drawable.ic_stat_session)
|
||||
.setContentTitle(getString(if (LinuxRuntimeInstaller.isRemoving()) R.string.rtinst_title_removing else R.string.rtinst_title_installing))
|
||||
.setContentTitle(getString(if (LinuxRuntimeInstaller.isMaintaining()) R.string.desktop_removing else if (LinuxRuntimeInstaller.isRemoving()) R.string.rtinst_title_removing else R.string.rtinst_title_installing))
|
||||
.setContentText(stage)
|
||||
.setProgress(100, percent.coerceIn(0, 100), percent < 0)
|
||||
.setContentIntent(open)
|
||||
|
||||
@@ -20,6 +20,19 @@ object SessionFiles {
|
||||
/** The driver sets staged under it: classic Wine 11 (Valve, GE) and the system-thread interface (Proton-CachyOS). */
|
||||
val DIRECTAUDIO_SETS = arrayOf("linux-wine11", "linux-wine11-systhread")
|
||||
|
||||
// Staged only with a complete desktop; removal matches these against the APK as well.
|
||||
internal val DESKTOP_FILES = arrayOf(
|
||||
"usr/local/bin/droiddeck-desktop" to "usr/local/bin/droiddeck-desktop",
|
||||
// Games and emulators from the menu, full screen in a gamescope of their own.
|
||||
"usr/local/bin/droiddeck-gpu" to "usr/local/bin/droiddeck-gpu",
|
||||
"usr/local/bin/droiddeck-desktop-gpu" to "usr/local/bin/droiddeck-desktop-gpu",
|
||||
"usr/local/bin/droiddeck-desktop-window-rules" to "usr/local/bin/droiddeck-desktop-window-rules",
|
||||
// KWin at the app's surface size, for Plasma's session (it starts KWin through this name).
|
||||
"usr/local/bin/kwin_wayland_wrapper" to "usr/local/bin/kwin_wayland_wrapper",
|
||||
"usr/lib/firefox/defaults/pref/droiddeck.js" to "usr/lib/firefox/defaults/pref/droiddeck.js",
|
||||
"etc/xdg/autostart/droiddeck-clipboard.desktop" to "etc/xdg/autostart/droiddeck-clipboard.desktop",
|
||||
)
|
||||
|
||||
/**
|
||||
* The libraries and scripts the session runs, refreshed from the apk at every launch.
|
||||
*
|
||||
@@ -30,6 +43,8 @@ object SessionFiles {
|
||||
* rename, so a session that still has one mapped keeps the file it opened.
|
||||
*/
|
||||
fun stage(context: Context, root: File) {
|
||||
if (DesktopCatalog.desktopInstalled(root)) try { DesktopCatalog.cleanLegacy(context) }
|
||||
catch (e: Exception) { Log.w(TAG, "LXQt cleanup will retry next session", e) }
|
||||
GameEnvironmentStore.publish(context)
|
||||
WinComponents.publish(context)
|
||||
val files = arrayOf(
|
||||
@@ -95,19 +110,6 @@ object SessionFiles {
|
||||
"usr/bin/steamos-polkit-helpers/jupiter-biosupdate" to "usr/bin/steamos-polkit-helpers/jupiter-biosupdate",
|
||||
"usr/bin/steamos-polkit-helpers/jupiter-dock-updater" to "usr/bin/steamos-polkit-helpers/jupiter-dock-updater",
|
||||
)
|
||||
// The desktop's launchers, only where the desktop package is installed:
|
||||
// staging them into a runtime without it would make the desktop look present when it is not.
|
||||
val desktop = arrayOf(
|
||||
"usr/local/bin/droiddeck-desktop" to "usr/local/bin/droiddeck-desktop",
|
||||
// Games and emulators from the menu, full screen in a gamescope of their own.
|
||||
"usr/local/bin/droiddeck-gpu" to "usr/local/bin/droiddeck-gpu",
|
||||
"usr/local/bin/droiddeck-desktop-gpu" to "usr/local/bin/droiddeck-desktop-gpu",
|
||||
"usr/local/bin/droiddeck-desktop-window-rules" to "usr/local/bin/droiddeck-desktop-window-rules",
|
||||
// KWin at the app's surface size, for Plasma's session (it starts KWin through this name).
|
||||
"usr/local/bin/kwin_wayland_wrapper" to "usr/local/bin/kwin_wayland_wrapper",
|
||||
"usr/lib/firefox/defaults/pref/droiddeck.js" to "usr/lib/firefox/defaults/pref/droiddeck.js",
|
||||
"etc/xdg/autostart/droiddeck-clipboard.desktop" to "etc/xdg/autostart/droiddeck-clipboard.desktop",
|
||||
)
|
||||
// The patched gamescope (tools/gamescope): the runtime's own version rebuilt with the ARM64
|
||||
// client fixes, over /usr/local/bin so it comes first in the session's PATH. Only when the
|
||||
// apk carries it - a build without the asset leaves the runtime's copy alone.
|
||||
@@ -137,7 +139,7 @@ object SessionFiles {
|
||||
val dir = asset.substringBeforeLast('/')
|
||||
runCatching { context.assets.list("linuxfs/$dir")?.contains(asset.substringAfterLast('/')) == true }.getOrDefault(false)
|
||||
}
|
||||
val all = (if (DesktopCatalog.desktopInstalled(root)) files + desktop else files) + optional
|
||||
val all = (if (DesktopCatalog.desktopInstalled(root)) files + DESKTOP_FILES else files) + optional
|
||||
for ((asset, relative) in all) {
|
||||
val target = File(root, relative)
|
||||
val staged = File(target.parentFile, target.name + ".staged")
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.droiddeck.launcher.audio.PulseAudioComponent
|
||||
import com.droiddeck.launcher.core.CpuCores
|
||||
import com.droiddeck.launcher.core.DeviceReport
|
||||
import com.droiddeck.launcher.core.HostEnvironment
|
||||
import com.droiddeck.launcher.core.DeviceSupport
|
||||
import com.droiddeck.launcher.core.SessionLogCapture
|
||||
import com.droiddeck.launcher.core.NetworkReport
|
||||
import com.droiddeck.launcher.core.SessionPart
|
||||
@@ -205,6 +206,10 @@ class SessionService : Service() {
|
||||
return START_NOT_STICKY
|
||||
}
|
||||
}
|
||||
if (com.droiddeck.launcher.runtime.LinuxRuntimeInstaller.isMaintaining()) {
|
||||
stopSelf(startId)
|
||||
return START_NOT_STICKY
|
||||
}
|
||||
startForeground(NOTIFICATION_ID, buildNotification())
|
||||
if (SessionState.running) return START_NOT_STICKY
|
||||
if (SessionState.stopRequested) {
|
||||
@@ -1571,8 +1576,10 @@ class SessionService : Service() {
|
||||
}
|
||||
try {
|
||||
val wifi = applicationContext.getSystemService(Context.WIFI_SERVICE) as? WifiManager
|
||||
val allowed = DeviceSupport.lowLatencyWifiSafe()
|
||||
if (!allowed) Log.i(TAG, "wifi lock skipped: its low-latency mode resets this device")
|
||||
@Suppress("DEPRECATION") // deprecated from API 29, still honoured; targetSdk is 28
|
||||
if (wifiLock?.isHeld != true) {
|
||||
if (allowed && wifiLock?.isHeld != true) {
|
||||
wifiLock = wifi?.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, "DroidDeck:session-wifi")
|
||||
?.apply {
|
||||
setReferenceCounted(false)
|
||||
|
||||
@@ -25,13 +25,15 @@ public final class AmazonApiClient {
|
||||
private static final String TAG = "AmazonApi";
|
||||
private static final String ENTITLEMENTS_URL = "https://gaming.amazon.com/api/distribution/entitlements";
|
||||
private static final String DISTRIBUTION_URL = "https://gaming.amazon.com/api/distribution/v2/public";
|
||||
private static final String GAMING_USER_AGENT = "com.amazon.agslauncher.win/3.0.9202.1";
|
||||
// As nile sends them: the session's User-Agent, and the launcher's own string under "UserAgent".
|
||||
private static final String GAMING_USER_AGENT = "AGSLauncher/1.0.0";
|
||||
private static final String LAUNCHER_USER_AGENT = "com.amazon.agslauncher.win/3.0.9202.1";
|
||||
private static final String DOWNLOAD_USER_AGENT = "nile/0.1 Amazon";
|
||||
private static final String KEY_ID = "d5dc8b8b-86c8-4fc4-ae93-18c0def5314d";
|
||||
|
||||
private AmazonApiClient() {}
|
||||
|
||||
/** The owned games, every page, one per productId. */
|
||||
/** The owned games, every page, one per productId; null when Amazon refused or could not be reached. */
|
||||
public static List<AmazonGame> getEntitlements(String accessToken, String deviceSerial) {
|
||||
Map<String, AmazonGame> seen = new HashMap<>();
|
||||
String nextToken = null;
|
||||
@@ -40,8 +42,9 @@ public final class AmazonApiClient {
|
||||
hardwareHash = AmazonPkce.sha256Upper(deviceSerial);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "hardware hash failed", e);
|
||||
return new ArrayList<>();
|
||||
return null;
|
||||
}
|
||||
boolean answered = false;
|
||||
do {
|
||||
try {
|
||||
JSONObject body = new JSONObject();
|
||||
@@ -56,19 +59,22 @@ public final class AmazonApiClient {
|
||||
String resp = postGaming(ENTITLEMENTS_URL, "com.amazon.animusdistributionservice.entitlement.AnimusEntitlementsService.GetEntitlements", accessToken, body.toString());
|
||||
if (resp == null) break;
|
||||
JSONObject json = new JSONObject(resp);
|
||||
answered = true;
|
||||
JSONArray entitlements = json.optJSONArray("entitlements");
|
||||
if (entitlements == null) break;
|
||||
for (int i = 0; i < entitlements.length(); i++) {
|
||||
if (entitlements != null) for (int i = 0; i < entitlements.length(); i++) {
|
||||
AmazonGame game = parseEntitlement(entitlements.getJSONObject(i));
|
||||
if (game != null && !game.productId.isEmpty()) seen.put(game.productId, game);
|
||||
}
|
||||
nextToken = json.optString("nextToken", null);
|
||||
// A JSON null reads as "null" through optString; the last page carries none.
|
||||
nextToken = json.isNull("nextToken") ? null : json.optString("nextToken", "");
|
||||
if (nextToken != null && nextToken.isEmpty()) nextToken = null;
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "entitlements page failed: " + e.getClass().getSimpleName());
|
||||
break;
|
||||
}
|
||||
} while (nextToken != null);
|
||||
if (!answered) return null;
|
||||
Log.i(TAG, "entitlements: " + seen.size());
|
||||
return new ArrayList<>(seen.values());
|
||||
}
|
||||
|
||||
@@ -140,7 +146,9 @@ public final class AmazonApiClient {
|
||||
JSONObject body = new JSONObject().put("adgProductIds", new JSONArray().put(productId)).put("Operation", "GetLiveVersionIds");
|
||||
String resp = postGaming(DISTRIBUTION_URL, "com.amazon.animusdistributionservice.external.AnimusDistributionService.GetLiveVersionIds", accessToken, body.toString());
|
||||
if (resp == null) return null;
|
||||
JSONObject versions = new JSONObject(resp).optJSONObject("versionIds");
|
||||
JSONObject json = new JSONObject(resp);
|
||||
JSONObject versions = json.optJSONObject("adgProductIdToVersionIdMap");
|
||||
if (versions == null) versions = json.optJSONObject("versionIds");
|
||||
return versions == null ? null : versions.optString(productId, null);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "GetLiveVersionIds failed: " + e.getClass().getSimpleName());
|
||||
@@ -165,13 +173,17 @@ public final class AmazonApiClient {
|
||||
conn.setRequestProperty("X-Amz-Target", target);
|
||||
conn.setRequestProperty("x-amzn-token", accessToken);
|
||||
conn.setRequestProperty("User-Agent", GAMING_USER_AGENT);
|
||||
conn.setRequestProperty("UserAgent", LAUNCHER_USER_AGENT);
|
||||
conn.setRequestProperty("Content-Type", "application/json");
|
||||
conn.setRequestProperty("Content-Encoding", "amz-1.0");
|
||||
try (OutputStream os = conn.getOutputStream()) { os.write(body.getBytes(StandardCharsets.UTF_8)); }
|
||||
int code = conn.getResponseCode();
|
||||
String resp = AmazonAuthClient.readStream(code < 400 ? conn.getInputStream() : conn.getErrorStream());
|
||||
conn.disconnect();
|
||||
if (code < 200 || code >= 300) { Log.e(TAG, "HTTP " + code + " from " + StoreLog.redactUrl(urlStr)); return null; }
|
||||
if (code < 200 || code >= 300) {
|
||||
Log.e(TAG, "HTTP " + code + " from " + StoreLog.redactUrl(urlStr) + ": " + (resp.length() > 200 ? resp.substring(0, 200) : resp));
|
||||
return null;
|
||||
}
|
||||
return resp;
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "POST failed: " + StoreLog.redactUrl(urlStr) + " (" + e.getClass().getSimpleName() + ")");
|
||||
|
||||
@@ -39,6 +39,8 @@ public final class AmazonAuthClient {
|
||||
public String refreshToken;
|
||||
public long expiresIn;
|
||||
public String name;
|
||||
/** The serial Amazon registered the device under; the entitlements call hashes this one. */
|
||||
public String deviceSerial;
|
||||
}
|
||||
|
||||
private AmazonAuthClient() {}
|
||||
@@ -78,8 +80,12 @@ public final class AmazonAuthClient {
|
||||
result.accessToken = bearer.getString("access_token");
|
||||
result.refreshToken = bearer.getString("refresh_token");
|
||||
result.expiresIn = bearer.optLong("expires_in", 3600L);
|
||||
JSONObject customer = success.optJSONObject("extensions") != null ? success.getJSONObject("extensions").optJSONObject("customer_info") : null;
|
||||
JSONObject ext = success.optJSONObject("extensions");
|
||||
JSONObject customer = ext != null ? ext.optJSONObject("customer_info") : null;
|
||||
result.name = customer != null ? customer.optString("name", "") : "";
|
||||
JSONObject device = ext != null ? ext.optJSONObject("device_info") : null;
|
||||
String registered = device != null ? device.optString("device_serial_number", "") : "";
|
||||
result.deviceSerial = registered.isEmpty() ? deviceSerial : registered;
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "registerDevice failed: " + e.getClass().getSimpleName());
|
||||
|
||||
@@ -75,10 +75,9 @@ object AmazonBackend : StoreBackend {
|
||||
StoresState.shelves[store] = StoreShelves(trending = items.filter { it.id !in installed }, free = emptyList(), deals = emptyList(), whatsNew = emptyList())
|
||||
}
|
||||
|
||||
override fun loadShelves(context: Context, force: Boolean) {
|
||||
// Nothing public to fetch; the shelves follow the library sync.
|
||||
if (!StoresState.library.containsKey(store)) syncLibrary(context, force)
|
||||
}
|
||||
// Nothing public to fetch; the shelves follow the library sync, which StoresState.open starts
|
||||
// alongside this. A second sync here only came back Busy and cleared the first one's status.
|
||||
override fun loadShelves(context: Context, force: Boolean) {}
|
||||
|
||||
override fun install(context: Context, item: CatalogItem, root: File) {
|
||||
val app = context.applicationContext
|
||||
@@ -119,7 +118,7 @@ object AmazonBackend : StoreBackend {
|
||||
val exe = spec.exeRelative.ifEmpty { StoreExe.pick(folder, null, game.title) }
|
||||
if (exe.isEmpty()) handle.log("amazon: no exe found in ${folder.name}; pick one in Steam settings › Added games")
|
||||
val env = LinkedHashMap<String, String>()
|
||||
for (kv in AmazonLaunchHelper.buildFuelEnv(game.entitlementId, game.productSku)) env[kv.substringBefore('=')] = kv.substringAfter('=')
|
||||
for (kv in AmazonLaunchHelper.buildFuelEnv(game.entitlementId, game.productSku, com.droiddeck.launcher.stores.StoreAccounts.signedInAs(app, Store.AMAZON)?.takeIf { it != Store.AMAZON.label })) env[kv.substringBefore('=')] = kv.substringAfter('=')
|
||||
val sidecar = StoreGameSidecar(
|
||||
Store.AMAZON, game.productId, game.title, exe = exe.ifEmpty { "game.exe" }, args = spec.args, env = env,
|
||||
installVersion = result.versionId ?: "", installedAt = System.currentTimeMillis(),
|
||||
@@ -159,7 +158,7 @@ object AmazonBackend : StoreBackend {
|
||||
val code = Uri.parse(url).getQueryParameter("openid.oa2.authorization_code")
|
||||
if (code.isNullOrEmpty()) { Log.w(TAG, "login: return URL without a code"); return activity.getString(com.droiddeck.launcher.R.string.stores_login_error_verification) }
|
||||
val result = AmazonAuthClient.registerDevice(code, verifier, serial, clientId) ?: return activity.getString(com.droiddeck.launcher.R.string.stores_login_error_generic)
|
||||
AmazonCredentialStore.save(activity, result.accessToken, result.refreshToken, serial, clientId, System.currentTimeMillis() + result.expiresIn * 1000L, result.name)
|
||||
AmazonCredentialStore.save(activity, result.accessToken, result.refreshToken, result.deviceSerial ?: serial, clientId, System.currentTimeMillis() + result.expiresIn * 1000L, result.name)
|
||||
Log.i(TAG, "signed in")
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -34,6 +34,16 @@ object AmazonCredentialStore {
|
||||
@JvmStatic
|
||||
fun isLoggedIn(context: Context): Boolean = load(context) != null
|
||||
|
||||
/** A fresh access token whatever the stored expiry says: for a call Amazon refused with the stored one. */
|
||||
@JvmStatic
|
||||
fun refresh(context: Context): String? {
|
||||
val creds = load(context) ?: return null
|
||||
val result = AmazonAuthClient.refreshAccessToken(creds.refreshToken ?: return null) ?: return null
|
||||
save(context, result.accessToken, creds.refreshToken, creds.deviceSerial, creds.clientId, System.currentTimeMillis() + result.expiresIn * 1000L, null)
|
||||
Log.i(TAG, "token refreshed (forced)")
|
||||
return result.accessToken
|
||||
}
|
||||
|
||||
/** A valid access token, refreshed within five minutes of expiry; null when signed out or the refresh failed. */
|
||||
@JvmStatic
|
||||
fun getValidAccessToken(context: Context): String? {
|
||||
|
||||
@@ -66,13 +66,13 @@ public final class AmazonLaunchHelper {
|
||||
}
|
||||
|
||||
/** The FuelPump variables, as KEY=VALUE, for the game's environment. */
|
||||
public static String[] buildFuelEnv(String entitlementId, String productSku) {
|
||||
public static String[] buildFuelEnv(String entitlementId, String productSku, String displayName) {
|
||||
return new String[]{
|
||||
"FUEL_DIR=C:\\ProgramData\\Amazon Games Services\\Legacy",
|
||||
"AMAZON_GAMES_SDK_PATH=C:\\ProgramData\\Amazon Games Services\\AmazonGamesSDK",
|
||||
"AMAZON_GAMES_FUEL_ENTITLEMENT_ID=" + entitlementId,
|
||||
"AMAZON_GAMES_FUEL_PRODUCT_SKU=" + productSku,
|
||||
"AMAZON_GAMES_FUEL_DISPLAY_NAME=Player",
|
||||
"AMAZON_GAMES_FUEL_DISPLAY_NAME=" + (displayName == null || displayName.isEmpty() ? "Player" : displayName),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -73,8 +73,11 @@ object AmazonLibrary {
|
||||
val creds = AmazonCredentialStore.load(app) ?: return SyncResult.NotLoggedIn
|
||||
val token = AmazonCredentialStore.getValidAccessToken(app) ?: return SyncResult.Failed(StoresState.notSignedInLine(Store.AMAZON))
|
||||
onStatus("Fetching game list…")
|
||||
// Refused with the stored token (revoked, or an expiry read wrong): once more on a fresh one.
|
||||
val all = AmazonApiClient.getEntitlements(token, creds.deviceSerial)
|
||||
if (all.isNullOrEmpty()) return if (cachedList.isEmpty()) SyncResult.Failed("No games found in your Amazon library") else SyncResult.Ok(cachedList)
|
||||
?: AmazonCredentialStore.refresh(app)?.let { AmazonApiClient.getEntitlements(it, creds.deviceSerial) }
|
||||
if (all == null) return if (cachedList.isEmpty()) SyncResult.Failed("Amazon Games did not answer for your library: refresh, or sign in again") else SyncResult.Ok(cachedList)
|
||||
if (all.isEmpty()) return if (cachedList.isEmpty()) SyncResult.Failed("No games found in your Amazon library") else SyncResult.Ok(cachedList)
|
||||
val games = all.filter { !(it.isDLC && it.parentProductId.isNotEmpty()) }.ifEmpty { all }
|
||||
.sortedWith { a, b -> a.title.compareTo(b.title, ignoreCase = true) }
|
||||
for (fresh in games) cachedList.firstOrNull { it.productId == fresh.productId }?.let { fresh.versionId = it.versionId }
|
||||
|
||||
@@ -17,6 +17,7 @@ import android.os.PowerManager
|
||||
import android.util.Log
|
||||
import com.droiddeck.launcher.MainActivity
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.core.DeviceSupport
|
||||
import com.droiddeck.launcher.stores.StoresState
|
||||
import com.droiddeck.launcher.stores.formatBytes
|
||||
import com.droiddeck.launcher.stores.formatSpeed
|
||||
@@ -134,7 +135,7 @@ class StoreDownloadService : Service() {
|
||||
private fun locks() {
|
||||
val running = StoresState.latestDownloads.any { it.state == DownloadState.RUNNING }
|
||||
if (!running) { releaseLocks(); return }
|
||||
if (wifi == null) {
|
||||
if (wifi == null && DeviceSupport.lowLatencyWifiSafe()) {
|
||||
runCatching {
|
||||
val wm = applicationContext.getSystemService(WIFI_SERVICE) as WifiManager
|
||||
@Suppress("DEPRECATION")
|
||||
|
||||
@@ -90,6 +90,7 @@ import androidx.compose.ui.window.Dialog
|
||||
import androidx.compose.ui.window.DialogProperties
|
||||
import coil.compose.AsyncImage
|
||||
import coil.request.ImageRequest
|
||||
import androidx.compose.ui.platform.LocalInspectionMode
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.core.FileUtils
|
||||
import com.droiddeck.launcher.files.InAppFilePicker
|
||||
@@ -302,7 +303,8 @@ internal fun EditAppDialog(app: UserApps.App, onDismiss: () -> Unit, onSave: (St
|
||||
/** Open from the first frame; [onDismiss] once the closing animation has run. */
|
||||
@Composable
|
||||
internal fun rememberShown(onDismiss: () -> Unit): MutableTransitionState<Boolean> {
|
||||
val shown = remember { MutableTransitionState(false).apply { targetState = true } }
|
||||
val inspecting = LocalInspectionMode.current
|
||||
val shown = remember { MutableTransitionState(inspecting).apply { targetState = true } }
|
||||
LaunchedEffect(shown.currentState, shown.isIdle) { if (shown.isIdle && !shown.currentState && !shown.targetState) onDismiss() }
|
||||
return shown
|
||||
}
|
||||
@@ -507,7 +509,9 @@ private fun IconActions(onChoose: () -> Unit, clear: Pair<Int, () -> Unit>?) {
|
||||
/** Icons found in [repo], looked up off the main thread once the name has settled; [selected] is ringed. */
|
||||
@Composable
|
||||
private fun IconSuggestions(repo: String, selected: String?, onPick: (String) -> Unit) {
|
||||
val inspecting = LocalInspectionMode.current
|
||||
val found by produceState<List<String>?>(null, repo) {
|
||||
if (inspecting) { value = emptyList(); return@produceState }
|
||||
value = null
|
||||
delay(500)
|
||||
value = withContext(Dispatchers.IO) { runCatching { UserApps.githubIcons(repo) }.getOrDefault(emptyList()) }
|
||||
@@ -570,8 +574,10 @@ private fun FileRow(path: String?, onChoose: () -> Unit) {
|
||||
/** Whether the script's folder will be linked or copied in, worked out off the main thread. */
|
||||
@Composable
|
||||
private fun FolderNote(scriptPath: String) {
|
||||
val inspecting = LocalInspectionMode.current
|
||||
var plan by remember(scriptPath) { mutableStateOf<UserApps.ScriptPlan?>(null) }
|
||||
LaunchedEffect(scriptPath) {
|
||||
if (inspecting) return@LaunchedEffect
|
||||
plan = withContext(Dispatchers.IO) { runCatching { UserApps.planScript(File(scriptPath)) }.getOrNull() }
|
||||
}
|
||||
val p = plan
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import androidx.compose.ui.platform.LocalInspectionMode
|
||||
import android.graphics.Bitmap
|
||||
import androidx.compose.animation.animateColorAsState
|
||||
import androidx.compose.animation.core.Animatable
|
||||
@@ -69,7 +70,8 @@ internal class Tile(
|
||||
@Composable
|
||||
internal fun Poster(art: File?, name: String, modifier: Modifier) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val t = remember { Animatable(0f) }
|
||||
val inspecting = LocalInspectionMode.current
|
||||
val t = remember { Animatable(if (inspecting) 1f else 0f) }
|
||||
LaunchedEffect(Unit) { t.animateTo(1f, Motion.sp(0.6f, Spring.StiffnessLow)) }
|
||||
Box(
|
||||
modifier = modifier.padding(start = 16.dp).aspectRatio(2f / 3f)
|
||||
|
||||
@@ -91,6 +91,7 @@ import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import coil.compose.AsyncImage
|
||||
import com.droiddeck.launcher.HomeApp
|
||||
import androidx.compose.ui.platform.LocalInspectionMode
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.frontend.Library
|
||||
import com.droiddeck.launcher.runtime.UserApps
|
||||
@@ -264,7 +265,8 @@ private fun Content(
|
||||
val installed = s.emulators.filter { it.installed }
|
||||
val available = s.emulators.filter { !it.installed }
|
||||
val ctx = LocalContext.current
|
||||
LaunchedEffect(Unit) { UserAppsState.refresh(ctx) }
|
||||
val inspecting = LocalInspectionMode.current
|
||||
LaunchedEffect(Unit) { if (!inspecting) UserAppsState.refresh(ctx) }
|
||||
val apps = UserAppsState.items
|
||||
var adding by rememberSaveable { mutableStateOf(false) }
|
||||
Rise(0) {
|
||||
@@ -424,11 +426,18 @@ private fun Content(
|
||||
private fun DesktopCard(s: FrontEndState, a: FrontEndActions) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
var confirmRemove by rememberSaveable { mutableStateOf(false) }
|
||||
if (confirmRemove) ConfirmDialog(
|
||||
stringResource(R.string.desktop_remove_title), stringResource(R.string.desktop_remove_text),
|
||||
stringResource(R.string.common_uninstall), a.onRemoveDesktop, { confirmRemove = false },
|
||||
)
|
||||
val actions: @Composable () -> Unit = {
|
||||
Actions {
|
||||
// Enabled without a runtime or the desktop: the session's loading screen installs them first.
|
||||
PrimaryButton(if (s.desktopInstalled) stringResource(R.string.content_open_desktop) else stringResource(R.string.content_install_open_desktop), enabled = !s.busy, main = true, onClick = a.onDesktop)
|
||||
Cog(onClick = a.onDesktopSettings)
|
||||
if (s.desktopPresent) SecondaryButton(stringResource(R.string.common_uninstall),
|
||||
enabled = !s.runtimeActionsBlocked) { confirmRemove = true }
|
||||
BusyChip(s)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.droiddeck.launcher.ui
|
||||
|
||||
import java.io.File
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.platform.LocalInspectionMode
|
||||
import com.droiddeck.launcher.R
|
||||
|
||||
import androidx.compose.runtime.staticCompositionLocalOf
|
||||
@@ -86,6 +87,7 @@ class FrontEndState(
|
||||
val stage: String,
|
||||
val percent: Int,
|
||||
val desktopInstalled: Boolean,
|
||||
val desktopPresent: Boolean = desktopInstalled,
|
||||
val offlineAccount: String?,
|
||||
val offline: Boolean,
|
||||
val frameGenLabel: String,
|
||||
@@ -175,6 +177,7 @@ class FrontEndActions(
|
||||
val onResume: () -> Unit,
|
||||
val onSteamSettings: () -> Unit,
|
||||
val onDesktopSettings: () -> Unit,
|
||||
val onRemoveDesktop: () -> Unit = {},
|
||||
val onInstallPackage: (String) -> Unit,
|
||||
val onRemovePackage: (String) -> Unit,
|
||||
val onRuntime: () -> Unit,
|
||||
@@ -257,7 +260,8 @@ internal fun artBrush(h: Float) = Brush.linearGradient(listOf(tint(h), tint((h +
|
||||
|
||||
@Composable
|
||||
internal fun Rise(i: Int, modifier: Modifier = Modifier, content: @Composable () -> Unit) {
|
||||
val state = remember { MutableTransitionState(false) }.apply { targetState = true }
|
||||
val inspecting = LocalInspectionMode.current
|
||||
val state = remember { MutableTransitionState(inspecting) }.apply { targetState = true }
|
||||
AnimatedVisibility(
|
||||
visibleState = state, modifier = modifier,
|
||||
enter = fadeIn(Motion.tw(450, i * 60)) + slideInVertically(Motion.tw(450, i * 60)) { it / 3 },
|
||||
@@ -268,6 +272,7 @@ internal fun Rise(i: Int, modifier: Modifier = Modifier, content: @Composable ()
|
||||
|
||||
@Composable
|
||||
private fun Modifier.staggerIn(i: Int): Modifier {
|
||||
if (LocalInspectionMode.current) return this
|
||||
val t = remember { Animatable(0f) }
|
||||
LaunchedEffect(Unit) { t.animateTo(1f, Motion.tw(360, i * 30)) }
|
||||
return graphicsLayer { alpha = t.value; translationY = (1f - t.value) * 10.dp.toPx() }
|
||||
@@ -376,15 +381,16 @@ internal suspend fun focusWithinFrames(done: () -> Boolean, target: () -> FocusR
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun FrontEndScreen(s: FrontEndState, a: FrontEndActions, page: (@Composable () -> Unit)? = null) {
|
||||
fun FrontEndScreen(s: FrontEndState, a: FrontEndActions, page: (@Composable () -> Unit)? = null, initialSelection: String = if (s.shortcutPicker) "games" else "steam") {
|
||||
val frontFocus = remember { FrontFocus() }
|
||||
CompositionLocalProvider(LocalFrontFocus provides frontFocus) { FrontEndScreenBody(s, a, page, frontFocus) }
|
||||
CompositionLocalProvider(LocalFrontFocus provides frontFocus) { FrontEndScreenBody(s, a, page, frontFocus, initialSelection) }
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalComposeUiApi::class)
|
||||
@Composable
|
||||
private fun FrontEndScreenBody(s: FrontEndState, a: FrontEndActions, page: (@Composable () -> Unit)?, frontFocus: FrontFocus) {
|
||||
var selected by rememberSaveable { mutableStateOf(if (s.shortcutPicker) "games" else "steam") }
|
||||
private fun FrontEndScreenBody(s: FrontEndState, a: FrontEndActions, page: (@Composable () -> Unit)?, frontFocus: FrontFocus, initialSelection: String) {
|
||||
val inspecting = LocalInspectionMode.current
|
||||
var selected by rememberSaveable { mutableStateOf(initialSelection) }
|
||||
LaunchedEffect(s.shortcutPicker) { if (s.shortcutPicker) selected = "games" }
|
||||
LaunchedEffect(s.navigate) {
|
||||
val target = s.navigate ?: return@LaunchedEffect
|
||||
@@ -433,7 +439,7 @@ private fun FrontEndScreenBody(s: FrontEndState, a: FrontEndActions, page: (@Com
|
||||
LaunchedEffect(s.steamGames.isEmpty()) {
|
||||
if (s.steamGames.isEmpty() && selected.startsWith("app:")) selected = "games"
|
||||
}
|
||||
remember { Motion.refresh(ctx); true }
|
||||
remember { if (!inspecting) Motion.refresh(ctx); true }
|
||||
|
||||
val railSelection = when {
|
||||
s.pageKey == "performance" || s.pageKey == "protons" || s.pageKey == "controller-mapping" -> "setup"
|
||||
|
||||
@@ -76,6 +76,7 @@ import com.droiddeck.launcher.core.DeviceSupport
|
||||
import com.droiddeck.launcher.core.PhantomProcessLimit
|
||||
import com.droiddeck.launcher.core.PhantomProcessStatus
|
||||
import com.droiddeck.launcher.session.SessionPrefs
|
||||
import androidx.compose.ui.platform.LocalInspectionMode
|
||||
import com.droiddeck.launcher.stores.download.StoreDownloadTier
|
||||
import com.droiddeck.launcher.R
|
||||
|
||||
@@ -130,6 +131,7 @@ internal fun SetupPanel(
|
||||
a: FrontEndActions,
|
||||
onOpenDeveloperOptions: () -> Unit,
|
||||
onRequestWirelessAdb: (Boolean) -> Unit,
|
||||
initialTab: Int = 0,
|
||||
) {
|
||||
val host = rememberMenuHost()
|
||||
val ctx = LocalContext.current
|
||||
@@ -158,9 +160,10 @@ internal fun SetupPanel(
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
// Tested hardware passes; an Adreno below it (a 610, say) warns rather than claiming support.
|
||||
val gpu = remember { com.droiddeck.launcher.gpu.GpuInfo.detect() }
|
||||
val inspecting = LocalInspectionMode.current
|
||||
val gpu = remember { if (inspecting) com.droiddeck.launcher.gpu.GpuInfo("Adreno 740", 740, com.droiddeck.launcher.gpu.GpuInfo.Family.A7XX, "Snapdragon 8 Gen 2", false) else com.droiddeck.launcher.gpu.GpuInfo.detect() }
|
||||
val gpuOk = gpu.support == com.droiddeck.launcher.gpu.GpuInfo.Support.TESTED
|
||||
val gpuName = remember { DeviceSupport.gpuName(ctx) }
|
||||
val gpuName = remember { if (inspecting) gpu.name else DeviceSupport.gpuName(ctx) }
|
||||
val limitBlocks = PhantomProcessLimit.blocksSteam(s.phantomProcessStatus)
|
||||
val signedIn = s.offlineAccount != null
|
||||
var showLimitDetails by rememberSaveable { mutableStateOf(false) }
|
||||
@@ -169,7 +172,7 @@ internal fun SetupPanel(
|
||||
// Four tabs instead of one long scroll; LB and RB turn them from anywhere on the page. Build
|
||||
// and credits are on the Updates page.
|
||||
val tabs = listOf(stringResource(R.string.setup_tab_overview), stringResource(R.string.setup_tab_controller), stringResource(R.string.setup_tab_session), stringResource(R.string.setup_tab_launcher))
|
||||
var tab by rememberSaveable { mutableStateOf(0) }
|
||||
var tab by rememberSaveable { mutableStateOf(initialTab.coerceIn(0, tabs.lastIndex)) }
|
||||
val tabFocus = remember { List(tabs.size) { FocusRequester() } }
|
||||
var tabTurned by remember { mutableStateOf(false) }
|
||||
val pick: (Int) -> Unit = { i -> tab = i; tabTurned = true }
|
||||
|
||||
@@ -38,6 +38,7 @@ import androidx.compose.ui.text.input.KeyboardType
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.compose.ui.platform.LocalInspectionMode
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.core.GameEnvironment
|
||||
import com.droiddeck.launcher.core.GameEnvironmentOptions
|
||||
@@ -81,12 +82,13 @@ internal fun PadFocus(byPad: Boolean, target: FocusRequester) {
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun GameEnvironmentEditor(byPad: Boolean, onClose: () -> Unit) {
|
||||
internal fun GameEnvironmentEditor(byPad: Boolean, initialConfig: GameEnvironment.Config = GameEnvironment.Config(), onClose: () -> Unit) {
|
||||
val context = LocalContext.current
|
||||
val coroutine = rememberCoroutineScope()
|
||||
val inspecting = LocalInspectionMode.current
|
||||
val shown = rememberShown(onClose)
|
||||
val close = { shown.targetState = false }
|
||||
var config by remember { mutableStateOf<GameEnvironment.Config?>(null) }
|
||||
var config by remember { mutableStateOf<GameEnvironment.Config?>(if (inspecting) initialConfig else null) }
|
||||
var games by remember { mutableStateOf(emptyList<Pair<String, String>>()) }
|
||||
var scope by remember { mutableStateOf("") }
|
||||
var otherId by remember { mutableStateOf<String?>(null) }
|
||||
@@ -94,12 +96,13 @@ private fun GameEnvironmentEditor(byPad: Boolean, onClose: () -> Unit) {
|
||||
var busy by remember { mutableStateOf(false) }
|
||||
var error by remember { mutableStateOf(false) }
|
||||
var editing by remember { mutableStateOf<Pair<String, String>?>(null) }
|
||||
val preset = SessionPrefs.fexPreset(context)
|
||||
val forceSsbs = SessionPrefs.forceSsbs(context)
|
||||
val preset = if (inspecting) com.droiddeck.launcher.core.FexPreset.all.first().id else SessionPrefs.fexPreset(context)
|
||||
val forceSsbs = !inspecting && SessionPrefs.forceSsbs(context)
|
||||
val firstFocus = remember { FocusRequester() }
|
||||
var editByPad by remember { mutableStateOf(false) }
|
||||
val dialogInput = LocalInputModeManager.current
|
||||
LaunchedEffect(Unit) {
|
||||
if (inspecting) return@LaunchedEffect
|
||||
runCatching {
|
||||
withContext(Dispatchers.IO) {
|
||||
GameEnvironmentStore.read(context) to Library.steamGames(context).map { it.appId.toString() to it.name }
|
||||
@@ -108,6 +111,7 @@ private fun GameEnvironmentEditor(byPad: Boolean, onClose: () -> Unit) {
|
||||
.onFailure { error = true }
|
||||
}
|
||||
fun save(next: GameEnvironment.Config) {
|
||||
if (inspecting) { config = next; return }
|
||||
busy = true
|
||||
coroutine.launch {
|
||||
val result = runCatching { withContext(Dispatchers.IO) { GameEnvironmentStore.save(context, next) } }
|
||||
|
||||
@@ -165,12 +165,12 @@ private enum class ModeSettingsTab(val label: Int) {
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun ModeSettingsPage(s: ModeSettings, a: ModeSettingsActions) {
|
||||
fun ModeSettingsPage(s: ModeSettings, a: ModeSettingsActions, initialTab: Int = 0) {
|
||||
val steam = s.mode == SessionService.MODE_STEAM
|
||||
val host = rememberMenuHost()
|
||||
var confirmDeckyRemoval by remember { mutableStateOf(false) }
|
||||
var explainWifiDiscovery by remember { mutableStateOf(false) }
|
||||
var tabIndex by androidx.compose.runtime.saveable.rememberSaveable(s.mode) { mutableStateOf(0) }
|
||||
var tabIndex by androidx.compose.runtime.saveable.rememberSaveable(s.mode) { mutableStateOf(initialTab.coerceIn(0, if (steam) ModeSettingsTab.entries.lastIndex else 2)) }
|
||||
val tabs = if (steam) ModeSettingsTab.entries else listOf(
|
||||
ModeSettingsTab.DISPLAY, ModeSettingsTab.CONTROLS, ModeSettingsTab.SESSION,
|
||||
)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import androidx.compose.ui.platform.LocalInspectionMode
|
||||
import com.droiddeck.launcher.R
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import android.content.Context
|
||||
@@ -53,8 +54,10 @@ fun PhantomProcessGatePage(
|
||||
) {
|
||||
BackHandler(onBack = onDismiss)
|
||||
val context = LocalContext.current
|
||||
val inspecting = LocalInspectionMode.current
|
||||
val stage by WirelessAdbPairingService.stage.collectAsState()
|
||||
val environment by produceState(GateEnvironment.read(context)) {
|
||||
val environment by produceState(if (inspecting) GateEnvironment(true, true) else GateEnvironment.read(context)) {
|
||||
if (inspecting) return@produceState
|
||||
while (true) {
|
||||
value = GateEnvironment.read(context)
|
||||
kotlinx.coroutines.delay(2_000)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import androidx.compose.ui.platform.LocalInspectionMode
|
||||
import com.droiddeck.launcher.R
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.animation.core.animateFloat
|
||||
@@ -148,8 +149,10 @@ fun LoadingOverlay(
|
||||
val active = reached.coerceAtMost(stages.lastIndex)
|
||||
val detail = if (percent >= 0 || readable) step.replaceFirstChar { it.uppercase() } else stringResource(stages[active].detail)
|
||||
val context = LocalContext.current
|
||||
val inspecting = LocalInspectionMode.current
|
||||
// The Steam tab's wall behind it, dimmed and slowed: starting Steam reads as the same place settling in.
|
||||
val games by produceState(emptyList<Library.SteamGame>()) {
|
||||
if (inspecting) return@produceState
|
||||
value = withContext(Dispatchers.IO) { runCatching { Library.steamGames(context).sortedByDescending { it.lastPlayed } }.getOrDefault(emptyList()) }
|
||||
}
|
||||
Box(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import androidx.compose.ui.platform.LocalInspectionMode
|
||||
import androidx.compose.ui.platform.testTag
|
||||
import com.droiddeck.launcher.R
|
||||
import androidx.compose.ui.res.stringResource
|
||||
@@ -269,7 +270,8 @@ fun AnchoredMenu(
|
||||
compact: Boolean = false, minWidth: androidx.compose.ui.unit.Dp = 120.dp,
|
||||
content: @Composable ColumnScope.(FocusRequester) -> Unit,
|
||||
) {
|
||||
val state = remember { MutableTransitionState(false) }
|
||||
val inspecting = LocalInspectionMode.current
|
||||
val state = remember { MutableTransitionState(inspecting && open) }
|
||||
state.targetState = open
|
||||
if (!state.currentState && !state.targetState && state.isIdle) return
|
||||
val firstItemFocus = remember { FocusRequester() }
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import androidx.compose.ui.platform.LocalInspectionMode
|
||||
import com.droiddeck.launcher.R
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.activity.compose.BackHandler
|
||||
@@ -69,8 +70,10 @@ import com.droiddeck.launcher.store.StoreState
|
||||
private val TABS = listOf(R.string.store_tab_discover, R.string.store_tab_search, R.string.store_tab_installed)
|
||||
|
||||
@Composable
|
||||
internal fun StorePage(s: FrontEndState, a: FrontEndActions, modifier: Modifier) {
|
||||
internal fun StorePage(s: FrontEndState, a: FrontEndActions, modifier: Modifier, previewSections: Map<String, List<FlathubApi.AppSummary>>? = null) {
|
||||
val ctx = LocalContext.current
|
||||
val inspecting = LocalInspectionMode.current
|
||||
val sections = previewSections.takeIf { inspecting } ?: StoreState.sections
|
||||
val narrow = LocalNarrowPane.current
|
||||
val padH = if (narrow) 16.dp else 22.dp
|
||||
val padV = if (narrow) 12.dp else 18.dp
|
||||
@@ -78,8 +81,8 @@ internal fun StorePage(s: FrontEndState, a: FrontEndActions, modifier: Modifier)
|
||||
var openApp by rememberSaveable { mutableStateOf<String?>(null) }
|
||||
var query by rememberSaveable { mutableStateOf("") }
|
||||
var category by rememberSaveable { mutableStateOf<String?>(null) }
|
||||
LaunchedEffect(s.ready) { StoreState.refresh(ctx) }
|
||||
LaunchedEffect(Unit) { StoreState.loadSections() }
|
||||
LaunchedEffect(s.ready) { if (!inspecting) StoreState.refresh(ctx) }
|
||||
LaunchedEffect(Unit) { if (!inspecting) StoreState.loadSections() }
|
||||
// A pad's focus sits on something the page is about to replace - the tile that opens an app,
|
||||
// a tab's contents - and would be lost with it. Each move says where focus goes next.
|
||||
val ff = LocalFrontFocus.current
|
||||
@@ -132,7 +135,7 @@ internal fun StorePage(s: FrontEndState, a: FrontEndActions, modifier: Modifier)
|
||||
}
|
||||
BusyBar()
|
||||
when (tab) {
|
||||
0 -> Discover(onOpen = { openApp = it }, onCategory = { category = it; query = ""; tab = 1; StoreState.search("", it) })
|
||||
0 -> Discover(onOpen = { openApp = it }, onCategory = { category = it; query = ""; tab = 1; if (!inspecting) StoreState.search("", it) }, sections = sections)
|
||||
1 -> Search(query, category, { query = it }, { category = it }, onOpen = { openApp = it })
|
||||
else -> Installed(a, onOpen = { openApp = it })
|
||||
}
|
||||
@@ -142,6 +145,7 @@ internal fun StorePage(s: FrontEndState, a: FrontEndActions, modifier: Modifier)
|
||||
/** Flatpak is not in the runtime yet: one button puts it there. */
|
||||
@Composable
|
||||
private fun SetupCard() {
|
||||
val inspecting = LocalInspectionMode.current
|
||||
val ctx = LocalContext.current
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
@@ -156,7 +160,7 @@ private fun SetupCard() {
|
||||
fontSize = 14.sp, color = colors.onSurfaceVariant,
|
||||
)
|
||||
Actions {
|
||||
PrimaryButton(if (busy) stringResource(R.string.store_setting_up) else stringResource(R.string.store_setup_title), enabled = StoreState.busy == null, main = true) { StoreState.setup(ctx) }
|
||||
PrimaryButton(if (busy) stringResource(R.string.store_setting_up) else stringResource(R.string.store_setup_title), enabled = StoreState.busy == null, main = true) { if (!inspecting) StoreState.setup(ctx) }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -181,20 +185,21 @@ private fun BusyBar() {
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun Discover(onOpen: (String) -> Unit, onCategory: (String) -> Unit) {
|
||||
private fun Discover(onOpen: (String) -> Unit, onCategory: (String) -> Unit, sections: Map<String, List<FlathubApi.AppSummary>>) {
|
||||
val inspecting = LocalInspectionMode.current
|
||||
Rise(3) { SectionTitle(stringResource(R.string.store_categories), null) }
|
||||
Rise(3) {
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(8.dp), modifier = Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()).padding(vertical = 4.dp)) {
|
||||
FlathubApi.categories.forEach { c -> PillButton(stringResource(c.label), selected = false) { onCategory(c.id) } }
|
||||
}
|
||||
}
|
||||
if (StoreState.sectionsFailed && StoreState.sections.values.all { it.isEmpty() }) {
|
||||
if (StoreState.sectionsFailed && sections.values.all { it.isEmpty() }) {
|
||||
Rise(4) { Note(stringResource(R.string.store_unreachable)) }
|
||||
Actions { SecondaryButton(stringResource(R.string.store_try_again)) { StoreState.loadSections(force = true) } }
|
||||
Actions { SecondaryButton(stringResource(R.string.store_try_again)) { if (!inspecting) StoreState.loadSections(force = true) } }
|
||||
return
|
||||
}
|
||||
StoreState.SECTIONS.forEachIndexed { i, (key, title) ->
|
||||
val apps = StoreState.sections[key]
|
||||
val apps = sections[key]
|
||||
Rise(4 + i) { SectionTitle(stringResource(title), apps?.let { if (it.isEmpty()) null else it.size.toString() } ?: stringResource(R.string.store_section_loading)) }
|
||||
if (apps != null && apps.isNotEmpty()) Rise(4 + i) { AppGrid(apps.take(12), first = i == 0, onOpen = onOpen) }
|
||||
}
|
||||
@@ -202,12 +207,13 @@ private fun Discover(onOpen: (String) -> Unit, onCategory: (String) -> Unit) {
|
||||
|
||||
@Composable
|
||||
private fun Search(query: String, category: String?, onQuery: (String) -> Unit, onCategory: (String?) -> Unit, onOpen: (String) -> Unit) {
|
||||
val inspecting = LocalInspectionMode.current
|
||||
val view = androidx.compose.ui.platform.LocalView.current
|
||||
val run = {
|
||||
// The field is an Android EditText; Done leaves its keyboard over the results otherwise.
|
||||
(view.context.getSystemService(android.content.Context.INPUT_METHOD_SERVICE) as? android.view.inputmethod.InputMethodManager)
|
||||
?.hideSoftInputFromWindow(view.windowToken, 0)
|
||||
StoreState.search(query.trim(), category)
|
||||
if (!inspecting) StoreState.search(query.trim(), category)
|
||||
}
|
||||
Rise(3) {
|
||||
Row(verticalAlignment = Alignment.Bottom, horizontalArrangement = Arrangement.spacedBy(10.dp), modifier = Modifier.fillMaxWidth().padding(top = 12.dp)) {
|
||||
@@ -220,9 +226,9 @@ private fun Search(query: String, category: String?, onQuery: (String) -> Unit,
|
||||
}
|
||||
Rise(4) {
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(8.dp), modifier = Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()).padding(top = 12.dp, bottom = 4.dp)) {
|
||||
PillButton(stringResource(R.string.store_all), selected = category == null) { onCategory(null); StoreState.search(query.trim(), null) }
|
||||
PillButton(stringResource(R.string.store_all), selected = category == null) { onCategory(null); if (!inspecting) StoreState.search(query.trim(), null) }
|
||||
FlathubApi.categories.forEach { c ->
|
||||
PillButton(stringResource(c.label), selected = category == c.id) { onCategory(c.id); StoreState.search(query.trim(), c.id) }
|
||||
PillButton(stringResource(c.label), selected = category == c.id) { onCategory(c.id); if (!inspecting) StoreState.search(query.trim(), c.id) }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -240,6 +246,7 @@ private fun Search(query: String, category: String?, onQuery: (String) -> Unit,
|
||||
|
||||
@Composable
|
||||
private fun Installed(a: FrontEndActions, onOpen: (String) -> Unit) {
|
||||
val inspecting = LocalInspectionMode.current
|
||||
val ctx = LocalContext.current
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
@@ -247,10 +254,10 @@ private fun Installed(a: FrontEndActions, onOpen: (String) -> Unit) {
|
||||
Rise(3) {
|
||||
Actions {
|
||||
SecondaryButton(if (StoreState.checkingUpdates) stringResource(R.string.common_checking) else stringResource(R.string.store_check_updates), enabled = StoreState.ready && !StoreState.checkingUpdates && StoreState.busy == null) {
|
||||
StoreState.checkUpdates(ctx)
|
||||
if (!inspecting) StoreState.checkUpdates(ctx)
|
||||
}
|
||||
if (StoreState.updates.isNotEmpty()) PrimaryButton(stringResource(R.string.store_update_all, StoreState.updates.size), enabled = StoreState.busy == null) {
|
||||
StoreState.update(ctx, null, ctx.getString(R.string.store_updates))
|
||||
if (!inspecting) StoreState.update(ctx, null, ctx.getString(R.string.store_updates))
|
||||
} else if (StoreState.updatesChecked && !StoreState.checkingUpdates) ActionChip(stringResource(R.string.store_all_current), ok = true)
|
||||
}
|
||||
}
|
||||
@@ -276,7 +283,7 @@ private fun Installed(a: FrontEndActions, onOpen: (String) -> Unit) {
|
||||
)
|
||||
}
|
||||
PrimaryButton(stringResource(R.string.store_open), compact = true, enabled = !s_busyFor(app.id)) { a.onFlatpakApp(app.id, app.name) }
|
||||
if (app.id in StoreState.updates) SecondaryButton(stringResource(R.string.common_update), compact = true, enabled = StoreState.busy == null) { StoreState.update(ctx, app.id, app.name) }
|
||||
if (app.id in StoreState.updates) SecondaryButton(stringResource(R.string.common_update), compact = true, enabled = StoreState.busy == null) { if (!inspecting) StoreState.update(ctx, app.id, app.name) }
|
||||
SecondaryButton(stringResource(R.string.store_details), compact = true) { onOpen(app.id) }
|
||||
}
|
||||
}
|
||||
@@ -292,7 +299,8 @@ private fun AppDetail(s: FrontEndState, a: FrontEndActions, id: String, onBack:
|
||||
val ctx = LocalContext.current
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val narrow = LocalNarrowPane.current
|
||||
LaunchedEffect(id) { StoreState.loadDetails(id) }
|
||||
val inspecting = LocalInspectionMode.current
|
||||
LaunchedEffect(id) { if (!inspecting) StoreState.loadDetails(id) }
|
||||
val d = StoreState.details[id]
|
||||
val local = StoreState.installed.firstOrNull { it.id == id }
|
||||
val name = d?.name ?: local?.name ?: id
|
||||
@@ -317,15 +325,15 @@ private fun AppDetail(s: FrontEndState, a: FrontEndActions, id: String, onBack:
|
||||
Actions {
|
||||
if (installed) {
|
||||
PrimaryButton(stringResource(R.string.store_open), enabled = !busyHere, main = true) { a.onFlatpakApp(id, name) }
|
||||
if (id in StoreState.updates) SecondaryButton(stringResource(R.string.common_update), enabled = StoreState.busy == null) { StoreState.update(ctx, id, name) }
|
||||
if (id in StoreState.updates) SecondaryButton(stringResource(R.string.common_update), enabled = StoreState.busy == null) { if (!inspecting) StoreState.update(ctx, id, name) }
|
||||
SecondaryButton(if (busyHere) stringResource(R.string.common_working) else if (confirmRemove) stringResource(R.string.store_press_again) else stringResource(R.string.store_remove), enabled = StoreState.busy == null) {
|
||||
if (confirmRemove) { confirmRemove = false; StoreState.uninstall(ctx, id, name) } else confirmRemove = true
|
||||
if (confirmRemove) { confirmRemove = false; if (!inspecting) StoreState.uninstall(ctx, id, name) } else confirmRemove = true
|
||||
}
|
||||
} else {
|
||||
PrimaryButton(
|
||||
if (busyHere) stringResource(R.string.store_installing) else stringResource(R.string.store_install), main = true,
|
||||
enabled = StoreState.ready && StoreState.busy == null && s.ready && (d == null || d.arches.isEmpty() || "aarch64" in d.arches),
|
||||
) { StoreState.install(ctx, id, name) }
|
||||
) { if (!inspecting) StoreState.install(ctx, id, name) }
|
||||
if (!StoreState.ready) ActionChip(stringResource(R.string.store_setup_first), ok = false)
|
||||
}
|
||||
d?.version?.let { ActionChip("v$it", ok = false) }
|
||||
|
||||
@@ -92,10 +92,10 @@ class UpdatesActions(
|
||||
)
|
||||
|
||||
@Composable
|
||||
internal fun UpdatesPage(s: FrontEndState, a: FrontEndActions, modifier: Modifier) {
|
||||
internal fun UpdatesPage(s: FrontEndState, a: FrontEndActions, modifier: Modifier, installed: AppUpdates.Installed? = null) {
|
||||
val u = s.updates
|
||||
val ua = a.updates
|
||||
val me = remember { AppUpdates.installed() }
|
||||
val me = remember(installed) { installed ?: AppUpdates.installed() }
|
||||
val colors = MaterialTheme.colorScheme
|
||||
Column(modifier = modifier) {
|
||||
PageHeader(stringResource(R.string.upd_title)) {
|
||||
|
||||
@@ -34,6 +34,7 @@ import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.compose.ui.platform.LocalInspectionMode
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.frontend.DependencyDetector
|
||||
import com.droiddeck.launcher.frontend.PrefixInstalledDetector
|
||||
@@ -68,10 +69,12 @@ internal fun WinComponentsDialog(
|
||||
appKey: String, gameName: String, gameDir: File?, byPad: Boolean,
|
||||
/** compatdata/<id>: what the prefix already has. [steamAppId]: a Steam title, whose appmanifest lists Steam's own redists. */
|
||||
compat: File? = null, steamAppId: Int? = null,
|
||||
previewComponents: List<WinComponents.Component> = emptyList(),
|
||||
onClose: () -> Unit,
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
val coroutine = rememberCoroutineScope()
|
||||
val inspecting = LocalInspectionMode.current
|
||||
val shown = rememberShown(onClose)
|
||||
val close = { shown.targetState = false }
|
||||
// null while the catalog loads; empty when it could not be had.
|
||||
@@ -81,7 +84,7 @@ internal fun WinComponentsDialog(
|
||||
var installed by remember { mutableStateOf(emptySet<String>()) }
|
||||
// Detector names (oalinst, physx...) already in the prefix from elsewhere.
|
||||
var present by remember { mutableStateOf(emptySet<String>()) }
|
||||
var picks by remember { mutableStateOf(WinComponents.picks(context, appKey)) }
|
||||
var picks by remember { mutableStateOf(if (inspecting) emptyList() else WinComponents.picks(context, appKey)) }
|
||||
// The row being worked on: its id, the latest progress (a dependency's while that installs
|
||||
// first), and whether it is turning off rather than on. The row greys out and shows the bar
|
||||
// the moment the switch is pressed, and only that row; the rest of the page stays as it is.
|
||||
@@ -104,6 +107,7 @@ internal fun WinComponentsDialog(
|
||||
var switchFocused by remember { mutableStateOf(false) }
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
if (inspecting) { catalog = previewComponents.associateBy { it.name }; return@LaunchedEffect }
|
||||
val (entries, found) = withContext(Dispatchers.IO) {
|
||||
// The folder's own installers first, then what Steam installs with the game.
|
||||
val own = gameDir?.let { DependencyDetector.detect(it) } ?: emptyList()
|
||||
@@ -118,9 +122,10 @@ internal fun WinComponentsDialog(
|
||||
}
|
||||
fun setPicks(next: List<String>) {
|
||||
picks = next
|
||||
coroutine.launch(Dispatchers.IO) { WinComponents.setPicks(context, appKey, next) }
|
||||
if (!inspecting) coroutine.launch(Dispatchers.IO) { WinComponents.setPicks(context, appKey, next) }
|
||||
}
|
||||
fun toggle(id: String, on: Boolean) {
|
||||
if (inspecting) { picks = if (on) picks + id else picks - id; return }
|
||||
// Switches stay enabled during a download - a disabled one drops the pad's focus - so a press
|
||||
// then is ignored here; the busy row is greyed instead.
|
||||
if (busyId != null) return
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import androidx.compose.ui.platform.LocalInspectionMode
|
||||
import com.droiddeck.launcher.R
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import android.text.Editable
|
||||
@@ -61,7 +62,8 @@ fun WirelessAdbFixPage(
|
||||
onApply: (String, Int, Boolean, (String?) -> Unit) -> Unit,
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
val savedAddress = remember { WirelessAdbFix.savedConnectionAddress(context) }
|
||||
val inspecting = LocalInspectionMode.current
|
||||
val savedAddress = remember { if (inspecting) null else WirelessAdbFix.savedConnectionAddress(context) }
|
||||
var step by rememberSaveable { mutableStateOf(if (savedAddress == null) 0 else 1) }
|
||||
var pairingAddress by rememberSaveable { mutableStateOf("") }
|
||||
var connectionAddress by rememberSaveable { mutableStateOf(savedAddress.orEmpty()) }
|
||||
|
||||
@@ -1592,6 +1592,7 @@
|
||||
<!-- The on-screen button is not shown -->
|
||||
<string name="ctrl_target_hidden">Oculto</string>
|
||||
<string name="ctrl_editor_drag">Arrastra para mover</string>
|
||||
<string name="ctrl_editor_snap">Ajustar</string>
|
||||
<string name="ctrl_editor_save">Guardar</string>
|
||||
|
||||
<!-- What the second screen shows during a session -->
|
||||
|
||||
@@ -1556,6 +1556,7 @@
|
||||
<!-- The on-screen button is not shown -->
|
||||
<string name="ctrl_target_hidden">非表示</string>
|
||||
<string name="ctrl_editor_drag">ドラッグして移動</string>
|
||||
<string name="ctrl_editor_snap">スナップ</string>
|
||||
<string name="ctrl_editor_save">保存</string>
|
||||
|
||||
<!-- What the second screen shows during a session -->
|
||||
|
||||
@@ -1556,6 +1556,7 @@
|
||||
<!-- The on-screen button is not shown -->
|
||||
<string name="ctrl_target_hidden">숨김</string>
|
||||
<string name="ctrl_editor_drag">드래그하여 이동</string>
|
||||
<string name="ctrl_editor_snap">맞춤</string>
|
||||
<string name="ctrl_editor_save">저장</string>
|
||||
|
||||
<!-- What the second screen shows during a session -->
|
||||
|
||||
@@ -1556,6 +1556,7 @@
|
||||
<!-- The on-screen button is not shown -->
|
||||
<string name="ctrl_target_hidden">隐藏</string>
|
||||
<string name="ctrl_editor_drag">拖动以移动</string>
|
||||
<string name="ctrl_editor_snap">对齐</string>
|
||||
<string name="ctrl_editor_save">保存</string>
|
||||
|
||||
<!-- What the second screen shows during a session -->
|
||||
|
||||
@@ -1556,6 +1556,7 @@
|
||||
<!-- The on-screen button is not shown -->
|
||||
<string name="ctrl_target_hidden">隱藏</string>
|
||||
<string name="ctrl_editor_drag">拖曳以移動</string>
|
||||
<string name="ctrl_editor_snap">對齊</string>
|
||||
<string name="ctrl_editor_save">儲存</string>
|
||||
|
||||
<!-- What the second screen shows during a session -->
|
||||
|
||||
@@ -1556,6 +1556,7 @@
|
||||
<!-- The on-screen button is not shown -->
|
||||
<string name="ctrl_target_hidden">隱藏</string>
|
||||
<string name="ctrl_editor_drag">拖曳以移動</string>
|
||||
<string name="ctrl_editor_snap">對齊</string>
|
||||
<string name="ctrl_editor_save">儲存</string>
|
||||
|
||||
<!-- What the second screen shows during a session -->
|
||||
|
||||
@@ -896,6 +896,12 @@
|
||||
<string name="content_page_gone">That page is gone. Pick a section on the left.</string>
|
||||
<string name="content_open_desktop">Open desktop</string>
|
||||
<string name="content_install_open_desktop">Install & open desktop</string>
|
||||
<string name="desktop_remove_title">Uninstall desktop</string>
|
||||
<string name="desktop_remove_text">Remove the desktop and its bundled apps. Keep games, added apps, settings and shared libraries.</string>
|
||||
<string name="desktop_removing">Removing desktop</string>
|
||||
<string name="desktop_removed">Desktop removed</string>
|
||||
<string name="desktop_cleaning_legacy">Removing old LXQt files</string>
|
||||
<string name="desktop_removal_unknown">Update DroidDeck before removing this desktop version.</string>
|
||||
<string name="content_linux_desktop">Linux desktop</string>
|
||||
<string name="content_linux_desktop_hint">KDE Plasma, Firefox and your emulators</string>
|
||||
<string name="games_empty">Games you install in Steam show up here after the session.</string>
|
||||
@@ -1527,6 +1533,7 @@
|
||||
<!-- The on-screen button is not shown -->
|
||||
<string name="ctrl_target_hidden">Hidden</string>
|
||||
<string name="ctrl_editor_drag">Drag to move</string>
|
||||
<string name="ctrl_editor_snap">Snap</string>
|
||||
<string name="ctrl_editor_save">Save</string>
|
||||
<!-- What the second screen shows during a session -->
|
||||
<string name="second_mode_none">None</string>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.droiddeck.launcher.input
|
||||
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.sqrt
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
@@ -32,6 +33,88 @@ class OnScreenControlsTest {
|
||||
view.layout(0, 0, 1200, 800)
|
||||
}
|
||||
|
||||
@Test fun editorSnapsToOtherGroupCentreLines() {
|
||||
editor()
|
||||
val button = control("lb")
|
||||
val target = control("rb")
|
||||
val x = value(button, "cx")
|
||||
val y = value(button, "cy")
|
||||
touch(MotionEvent.ACTION_DOWN, 1 to (x to y))
|
||||
touch(MotionEvent.ACTION_MOVE, 1 to (x to y + 5f))
|
||||
assertEquals(value(target, "cy"), value(button, "cy"), 0f)
|
||||
assertEquals(value(target, "cy"), nullableFloat(view, "snapY")!!, 0f)
|
||||
touch(MotionEvent.ACTION_UP, 1 to (x to y + 5f))
|
||||
assertNull(nullableFloat(view, "snapY"))
|
||||
}
|
||||
|
||||
@Test fun editorSnapsToClusterCentresNotTheirOuterButtons() {
|
||||
editor()
|
||||
val button = control("lb")
|
||||
val x = value(button, "cx")
|
||||
val row = value(control("y"), "cy") + 3f
|
||||
touch(MotionEvent.ACTION_DOWN, 1 to (x to value(button, "cy")))
|
||||
touch(MotionEvent.ACTION_MOVE, 1 to (x to row))
|
||||
assertEquals(row, value(button, "cy"), 0f)
|
||||
assertNull(nullableFloat(view, "snapY"))
|
||||
touch(MotionEvent.ACTION_MOVE, 1 to (x to value(control("x"), "cy") + 3f))
|
||||
assertEquals(value(control("x"), "cy"), value(button, "cy"), 0f)
|
||||
touch(MotionEvent.ACTION_UP, 1 to (x to row))
|
||||
}
|
||||
|
||||
@Test fun editorDoesNotSnapBeyondDistanceAndCanDragFreeFromGuide() {
|
||||
editor()
|
||||
val button = control("lb")
|
||||
val x = value(button, "cx")
|
||||
val y = value(button, "cy")
|
||||
val otherYs = (field(view, "controls") as List<*>)
|
||||
.filter { field(it!!, "group") != "lb" }
|
||||
.map { value(it!!, "cy") }
|
||||
val freeY = (100..700 step 31).map(Int::toFloat).first {
|
||||
otherYs.minOf { targetY -> abs(it - targetY) } > 12f
|
||||
}
|
||||
touch(MotionEvent.ACTION_DOWN, 1 to (x to y))
|
||||
touch(MotionEvent.ACTION_MOVE, 1 to (x to freeY))
|
||||
assertEquals(freeY, value(button, "cy"), 0f)
|
||||
assertNull(nullableFloat(view, "snapY"))
|
||||
val target = value(control("rb"), "cy")
|
||||
touch(MotionEvent.ACTION_MOVE, 1 to (x to target + 5f))
|
||||
assertEquals(target, value(button, "cy"), 0f)
|
||||
touch(MotionEvent.ACTION_MOVE, 1 to (x to freeY))
|
||||
assertEquals(freeY, value(button, "cy"), 0f)
|
||||
assertNull(nullableFloat(view, "snapY"))
|
||||
touch(MotionEvent.ACTION_UP, 1 to (x to freeY))
|
||||
}
|
||||
|
||||
@Test fun editorSnapsToScreenCentreAndCanDisableSnapping() {
|
||||
editor()
|
||||
val button = control("lb")
|
||||
val y = value(button, "cy")
|
||||
touch(MotionEvent.ACTION_DOWN, 1 to (value(button, "cx") to y))
|
||||
touch(MotionEvent.ACTION_MOVE, 1 to (605f to y))
|
||||
assertEquals(600f, value(button, "cx"), 0f)
|
||||
assertEquals(600f, nullableFloat(view, "snapX")!!, 0f)
|
||||
touch(MotionEvent.ACTION_UP, 1 to (605f to y))
|
||||
|
||||
ControllerPrefs.setSnap(context, false)
|
||||
editor()
|
||||
val unsnapped = control("lb")
|
||||
val x = value(unsnapped, "cx")
|
||||
val startY = value(unsnapped, "cy")
|
||||
touch(MotionEvent.ACTION_DOWN, 1 to (x to startY))
|
||||
touch(MotionEvent.ACTION_MOVE, 1 to (605f to startY))
|
||||
assertEquals(605f, value(unsnapped, "cx"), 0f)
|
||||
assertNull(nullableFloat(view, "snapX"))
|
||||
touch(MotionEvent.ACTION_UP, 1 to (605f to startY))
|
||||
}
|
||||
|
||||
@Test fun editorSnapPreferenceDefaultsOnAndCanBeChanged() {
|
||||
assertTrue(ControllerPrefs.read(context).snap)
|
||||
ControllerPrefs.setSnap(context, false)
|
||||
assertFalse(ControllerPrefs.read(context).snap)
|
||||
ControllerPrefs.resetAll(context)
|
||||
assertTrue(ControllerPrefs.read(context).snap)
|
||||
}
|
||||
|
||||
@Test fun adaptiveStickHidesUntilTouchedAndReturnsToNeutralOnRelease() {
|
||||
val left = control("ls")
|
||||
assertEquals(0, pixel(value(left, "cx"), value(left, "cy")))
|
||||
@@ -171,6 +254,10 @@ class OnScreenControlsTest {
|
||||
}
|
||||
|
||||
private fun control(id: String): Any = (field(view, "controls") as List<*>).first { field(it!!, "id") == id }!!
|
||||
private fun editor() {
|
||||
view = OnScreenControls(context, null, editing = true)
|
||||
view.layout(0, 0, 1200, 800)
|
||||
}
|
||||
|
||||
@Test fun keyboardShortcutWorksWithHiddenPadAndButtonsOnly() {
|
||||
var opened = 0
|
||||
@@ -236,6 +323,7 @@ class OnScreenControlsTest {
|
||||
}
|
||||
}
|
||||
private fun field(owner: Any, name: String): Any = owner.javaClass.getDeclaredField(name).apply { isAccessible = true }.get(owner)!!
|
||||
private fun nullableFloat(owner: Any, name: String) = owner.javaClass.getDeclaredField(name).apply { isAccessible = true }.get(owner) as Float?
|
||||
private fun value(owner: Any, name: String) = field(owner, name) as Float
|
||||
|
||||
private fun pixel(x: Float, y: Float): Int {
|
||||
|
||||
@@ -23,6 +23,10 @@ class DesktopCatalogTest {
|
||||
assertFalse(DesktopCatalog.desktopInstalled(root))
|
||||
marker.writeText("${BuildConfig.DESKTOP_KDE_TAG}\n")
|
||||
assertTrue(DesktopCatalog.desktopInstalled(root))
|
||||
val pending = File(root, DesktopRemoval.PENDING).apply { writeText(BuildConfig.DESKTOP_KDE_TAG) }
|
||||
assertFalse(DesktopCatalog.desktopInstalled(root))
|
||||
pending.delete()
|
||||
assertTrue(DesktopCatalog.desktopInstalled(root))
|
||||
kwin.delete()
|
||||
assertFalse(DesktopCatalog.desktopInstalled(root))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.droiddeck.launcher.runtime
|
||||
|
||||
import java.io.File
|
||||
import java.nio.file.Files
|
||||
import org.junit.After
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class DesktopFileRemovalTest {
|
||||
private lateinit var dir: File
|
||||
private lateinit var root: File
|
||||
@Before fun setup() { dir = Files.createTempDirectory("desktop-removal").toFile(); root = File(dir, "linuxfs").apply { mkdirs() } }
|
||||
@After fun cleanup() { RuntimeFileTree.delete(dir, null) }
|
||||
private fun file(path: String, data: String) = File(root, path).apply { parentFile.mkdirs(); writeText(data) }
|
||||
private fun entry(path: String, file: File) = DesktopFileRemoval.Entry("F", file.length(), DesktopFileRemoval.sha(file), path)
|
||||
|
||||
@Test fun removesUnchangedFilesAndEmptyParentsButPreservesUserDataAndSharedFiles() {
|
||||
val desktop = file("usr/share/plasma/only/asset", "desktop")
|
||||
val shared = file("usr/lib/shared.so", "shared")
|
||||
val custom = file("usr/share/plasma/custom", "user")
|
||||
val home = file("root/.local/share/Steam/game", "game")
|
||||
val result = DesktopFileRemoval.remove(root, listOf(entry("usr/share/plasma/only/asset", desktop), entry("usr/lib/shared.so", shared), entry("root/.local/share/Steam/game", home)), setOf("usr/lib/shared.so"))
|
||||
assertEquals(1, result.removed)
|
||||
assertEquals(7L, result.bytes)
|
||||
assertFalse(desktop.parentFile.exists())
|
||||
assertEquals("shared", shared.readText())
|
||||
assertEquals("user", custom.readText())
|
||||
assertEquals("game", home.readText())
|
||||
}
|
||||
|
||||
@Test fun preservesChangesIncludingSameLengthEditsAndSymlinkReplacement() {
|
||||
val file = file("usr/bin/desktop", "before")
|
||||
val expected = entry("usr/bin/desktop", file)
|
||||
file.writeText("edited")
|
||||
val target = file("root/private", "data")
|
||||
val link = File(root, "usr/bin/link")
|
||||
Files.createSymbolicLink(link.toPath(), target.toPath())
|
||||
val result = DesktopFileRemoval.remove(root, listOf(expected, DesktopFileRemoval.Entry("L", 0, "/usr/bin/original", "usr/bin/link")), emptySet())
|
||||
assertEquals(0, result.removed)
|
||||
assertEquals("edited", file.readText())
|
||||
assertTrue(Files.isSymbolicLink(link.toPath()))
|
||||
}
|
||||
|
||||
@Test fun neverFollowsParentsEvenWhenTheyPointInsideRootAndOnlyUnlinksRecordedLinks() {
|
||||
val keep = file("root/private/asset", "desktop")
|
||||
File(root, "usr/share").mkdirs()
|
||||
Files.createSymbolicLink(File(root, "usr/share/plasma").toPath(), File(root, "root/private").toPath())
|
||||
val dangling = File(root, "usr/share/dangling")
|
||||
Files.createSymbolicLink(dangling.toPath(), File("/missing").toPath())
|
||||
val result = DesktopFileRemoval.remove(root, listOf(entry("usr/share/plasma/asset", keep), DesktopFileRemoval.Entry("L", 0, "/missing", "usr/share/dangling")), emptySet())
|
||||
assertEquals(1, result.removed)
|
||||
assertEquals("desktop", keep.readText())
|
||||
assertFalse(Files.exists(dangling.toPath(), java.nio.file.LinkOption.NOFOLLOW_LINKS))
|
||||
}
|
||||
|
||||
@Test fun rejectsTraversalAbsolutePathsAndUserHome() {
|
||||
for (path in listOf("../etc/x", "/etc/x", "usr/../../x", "usr/./x", "usr//x", "root/x", "opt/appimages/x"))
|
||||
assertNull(path, DesktopFileRemoval.safeFile(root, path))
|
||||
}
|
||||
|
||||
@Test fun interruptedRemovalIsIdempotentAndRetriesRemainingFiles() {
|
||||
val one = file("usr/bin/one", "one")
|
||||
val two = file("usr/bin/two", "two")
|
||||
val entries = listOf(entry("usr/bin/one", one), entry("usr/bin/two", two))
|
||||
try { DesktopFileRemoval.remove(root, entries.asSequence().constrainOnce().asIterable(), emptySet()) { throw IllegalStateException("process ended") }; fail() }
|
||||
catch (_: IllegalStateException) { }
|
||||
assertFalse(one.exists())
|
||||
assertTrue(two.exists())
|
||||
assertEquals(1, DesktopFileRemoval.remove(root, entries, emptySet()).removed)
|
||||
assertEquals(0, DesktopFileRemoval.remove(root, entries, emptySet()).removed)
|
||||
}
|
||||
|
||||
@Test fun readsOnlyRuntimePackageFilesAndRefusesMissingOwnership() {
|
||||
try { DesktopFileRemoval.runtimeFiles(root); fail() } catch (_: java.io.IOException) { }
|
||||
file("var/lib/pacman/local/base-1/files", "%FILES%\nusr/\nusr/bin/\nusr/bin/gamescope\n\n%BACKUP%\netc/config\n")
|
||||
assertEquals(setOf("usr/bin/gamescope"), DesktopFileRemoval.runtimeFiles(root))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.droiddeck.launcher.runtime
|
||||
|
||||
import com.droiddeck.launcher.session.SessionPhase
|
||||
import com.droiddeck.launcher.session.SessionState
|
||||
import java.util.concurrent.CountDownLatch
|
||||
import java.util.concurrent.TimeUnit
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
|
||||
class DesktopMaintenanceTest {
|
||||
@Test(timeout = 15000) fun reservationBlocksRuntimeChangesAndFollowersSurviveScreenRecreation() {
|
||||
SessionState.running = false
|
||||
SessionState.phase = SessionPhase.IDLE
|
||||
val operation = LinuxRuntimeInstaller.beginMaintenance(null, "Removing desktop")!!
|
||||
assertTrue(LinuxRuntimeInstaller.isBusy())
|
||||
assertTrue(LinuxRuntimeInstaller.isMaintaining())
|
||||
assertFalse(LinuxRuntimeInstaller.isRemoving())
|
||||
assertFalse(LinuxRuntimeInstaller.install(null, null, null))
|
||||
assertNull(LinuxRuntimeInstaller.beginMaintenance(null, "other"))
|
||||
assertNull(LinuxRuntimeInstaller.beginUninstall(null, java.io.File("unused")))
|
||||
val entered = CountDownLatch(1)
|
||||
val release = CountDownLatch(1)
|
||||
val worker = Thread {
|
||||
assertTrue(operation.run(null) { progress ->
|
||||
progress.onProgress("Removing desktop", 30)
|
||||
entered.countDown()
|
||||
assertTrue(release.await(5, TimeUnit.SECONDS))
|
||||
progress.onProgress("Desktop removed", 100)
|
||||
null
|
||||
})
|
||||
}
|
||||
worker.start()
|
||||
try {
|
||||
assertTrue(entered.await(5, TimeUnit.SECONDS))
|
||||
val following = CountDownLatch(1)
|
||||
val follower = Thread {
|
||||
assertEquals(true, LinuxRuntimeInstaller.attach { stage, _ ->
|
||||
if (stage == "Removing desktop") following.countDown()
|
||||
})
|
||||
}
|
||||
follower.start()
|
||||
assertTrue(following.await(5, TimeUnit.SECONDS))
|
||||
release.countDown()
|
||||
worker.join(5000); follower.join(5000)
|
||||
assertFalse(LinuxRuntimeInstaller.isBusy())
|
||||
} finally { release.countDown(); worker.join(5000) }
|
||||
}
|
||||
|
||||
@Test(timeout = 15000) fun refusesActiveOrStartingSessionsAndReportsFailureWithoutRetainingTheReservation() {
|
||||
SessionState.phase = SessionPhase.STARTING_GUEST
|
||||
assertNull(LinuxRuntimeInstaller.beginMaintenance(null, "Removing desktop"))
|
||||
SessionState.phase = SessionPhase.IDLE
|
||||
SessionState.running = true
|
||||
assertNull(LinuxRuntimeInstaller.beginMaintenance(null, "Removing desktop"))
|
||||
SessionState.running = false
|
||||
val operation = LinuxRuntimeInstaller.beginMaintenance(null, "Removing desktop")!!
|
||||
assertFalse(operation.run(null) { "cannot unlink" })
|
||||
assertEquals("cannot unlink", LinuxRuntimeInstaller.removalError())
|
||||
assertFalse(LinuxRuntimeInstaller.isBusy())
|
||||
assertTrue(LinuxRuntimeInstaller.beginMaintenance(null, "retry")!!.run(null) { null })
|
||||
assertNull(LinuxRuntimeInstaller.removalError())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import android.app.Application
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Canvas
|
||||
import android.os.Looper
|
||||
import android.view.inspector.WindowInspector
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.compose.ui.test.junit4.createComposeRule
|
||||
import com.droiddeck.launcher.files.filePreviewCases
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.ParameterizedRobolectricTestRunner
|
||||
import org.robolectric.ParameterizedRobolectricTestRunner.Parameters
|
||||
import org.robolectric.Robolectric
|
||||
import org.robolectric.Shadows.shadowOf
|
||||
import org.robolectric.annotation.Config
|
||||
import org.robolectric.annotation.GraphicsMode
|
||||
import java.io.File
|
||||
import java.time.Duration
|
||||
|
||||
/** Render the actual preview entry points, including dialogs and their inspection-only paths. */
|
||||
@RunWith(ParameterizedRobolectricTestRunner::class)
|
||||
@Config(sdk = [34], application = Application::class, qualifiers = "w960dp-h540dp-land-mdpi")
|
||||
@GraphicsMode(GraphicsMode.Mode.NATIVE)
|
||||
internal class PreviewRenderTest(private val case: PreviewCase) {
|
||||
@get:Rule val compose = createComposeRule()
|
||||
|
||||
@Test fun rendersContentWithoutDeviceOrRuntime() = render("handheld")
|
||||
|
||||
@Test @Config(qualifiers = "w480dp-h360dp-land-mdpi")
|
||||
fun rendersCompactLayout() = render("compact")
|
||||
|
||||
@Test @Config(qualifiers = "w400dp-h700dp-port-mdpi")
|
||||
fun rendersPortraitLayout() = render("portrait")
|
||||
|
||||
private fun render(size: String) {
|
||||
if (case.name == "CustomResolution") {
|
||||
// Compose 1.6's AlertDialog + weighted text fields never report idle to Espresso here.
|
||||
// Render this dialog with bounded native frames instead of changing production UI.
|
||||
val activity = Robolectric.buildActivity(ComponentActivity::class.java).setup()
|
||||
try {
|
||||
activity.get().setContent { case.content() }
|
||||
shadowOf(Looper.getMainLooper()).idleFor(Duration.ofMillis(1000))
|
||||
saveWindow(size)
|
||||
} finally {
|
||||
activity.pause().stop().destroy()
|
||||
}
|
||||
return
|
||||
}
|
||||
compose.mainClock.autoAdvance = false
|
||||
compose.setContent { case.content() }
|
||||
compose.mainClock.advanceTimeBy(1000)
|
||||
compose.waitForIdle()
|
||||
compose.runOnIdle { saveWindow(size) }
|
||||
}
|
||||
|
||||
private fun saveWindow(size: String) {
|
||||
// Dialogs have their own root; capture their content rather than the empty host.
|
||||
val view = WindowInspector.getGlobalWindowViews().last()
|
||||
assertTrue("${case.name}: empty bounds", view.width > 0 && view.height > 0)
|
||||
val image = Bitmap.createBitmap(view.width, view.height, Bitmap.Config.ARGB_8888)
|
||||
view.draw(Canvas(image))
|
||||
val pixels = IntArray(image.width * image.height)
|
||||
image.getPixels(pixels, 0, image.width, 0, 0, image.width, image.height)
|
||||
assertTrue("${case.name}: blank preview", pixels.any { it != pixels.first() })
|
||||
val output = File("build/preview-renders/$size/${case.name}.png")
|
||||
output.parentFile?.mkdirs()
|
||||
output.outputStream().use { image.compress(Bitmap.CompressFormat.PNG, 100, it) }
|
||||
image.recycle()
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic @Parameters(name = "{0}")
|
||||
fun previews(): List<Array<Any>> = (screenPreviewCases + filePreviewCases).map { arrayOf(it) }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
# Compose previews
|
||||
|
||||
Select the **debug** build variant in Android Studio, then open a preview file under
|
||||
`app/src/debug/java/com/droiddeck/launcher/` and choose **Split** or **Design**.
|
||||
Build the project after syncing Gradle. Previews call the production composables;
|
||||
there is no separate mock UI to keep in sync.
|
||||
|
||||
| File | Coverage |
|
||||
| --- | --- |
|
||||
| `ui/LauncherPreviews.kt` | Steam home, runtime missing/downloading, populated/empty library, game details, desktop, emulator, Android apps, Store, Updates, alternate theme |
|
||||
| `ui/SettingsPreviews.kt` | All four Setup tabs, all six Steam settings tabs, desktop settings, controller/mapping, performance, shared settings widgets |
|
||||
| `ui/RuntimePreviews.kt` | Proton installed/empty/downloading, components/loading, GPU drivers and driver downloads |
|
||||
| `ui/SessionPreviews.kt` | Every session drawer page, loading/starting/error screens, PC keyboard, HUD, cursor |
|
||||
| `ui/DialogPreviews.kt` | Add/edit app, confirmation, custom resolution, ROM folder, environment variables, Windows components, display chooser, wireless ADB, process-limit help |
|
||||
| `files/FilePreviews.kt` | File manager grid/list/empty/favorites, file/folder pickers, properties |
|
||||
|
||||
`@DroidDeckPreviews` shows handheld landscape (960×540 dp), compact landscape
|
||||
(480×360 dp), portrait (400×700 dp), and larger text. The Paper theme has a separate
|
||||
launcher preview. Dimensions are Android layout units, not physical display pixels.
|
||||
|
||||
Edit the real UI components to adjust layouts. Edit `PreviewData.kt` for sample
|
||||
screen state and callbacks, and `FilePreviews.kt` for file metadata. Add a preview
|
||||
for each new screen or materially different state. Add its entry to
|
||||
`PreviewCases.kt` or `filePreviewCases` so it is covered by the render check.
|
||||
|
||||
Preview fixtures and tooling are debug-only. `PreviewHost` supplies the production
|
||||
theme, inspection mode, and inert navigation/file-picker owners. Inspection paths
|
||||
skip automatic runtime, directory, device, and network operations and settle
|
||||
entrance animations so content is visible immediately. File manager mutation
|
||||
commands are disabled in inspection mode. Previews are for layout and local UI
|
||||
interaction; they do not validate installation, pairing, launching, or controller
|
||||
input latency.
|
||||
|
||||
The native game surface, Termux terminal, on-screen gamepad, and second-screen
|
||||
View controls are outside this Compose preview set. Their surrounding Compose
|
||||
menus are covered. These components still need device validation.
|
||||
|
||||
Run the preview render smoke checks:
|
||||
|
||||
```sh
|
||||
./gradlew app:testDebugUnitTest --tests '*PreviewRenderTest'
|
||||
```
|
||||
|
||||
The checks use Robolectric native graphics with an ordinary `Application`, render
|
||||
the same 68 preview entry points at handheld, compact, and portrait sizes, reject
|
||||
empty/solid-color output, and write PNGs to
|
||||
`app/build/preview-renders/`. This catches composition/render errors without starting
|
||||
the Linux runtime. Android Studio uses Layoutlib, so the smoke check complements
|
||||
Studio preview validation rather than replacing it.
|
||||
@@ -33,3 +33,28 @@ The desktop workflow replaces the same-version `kwin_wayland` executable and `li
|
||||
comes from the signature-checked Arch packages. `desktop-kde.kwin.txt` records the source, patch,
|
||||
executable, library and build package hashes. Corresponding source is
|
||||
https://download.kde.org/stable/plasma/6.7.5/kwin-6.7.5.tar.xz plus the patch in this repository.
|
||||
|
||||
The inventories use `.gzip` rather than `.gz`: Android's asset packer expands `.gz` and strips
|
||||
its suffix. The shared local/CI runtime payload check verifies the exact APK names and bytes.
|
||||
|
||||
Desktop removal uses `app/src/main/assets/desktop-removal/`, generated by `removal-manifests.py`
|
||||
from the checksum-pinned LXQt r1, KDE r1/r2 and emulator r1 archives. KDE candidates are the files
|
||||
of the desktop applications/themes in `seeds.txt` (their source package hashes verified against
|
||||
`desktop-kde.packages.txt`) plus our overlay. Shared dependencies, fonts, Xwayland and Qt Wayland
|
||||
remain available to Steam, native apps and emulators. Regenerate the inventories and add the new
|
||||
version to `versions.txt` when publishing another desktop pin; unknown versions cannot be removed.
|
||||
|
||||
Removal checks file size and SHA-256, or the exact symlink target, before unlinking. Base-runtime
|
||||
pacman files and emulator bundle paths are protected even when they overlap an application.
|
||||
It never follows parent symlinks or recursively deletes directories. Home, added apps, custom
|
||||
files and modified package files stay. A pending marker disables the installed state and allows
|
||||
retry after interruption. Installing the desktop again repairs its package files and clears it.
|
||||
The old LXQt applications are cleaned after KDE installation and before the next guest launch on
|
||||
an already-upgraded runtime, protecting both KDE inventories as well as the runtime and emulators.
|
||||
Only files owned by `lxqt-applications.txt`'s application packages are candidates; dependencies
|
||||
stay even when the old runtime's pacman database does not record them. In particular, gamescope
|
||||
still needs the old package's libseat. The source LXQt application archives are the versions in
|
||||
the published `steamdeck-desktop-r1/desktop.packages.txt`; verify their `.sig` files with
|
||||
`gpgv --keyring tools/desktop-kde/archlinuxarm-builder.gpg` and the Build System fingerprint used
|
||||
by `build.sh`. Put their filenames in `selected.txt` in the LXQt cache. `sources.json` records
|
||||
their SHA-256 values; file identities still come from the checksum-pinned published desktop.
|
||||
@@ -0,0 +1,17 @@
|
||||
# Application packages from steamdeck-desktop-r1's desktop.packages.txt.
|
||||
# Keep dependencies and shared apps/icons (Firefox, mpv, Breeze, xdg-utils and portals).
|
||||
labwc
|
||||
lxqt-panel
|
||||
lxqt-config
|
||||
lxqt-runner
|
||||
lxqt-session
|
||||
lxqt-wayland-session
|
||||
lxqt-themes
|
||||
lxqt-qtplugin
|
||||
pcmanfm-qt
|
||||
qterminal
|
||||
featherpad
|
||||
lximage-qt
|
||||
papirus-icon-theme
|
||||
swaybg
|
||||
wlr-randr
|
||||
@@ -0,0 +1,121 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Generate removal inventories from checksum-pinned published archives.
|
||||
|
||||
Usage: removal-manifests.py <LXQt tar.zst> <KDE r1 tar.zst> <KDE r2 tar.zst>
|
||||
<emulators tar.zst> <verified KDE package cache> <output dir>
|
||||
<verified LXQt package cache>
|
||||
Removal includes desktop applications/themes and our overlay, not their shared dependencies.
|
||||
The KDE cache is verified against the published desktop-kde.packages.txt before use.
|
||||
The LXQt cache contains the signed application packages listed by desktop.packages.txt;
|
||||
verify their Arch Linux ARM Build System signatures before generating the inventory.
|
||||
"""
|
||||
import gzip
|
||||
import hashlib
|
||||
import json
|
||||
import pathlib
|
||||
import subprocess
|
||||
import sys
|
||||
import tarfile
|
||||
|
||||
PINS = [
|
||||
('lxqt-r1', 'c2bb860b3b1688287451e2495be5db313ec07f8c8af501dfac2768a9f417bc86'),
|
||||
('desktop-kde-r1', '55747e75d0ec055ab7ea1e92a757f3be227cc3205bb9101f5b53cadef6318579'),
|
||||
('desktop-kde-r2', '9ba832677b498654136c69d8c8330434d17e4d53cd099acac9bde3ba429b35bf'),
|
||||
('emulators-r1', 'a1f4806a9663d28f424b4cab1277e0ede80a92e69de5bc063cdc8b45af220164'),
|
||||
]
|
||||
SHARED_SEEDS = {'xorg-xwayland', 'qt6-wayland', 'wayland-utils', 'noto-fonts', 'noto-fonts-emoji', 'xdg-utils'}
|
||||
|
||||
|
||||
def sha(file):
|
||||
with open(file, 'rb') as stream:
|
||||
return hashlib.file_digest(stream, 'sha256').hexdigest()
|
||||
|
||||
|
||||
def inventory(archive, digest):
|
||||
if sha(archive) != digest:
|
||||
raise ValueError(f'{archive}: checksum differs from the published pin')
|
||||
entries = {}
|
||||
process = subprocess.Popen(['zstd', '-dc', str(archive)], stdout=subprocess.PIPE)
|
||||
try:
|
||||
with tarfile.open(fileobj=process.stdout, mode='r|') as tar:
|
||||
for entry in tar:
|
||||
path = entry.name.removeprefix('./').rstrip('/')
|
||||
assert not any(c in path for c in '\t\n\r') and '..' not in path.split('/') and not path.startswith('/')
|
||||
if entry.isfile():
|
||||
entries[path] = f'F\t{entry.size}\t{hashlib.file_digest(tar.extractfile(entry), "sha256").hexdigest()}\t{path}'
|
||||
elif entry.issym():
|
||||
assert not any(c in entry.linkname for c in '\t\n\r')
|
||||
entries[path] = f'L\t0\t{entry.linkname}\t{path}'
|
||||
elif entry.islnk():
|
||||
target = entry.linkname.removeprefix('./')
|
||||
record = entries[target].split('\t', 3)
|
||||
entries[path] = '\t'.join(record[:3] + [path])
|
||||
finally:
|
||||
process.stdout.close()
|
||||
if process.wait() != 0:
|
||||
raise ValueError('zstd failed')
|
||||
return entries
|
||||
|
||||
|
||||
def write(out, name, records):
|
||||
with open(out / name, 'wb') as stream:
|
||||
with gzip.GzipFile(fileobj=stream, mode='wb', mtime=0, filename='') as gz:
|
||||
gz.write(('\n'.join(sorted(set(records))) + '\n').encode())
|
||||
|
||||
|
||||
def main():
|
||||
archives = [pathlib.Path(p) for p in sys.argv[1:5]]
|
||||
cache, out, legacy_cache = map(pathlib.Path, sys.argv[5:8])
|
||||
here = pathlib.Path(__file__).resolve().parent
|
||||
seeds = {line.strip() for line in (here / 'seeds.txt').read_text().splitlines() if line.strip() and not line.startswith('#')} - SHARED_SEEDS
|
||||
# Published source package hashes; the caller places this beside the verified cache.
|
||||
packages = dict(line.split() for line in (cache / 'desktop-kde.packages.txt').read_text().splitlines())
|
||||
selected = set()
|
||||
found = set()
|
||||
for filename, digest in packages.items():
|
||||
package = filename.rsplit('-', 3)[0]
|
||||
if package not in seeds:
|
||||
continue
|
||||
archive = cache / filename
|
||||
if sha(archive) != digest:
|
||||
raise ValueError(f'{filename}: source package checksum mismatch')
|
||||
with tarfile.open(archive) as tar:
|
||||
selected.update(e.name.removeprefix('./').rstrip('/') for e in tar if not e.isdir())
|
||||
found.add(package)
|
||||
assert found == seeds, f'missing desktop packages: {seeds - found}'
|
||||
selected.update(str(p.relative_to(here / 'overlay')) for p in (here / 'overlay').rglob('*') if p.is_file())
|
||||
inventories = [inventory(p, pin[1]) for p, pin in zip(archives, PINS)]
|
||||
out.mkdir(parents=True, exist_ok=True)
|
||||
# The old runtime's pacman database omits some gamescope dependencies (e.g. libseat).
|
||||
# Own only the LXQt application packages, never their dependency closure.
|
||||
legacy_seeds = {line.strip() for line in (here / 'lxqt-applications.txt').read_text().splitlines()
|
||||
if line.strip() and not line.startswith('#')}
|
||||
legacy_selected = set()
|
||||
legacy_sources = {}
|
||||
legacy_found = set()
|
||||
for filename in (legacy_cache / 'selected.txt').read_text().splitlines():
|
||||
package = filename.rsplit('-', 3)[0]
|
||||
if package not in legacy_seeds:
|
||||
continue
|
||||
archive = legacy_cache / filename
|
||||
with tarfile.open(archive) as tar:
|
||||
legacy_selected.update(e.name.removeprefix('./').rstrip('/') for e in tar if not e.isdir())
|
||||
legacy_sources[filename] = sha(archive)
|
||||
legacy_found.add(package)
|
||||
assert legacy_found == legacy_seeds, f'missing LXQt applications: {legacy_seeds - legacy_found}'
|
||||
legacy_selected.update({'usr/local/bin/steamdeck-desktop', 'usr/local/bin/steamdeck-steam'})
|
||||
write(out, 'lxqt-r1.tsv.gzip', [record for path, record in inventories[0].items() if path in legacy_selected])
|
||||
write(out, 'kde-remove.tsv.gzip', [record for inv in inventories[1:3] for path, record in inv.items() if path in selected])
|
||||
write(out, 'kde-keep.txt.gzip', [path for inv in inventories[1:3] for path in inv])
|
||||
write(out, 'emulators-keep.txt.gzip', inventories[3])
|
||||
(out / 'versions.txt').write_text('desktop-kde-r1\ndesktop-kde-r2\n')
|
||||
(out / 'sources.json').write_text(json.dumps({'archives': dict(PINS), 'desktopApplications': {n: h for n, h in packages.items() if n.rsplit('-', 3)[0] in seeds}, 'legacyApplications': legacy_sources}, indent=2) + '\n')
|
||||
for name, digest in PINS:
|
||||
print(name, digest)
|
||||
print('KDE removable paths', sum(path in selected for path in inventories[2]))
|
||||
print('KDE removable bytes', sum(int(record.split('\t')[1]) for path, record in inventories[2].items() if path in selected))
|
||||
print('LXQt removable paths', sum(path in legacy_selected for path in inventories[0]))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -1,5 +1,6 @@
|
||||
"""Attest prepared runtime inputs and reject stale local or CI APK payloads."""
|
||||
import hashlib
|
||||
import gzip
|
||||
import json
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
@@ -15,7 +16,7 @@ SOURCE_PATHS = ['app/build.gradle', 'app/src/main/cpp/fakeinput_steam.cpp', 'app
|
||||
'tools/linuxfs', 'tools/proot', 'tools/aaudio-sink', 'tools/directaudio',
|
||||
'tools/gamescope/release.env', 'tools/droiddeck-esync/release.env',
|
||||
'tools/mangoapp', 'tools/msitools', 'tools/build_local.sh',
|
||||
'tools/release/runtime_inputs.py']
|
||||
'tools/release/runtime_inputs.py', 'app/src/main/assets/desktop-removal']
|
||||
|
||||
|
||||
def digest(path):
|
||||
@@ -39,7 +40,7 @@ def sources(root):
|
||||
|
||||
def outputs(root):
|
||||
result = {}
|
||||
for tree in ['linuxfs', 'directaudio', 'droiddeck-esync']:
|
||||
for tree in ['linuxfs', 'directaudio', 'droiddeck-esync', 'desktop-removal']:
|
||||
base = root / 'app/src/main/assets' / tree
|
||||
for path in base.rglob('*'):
|
||||
if path.is_file() and not any(part.startswith('.') for part in path.relative_to(base).parts):
|
||||
@@ -69,6 +70,9 @@ def required():
|
||||
paths += ['assets/droiddeck-esync/index.json', 'assets/droiddeck-esync/index.json.sig',
|
||||
'lib/arm64-v8a/libproot.so', 'lib/arm64-v8a/libproot-loader.so',
|
||||
'lib/arm64-v8a/libdirectaudiorelay.so', 'assets/pulseaudio.tzst']
|
||||
paths += ['assets/desktop-removal/' + name for name in
|
||||
['lxqt-r1.tsv.gzip', 'kde-remove.tsv.gzip', 'kde-keep.txt.gzip',
|
||||
'emulators-keep.txt.gzip', 'versions.txt', 'sources.json']]
|
||||
return paths
|
||||
|
||||
|
||||
@@ -84,6 +88,12 @@ def record(root=ROOT):
|
||||
missing = [name for name in required() if name not in paths or not (root / paths[name]).is_file()]
|
||||
if missing:
|
||||
raise ValueError('Missing runtime inputs:\n' + '\n'.join(missing))
|
||||
for name, path in paths.items():
|
||||
if name.startswith('assets/desktop-removal/') and name.endswith('.gzip'):
|
||||
try:
|
||||
gzip.decompress((root / path).read_bytes())
|
||||
except (OSError, EOFError) as error:
|
||||
raise ValueError('Invalid desktop removal inventory: ' + name) from error
|
||||
# Check inside the compressed payload, where a plain Gradle build used to ship no sinks.
|
||||
process = subprocess.Popen(['zstd', '-dc', str(root / paths['assets/pulseaudio.tzst'])], stdout=subprocess.PIPE)
|
||||
try:
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import gzip
|
||||
from pathlib import Path
|
||||
import unittest
|
||||
|
||||
|
||||
ASSETS = Path(__file__).resolve().parents[2] / 'app/src/main/assets/desktop-removal'
|
||||
|
||||
|
||||
class DesktopRemovalInventoryTest(unittest.TestCase):
|
||||
def test_legacy_inventory_removes_the_shell_and_retains_gamescope_dependencies(self):
|
||||
records = gzip.decompress((ASSETS / 'lxqt-r1.tsv.gzip').read_bytes()).decode().splitlines()
|
||||
paths = {record.split('\t', 3)[3] for record in records}
|
||||
self.assertIn('usr/bin/lxqt-session', paths)
|
||||
self.assertIn('usr/bin/labwc', paths)
|
||||
self.assertIn('usr/local/bin/steamdeck-desktop', paths)
|
||||
# The runtime pacman database did not protect libseat on the Thor. Removing it
|
||||
# made gamescope and every Steam/native session exit 127 after desktop cleanup.
|
||||
self.assertNotIn('usr/lib/libseat.so.1', paths)
|
||||
self.assertNotIn('usr/lib/libseat.so', paths)
|
||||
self.assertFalse(any(p.startswith('usr/lib/libSDL2') for p in paths))
|
||||
self.assertFalse(any(p.startswith(('root/', 'opt/', 'var/')) for p in paths))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -1,4 +1,5 @@
|
||||
import importlib.util
|
||||
import gzip
|
||||
import io
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
@@ -22,7 +23,7 @@ class RuntimeInputsTest(unittest.TestCase):
|
||||
for name in runtime.required():
|
||||
path = self.root / paths.get(name, 'app/src/main/' + name)
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_bytes(b'prepared runtime')
|
||||
path.write_bytes(gzip.compress(b'inventory') if path.suffix == '.gzip' else b'prepared runtime')
|
||||
self.source = self.root / 'tools/linuxfs/preload/test.c'
|
||||
self.source.parent.mkdir(parents=True)
|
||||
self.source.write_text('current source')
|
||||
@@ -73,4 +74,29 @@ class RuntimeInputsTest(unittest.TestCase):
|
||||
|
||||
def test_complete_current_payload_passes(self):
|
||||
runtime.record(self.root)
|
||||
runtime.verify(self.root)
|
||||
data = runtime.verify(self.root)
|
||||
apk = self.root / 'current.apk'
|
||||
with ZipFile(apk, 'w') as package:
|
||||
for name, output in data['outputs'].items():
|
||||
package.writestr(name, (self.root / output['path']).read_bytes())
|
||||
runtime.check_apk(apk, self.root)
|
||||
|
||||
def test_android_expanding_or_renaming_a_compressed_inventory_is_rejected(self):
|
||||
runtime.record(self.root)
|
||||
data = runtime.verify(self.root)
|
||||
apk = self.root / 'expanded.apk'
|
||||
with ZipFile(apk, 'w') as package:
|
||||
for name, output in data['outputs'].items():
|
||||
content = (self.root / output['path']).read_bytes()
|
||||
if name.endswith('.gzip'):
|
||||
name = name.removesuffix('.gzip')
|
||||
content = gzip.decompress(content)
|
||||
package.writestr(name, content)
|
||||
with self.assertRaisesRegex(ValueError, 'APK missing assets/desktop-removal/'):
|
||||
runtime.check_apk(apk, self.root)
|
||||
|
||||
def test_malformed_removal_inventory_cannot_be_attested(self):
|
||||
path = self.root / 'app/src/main/assets/desktop-removal/kde-remove.tsv.gzip'
|
||||
path.write_bytes(b'not a gzip stream')
|
||||
with self.assertRaisesRegex(ValueError, 'Invalid desktop removal inventory'):
|
||||
runtime.record(self.root)
|
||||
Reference in new issue
Block a user