Compare commits

..
Author SHA1 Message Date
The412Banner 2718df040a fix(components): fetch the bridge DXVK when the release listing is rate-limited 2026-12-06 09:16:56 +00:00
MaxsTechReview a8224c76a2 fix(components): pair native D3DX with its effect compilers (#3461) 2026-12-06 02:09:29 -05:00
DantalianandDantalian ed106ea840 fix(theme): pin the status bar black like the navigation bar (#3780)
Co-authored-by: Dantalian <Dantalian-dev@users.noreply.github.com>
2026-12-06 01:37:02 -05:00
The412Banner 96ae61541c fix(components): Match bundled .NET installers to their runtime
Detect modern .NET runtimes separately from .NET Framework and refresh cached detector results.
2026-12-06 01:06:57 -05:00
Tushar Gandhe a4751dacbe feat(settings): Keep search history and center opened settings
Recall recent Settings searches and bring the setting opened from search into view.
2026-12-06 00:34:44 -05:00
LunaDL f50691ebc9 fix(theme): Keep Inner Gamer animation from resetting screens
Keep the settings composition stable while the animated palette and speed change.
2026-12-06 00:03:11 -05:00
kalac2232 2ab642bf4e fix(session): Handle invalid filenames when trimming page cache
Walk files with NIO and skip unreadable entries. Keep page-cache trimming from interrupting session startup.
2026-12-05 23:34:33 -05:00
Kurt Himebauch cad55fc2b9 Keep adaptive sticks visible at rest
Separate adaptive stick capture from idle visibility and keep dock touch capture bounded.
2026-12-05 23:33:11 -05:00
66 changed files with 678 additions and 205 deletions

No files matched your search

@@ -28,7 +28,8 @@ object AutoComponents {
else -> game.appId.takeIf { it > 0 }?.toString()
}
fun autoPicks(findings: List<WinCompSources.Finding>, catalog: Map<String, WinComponents.Component>): Map<String, WinComponents.AutoReason> {
fun autoPicks(findings: List<WinCompSources.Finding>, catalog: Map<String, WinComponents.Component>,
user: Map<String, Boolean> = emptyMap()): Map<String, WinComponents.AutoReason> {
val out = LinkedHashMap<String, WinComponents.AutoReason>()
for (f in findings) {
if (!f.auto || f.component == null) continue
@@ -37,6 +38,13 @@ object AutoComponents {
if (WinComponents.support(c, catalog) != WinComponents.Support.READY) continue
if (id !in out) out[id] = WinComponents.AutoReason(f.origin.name, listOf(f.original) + f.args)
}
if (user["d3dx9"] != false && (user["d3dx9"] == true || "d3dx9" in out)) {
val reason = out["d3dx9"] ?: WinComponents.AutoReason(WinCompSources.Origin.FOLDER.name, listOf("d3dx9"))
for (id in listOf("d3dcompiler_42", "d3dcompiler_43")) {
val c = catalog[id] ?: continue
if (WinComponents.support(c, catalog) == WinComponents.Support.READY) out.putIfAbsent(id, reason)
}
}
return out
}
@@ -228,8 +236,8 @@ object AutoComponents {
val findings = findings(context, game)
val refreshed = if (knownCatalog == null && asked && online(context)) catalogOf(context, true) else null
val catalog = knownCatalog ?: (refreshed ?: catalogOf(context, false) ?: catalogOf(context, true))?.associateBy { it.name } ?: return
val wanted = autoPicks(findings, catalog)
val user = WinComponents.selection(context, key).user
val wanted = autoPicks(findings, catalog, user)
val before = WinComponents.selection(context, key).auto
val installed = installedOf(context)
val kept = LinkedHashMap<String, WinComponents.AutoReason>()
@@ -373,7 +381,7 @@ object AutoComponents {
private const val FINDINGS = "wincomp-findings.json"
private const val DETECTORS = "d3"
private const val DETECTORS = "d4"
internal fun signature(context: Context, game: Library.SteamGame): String {
val folder = game.gameFiles
@@ -452,9 +460,9 @@ object AutoComponents {
}
return pendingSaved && pending.isEmpty()
}
val wanted = autoPicks(findings, catalog)
val selection = WinComponents.selection(context, key)
val user = selection.user
val wanted = autoPicks(findings, catalog, user)
val installed = installedOf(context)
val roots = selection.effective + wanted.keys.filter { user[it] != false }
val required = withParts(roots.filter { WinComponents.validId(it) }, catalog)
@@ -42,6 +42,7 @@ object DependencyDetector {
"dotnet45" to ".NET Framework 4.5", "dotnet452" to ".NET Framework 4.5.2",
"dotnet46" to ".NET Framework 4.6", "dotnet472" to ".NET Framework 4.7.2",
"dotnet48" to ".NET Framework 4.8", "dotnet35" to ".NET Framework 3.5",
"dotnetcoredesktop3" to ".NET Desktop 3", "dotnet50" to ".NET 5",
"dotnetcoredesktop6" to ".NET Desktop 6", "dotnetcoredesktop7" to ".NET Desktop 7",
"dotnetcoredesktop8" to ".NET Desktop 8",
)
@@ -50,7 +51,7 @@ object DependencyDetector {
"vcredist2005", "vcredist2008", "vcredist2010", "vcredist2012", "vcredist2013",
"vcredist2015", "vcredist2019", "vcredist2022",
"dotnet35", "dotnet40", "dotnet45", "dotnet452", "dotnet46", "dotnet472", "dotnet48",
"dotnetcoredesktop6", "dotnetcoredesktop7", "dotnetcoredesktop8",
"dotnetcoredesktop3", "dotnet50", "dotnetcoredesktop6", "dotnetcoredesktop7", "dotnetcoredesktop8",
"d3dx9", "d3dx11", "xact", "xact_x64", "xna31", "xna40", "physx", "oalinst", "XLiveRedist",
)
@@ -148,7 +149,7 @@ object DependencyDetector {
val comp = dotnetComponent("$path $name")
return when {
comp != null -> listOf(comp)
isDir -> emptyList()
isDir || CORE_RUNTIME.containsMatchIn(path) -> emptyList()
else -> listOf("dotnet48")
}
}
@@ -172,10 +173,20 @@ object DependencyDetector {
private val D3DX11_RE = Regex("""d3dx11_\d+\.dll""")
private val D3DCOMPILER_RE = Regex("""d3dcompiler_\d+\.dll""")
private fun dotnetComponent(s: String): String? = when {
s.contains("desktop-runtime-8") || Regex("""\b8\.\d""").containsMatchIn(s) -> "dotnetcoredesktop8"
s.contains("desktop-runtime-7") || Regex("""\b7\.\d""").containsMatchIn(s) -> "dotnetcoredesktop7"
s.contains("desktop-runtime-6") || Regex("""\b6\.\d""").containsMatchIn(s) -> "dotnetcoredesktop6"
private val CORE_RUNTIME = Regex("""(?:windowsdesktop|dotnet)-runtime-(\d+)\.""")
private val CORE_RUNTIMES = mapOf(
"3" to "dotnetcoredesktop3", "5" to "dotnet50", "6" to "dotnetcoredesktop6", "7" to "dotnetcoredesktop7", "8" to "dotnetcoredesktop8",
)
private fun dotnetComponent(s: String): String? {
CORE_RUNTIME.find(s)?.let { return CORE_RUNTIMES[it.groupValues[1]] }
return byVersion(s)
}
private fun byVersion(s: String): String? = when {
s.contains("desktop-runtime-8") || Regex("""(?<![\d.])8\.\d""").containsMatchIn(s) -> "dotnetcoredesktop8"
s.contains("desktop-runtime-7") || Regex("""(?<![\d.])7\.\d""").containsMatchIn(s) -> "dotnetcoredesktop7"
s.contains("desktop-runtime-6") || Regex("""(?<![\d.])6\.\d""").containsMatchIn(s) -> "dotnetcoredesktop6"
s.contains("ndp48") || s.contains("fx48") || s.contains("4.8") -> "dotnet48"
s.contains("ndp472") || s.contains("4.7.2") -> "dotnet472"
s.contains("ndp46") || s.contains("4.6") -> "dotnet46"
@@ -3,6 +3,7 @@ package com.droiddeck.launcher.frontend
import android.content.Context
import android.util.Log
import com.droiddeck.launcher.runtime.LinuxRuntime
import com.droiddeck.launcher.session.ComponentsManager
import com.droiddeck.launcher.session.GameStorage
import com.droiddeck.launcher.session.SessionState
import java.io.File
@@ -59,6 +60,8 @@ object SessionInstalls {
Library.SteamGame(m.appId, m.name.ifEmpty { m.appId.toString() }, null, m.steamapps.parentFile?.path ?: "steam",
gameFiles = File(m.steamapps, "common/${m.installDir}"), source = Library.SOURCE_STEAM)
internal fun isProton(m: Manifest): Boolean = ComponentsManager.isProtonTree(File(m.steamapps, "common/${m.installDir}"))
fun watch(context: Context) {
val app = context.applicationContext
Thread({
@@ -71,6 +74,7 @@ object SessionInstalls {
while (SessionState.running) {
for (m in watch.poll()) {
Log.i(TAG, "wincomp: ${m.name} (${m.appId}) finished installing in the session")
if (isProton(m)) ComponentsManager.settleAutoDxvk(app)
AutoComponents.queueInSession(app, gameOf(m))
}
Thread.sleep(POLL_MS)
@@ -156,7 +156,13 @@ object InputLibraries {
update(context) { library ->
library.copy(layouts = library.layouts.map { layout ->
if (layout.id != layoutId || !layout.editable) layout
else layout.copy(elements = layout.elements.map { if (it.kind == InputElementKind.STICK) it.copy(floating = on, hideWhenIdle = on) else it })
else {
fun updateSticks(elements: List<InputSurfaceElement>) = elements.map {
if (it.kind == InputElementKind.STICK) it.copy(floating = on, hideWhenIdle = it.hideStickAtRest, adaptiveCapture = on)
else it
}
layout.copy(elements = updateSticks(layout.elements), rotated = updateSticks(layout.rotated))
}
})
}
}.onSuccess { ControllerPrefs.setAdaptiveSticks(context, on) }.isSuccess
@@ -328,7 +334,8 @@ object InputLibraries {
for (e in list) elements.put(JSONObject().put("id", e.id).put("kind", e.kind.name)
.put("control", e.control.id).put("name", e.name).put("x", e.x.toDouble()).put("y", e.y.toDouble())
.put("width", e.width.toDouble()).put("height", e.height.toDouble()).put("floating", e.floating).put("hideWhenIdle", e.hideWhenIdle).put("mouseGestures", e.mouseGestures).put("toggle", e.toggle).put("icon", e.icon).put("image", e.image)
.put("elementOpacity", e.opacity.toDouble()).put("buttonShape", e.buttonShape.name).put("showLabel", e.showLabel).put("alwaysShown", e.alwaysShown))
.put("elementOpacity", e.opacity.toDouble()).put("buttonShape", e.buttonShape.name).put("showLabel", e.showLabel).put("alwaysShown", e.alwaysShown)
.put("adaptiveCapture", e.adaptiveCapture))
}
private fun decodeElements(array: JSONArray) = array.objects(64).map { e ->
@@ -336,7 +343,8 @@ object InputLibraries {
e.getDouble("y").toFloat(), e.getDouble("width").toFloat(), e.getDouble("height").toFloat(),
e.getString("id"), InputElementKind.valueOf(e.getString("kind")), e.getString("name"),
e.optBoolean("floating", true), e.optBoolean("hideWhenIdle", false), e.optBoolean("mouseGestures", false), e.optBoolean("toggle", false), e.optInt("icon", 0), e.optString("image", ""),
e.optDouble("elementOpacity", 1.0).toFloat(), InputButtonShape.valueOf(e.optString("buttonShape", InputButtonShape.ROUNDED.name)), e.optBoolean("showLabel", true), e.optBoolean("alwaysShown", false))
e.optDouble("elementOpacity", 1.0).toFloat(), InputButtonShape.valueOf(e.optString("buttonShape", InputButtonShape.ROUNDED.name)), e.optBoolean("showLabel", true), e.optBoolean("alwaysShown", false),
if (e.isNull("adaptiveCapture")) null else e.optBoolean("adaptiveCapture", false))
}
internal fun encode(library: InputLibrary): String {
@@ -32,7 +32,7 @@ data class SavedInputLayout(
fun withQuickButton(button: InputCommand, shown: Boolean) =
copy(style = style.copy(hidden = if (shown) style.hidden - button else style.hidden + button))
fun derived(id: String, name: String) = copy(id = id, name = name, origin = origin ?: this.id)
val adaptiveSticks get() = elements.filter { it.kind == InputElementKind.STICK }.takeIf { editable && it.isNotEmpty() }?.all { it.floating && it.hideWhenIdle }
val adaptiveSticks get() = elements.filter { it.kind == InputElementKind.STICK }.takeIf { editable && it.isNotEmpty() }?.all { it.adaptiveStick }
fun supports(role: InputRole) = screen.supports(role) && when (template) {
InputLayoutTemplate.OVERLAY -> role == InputRole.PRIMARY
InputLayoutTemplate.DECK, InputLayoutTemplate.TRACKPAD -> role == InputRole.SECONDARY
@@ -37,7 +37,12 @@ data class InputSurfaceElement(
val buttonShape: InputButtonShape = InputButtonShape.ROUNDED,
val showLabel: Boolean = true,
val alwaysShown: Boolean = false,
val adaptiveCapture: Boolean? = null,
) {
// Old layouts encoded Adaptive sticks as Floating + Hide when idle.
val adaptiveStick get() = kind == InputElementKind.STICK && floating && (adaptiveCapture ?: hideWhenIdle)
val hideStickAtRest get() = hideWhenIdle && (adaptiveCapture != null || !adaptiveStick)
val hasClick get() = kind == InputElementKind.STICK || kind == InputElementKind.TRACKPAD
fun bounded() = copy(x = x.coerceIn(0f, 0.97f), y = y.coerceIn(0f, 0.97f),
@@ -188,7 +188,7 @@ internal class LegacyGamepadLayout(private val context: Context, private val wid
settings.mapping[it.id] != ControllerPrefs.OFF && (it.id != "guide" || settings.steamButton) && (it.id != "qam" || settings.qamButton)
}.map { c ->
InputSurfaceElement(requireNotNull(InputControl.fromId(c.id)), (c.cx - c.halfW) / width, (c.cy - c.halfH) / height,
2 * c.halfW / width, 2 * c.halfH / height, floating = settings.adaptiveSticks, hideWhenIdle = c.stick >= 0 && settings.adaptiveSticks,
2 * c.halfW / width, 2 * c.halfH / height, floating = settings.adaptiveSticks, adaptiveCapture = if (c.stick >= 0) settings.adaptiveSticks else null,
buttonShape = if (c.id in shoulderIds) InputButtonShape.PILL else InputButtonShape.CIRCLE).let { if (previousStickGeometry) widenStickPreviously(it) else widenStick(it) }.bounded()
}.toMutableList()
if (settings.keyboardButton) result += keyboard()
@@ -37,8 +37,10 @@ object OnScreenLayout {
buttonsOnly: Boolean = false, dock: Dock? = null, rearButtons: Boolean? = null,
trackpads: Boolean? = null): List<InputSurfaceElement> {
val placed = placeElements(context, saved, width, height, safe, buttonsOnly, dock, rearButtons, trackpads)
// Below the game a stick covers nothing, so it keeps its base in view instead of appearing only under the thumb.
return if (dock == null) placed else placed.map { if (it.kind == InputElementKind.STICK) it.copy(hideWhenIdle = false) else it }
// Docked sticks stay visible and only pick up touches inside their own bounds.
return if (dock == null) placed else placed.map {
if (it.kind == InputElementKind.STICK) it.copy(hideWhenIdle = false, adaptiveCapture = false) else it
}
}
private fun placeElements(context: Context, saved: SavedInputLayout?, width: Int, height: Int, safe: Rect,
@@ -1316,6 +1316,16 @@ object ComponentsManager {
internal const val DXVK_FOR_VULKAN_1_1 = "dxvk-1.10.3-linux.wcp"
internal const val DXVK_FOR_VULKAN_1_3_NO_INT64 = "dxvk-2.6.2-linux.wcp"
internal val FORCED_ASSETS = listOf(
nightlyAsset(DXVK_FOR_VULKAN_1_1, "Dxvk-Linux", 2820271, "sha256:215b8b9715f2d51b4c93c166d92e0b68afcdce41ec5c8cbac093f8cc86051a77"),
nightlyAsset(DXVK_FOR_VULKAN_1_3_NO_INT64, "Dxvk-Linux", 3880066, "sha256:62f3dcafafd94d1e28776dadb5589a55fb08660a24736200e5f0638f59a84845"),
nightlyAsset("dxvk-2.7.1-linux.wcp", "Dxvk-Linux", 3970498, "sha256:998f5b375e759d63dbd7a8dbcfec1e0ebd7bfff9e2fbccfb045ae88b4ebccb38"),
nightlyAsset("dxvk-gplasync-2.7.1-1-linux.wcp", "Dxvk-gplasync-Linux", 3977394, "sha256:ecea141779def28e25340f5430b96efb2760d70763ea66c27e495f2fcc7794b1"),
)
private fun nightlyAsset(file: String, release: String, size: Long, digest: String) =
CatalogItem(file, RELEASES.getValue(release), release, "https://github.com/$NIGHTLIES/releases/download/$release/$file", size, digest)
private data class ForcedRule(
val pkg: ForcedPackage,
val auto: Boolean,
@@ -1462,7 +1472,7 @@ object ComponentsManager {
release: String,
cached: () -> List<CatalogItem>,
refresh: () -> List<CatalogItem>,
): CatalogItem? = catalogMatch(cached(), file, release) ?: catalogMatch(refresh(), file, release)
): CatalogItem? = catalogMatch(cached(), file, release) ?: catalogMatch(refresh(), file, release) ?: catalogMatch(FORCED_ASSETS, file, release)
fun download(context: Context, item: CatalogItem, progress: (Int) -> Unit): Package {
require(allowedDownload(item.url)) { context.getString(R.string.cmgr_nightlies_only) }
@@ -2,10 +2,16 @@ package com.droiddeck.launcher.session
import android.util.Log
import java.io.File
import java.io.IOException
import java.nio.file.FileVisitResult
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.SimpleFileVisitor
import java.nio.file.attribute.BasicFileAttributes
internal object PageCacheTrim {
private const val TAG = "PageCacheTrim"
private const val MIN_FILE_BYTES = 8L shl 20
internal const val MIN_FILE_BYTES = 8L shl 20
private const val POLL_MS = 3000L
private const val RESCAN_MS = 120_000L
@@ -37,7 +43,7 @@ internal object PageCacheTrim {
if (mem != null && shouldTrim(mem, baseline)) {
val now = System.currentTimeMillis()
if (now - scanned > RESCAN_MS) {
files = roots().flatMap { root -> root.walkTopDown().onEnter { !java.nio.file.Files.isSymbolicLink(it.toPath()) }.filter { it.isFile && it.length() >= MIN_FILE_BYTES }.toList() }
files = roots().flatMap { root -> bigFiles(root) }
scanned = now
}
val began = System.nanoTime()
@@ -56,6 +62,34 @@ internal object PageCacheTrim {
}, "page-cache-trim").apply { isDaemon = true }.start()
}
// java.io's directory listing hands raw entry names to JNI NewStringUTF, which aborts the
// process on names that are not valid UTF-8; NIO decodes them with replacement instead.
// Without FOLLOW_LINKS, symlinked directories are never descended into, like the old onEnter,
// except that a starting directory that is itself a link has to be resolved first; a link
// whose target has vanished yields an empty result instead of an error.
internal fun bigFiles(root: File): List<File> {
val out = ArrayList<File>()
val start = root.toPath()
val real = if (Files.isSymbolicLink(start)) {
try {
start.toRealPath()
} catch (_: IOException) {
return out
}
} else start
Files.walkFileTree(real, object : SimpleFileVisitor<Path>() {
override fun visitFile(file: Path, attrs: BasicFileAttributes): FileVisitResult {
if (attrs.isRegularFile && attrs.size() >= MIN_FILE_BYTES) out.add(file.toFile())
return FileVisitResult.CONTINUE
}
override fun visitFileFailed(file: Path, error: IOException): FileVisitResult = FileVisitResult.CONTINUE
override fun postVisitDirectory(dir: Path, error: IOException?): FileVisitResult = FileVisitResult.CONTINUE
})
return out
}
private fun drop(file: File) {
PageCacheNative.fadviseDontNeed(file.path)
}
@@ -10,6 +10,7 @@ import com.droiddeck.launcher.gpu.Cardboard
import com.droiddeck.launcher.gpu.ScreenEffects
import com.droiddeck.launcher.gpu.SystemVulkanDriver
import com.droiddeck.launcher.gpu.TurnipDriver
import org.json.JSONArray
import org.json.JSONObject
import java.io.File
@@ -317,6 +318,14 @@ object SessionPrefs {
prefs(context).edit().putBoolean("telemetryAuto", on).apply()
}
fun settingsSearches(context: Context): List<String> = runCatching {
JSONArray(prefs(context).getString("settingsSearches", null) ?: "[]").let { a -> List(a.length()) { a.getString(it) } }
}.getOrDefault(emptyList())
fun setSettingsSearches(context: Context, searches: List<String>) {
prefs(context).edit().putString("settingsSearches", JSONArray(searches).toString()).apply()
}
fun telemetryOff(context: Context): Set<String> = prefs(context).getStringSet("telemetryOff", null)?.toSet().orEmpty()
fun setTelemetryOff(context: Context, keys: Set<String>) {
@@ -231,7 +231,10 @@ internal fun SetupPanel(
}
val chipFocus = remember { List(tabs.size) { FocusRequester() } }
var tabTurned by remember { mutableStateOf(false) }
val pick: (Int) -> Unit = { i -> tab = i; tabTurned = true; searching = false; query = ""; if (i == DEVELOPER_TAB) logsRefresh++ }
remember { SettingsSearchHistory.load(ctx) }
var fromHistory by remember { mutableStateOf(false) }
val keepSearch = { if (searching && SettingsIndex.search(ctx, query, frostRow).isNotEmpty()) SettingsSearchHistory.add(ctx, query) }
val pick: (Int) -> Unit = { i -> keepSearch(); tab = i; tabTurned = true; searching = false; query = ""; if (i == DEVELOPER_TAB) logsRefresh++ }
val inputModeManager = LocalInputModeManager.current
LaunchedEffect(Unit) {
while (true) {
@@ -258,8 +261,9 @@ internal fun SetupPanel(
) {
val sectionBar: @Composable (Modifier) -> Unit = { m ->
SettingsPillSearch(
m, searching, query, { query = it },
onOpen = { searching = true }, onClose = { searching = false; query = "" },
m, searching, query, { query = it; fromHistory = false },
onOpen = { searching = true }, onClose = { keepSearch(); searching = false; query = "" },
keepOpen = SettingsSearchHistory.items.isNotEmpty(), onSearch = keepSearch,
) { SheetChips(tabs, tab, chipFocus, onPick = pick) }
}
val portrait = androidx.compose.ui.platform.LocalConfiguration.current.orientation == android.content.res.Configuration.ORIENTATION_PORTRAIT
@@ -268,9 +272,11 @@ internal fun SetupPanel(
Row(Modifier.fillMaxWidth().padding(bottom = 10.dp)) { sectionBar(Modifier.weight(1f)) }
} else PageHeader(stringResource(R.string.setup_title)) { sectionBar(Modifier.weight(1f)) }
val listing = searching && query.isNotBlank()
val fixed = tab == CONTROLLER_TAB && !listing
val history = searching && query.isBlank() && SettingsSearchHistory.items.isNotEmpty()
val fixed = tab == CONTROLLER_TAB && !listing && !history
Column(modifier = Modifier.weight(1f).fillMaxWidth().then(if (fixed) Modifier else Modifier.verticalScroll(rememberScrollState())).padding(bottom = if (fixed) 0.dp else 24.dp)) {
if (listing) SettingsSearchResults(query, frostRow) { section -> pick(section.ordinal) }
if (listing) SettingsSearchResults(query, frostRow, focusFirst = fromHistory, onSearched = keepSearch) { section -> pick(section.ordinal) }
else if (history) SettingsSearchHistoryList(onPick = { fromHistory = true; query = it }) { SettingsSearchHistory.clear(ctx) }
else when (tab) {
OVERVIEW_TAB -> {
OnboardingCard(limitBlocks, a.onShowPhantomGate)
@@ -67,8 +67,18 @@ internal fun InputElementProperties(element: InputSurfaceElement, action: InputA
}
if (element.kind == InputElementKind.STICK) {
val host = rememberMenuHost()
ToggleRow(host, "element-floating", stringResource(R.string.input_floating_stick), null, element.floating) { onChange(element.copy(floating = it)) }
ToggleRow(host, "element-hide-idle", stringResource(R.string.input_hide_idle), null, element.hideWhenIdle) { onChange(element.copy(hideWhenIdle = it)) }
val adaptive = element.adaptiveCapture ?: element.adaptiveStick
ToggleRow(host, "element-floating", stringResource(R.string.input_floating_stick), null, element.floating) {
onChange(element.copy(floating = it, hideWhenIdle = element.hideStickAtRest, adaptiveCapture = adaptive))
}
if (element.floating) {
ToggleRow(host, "element-adaptive-capture", stringResource(R.string.input_adaptive_capture), null, element.adaptiveStick) {
onChange(element.copy(hideWhenIdle = element.hideStickAtRest, adaptiveCapture = it))
}
}
ToggleRow(host, "element-hide-idle", stringResource(R.string.input_hide_idle), null, element.hideStickAtRest) {
onChange(element.copy(hideWhenIdle = it, adaptiveCapture = adaptive))
}
}
val host = rememberMenuHost()
if ((element.kind == InputElementKind.BUTTON || element.kind == InputElementKind.TRIGGER) && element.icon == 0 && element.image.isEmpty() ||
@@ -236,11 +236,11 @@ class InputSurfaceView(
super.dispatchDraw(canvas)
}
}
canvas.clipChildren = customLayout.none { it.kind == InputElementKind.STICK && (classic(it) || adaptive(it)) }
canvas.clipChildren = customLayout.none { it.kind == InputElementKind.STICK && (classic(it) || it.adaptiveStick) }
for (element in customLayout) {
val source = pad?.let { InputSurfaceSource(it, inputRole, element).also { s -> elementSources += s } }
canvas.addView(when (element.kind) {
InputElementKind.STICK -> StickView(context, element, source, element.floating, element.hideWhenIdle && pad != null)
InputElementKind.STICK -> StickView(context, element, source, element.floating, element.hideStickAtRest && pad != null)
InputElementKind.TRACKPAD -> TrackpadView(context, element.control == InputControl.RIGHT_PAD, captioned = element.showLabel,
stock = element.id == "legacy:${element.control.id}", source = source)
InputElementKind.DPAD -> DirectionPad(context, element, source)
@@ -641,7 +641,7 @@ class InputSurfaceView(
private val ring = Paint(Paint.ANTI_ALIAS_FLAG).apply { style = Paint.Style.STROKE }
private val knob = Paint(Paint.ANTI_ALIAS_FLAG)
val adaptive get() = adaptive(element)
val adaptive get() = element.adaptiveStick
fun reach() = min(width, height) * if (classic(element)) CLASSIC_REACH else PANEL_REACH
@@ -859,8 +859,6 @@ class InputSurfaceView(
private val TEXT_DIM = Color.rgb(0x7A, 0x80, 0x8A)
private val KNOB = Color.rgb(0x2A, 0x2D, 0x33)
private fun adaptive(element: InputSurfaceElement) = element.kind == InputElementKind.STICK && element.floating && element.hideWhenIdle
private fun classic(element: InputSurfaceElement) = (element.id == "legacy:${element.control.id}" || element.id == "builtin:keyboard") &&
(element.buttonShape == InputButtonShape.CIRCLE || element.buttonShape == InputButtonShape.PILL)
@@ -16,6 +16,10 @@ import androidx.compose.runtime.setValue
import androidx.compose.runtime.withFrameNanos
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.layout.LayoutCoordinates
import androidx.compose.ui.layout.onPlaced
/** The row a settings search result opens, so the page it lands on can scroll to it and flash it. */
internal object SettingsJump {
@@ -31,12 +35,32 @@ private const val JUMP_WINDOW_MS = 5_000L
/** False in the search results, whose rows carry the same labels as the rows they open. */
internal val LocalSearchTargets = staticCompositionLocalOf { true }
/** How far a page has to be scrolled to show a row in its middle, or as near to it as the page's ends allow. */
internal fun centeredScroll(rowTop: Float, rowHeight: Float, page: Float, content: Float): Float =
(rowTop + rowHeight / 2f - page / 2f).coerceIn(0f, (content - page).coerceAtLeast(0f))
/** The part of the page to show around a row to have it in the middle, relative to the row. Null when nothing around it scrolls. */
private fun pageAround(row: LayoutCoordinates): Rect? {
var content = row
while (true) {
val page = content.parentCoordinates ?: return null
if (content.size.height > page.size.height) {
val top = content.localPositionOf(row, Offset.Zero).y
val height = page.size.height.toFloat()
val from = centeredScroll(top, row.size.height.toFloat(), height, content.size.height.toFloat()) - top
return Rect(0f, from, row.size.width.toFloat(), from + height)
}
content = page
}
}
@OptIn(androidx.compose.foundation.ExperimentalFoundationApi::class)
@Composable
internal fun Modifier.searchTarget(label: String): Modifier {
val pal = LocalPalette.current
val flash = remember { Animatable(0f) }
val reveal = remember { BringIntoViewRequester() }
val row = remember { arrayOfNulls<LayoutCoordinates>(1) }
var claimed by remember { mutableStateOf<SettingsJump.Target?>(null) }
val target = SettingsJump.target.takeIf { LocalSearchTargets.current }
if (target != null && target.label == label) SideEffect {
@@ -48,7 +72,7 @@ internal fun Modifier.searchTarget(label: String): Modifier {
claimed?.let { mine ->
LaunchedEffect(mine) {
withFrameNanos { }
reveal.bringIntoView()
reveal.bringIntoView(row[0]?.takeIf { it.isAttached }?.let(::pageAround))
repeat(2) {
flash.animateTo(1f, tween(220))
flash.animateTo(0f, tween(420))
@@ -56,7 +80,7 @@ internal fun Modifier.searchTarget(label: String): Modifier {
claimed = null
}
}
return bringIntoViewRequester(reveal).drawBehind {
return bringIntoViewRequester(reveal).onPlaced { row[0] = it }.drawBehind {
if (flash.value > 0f) drawRect(pal.signal.copy(alpha = 0.28f * flash.value))
}
}
@@ -42,7 +42,7 @@ import androidx.compose.ui.semantics.clearAndSetSemantics
@Composable
internal fun SettingsPillSearch(
modifier: Modifier, searching: Boolean, query: String, onQuery: (String) -> Unit,
onOpen: () -> Unit, onClose: () -> Unit, pills: @Composable () -> Unit,
onOpen: () -> Unit, onClose: () -> Unit, keepOpen: Boolean = false, onSearch: () -> Unit = {}, pills: @Composable () -> Unit,
) {
val colors = MaterialTheme.colorScheme
val open by animateFloatAsState(if (searching) 1f else 0f, Motion.sp(0.75f, 420f), label = "settingsSearch")
@@ -53,10 +53,11 @@ internal fun SettingsPillSearch(
var fieldFocused by remember { mutableStateOf(false) }
CancelPendingFocus(focusOnOpen, focusTap, fieldFocused) {
focusOnOpen = false
if (query.isEmpty()) onClose()
if (query.isEmpty() && !keepOpen) onClose()
}
val close = { toIcon = true; focusOnOpen = false; onClose() }
BackHandler(enabled = searching) { close() }
LaunchedEffect(keepOpen) { if (!keepOpen && searching && !fieldFocused && !focusOnOpen && query.isEmpty()) close() }
LaunchedEffect(toIcon, searching, open <= 0.01f) {
if (searching) toIcon = false
else if (toIcon && open <= 0.01f) { focusSoon { icon }; toIcon = false }
@@ -80,10 +81,13 @@ internal fun SettingsPillSearch(
AdbTextField(
value = query, onValueChange = onQuery, label = "", keyboardType = KeyboardType.Text, imeAction = ImeAction.Search,
placeholder = stringResource(R.string.settings_search), compact = true, showLabel = false, focusOnShow = focusOnOpen, focusAtTap = focusTap,
clearFocus = !searching,
clearFocus = !searching, onDone = onSearch,
onFocusChange = { focused ->
fieldFocused = focused
if (!focused && query.isEmpty() && searching) { focusOnOpen = false; onClose() }
if (!focused && query.isEmpty() && searching) {
focusOnOpen = false
if (!keepOpen) onClose()
}
},
)
}
@@ -96,13 +100,19 @@ internal fun SettingsPillSearch(
}
@Composable
internal fun SettingsSearchResults(query: String, frost: Boolean, onOpen: (SettingsSection) -> Unit) {
internal fun SettingsSearchResults(query: String, frost: Boolean, focusFirst: Boolean = false, onSearched: () -> Unit = {}, onOpen: (SettingsSection) -> Unit) {
val ctx = LocalContext.current
val found = remember(query, frost) { SettingsIndex.search(ctx, query, frost) }
if (found.isEmpty()) {
Note(stringResource(R.string.settings_search_none, query.trim()))
return
}
val first = remember { FocusRequester() }
val firstToOpen = found.groupBy { it.place }.values.flatten().firstOrNull { it.section != null || it.tab != null }
val inputMode = androidx.compose.ui.platform.LocalInputModeManager.current
LaunchedEffect(Unit) {
if (focusFirst && firstToOpen != null && inputMode.inputMode == androidx.compose.ui.input.InputMode.Keyboard) focusSoon { first }
}
androidx.compose.runtime.CompositionLocalProvider(LocalSearchTargets provides false) { Column {
found.groupBy { it.place }.forEach { (place, entries) ->
SettingsGroup(stringResource(place.title)) {
@@ -111,10 +121,12 @@ internal fun SettingsSearchResults(query: String, frost: Boolean, onOpen: (Setti
val title = stringResource(entry.title)
val section = entry.section
val tab = entry.tab
val button = if (entry === firstToOpen) Modifier.focusRequester(first) else Modifier
if (section != null) {
ActionRow(title, within, stringResource(R.string.store_open), onClick = { SettingsJump.to(title); onOpen(section) })
ActionRow(title, within, stringResource(R.string.store_open), modifier = button, onClick = { onSearched(); SettingsJump.to(title); onOpen(section) })
} else if (tab != null) {
ActionRow(title, within, stringResource(R.string.store_open), onClick = {
ActionRow(title, within, stringResource(R.string.store_open), modifier = button, onClick = {
onSearched()
SettingsJump.to(title)
if (tab == NavTabs.MORE) MoreTabs.editing = true
if (tab == "downloads") DownloadsNav.showSettings = true
@@ -0,0 +1,101 @@
package com.droiddeck.launcher.ui
import android.content.Context
import androidx.compose.foundation.LocalIndication
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.hoverable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ExperimentalLayoutApi
import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Delete
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
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.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
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 com.droiddeck.launcher.R
import com.droiddeck.launcher.session.SessionPrefs
/** What was searched for in Settings, newest first. */
internal object SettingsSearchHistory {
const val MAX = 8
var items by mutableStateOf<List<String>>(emptyList())
private set
fun load(context: Context) { items = SessionPrefs.settingsSearches(context) }
fun add(context: Context, query: String) {
val next = withSearch(items, query)
if (next == items) return
items = next
SessionPrefs.setSettingsSearches(context, next)
}
fun clear(context: Context) {
items = emptyList()
SessionPrefs.setSettingsSearches(context, emptyList())
}
fun withSearch(items: List<String>, query: String): List<String> {
val text = query.trim().replace(Regex("\\s+"), " ")
if (text.isEmpty()) return items
return (listOf(text) + items.filterNot { it.equals(text, ignoreCase = true) }).take(MAX)
}
}
@OptIn(ExperimentalLayoutApi::class)
@Composable
internal fun SettingsSearchHistoryList(onPick: (String) -> Unit, onClear: () -> Unit) {
val colors = MaterialTheme.colorScheme
Column(Modifier.fillMaxWidth()) {
Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth().padding(top = 12.dp, bottom = 8.dp)) {
Text(
stringResource(R.string.settings_search_history), fontSize = 16.sp, fontWeight = FontWeight.SemiBold, color = colors.onSurfaceVariant,
modifier = Modifier.weight(1f).padding(start = 4.dp),
)
SmallIconButton(Icons.Outlined.Delete, stringResource(R.string.settings_search_history_clear), tint = colors.onSurfaceVariant, onClick = onClear)
}
FlowRow(horizontalArrangement = Arrangement.spacedBy(8.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {
SettingsSearchHistory.items.forEach { HistoryChip(it) { onPick(it) } }
}
}
}
@Composable
private fun HistoryChip(text: String, onClick: () -> Unit) {
val colors = MaterialTheme.colorScheme
val pal = LocalPalette.current
val src = remember { MutableInteractionSource() }
val hot = rememberHot(src)
Box(
contentAlignment = Alignment.Center,
modifier = Modifier.heightIn(min = 40.dp).widthIn(min = 56.dp, max = 260.dp).clip(CircleShape)
.background(colors.surface).glideBorder(hot, CircleShape, pal.signal, pal.line)
.hoverable(src).clickable(interactionSource = src, indication = LocalIndication.current, role = Role.Button, onClick = onClick)
.controllerConfirm(onClick = onClick)
.padding(horizontal = 16.dp, vertical = 8.dp),
) { Text(text, fontSize = 14.sp, color = colors.onBackground, maxLines = 1, overflow = TextOverflow.Ellipsis) }
}
@@ -14,6 +14,7 @@ import androidx.compose.animation.core.infiniteRepeatable
import androidx.compose.animation.core.rememberInfiniteTransition
import androidx.compose.animation.core.tween
import androidx.compose.runtime.Composable
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.key
import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.CompositionLocalProvider
@@ -88,7 +89,7 @@ object Themes {
var rgbSpeed by mutableStateOf(DEFAULT_RGB_SPEED)
private set
var rgbHue by mutableStateOf(0f)
@Volatile var rgbHue = 0f
private set
fun moveRgbHue(hue: Float) {
@@ -237,8 +238,36 @@ fun DroidDeckTheme(theme: String? = null, appScale: Int = AppUiPrefs.DEFAULT_SCA
val context = LocalContext.current
remember(context) { Themes.loadGradient(context) }
val id = theme ?: SessionPrefs.theme(context)
if (id == Themes.INNER_GAMER) InnerGamerHue(Themes.rgbSpeed)
val solid = Themes.byId(id)
val solid = if (id == Themes.INNER_GAMER) {
rememberInnerGamerPalette(Themes.rgbSpeed)
} else {
Themes.byId(id)
}
DroidDeckThemePalette(solid, appScale, frost, content)
}
@Composable
private fun rememberInnerGamerPalette(speed: Int): Palette = key(speed) {
val start = remember { Themes.rgbHue }
val animatedHue by rememberInfiniteTransition(label = "innerGamer").animateFloat(
start, start + 360f,
infiniteRepeatable(
tween(Themes.rgbCycleMillis(speed).coerceAtLeast(1), easing = LinearEasing),
RepeatMode.Restart,
),
label = "hue",
)
val steppedHue by remember {
derivedStateOf {
((animatedHue % 360f) / Themes.RGB_HUE_STEP).toInt() * Themes.RGB_HUE_STEP
}
}
SideEffect { Themes.moveRgbHue(steppedHue) }
Themes.innerGamer(steppedHue)
}
@Composable
private fun DroidDeckThemePalette(solid: Palette, appScale: Int, frost: FrostChoice?, content: @Composable () -> Unit) {
val look = frost?.let { frostLook(solid, it) }
val p = if (look == null) solid else solid.frosted(look)
val baseDensity = LocalDensity.current
@@ -286,17 +315,3 @@ private val ContentDirected = Typography().run {
)
}
@Composable
private fun InnerGamerHue(speed: Int) {
key(speed) { InnerGamerCycle(speed) }
}
@Composable
private fun InnerGamerCycle(speed: Int) {
val start = remember { Themes.rgbHue }
val hue by rememberInfiniteTransition(label = "innerGamer").animateFloat(
start, start + 360f, infiniteRepeatable(tween(Themes.rgbCycleMillis(speed).coerceAtLeast(1), easing = LinearEasing), RepeatMode.Restart), label = "hue",
)
val stepped = ((hue % 360f) / Themes.RGB_HUE_STEP).toInt() * Themes.RGB_HUE_STEP
SideEffect { Themes.moveRgbHue(stepped) }
}
+2
View File
@@ -4356,4 +4356,6 @@
<string name="glasses_show_shortcut_hint">إظهار زر النظارات الذكية العائم فوق اللعبة.</string>
<string name="display_filter_game_profile">استخدام ملف تعريف %1$s: %2$s</string>
<string name="display_filter_default_profile">استخدام الملف التعريفي الافتراضي: %1$s</string>
<string name="settings_search_history">سجل البحث</string>
<string name="settings_search_history_clear">مسح سجل البحث</string>
</resources>
@@ -4234,4 +4234,6 @@
<string name="glasses_show_shortcut_hint">Mostrar el botón flotante de Smart Glasses sobre el juego.</string>
<string name="display_filter_game_profile">Usando el perfil %1$s: %2$s</string>
<string name="display_filter_default_profile">Usando el perfil predeterminado: %1$s</string>
<string name="settings_search_history">Historial de búsqueda</string>
<string name="settings_search_history_clear">Borrar historial de búsqueda</string>
</resources>
+2
View File
@@ -4196,4 +4196,6 @@
<string name="glasses_show_shortcut_hint">Показва плаващия бутон за Smart Glasses върху играта.</string>
<string name="display_filter_game_profile">Използва се профил %1$s: %2$s</string>
<string name="display_filter_default_profile">Използва се профилът по подразбиране: %1$s</string>
<string name="settings_search_history">История на търсенето</string>
<string name="settings_search_history_clear">Изчистване на историята на търсенето</string>
</resources>
+2
View File
@@ -4276,4 +4276,6 @@
<string name="glasses_show_shortcut_hint">Zobrazit plovoucí tlačítko Smart Glasses nad hrou.</string>
<string name="display_filter_game_profile">Používá se profil %1$s: %2$s</string>
<string name="display_filter_default_profile">Používá se výchozí profil: %1$s</string>
<string name="settings_search_history">Historie hledání</string>
<string name="settings_search_history_clear">Vymazat historii hledání</string>
</resources>
+2
View File
@@ -4196,4 +4196,6 @@
<string name="glasses_show_shortcut_hint">Vis den flydende Smart Glasses-knap oven på spillet.</string>
<string name="display_filter_game_profile">Bruger profilen %1$s: %2$s</string>
<string name="display_filter_default_profile">Bruger standardprofilen: %1$s</string>
<string name="settings_search_history">Søgehistorik</string>
<string name="settings_search_history_clear">Ryd søgehistorik</string>
</resources>
+2
View File
@@ -4196,4 +4196,6 @@
<string name="glasses_show_shortcut_hint">Die schwebende Smart-Glasses-Schaltfläche über dem Spiel anzeigen.</string>
<string name="display_filter_game_profile">Profil %1$s wird verwendet: %2$s</string>
<string name="display_filter_default_profile">Standardprofil wird verwendet: %1$s</string>
<string name="settings_search_history">Suchverlauf</string>
<string name="settings_search_history_clear">Suchverlauf löschen</string>
</resources>
+2
View File
@@ -4196,4 +4196,6 @@
<string name="glasses_show_shortcut_hint">Εμφάνιση του αιωρούμενου κουμπιού Smart Glasses πάνω από το παιχνίδι.</string>
<string name="display_filter_game_profile">Χρήση προφίλ %1$s: %2$s</string>
<string name="display_filter_default_profile">Χρήση προεπιλεγμένου προφίλ: %1$s</string>
<string name="settings_search_history">Ιστορικό αναζήτησης</string>
<string name="settings_search_history_clear">Εκκαθάριση ιστορικού αναζήτησης</string>
</resources>
+2
View File
@@ -4236,4 +4236,6 @@
<string name="glasses_show_shortcut_hint">Mostrar el botón flotante de Smart Glasses sobre el juego.</string>
<string name="display_filter_game_profile">Usando el perfil %1$s: %2$s</string>
<string name="display_filter_default_profile">Usando el perfil predeterminado: %1$s</string>
<string name="settings_search_history">Historial de búsqueda</string>
<string name="settings_search_history_clear">Borrar historial de búsqueda</string>
</resources>
+2
View File
@@ -4196,4 +4196,6 @@
<string name="glasses_show_shortcut_hint">Näytä pelin päällä kelluva Smart Glasses -painike.</string>
<string name="display_filter_game_profile">Käytössä profiili %1$s: %2$s</string>
<string name="display_filter_default_profile">Käytössä oletusprofiili: %1$s</string>
<string name="settings_search_history">Hakuhistoria</string>
<string name="settings_search_history_clear">Tyhjennä hakuhistoria</string>
</resources>
+2
View File
@@ -4235,4 +4235,6 @@
<string name="glasses_show_shortcut_hint">Afficher le bouton flottant Smart Glasses par-dessus le jeu.</string>
<string name="display_filter_game_profile">Profil %1$s utilisé : %2$s</string>
<string name="display_filter_default_profile">Profil par défaut utilisé : %1$s</string>
<string name="settings_search_history">Historique de recherche</string>
<string name="settings_search_history_clear">Effacer l\'historique de recherche</string>
</resources>
+2
View File
@@ -4196,4 +4196,6 @@
<string name="glasses_show_shortcut_hint">गेम के ऊपर तैरता हुआ Smart Glasses बटन दिखाएँ।</string>
<string name="display_filter_game_profile">%1$s प्रोफ़ाइल का उपयोग: %2$s</string>
<string name="display_filter_default_profile">डिफ़ॉल्ट प्रोफ़ाइल का उपयोग: %1$s</string>
<string name="settings_search_history">खोज इतिहास</string>
<string name="settings_search_history_clear">खोज इतिहास मिटाएं</string>
</resources>
+2
View File
@@ -4196,4 +4196,6 @@
<string name="glasses_show_shortcut_hint">A játék fölött lebegő Smart Glasses gomb megjelenítése.</string>
<string name="display_filter_game_profile">Használt profil: %1$s – %2$s</string>
<string name="display_filter_default_profile">Alapértelmezett profil használata: %1$s</string>
<string name="settings_search_history">Keresési előzmények</string>
<string name="settings_search_history_clear">Keresési előzmények törlése</string>
</resources>
+2
View File
@@ -4166,4 +4166,6 @@
<string name="glasses_show_shortcut_hint">Tampilkan tombol Smart Glasses mengambang di atas game.</string>
<string name="display_filter_game_profile">Menggunakan profil %1$s: %2$s</string>
<string name="display_filter_default_profile">Menggunakan profil default: %1$s</string>
<string name="settings_search_history">Riwayat pencarian</string>
<string name="settings_search_history_clear">Hapus riwayat pencarian</string>
</resources>
+2
View File
@@ -4235,4 +4235,6 @@
<string name="glasses_show_shortcut_hint">Mostra il pulsante mobile Smart Glasses sopra il gioco.</string>
<string name="display_filter_game_profile">Profilo %1$s in uso: %2$s</string>
<string name="display_filter_default_profile">Profilo predefinito in uso: %1$s</string>
<string name="settings_search_history">Cronologia ricerche</string>
<string name="settings_search_history_clear">Cancella cronologia ricerche</string>
</resources>
+2
View File
@@ -4166,4 +4166,6 @@
<string name="glasses_show_shortcut_hint">ゲーム画面上に Smart Glasses のフローティングボタンを表示します。</string>
<string name="display_filter_game_profile">%1$s プロファイルを使用中: %2$s</string>
<string name="display_filter_default_profile">デフォルトプロファイルを使用中: %1$s</string>
<string name="settings_search_history">検索履歴</string>
<string name="settings_search_history_clear">検索履歴を消去</string>
</resources>
+2
View File
@@ -4166,4 +4166,6 @@
<string name="glasses_show_shortcut_hint">게임 위에 떠 있는 Smart Glasses 버튼을 표시합니다.</string>
<string name="display_filter_game_profile">%1$s 프로필 사용 중: %2$s</string>
<string name="display_filter_default_profile">기본 프로필 사용 중: %1$s</string>
<string name="settings_search_history">검색 기록</string>
<string name="settings_search_history_clear">검색 기록 지우기</string>
</resources>
+2
View File
@@ -4166,4 +4166,6 @@
<string name="glasses_show_shortcut_hint">Tunjukkan butang Smart Glasses terapung di atas permainan.</string>
<string name="display_filter_game_profile">Menggunakan profil %1$s: %2$s</string>
<string name="display_filter_default_profile">Menggunakan profil lalai: %1$s</string>
<string name="settings_search_history">Sejarah carian</string>
<string name="settings_search_history_clear">Kosongkan sejarah carian</string>
</resources>
+2
View File
@@ -4196,4 +4196,6 @@
<string name="glasses_show_shortcut_hint">Vis den flytende Smart Glasses-knappen over spillet.</string>
<string name="display_filter_game_profile">Bruker profilen %1$s: %2$s</string>
<string name="display_filter_default_profile">Bruker standardprofilen: %1$s</string>
<string name="settings_search_history">Søkelogg</string>
<string name="settings_search_history_clear">Tøm søkeloggen</string>
</resources>
+2
View File
@@ -4196,4 +4196,6 @@
<string name="glasses_show_shortcut_hint">Toon de zwevende Smart Glasses-knop boven het spel.</string>
<string name="display_filter_game_profile">Profiel %1$s in gebruik: %2$s</string>
<string name="display_filter_default_profile">Standaardprofiel in gebruik: %1$s</string>
<string name="settings_search_history">Zoekgeschiedenis</string>
<string name="settings_search_history_clear">Zoekgeschiedenis wissen</string>
</resources>
+2
View File
@@ -4276,4 +4276,6 @@
<string name="glasses_show_shortcut_hint">Pokaż pływający przycisk Smart Glasses nad grą.</string>
<string name="display_filter_game_profile">Używany profil %1$s: %2$s</string>
<string name="display_filter_default_profile">Używany profil domyślny: %1$s</string>
<string name="settings_search_history">Historia wyszukiwania</string>
<string name="settings_search_history_clear">Wyczyść historię wyszukiwania</string>
</resources>
@@ -4235,4 +4235,6 @@
<string name="glasses_show_shortcut_hint">Mostrar o botão flutuante do Smart Glasses sobre o jogo.</string>
<string name="display_filter_game_profile">Perfil %1$s em utilização: %2$s</string>
<string name="display_filter_default_profile">Perfil predefinido em utilização: %1$s</string>
<string name="settings_search_history">Histórico de pesquisa</string>
<string name="settings_search_history_clear">Limpar histórico de pesquisa</string>
</resources>
+2
View File
@@ -4243,4 +4243,6 @@
<string name="glasses_show_shortcut_hint">Mostrar o botão flutuante do Smart Glasses sobre o jogo.</string>
<string name="display_filter_game_profile">Perfil %1$s em uso: %2$s</string>
<string name="display_filter_default_profile">Perfil predefinido em uso: %1$s</string>
<string name="settings_search_history">Histórico de pesquisa</string>
<string name="settings_search_history_clear">Limpar histórico de pesquisa</string>
</resources>
+2
View File
@@ -4236,4 +4236,6 @@
<string name="glasses_show_shortcut_hint">Afișează butonul plutitor Smart Glasses peste joc.</string>
<string name="display_filter_game_profile">Se folosește profilul %1$s: %2$s</string>
<string name="display_filter_default_profile">Se folosește profilul implicit: %1$s</string>
<string name="settings_search_history">Istoricul căutărilor</string>
<string name="settings_search_history_clear">Șterge istoricul căutărilor</string>
</resources>
+2
View File
@@ -4277,4 +4277,6 @@
<string name="glasses_show_shortcut_hint">Показывать плавающую кнопку Smart Glasses поверх игры.</string>
<string name="display_filter_game_profile">Используется профиль %1$s: %2$s</string>
<string name="display_filter_default_profile">Используется профиль по умолчанию: %1$s</string>
<string name="settings_search_history">История поиска</string>
<string name="settings_search_history_clear">Очистить историю поиска</string>
</resources>
+2
View File
@@ -4196,4 +4196,6 @@
<string name="glasses_show_shortcut_hint">Visa den flytande Smart Glasses-knappen ovanpå spelet.</string>
<string name="display_filter_game_profile">Använder profilen %1$s: %2$s</string>
<string name="display_filter_default_profile">Använder standardprofilen: %1$s</string>
<string name="settings_search_history">Sökhistorik</string>
<string name="settings_search_history_clear">Rensa sökhistorik</string>
</resources>
+2
View File
@@ -4166,4 +4166,6 @@
<string name="glasses_show_shortcut_hint">แสดงปุ่ม Smart Glasses แบบลอยทับบนเกม</string>
<string name="display_filter_game_profile">ใช้โปรไฟล์ %1$s: %2$s</string>
<string name="display_filter_default_profile">ใช้โปรไฟล์เริ่มต้น: %1$s</string>
<string name="settings_search_history">ประวัติการค้นหา</string>
<string name="settings_search_history_clear">ล้างประวัติการค้นหา</string>
</resources>
+2
View File
@@ -4196,4 +4196,6 @@
<string name="glasses_show_shortcut_hint">Oyun üzerinde yüzen Smart Glasses düğmesini göster.</string>
<string name="display_filter_game_profile">%1$s profili kullanılıyor: %2$s</string>
<string name="display_filter_default_profile">Varsayılan profil kullanılıyor: %1$s</string>
<string name="settings_search_history">Arama geçmişi</string>
<string name="settings_search_history_clear">Arama geçmişini temizle</string>
</resources>
+2
View File
@@ -4276,4 +4276,6 @@
<string name="glasses_show_shortcut_hint">Показувати плаваючу кнопку Smart Glasses поверх гри.</string>
<string name="display_filter_game_profile">Використовується профіль %1$s: %2$s</string>
<string name="display_filter_default_profile">Використовується профіль за замовчуванням: %1$s</string>
<string name="settings_search_history">Історія пошуку</string>
<string name="settings_search_history_clear">Очистити історію пошуку</string>
</resources>
+2
View File
@@ -4166,4 +4166,6 @@
<string name="glasses_show_shortcut_hint">Hiển thị nút Smart Glasses nổi phía trên trò chơi.</string>
<string name="display_filter_game_profile">Đang dùng hồ sơ %1$s: %2$s</string>
<string name="display_filter_default_profile">Đang dùng hồ sơ mặc định: %1$s</string>
<string name="settings_search_history">Lịch sử tìm kiếm</string>
<string name="settings_search_history_clear">Xóa lịch sử tìm kiếm</string>
</resources>
@@ -4164,4 +4164,6 @@
<string name="glasses_show_shortcut_hint">在游戏画面上显示悬浮的 Smart Glasses 按钮。</string>
<string name="display_filter_game_profile">正在使用 %1$s 配置:%2$s</string>
<string name="display_filter_default_profile">正在使用默认配置:%1$s</string>
<string name="settings_search_history">搜索历史</string>
<string name="settings_search_history_clear">清除搜索历史</string>
</resources>
@@ -4164,4 +4164,6 @@
<string name="glasses_show_shortcut_hint">在遊戲畫面上顯示浮動的 Smart Glasses 按鈕。</string>
<string name="display_filter_game_profile">正在使用 %1$s 設定檔:%2$s</string>
<string name="display_filter_default_profile">正在使用預設設定檔:%1$s</string>
<string name="settings_search_history">搜尋記錄</string>
<string name="settings_search_history_clear">清除搜尋記錄</string>
</resources>
@@ -4164,4 +4164,6 @@
<string name="glasses_show_shortcut_hint">在遊戲畫面上顯示浮動的 Smart Glasses 按鈕。</string>
<string name="display_filter_game_profile">正在使用 %1$s 設定檔:%2$s</string>
<string name="display_filter_default_profile">正在使用預設設定檔:%1$s</string>
<string name="settings_search_history">搜尋記錄</string>
<string name="settings_search_history_clear">清除搜尋記錄</string>
</resources>
@@ -74,6 +74,7 @@
<string name="input_keep_shared">Keep shared</string>
<string name="input_independent_copy">Independent copy</string>
<string name="input_floating_stick">Start stick at touch position</string>
<string name="input_adaptive_capture">Adaptive touch area</string>
<string name="input_hide_idle">Hide stick when not in use</string>
<string name="input_tools">Tools</string>
<string name="input_quick_auto">Auto (%1$s)</string>
+2
View File
@@ -4459,6 +4459,8 @@
<string name="settings_search">Search settings</string>
<string name="settings_search_none">No setting matches \"%1$s\"</string>
<string name="settings_search_clear">Clear search</string>
<string name="settings_search_history">Search history</string>
<string name="settings_search_history_clear">Clear search history</string>
<string name="settings_place_settings">Settings</string>
<string name="settings_place_drawer">In-game menu</string>
<string name="settings_place_sheet">Steam or Desktop options (swipe up)</string>
+2
View File
@@ -3,6 +3,8 @@
<style name="AppTheme" parent="@android:style/Theme.Material.NoActionBar">
<item name="android:colorBackground">#FF101418</item>
<item name="android:navigationBarColor">@android:color/black</item>
<item name="android:statusBarColor">@android:color/black</item>
<item name="android:windowLightStatusBar">false</item>
</style>
<style name="SessionTheme" parent="@android:style/Theme.Material.NoActionBar.Fullscreen">
<item name="android:windowBackground">@android:color/black</item>
@@ -15,4 +15,29 @@ class DependencyDetectorTest {
File(folder, "_CommonRedist/vcredist/2013/vcredist_x64.exe").writeText("x")
assertEquals(listOf("vcredist2013"), DependencyDetector.detect(folder).map { it.componentName })
}
@Test fun dotNetRuntimeInstallersMapToTheirOwnRuntime() {
assertEquals(listOf("dotnetcoredesktop3"), DependencyDetector.componentsFor("%INSTALLDIR%\\DotNetCore\\windowsdesktop-runtime-3.1.8-win-x64.exe"))
assertEquals(listOf("dotnetcoredesktop3"), DependencyDetector.componentsFor("_CommonRedist/DotNet/dotnet-runtime-3.1.32-win-x64.exe"))
assertEquals(listOf("dotnet50"), DependencyDetector.componentsFor("_CommonRedist/windowsdesktop-runtime-5.0.17-win-x64.exe"))
assertEquals(listOf("dotnetcoredesktop6"), DependencyDetector.componentsFor("_CommonRedist/windowsdesktop-runtime-6.0.16-win-x64.exe"))
assertEquals(listOf("dotnetcoredesktop8"), DependencyDetector.componentsFor("_CommonRedist/windowsdesktop-runtime-8.0.4-win-x64.exe"))
assertEquals(emptyList<String>(), DependencyDetector.componentsFor("_CommonRedist/windowsdesktop-runtime-9.0.0-win-x64.exe"))
}
@Test fun dotNetFrameworkInstallersKeepTheirMapping() {
assertEquals(listOf("dotnet48"), DependencyDetector.componentsFor("_CommonRedist/DotNet/4.8/ndp48-x86-x64-allos-enu.exe"))
assertEquals(listOf("dotnet472"), DependencyDetector.componentsFor("_CommonRedist/DotNet/4.7.2/NDP472-KB4054530-x86-x64-AllOS-ENU.exe"))
assertEquals(listOf("dotnet46"), DependencyDetector.componentsFor("_CommonRedist/DotNet/4.6.2/NDP462-KB3151800-x86-x64-AllOS-ENU.exe"))
assertEquals(listOf("dotnet40"), DependencyDetector.componentsFor("_CommonRedist/DotNet/dotNetFx40_Full_x86_x64.exe"))
assertEquals(listOf("dotnetcoredesktop6"), DependencyDetector.componentsFor("_CommonRedist/DotNet/6.0/setup_dotnet.exe"))
assertEquals(listOf("dotnet48"), DependencyDetector.componentsFor("_CommonRedist/DotNet/setup_dotnet.exe"))
}
@Test fun aBundledDesktopRuntimeFolderIsNotTakenForTheFramework() {
val folder = tmp.newFolder("Game")
File(folder, "DotNetCore").mkdirs()
File(folder, "DotNetCore/windowsdesktop-runtime-3.1.8-win-x64.exe").writeText("x")
assertEquals(listOf("dotnetcoredesktop3"), DependencyDetector.detect(folder).map { it.componentName })
}
}
@@ -205,6 +205,36 @@ class WinCompSourcesTest {
assertEquals("GOG", picks.getValue("vcredist2015_dll").kind)
}
@Test fun nativeD3dxSelectsItsEffectCompilersForEveryAutomaticSource() {
val catalog = listOf(ready("d3dx9"), ready("d3dcompiler_42"), ready("d3dcompiler_43")).associateBy { it.name }
for (origin in WinCompSources.Origin.values()) {
val finding = WinCompSources.Finding("d3dx9", "DirectX", origin, true)
val picks = AutoComponents.autoPicks(listOf(finding), catalog)
assertEquals(setOf("d3dx9", "d3dcompiler_42", "d3dcompiler_43"), picks.keys)
assertEquals(origin.name, picks.getValue("d3dcompiler_43").kind)
assertEquals(picks.getValue("d3dx9").args, picks.getValue("d3dcompiler_43").args)
assertEquals(setOf("d3dx9"), AutoComponents.autoPicks(listOf(finding), catalog, mapOf("d3dx9" to false)).keys)
assertTrue(AutoComponents.autoPicks(listOf(finding.copy(auto = false)), catalog).isEmpty())
}
assertEquals(setOf("d3dcompiler_42", "d3dcompiler_43"),
AutoComponents.autoPicks(emptyList(), catalog, mapOf("d3dx9" to true)).keys)
assertTrue(AutoComponents.autoPicks(emptyList(), catalog, mapOf("xact" to true)).isEmpty())
}
@Test fun effectCompilerSelectionKeepsIndependentFindingsAndSkipsUnavailableComponents() {
val catalog = listOf(ready("d3dx9"), ready("d3dcompiler_43"),
WinComponents.Component("d3dcompiler_42", "", "", "broken", emptyList(), emptyList())).associateBy { it.name }
val findings = listOf(
WinCompSources.Finding("d3dx9", "DirectX", WinCompSources.Origin.GOG, true),
WinCompSources.Finding("d3dcompiler_43", "Compiler", WinCompSources.Origin.STEAM, true),
)
val picks = AutoComponents.autoPicks(findings, catalog)
assertEquals(setOf("d3dx9", "d3dcompiler_43"), picks.keys)
assertEquals("STEAM", picks.getValue("d3dcompiler_43").kind)
assertEquals(picks.keys, AutoComponents.autoPicks(findings, catalog, mapOf("d3dx9" to false)).keys)
assertEquals(setOf("d3dx9"), AutoComponents.autoPicks(findings.take(1), catalog - "d3dcompiler_43").keys)
}
@Test fun theUsersSwitchWinsOverAnAutoPickEitherWay() {
val key = "12345"
WinComponents.setAuto(app, key, mapOf("d3dx9" to WinComponents.AutoReason("GOG", listOf("DirectX")), "xact" to WinComponents.AutoReason("GOG", listOf("XACT"))))
@@ -279,6 +309,42 @@ class WinCompSourcesTest {
}
}
@Test fun installedD3dxGainsCompilersWithoutReplacingUserChoices() = withFakeWorker {
AutoComponents.catalogOf = { _, _ -> catalog3 + ready("d3dcompiler_42") + ready("d3dcompiler_43") }
installedNow.addAll(catalog3.map { it.name })
val game = payback()
WinComponents.setUser(app, "1262580", "d3dcompiler_42", false)
AutoComponents.queueGame(app, game, asked = true)
assertEquals(listOf("d3dcompiler_43"), downloaded)
assertEquals(setOf("d3dx9", "vcredist2013_dll", "vcredist2019_dll", "d3dcompiler_43"), WinComponents.picks(app, "1262580").toSet())
assertEquals(mapOf("d3dcompiler_42" to false), WinComponents.selection(app, "1262580").user)
assertTrue(AutoComponents.Pending.ids(app, "1262580").isEmpty())
AutoComponents.queueGame(app, game, asked = true)
assertEquals(listOf("d3dcompiler_43"), downloaded)
WinComponents.setUser(app, "1262580", "d3dx9", false)
AutoComponents.queueGame(app, game, asked = true)
assertEquals(setOf("vcredist2013_dll", "vcredist2019_dll"), WinComponents.picks(app, "1262580").toSet())
}
@Test fun manuallySelectedD3dxQueuesCompilersBeforeLaunch() = withFakeWorker {
AutoComponents.catalogOf = { _, _ -> catalog3 + ready("d3dcompiler_42") + ready("d3dcompiler_43") }
installedNow.add("d3dx9")
val game = game(tmp.newFolder("ManualEffects"), Library.ADDED)
val key = AutoComponents.appKey(game)!!
WinComponents.setUser(app, key, "d3dx9", true)
WinComponents.setUser(app, key, "d3dcompiler_42", false)
session = true
gameUp = true
assertTrue(AutoComponents.prepareLaunch(app, game))
assertEquals(listOf("d3dcompiler_43"), AutoComponents.Pending.ids(app, key))
assertTrue(downloaded.isEmpty())
gameUp = false
AutoComponents.drain(app)
assertEquals(listOf("d3dcompiler_43"), downloaded)
assertEquals(setOf("d3dx9", "d3dcompiler_43"), WinComponents.picks(app, key).toSet())
assertTrue(AutoComponents.Pending.ids(app, key).isEmpty())
}
@Test fun anExplicitCheckRefreshesTheCatalogAndAnOfflineCheckUsesTheCache() = withFakeWorker {
installedNow.addAll(catalog3.map { it.name })
val requests = ArrayList<Boolean>()
@@ -727,6 +793,17 @@ class WinCompSourcesTest {
assertTrue(watch.poll().isEmpty())
}
@Test fun aProtonFinishingInTheSessionIsToldApartFromAGame() {
val steamapps = tmp.newFolder("steamapps")
File(steamapps, "common/Proton Experimental (ARM64)/files/lib/wine").mkdirs()
File(steamapps, "common/Proton Experimental (ARM64)/proton").writeText("#!/bin/sh\n")
File(steamapps, "common/Audiosurf").mkdirs()
val proton = SessionInstalls.Manifest(4427310, "Proton Experimental (ARM64)", "Proton Experimental (ARM64)", true, steamapps)
assertTrue(SessionInstalls.isProton(proton))
assertFalse(SessionInstalls.isProton(SessionInstalls.Manifest(12900, "Audiosurf", "Audiosurf", true, steamapps)))
assertFalse(SessionInstalls.isProton(SessionInstalls.Manifest(1, "Gone", "Gone", true, steamapps)))
}
@Test fun anInSessionJobWaitsWhileAGameRunsThenReadiesItsComponents() = withFakeWorker {
val installed = payback()
session = true
@@ -97,6 +97,32 @@ class WinComponentDetectorsTest {
assertEquals(emptyList<Pair<String, String>>(), SteamRedists.installScript(File(steamapps, "missing")))
}
@Test fun aDesktopRuntimeTheInstallScriptRunsIsInstalledInsteadOfTheFramework() {
val steamapps = tmp.newFolder("steamapps")
val game = File(steamapps, "common/Launcher Game").apply { mkdirs() }
File(steamapps, "appmanifest_435150.acf").writeText("\"AppState\"\n{\n\t\"SharedDepots\"\n\t{\n\t\t\"228988\"\t\t\"228980\"\n\t\t\"228990\"\t\t\"228980\"\n\t}\n}\n")
File(game, "installscript.vdf").writeText(
"""
"InstallScript"
{
"Run Process"
{
"DotNetCore"
{
"HasRunKey" "HKEY_LOCAL_MACHINE\\Software\\Valve\\Steam\\Apps\\435150"
"process 1" "%INSTALLDIR%\\DotNetCore\\windowsdesktop-runtime-3.1.8-win-x64.exe"
"command 1" "/install /quiet /norestart"
}
}
}
""".trimIndent(),
)
val context = androidx.test.core.app.ApplicationProvider.getApplicationContext<android.content.Context>()
val found = WinCompSources.steamList(context, game, 435150, "Launcher Game", auto = true)
assertEquals(listOf("vcredist2019_dll", "d3dx9", "dotnetcoredesktop3"), found.map { it.component })
assertTrue(found.all { it.auto && it.origin == WinCompSources.Origin.STEAM })
}
@Test fun thePrefixCountsOnlyWhatDroidDeckDidNotPutThere() {
val compat = tmp.newFolder("compatdata", "409710")
val pfx = File(compat, "pfx")
@@ -467,6 +467,7 @@ class InputLibraryTest {
val enabled = InputLibraries.read(context)
val changed = enabled.layouts.single { it.id == overlay.id }
assertEquals(true, changed.adaptiveSticks)
assertTrue(changed.elements.filter { it.kind == InputElementKind.STICK }.all { !it.hideStickAtRest && it.adaptiveCapture == true })
assertTrue(ControllerPrefs.read(context).adaptiveSticks)
assertEquals(overlay.elements.filter { it.kind != InputElementKind.STICK }, changed.elements.filter { it.kind != InputElementKind.STICK })
assertEquals(library.layouts.filter { it.id != overlay.id }, enabled.layouts.filter { it.id != overlay.id })
@@ -336,6 +336,20 @@ class OnScreenLayoutTest {
}
}
@Test fun dockedSticksStayVisibleWithoutExpandingTheirTouchArea() {
val custom = InputSurfaceElement(InputControl.LS, .2f, .2f, .2f, .3f,
id = "custom-stick", hideWhenIdle = true, adaptiveCapture = true)
val layout = SavedInputLayout("custom", "Custom", listOf(custom), aspect = 1.5f)
val overlay = OnScreenLayout.elements(context, layout, 1200, 800, Rect()).single()
assertTrue(overlay.adaptiveStick)
assertTrue(overlay.hideStickAtRest)
val docked = OnScreenLayout.elements(context, layout, 1200, 800, Rect(),
dock = OnScreenLayout.Dock(false, false)).single()
assertFalse(docked.adaptiveStick)
assertFalse(docked.hideStickAtRest)
assertTrue(docked.floating)
}
@Test fun dockedControlsStayInsideTheSafeAreaAtTheDefaultSizeWithoutAControllerKit() {
SessionPrefs.setSteamController(context, SessionPrefs.CONTROLLER_NONE)
ControllerPrefs.setSize(context, 100)
@@ -1,6 +1,7 @@
package com.droiddeck.launcher.session
import android.content.Context
import com.droiddeck.launcher.gpu.AppVulkan
import com.droiddeck.launcher.gpu.GpuInfo
import com.droiddeck.launcher.core.Hashes
import com.droiddeck.launcher.runtime.LinuxRuntime
@@ -577,6 +578,29 @@ class ForcedPackageTest {
assertEquals(cached, ComponentsManager.resolveCatalogItem(dxvk2, "Dxvk-Linux", { listOf(cached) }, { error("refresh") }))
}
@Test fun anUnreachableListingStillFindsEveryForcedPackage() {
val rules = ComponentsManager.FORCED_PACKAGES.flatMap { listOfNotNull(it, it.autoRule()) } + listOf(
ComponentsManager.bridgeDxvk(AppVulkan(1, 1, shaderInt64 = false, maxPushConstants = 128, source = "driver"))!!,
ComponentsManager.bridgeDxvk(AppVulkan(1, 3, shaderInt64 = false, maxPushConstants = 256, source = "driver"))!!,
)
for (rule in rules) {
val found = ComponentsManager.resolveCatalogItem(rule.file, rule.release, { emptyList() }, { emptyList() })
assertNotNull(rule.file, found)
assertEquals(rule.comp, found!!.comp)
assertTrue(found.url, ComponentsManager.allowedDownload(found.url))
assertTrue(found.url.endsWith("/releases/download/${rule.release}/${rule.file}"))
assertTrue(Hashes.isGithubSha256(found.digest))
assertTrue(found.size > 0)
}
}
@Test fun theListingStillWinsOverThePinnedCopy() {
val listed = item(ComponentsManager.DXVK_FOR_VULKAN_1_3_NO_INT64, "Dxvk-Linux")
assertEquals(listed, ComponentsManager.resolveCatalogItem(listed.file, "Dxvk-Linux", { emptyList() }, { listOf(listed) }))
assertNull(ComponentsManager.resolveCatalogItem(listed.file, "Dxvk-gplasync-Linux", { emptyList() }, { emptyList() }))
assertNull(ComponentsManager.resolveCatalogItem("dxvk-3.1-linux.wcp", "Dxvk-Linux", { emptyList() }, { emptyList() }))
}
private fun gpu(model: Int, family: GpuInfo.Family) = GpuInfo("Adreno $model", model, family, "", false)
private fun install(
@@ -5,6 +5,8 @@ import org.junit.Assert.assertFalse
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Test
import java.nio.file.Files
import java.nio.file.Path
class PageCacheTrimTest {
private val meminfo = "MemFree: 1048576 kB\nActive(file): 2097152 kB\nInactive(file): 1048576 kB\n"
@@ -15,4 +17,31 @@ class PageCacheTrimTest {
@Test fun skipsSmallBuildUp() = assertFalse(PageCacheTrim.shouldTrim(PageCacheTrim.Mem(2000 * 1024, 1200 * 1024), 1000 * 1024))
@Test fun skipsWhenPlentyFree() = assertFalse(PageCacheTrim.shouldTrim(PageCacheTrim.Mem(6000 * 1024, 5000 * 1024), 1000 * 1024))
@Test fun lowFreeAcceptsSmallerBuildUp() = assertTrue(PageCacheTrim.shouldTrim(PageCacheTrim.Mem(500 * 1024, 1200 * 1024), 1000 * 1024))
@Test fun bigFilesSkipLinksButEnterALinkedRoot() {
fun big(dir: Path, name: String): Path = Files.createFile(dir.resolve(name)).also {
java.io.RandomAccessFile(it.toFile(), "rw").use { it.setLength(PageCacheTrim.MIN_FILE_BYTES + 1) }
}
val base = Files.createTempDirectory("dd-trim")
try {
val root = Files.createDirectories(base.resolve("root"))
val outside = Files.createDirectories(base.resolve("outside"))
val big = big(root, "big.bin")
big(Files.createDirectories(root.resolve("sub")), "nested.bin")
Files.createFile(root.resolve("small.bin"))
big(outside, "outside.bin")
Files.createSymbolicLink(root.resolve("linked-dir"), outside)
Files.createSymbolicLink(root.resolve("linked-file"), big)
val rootLink = Files.createSymbolicLink(base.resolve("root-link"), root)
val expected = listOf("big.bin", "nested.bin")
assertEquals(expected, PageCacheTrim.bigFiles(root.toFile()).map { it.name }.sorted())
assertEquals(expected, PageCacheTrim.bigFiles(rootLink.toFile()).map { it.name }.sorted())
val dangling = Files.createSymbolicLink(base.resolve("dangling"), base.resolve("gone"))
assertTrue(PageCacheTrim.bigFiles(dangling.toFile()).isEmpty())
} finally {
base.toFile().deleteRecursively()
}
}
}
@@ -4,6 +4,7 @@ import android.graphics.Color
import android.view.ContextThemeWrapper
import com.droiddeck.launcher.R
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
import org.junit.runner.RunWith
@@ -22,4 +23,17 @@ class AppThemeTest {
assertEquals(0xFF, Color.alpha(color))
assertTrue(Color.luminance(color) < 0.1f)
}
@Test fun theStatusBarIsOpaqueAndDarkSoNothingLightShowsThroughIt() {
val themed = ContextThemeWrapper(RuntimeEnvironment.getApplication(), R.style.AppTheme)
val attrs = themed.obtainStyledAttributes(
intArrayOf(android.R.attr.statusBarColor, android.R.attr.windowLightStatusBar),
)
val color = attrs.getColor(0, Color.TRANSPARENT)
val lightIcons = attrs.getBoolean(1, true)
attrs.recycle()
assertEquals(0xFF, Color.alpha(color))
assertTrue(Color.luminance(color) < 0.1f)
assertFalse(lightIcons)
}
}
@@ -1,6 +1,9 @@
package com.droiddeck.launcher.ui
import android.content.Context
import android.graphics.Bitmap
import android.graphics.Canvas
import android.graphics.Color
import android.view.HapticFeedbackConstants
import android.view.MotionEvent
import android.view.View
@@ -18,6 +21,7 @@ import org.robolectric.RobolectricTestRunner
import org.robolectric.RuntimeEnvironment
import org.robolectric.Shadows.shadowOf
import org.robolectric.annotation.Config
import org.robolectric.annotation.GraphicsMode
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [34], manifest = Config.NONE, shadows = [JoyConPadTest.RecordingWriter::class])
@@ -355,6 +359,28 @@ class InputSurfaceTouchTest {
touch(MotionEvent.ACTION_UP, 1 to (490f to 170f))
}
@Test @GraphicsMode(GraphicsMode.Mode.NATIVE)
fun adaptiveSticksDrawAtRestUnlessExplicitlyHidden() {
val legacy = InputSurfaceElement(InputControl.LS, .3f, .3f, .2f, .4f, hideWhenIdle = true)
fun idlePixel(e: InputSurfaceElement): Int {
show(e)
val target = element(view, e.id)
val bitmap = Bitmap.createBitmap(target.width, target.height, Bitmap.Config.ARGB_8888)
return try {
target.draw(Canvas(bitmap))
bitmap.getPixel(target.width / 2, target.height / 2)
} finally {
bitmap.recycle()
}
}
assertTrue(Color.alpha(idlePixel(legacy)) > 0)
val visible = legacy.copy(adaptiveCapture = true, hideWhenIdle = false)
assertTrue(Color.alpha(idlePixel(visible)) > 0)
assertTrue(view.takesTouchAt(10f, 300f))
assertEquals(0, Color.alpha(idlePixel(visible.copy(hideWhenIdle = true))))
assertTrue(view.takesTouchAt(10f, 300f))
}
@Test fun adaptiveSticksCaptureAroundThemAndTheLeftOneToTheEdge() {
val left = InputSurfaceElement(InputControl.LS, .3f, .3f, .2f, .4f, hideWhenIdle = true)
val right = InputSurfaceElement(InputControl.RS, .6f, .3f, .2f, .4f, hideWhenIdle = true)
@@ -0,0 +1,15 @@
package com.droiddeck.launcher.ui
import org.junit.Assert.assertEquals
import org.junit.Test
class SettingsJumpTest {
@Test fun rowInTheMiddleOfThePageIsCentered() = assertEquals(1050f, centeredScroll(1500f, 100f, 1000f, 4000f), 0f)
@Test fun rowsNearTheEndsStopAtTheEnds() {
assertEquals(0f, centeredScroll(200f, 100f, 1000f, 4000f), 0f)
assertEquals(3000f, centeredScroll(3800f, 100f, 1000f, 4000f), 0f)
}
@Test fun pageThatFitsDoesNotScroll() = assertEquals(0f, centeredScroll(700f, 100f, 1000f, 800f), 0f)
}
@@ -0,0 +1,43 @@
package com.droiddeck.launcher.ui
import android.content.Context
import org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.RuntimeEnvironment
import org.robolectric.annotation.Config
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [28], manifest = Config.NONE)
class SettingsSearchHistoryTest {
private val context: Context get() = RuntimeEnvironment.getApplication()
@Before fun reset() = SettingsSearchHistory.clear(context)
@Test fun newestComesFirstAndARepeatMovesUp() {
listOf("font", "cpu", "Font ").forEach { SettingsSearchHistory.add(context, it) }
assertEquals(listOf("Font", "cpu"), SettingsSearchHistory.items)
}
@Test fun blankSearchesAreNotKept() {
SettingsSearchHistory.add(context, " ")
assertEquals(emptyList<String>(), SettingsSearchHistory.items)
}
@Test fun onlyTheLatestAreKept() {
(1..SettingsSearchHistory.MAX + 2).forEach { SettingsSearchHistory.add(context, "search $it") }
assertEquals(SettingsSearchHistory.MAX, SettingsSearchHistory.items.size)
assertEquals("search ${SettingsSearchHistory.MAX + 2}", SettingsSearchHistory.items.first())
}
@Test fun savedSearchesLoadInOrderUntilCleared() {
listOf("one", "two, \"three\"").forEach { SettingsSearchHistory.add(context, it) }
SettingsSearchHistory.load(context)
assertEquals(listOf("two, \"three\"", "one"), SettingsSearchHistory.items)
SettingsSearchHistory.clear(context)
SettingsSearchHistory.load(context)
assertEquals(emptyList<String>(), SettingsSearchHistory.items)
}
}
-53
View File
@@ -8,7 +8,6 @@
#define _GNU_SOURCE
#include <dirent.h>
#include <dlfcn.h>
#include <elf.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
@@ -548,55 +547,3 @@ EXPORT uid_t getuid(void)
}
return (uid_t)raw_getuid();
}
static bool read_at(int fd, void *buf, size_t n, off_t at)
{
return pread(fd, buf, n, at) == (ssize_t)n;
}
static void load_needed_of(const char *path)
{
Elf64_Ehdr e;
Elf64_Phdr ph[32];
Elf64_Dyn dyn[128];
uint64_t strtab = 0, strsz = 0, needed[32];
size_t n_dyn = 0, n_needed = 0;
off_t names_at = -1;
char *names = NULL;
int fd = open(path, O_RDONLY | O_CLOEXEC);
if (fd < 0) return;
if (!read_at(fd, &e, sizeof e, 0) || memcmp(e.e_ident, ELFMAG, SELFMAG) || e.e_ident[EI_CLASS] != ELFCLASS64 ||
e.e_phentsize != sizeof *ph || e.e_phnum > 32 || !read_at(fd, ph, e.e_phnum * sizeof *ph, (off_t)e.e_phoff))
goto out;
for (int i = 0; i < e.e_phnum; i++) {
if (ph[i].p_type != PT_DYNAMIC) continue;
n_dyn = ph[i].p_filesz / sizeof *dyn;
if (n_dyn > 128) n_dyn = 128;
if (!read_at(fd, dyn, n_dyn * sizeof *dyn, (off_t)ph[i].p_offset)) goto out;
break;
}
for (size_t i = 0; i < n_dyn && dyn[i].d_tag != DT_NULL; i++) {
if (dyn[i].d_tag == DT_STRTAB) strtab = dyn[i].d_un.d_ptr;
else if (dyn[i].d_tag == DT_STRSZ) strsz = dyn[i].d_un.d_val;
else if (dyn[i].d_tag == DT_NEEDED && n_needed < 32) needed[n_needed++] = dyn[i].d_un.d_val;
}
for (int i = 0; i < e.e_phnum; i++)
if (ph[i].p_type == PT_LOAD && strtab >= ph[i].p_vaddr && strtab - ph[i].p_vaddr + strsz <= ph[i].p_filesz)
names_at = (off_t)(ph[i].p_offset + strtab - ph[i].p_vaddr);
if (names_at < 0 || !strsz || strsz > (16u << 20) || !(names = malloc(strsz + 1)) ||
!read_at(fd, names, strsz, names_at))
goto out;
names[strsz] = 0;
for (size_t i = 0; i < n_needed; i++)
if (needed[i] < strsz && !dlopen(names + needed[i], RTLD_NOW))
say("steamshm: %s, needed by %s, did not load: %s\n", names + needed[i], path, dlerror());
out:
free(names);
close(fd);
}
__attribute__((constructor)) static void link_steamclient_needs_before_it(void)
{
const char *path = getenv("WINESTEAMCLIENTPATH64");
if (path && *path) load_needed_of(path);
}
@@ -1,94 +0,0 @@
import os
from pathlib import Path
import shutil
import subprocess
import tempfile
import unittest
STEAMSHM = Path(__file__).resolve().parents[1] / "bionic-runtime/steamshm.c"
SOURCES = {
"libsystemxml.so": ("int xml_copy(void) { return 1; }\n", []),
"libvendor.so": ("int xml_copy(void);\nint vendor_xml_copy(void) { return xml_copy(); }\n", ["systemxml"]),
"libframework.so": ("int framework(void) { return 0; }\n", ["vendor"]),
"libsteam.so": ("int xml_copy(void) { return 2; }\nint CreateInterface(void) { return 0; }\n", ["framework"]),
}
LOADER_PRELUDE = r"""
#define _GNU_SOURCE
#include <dlfcn.h>
#include <elf.h>
#include <fcntl.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#define say(...) fprintf(stderr, __VA_ARGS__)
"""
def steamclient_loader():
source = STEAMSHM.read_text()
return LOADER_PRELUDE + source[source.index("static bool read_at("):]
PROGRAM = r"""
#include <dlfcn.h>
#include <stdio.h>
int main(void) {
if (!dlopen("libsteam.so", RTLD_NOW)) { puts(dlerror()); return 1; }
void *vendor = dlopen("libvendor.so", RTLD_NOW | RTLD_NOLOAD);
int (*copy)(void) = vendor ? (int (*)(void))dlsym(vendor, "vendor_xml_copy") : 0;
if (!copy) return 1;
printf("%d\n", copy());
return 0;
}
"""
@unittest.skipUnless(shutil.which("cc"), "needs a C compiler")
class SteamClientNeedsTest(unittest.TestCase):
def setUp(self):
self.dir = Path(tempfile.mkdtemp())
self.addCleanup(shutil.rmtree, self.dir, True)
for name, (code, needs) in SOURCES.items():
src = self.dir / (name + ".c")
src.write_text(code)
subprocess.run(["cc", "-shared", "-fPIC", "-o", str(self.dir / name), str(src), "-L", str(self.dir),
"-Wl,--no-as-needed", *("-l" + n for n in needs)], check=True)
(self.dir / "main.c").write_text(PROGRAM)
subprocess.run(["cc", "-o", str(self.dir / "main"), str(self.dir / "main.c"), "-ldl"], check=True)
loader = self.dir / "loader.c"
loader.write_text(steamclient_loader())
self.preload = self.dir / "libsteamshm.so"
subprocess.run(["cc", "-shared", "-fPIC", "-O2", "-Wall", "-Wextra", "-fvisibility=hidden",
str(loader), "-ldl", "-o", str(self.preload)], check=True)
def vendor_binding(self, preload=True, steam=None):
env = {k: v for k, v in os.environ.items() if k not in ("LD_PRELOAD", "WINESTEAMCLIENTPATH64")}
env["LD_LIBRARY_PATH"] = str(self.dir)
if steam:
env["WINESTEAMCLIENTPATH64"] = steam
if preload:
env["LD_PRELOAD"] = str(self.preload)
run = subprocess.run([str(self.dir / "main")], env=env, capture_output=True, text=True, check=True)
return run.stdout.strip()
def test_without_the_preload_a_framework_library_binds_to_steams_copy(self):
self.assertEqual(self.vendor_binding(preload=False), "2")
def test_the_libraries_steam_needs_link_to_their_own_copy_first(self):
self.assertEqual(self.vendor_binding(steam=str(self.dir / "libsteam.so")), "1")
def test_without_a_steam_library_path_nothing_is_loaded_early(self):
self.assertEqual(self.vendor_binding(), "2")
def test_a_missing_or_foreign_steam_library_is_ignored(self):
self.assertEqual(self.vendor_binding(steam=str(self.dir / "missing.so")), "2")
self.assertEqual(self.vendor_binding(steam=str(self.dir / "main.c")), "2")
if __name__ == "__main__":
unittest.main()