mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-04 12:05:39 +00:00
Compare commits
28
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b4b84789d7 | ||
|
|
8f9ce19638 | ||
|
|
b74edb7e8d | ||
|
|
2503d69293 | ||
|
|
5e38e79c96 | ||
|
|
5e5ffee93e | ||
|
|
a7662ae13a | ||
|
|
a249e896f7 | ||
|
|
ca3743520e | ||
|
|
98822fdd27 | ||
|
|
8d0225932c | ||
|
|
40bca96db5 | ||
|
|
a2a9586b54 | ||
|
|
2fe6ba36c4 | ||
|
|
e4c84e6e24 | ||
|
|
10ef8c4bd6 | ||
|
|
8e01cfb2ef | ||
|
|
b25c4ea26b | ||
|
|
cebad5692d | ||
|
|
6b2c8ace09 | ||
|
|
4d1b8421fb | ||
|
|
ced4ac5db8 | ||
|
|
e190f57b53 | ||
|
|
22f02fb6bf | ||
|
|
52c67df4c7 | ||
|
|
de1a734fb5 | ||
|
|
be9939d82c | ||
|
|
e4c375ad0d |
No files matched your search
@@ -0,0 +1,3 @@
|
||||
# Vendored files preserve upstream license spacing and unified-diff context lines.
|
||||
tools/comet/LICENSE whitespace=-blank-at-eof
|
||||
tools/comet/droiddeck.patch whitespace=-blank-at-eol,-blank-at-eof
|
||||
@@ -186,7 +186,7 @@ jobs:
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: app/src/main/assets/linuxfs
|
||||
key: preloads-${{ env.PRELOAD_CACHE_VERSION }}-${{ hashFiles('app/src/main/cpp/fakeinput_steam.cpp', 'tools/linuxfs/preload/*.c', 'tools/linuxfs/build-x86-preloads.sh', 'tools/linuxfs/fex/*', 'tools/linuxfs/clipboard/*.c', 'tools/linuxfs/ssbs/*.c', 'tools/proot/fastpath/*.c', 'tools/linuxfs/overlay/usr/local/bin/*', 'tools/linuxfs/overlay/usr/bin/**', 'tools/linuxfs/desktop/*', 'tools/gamescope/release.env', 'tools/wlroots/release.env', 'tools/linuxfs/uruntime.env', 'tools/linuxfs/licenses/*', 'tools/mangoapp/*', 'tools/msitools/**', 'tools/linuxfs/debian-image.env') }}
|
||||
key: preloads-${{ env.PRELOAD_CACHE_VERSION }}-${{ hashFiles('app/src/main/cpp/fakeinput_steam.cpp', 'app/src/main/cpp/adrenotools/src/hook/kgsl.h', 'tools/quest/*', 'tools/linuxfs/preload/*.c', 'tools/linuxfs/build-x86-preloads.sh', 'tools/linuxfs/fex/*', 'tools/linuxfs/clipboard/*.c', 'tools/linuxfs/ssbs/*.c', 'tools/proot/fastpath/*.c', 'tools/linuxfs/overlay/usr/local/bin/*', 'tools/linuxfs/overlay/usr/bin/**', 'tools/linuxfs/desktop/*', 'tools/gamescope/release.env', 'tools/wlroots/release.env', 'tools/linuxfs/uruntime.env', 'tools/linuxfs/licenses/*', 'tools/mangoapp/*', 'tools/msitools/**', 'tools/comet/**', 'tools/linuxfs/debian-image.env') }}
|
||||
|
||||
- name: Build libfakeinput.so and libblsession.so (glibc aarch64)
|
||||
if: steps.preloads.outputs.cache-hit != 'true'
|
||||
@@ -450,6 +450,13 @@ jobs:
|
||||
restore-keys: |
|
||||
cxx-${{ env.NDK_VERSION }}-
|
||||
|
||||
- name: Build GOG Galaxy companion
|
||||
if: steps.preloads.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
rustup toolchain install 1.90.0 --profile minimal
|
||||
rustup target add --toolchain 1.90.0 aarch64-unknown-linux-gnu
|
||||
RUSTUP_TOOLCHAIN=1.90.0 bash tools/comet/build.sh
|
||||
|
||||
- name: Build
|
||||
id: build
|
||||
env:
|
||||
@@ -457,6 +464,7 @@ jobs:
|
||||
SGDB_API_KEY: ${{ secrets.SGDB_API_KEY }}
|
||||
run: |
|
||||
set -o pipefail
|
||||
python3 tools/quest/build-driver.py "$ANDROID_HOME/ndk/$NDK_VERSION"
|
||||
python3 tools/release/runtime_inputs.py record
|
||||
./gradlew assembleRelease --console=plain -PndkVersion="$NDK_VERSION" 2>&1 | tee /tmp/build.log
|
||||
python3 tools/release/check_session_assets.py app/build/outputs/apk/release/app-release.apk
|
||||
|
||||
+5
-2
@@ -92,8 +92,8 @@ android {
|
||||
// file out of its own data directory, and this app's entire job is to exec a rootfs:
|
||||
// proot, gamescope, the Steam client and everything it launches all live under files/.
|
||||
targetSdkVersion 28
|
||||
versionCode 12
|
||||
versionName "0.3.2"
|
||||
versionCode 13
|
||||
versionName "0.4.0"
|
||||
buildConfigField "String", "BUILD_LABEL", "\"${escapedBuildLabel}\""
|
||||
buildConfigField "String", "SOURCE_COMMIT", "\"${sourceCommit}\""
|
||||
buildConfigField "int", "PR_NUMBER", "${prNumber}"
|
||||
@@ -287,6 +287,9 @@ dependencies {
|
||||
implementation platform('androidx.compose:compose-bom:2024.02.00')
|
||||
implementation 'androidx.compose.ui:ui'
|
||||
implementation 'androidx.compose.material3:material3'
|
||||
// @Preview for the composables; the tooling that renders them is a debug-only dependency.
|
||||
implementation 'androidx.compose.ui:ui-tooling-preview'
|
||||
debugImplementation 'androidx.compose.ui:ui-tooling'
|
||||
implementation 'androidx.activity:activity-compose:1.8.2'
|
||||
// The File Manager, Bannerlator's: its icon set, image thumbnails and the coroutines it
|
||||
// copies on. Same versions as Bannerlator so the screen stays a straight copy.
|
||||
|
||||
@@ -3600,6 +3600,13 @@ static bool wait_snapshot(std::shared_ptr<FakeController> fake,
|
||||
}
|
||||
}
|
||||
|
||||
static int forward_ioctl(int fd, ioctl_request_t op, void *argp) {
|
||||
using ioctl_fn = int (*)(int, ioctl_request_t, ...);
|
||||
// Preserve later preload hooks, including GPU allocation adapters.
|
||||
static const auto next = reinterpret_cast<ioctl_fn>(dlsym(RTLD_NEXT, "ioctl"));
|
||||
return next ? next(fd, op, argp) : static_cast<int>(syscall(SYS_ioctl, fd, op, argp));
|
||||
}
|
||||
|
||||
EXPORT int ioctl(int fd, ioctl_request_t op, ...) {
|
||||
va_list va;
|
||||
void *argp;
|
||||
@@ -3611,7 +3618,7 @@ EXPORT int ioctl(int fd, ioctl_request_t op, ...) {
|
||||
// The lock must not be held across the passthrough: binder's transport is a
|
||||
// blocking ioctl(BINDER_WRITE_READ), so a parked binder pool thread would own
|
||||
// controller_mutex() for as long as it waits and deadlock every other ioctl.
|
||||
if (!watched(fd)) return syscall(SYS_ioctl, fd, op, argp);
|
||||
if (!watched(fd)) return forward_ioctl(fd, op, argp);
|
||||
std::unique_lock<std::recursive_mutex> guard(controller_mutex());
|
||||
auto maker = uinput_map().find(fd);
|
||||
if (maker != uinput_map().end()) return ioctl_uinput(*maker->second, op, argp);
|
||||
@@ -3629,7 +3636,7 @@ EXPORT int ioctl(int fd, ioctl_request_t op, ...) {
|
||||
auto controller = controller_map().find(fd);
|
||||
if (controller == controller_map().end()) {
|
||||
guard.unlock();
|
||||
return syscall(SYS_ioctl, fd, op, argp);
|
||||
return forward_ioctl(fd, op, argp);
|
||||
}
|
||||
|
||||
int type = (op >> 8 & 0xFF);
|
||||
@@ -3825,7 +3832,7 @@ EXPORT int ioctl(int fd, ioctl_request_t op, ...) {
|
||||
} else {
|
||||
Logger::log("Unhandled evdev ioctl, type %d number %d\n", type, number);
|
||||
guard.unlock();
|
||||
return syscall(SYS_ioctl, fd, op, argp);
|
||||
return forward_ioctl(fd, op, argp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -255,7 +255,11 @@ static void target_destroy(struct fx_target *t) {
|
||||
static int target_ensure(struct fx_target *t, int w, int h, const char *what) {
|
||||
if (t->img && t->w == w && t->h == h) return 0;
|
||||
target_destroy(t);
|
||||
VkImageCreateInfo ii = {.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, .imageType = VK_IMAGE_TYPE_2D,
|
||||
/* Unrestricted mutable views keep these render-then-blit targets uncompressed on Turnip.
|
||||
* UBWC targets corrupt even a constant-colour pass on Adreno 740 (FSR becomes black).
|
||||
* Only the chain's intermediate images need this; the scene and guest images stay unchanged. */
|
||||
VkImageCreateInfo ii = {.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
|
||||
.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT, .imageType = VK_IMAGE_TYPE_2D,
|
||||
.format = g_fx_fmt, .extent = {(uint32_t)w, (uint32_t)h, 1}, .mipLevels = 1,
|
||||
.arrayLayers = 1, .samples = VK_SAMPLE_COUNT_1_BIT, .tiling = VK_IMAGE_TILING_OPTIMAL,
|
||||
.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT |
|
||||
@@ -292,6 +296,10 @@ static void scene_release(void) {
|
||||
memset(&g_scene, 0, sizeof(g_scene));
|
||||
}
|
||||
|
||||
void vkp_effects_forget_image(VkImage img) {
|
||||
if (img && g_scene.img == img) scene_release();
|
||||
}
|
||||
|
||||
static int scene_ensure(VkImage img, int w, int h) {
|
||||
if (g_scene.img == img && g_scene.w == w && g_scene.h == h && g_scene.ds) return 0;
|
||||
scene_release();
|
||||
|
||||
@@ -55,6 +55,10 @@ VkImage vkp_effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int sce
|
||||
/* Compositor thread: drop every Vulkan object (device teardown / device lost). */
|
||||
void vkp_effects_destroy(void);
|
||||
|
||||
/* Compositor thread: release the cached source view/descriptor before its owner destroys img.
|
||||
* A later image can reuse the same Vulkan handle and dimensions; that is not the same resource. */
|
||||
void vkp_effects_forget_image(VkImage img);
|
||||
|
||||
/* Compositor thread, before vkp_effects_run(): the format of the scene image it will be handed and the
|
||||
* format its own targets use. R8G8B8A8 / R8G8B8A8 for every SDR frame (the default); A2B10G10R10 /
|
||||
* A2B10G10R10 while an HDR picture runs through it (hdr_compose.h). A target-format change rebuilds the
|
||||
|
||||
@@ -1164,6 +1164,7 @@ static void record_draw(VkCommandBuffer cmd, const struct vkp_draw *d, const VkI
|
||||
}
|
||||
|
||||
static void destroy_scene_image(void) {
|
||||
if (g_scene.img) vkp_effects_forget_image(g_scene.img);
|
||||
if (g_scene.img) hdrc_forget_image(g_scene.img); /* the HDR pass may have drawn into it */
|
||||
if (g_scene.img) blendp_forget_image(g_scene.img);
|
||||
if (g_scene.img) g_vk.DestroyImage(g_dev, g_scene.img, NULL);
|
||||
@@ -1203,6 +1204,7 @@ static int ensure_scene_image(int w, int h) {
|
||||
static int ensure_img(struct vkp_img_slot *s, int w, int h, VkFormat fmt, VkImageUsageFlags usage, const char *what) {
|
||||
if (s->img && s->w == w && s->h == h && s->fmt == fmt) return 0;
|
||||
if (s->img) hdrc_forget_image(s->img);
|
||||
if (s->img) vkp_effects_forget_image(s->img);
|
||||
if (s->img) blendp_forget_image(s->img);
|
||||
if (s->img) g_vk.DestroyImage(g_dev, s->img, NULL);
|
||||
if (s->mem) g_vk.FreeMemory(g_dev, s->mem, NULL);
|
||||
|
||||
@@ -22,6 +22,7 @@ class App : Application() {
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
CrashHandler.install(this)
|
||||
com.droiddeck.launcher.session.QuestExperimental.initialize(this)
|
||||
com.droiddeck.launcher.session.SessionPrefs.settleGpuDriverMode(this)
|
||||
com.droiddeck.launcher.update.AppUpdates.init(this)
|
||||
GpuClockPin.clearLeftover(this)
|
||||
|
||||
@@ -9,10 +9,10 @@ import com.droiddeck.launcher.session.ComponentsManager
|
||||
import com.droiddeck.launcher.session.ProtonDefault
|
||||
|
||||
/**
|
||||
* The Components page's state and work: the Protons and their DXVK/VKD3D sets, the Nightlies
|
||||
* catalog, downloads and the swap/restore actions. The launcher screen keeps one and shows it.
|
||||
* Component state and work for the launcher and session drawer: the Protons and their
|
||||
* DXVK/VKD3D sets, the Nightlies catalog, downloads and the swap/restore actions.
|
||||
*/
|
||||
internal class ComponentsMenu(private val activity: android.app.Activity, private val ui: android.os.Handler) {
|
||||
internal class ComponentsMenu(private val activity: android.app.Activity, private val ui: Handler) {
|
||||
var compSnapshot by mutableStateOf<ComponentsManager.Snapshot?>(null)
|
||||
var compCatalog by mutableStateOf<List<ComponentsManager.CatalogItem>>(emptyList())
|
||||
var compCatalogAt by mutableStateOf(0L)
|
||||
@@ -20,7 +20,10 @@ internal class ComponentsMenu(private val activity: android.app.Activity, privat
|
||||
var compComp by mutableStateOf(com.droiddeck.launcher.ui.GPU_TAB)
|
||||
var compChecking by mutableStateOf(false)
|
||||
var compBusy by mutableStateOf<String?>(null)
|
||||
var compDownloads by mutableStateOf<Map<String, Int>>(emptyMap())
|
||||
var compDownloads: Map<String, Int>
|
||||
get() = downloads
|
||||
private set(value) { downloads = value }
|
||||
val compDownloadRevision: Long get() = downloadRevision
|
||||
private var shownDefault: String? = null
|
||||
|
||||
/** Reads the Protons (and on first open saves their originals) off the UI thread; the Nightlies list comes from its cache. */
|
||||
@@ -72,15 +75,15 @@ internal class ComponentsMenu(private val activity: android.app.Activity, privat
|
||||
}, "components-action").start()
|
||||
}
|
||||
|
||||
fun refreshComponentCatalog() {
|
||||
fun refreshComponentCatalog(force: Boolean = true) {
|
||||
if (compChecking) return
|
||||
compChecking = true
|
||||
Thread({
|
||||
val cat = runCatching { ComponentsManager.catalog(activity, true) }.getOrNull()
|
||||
val cat = runCatching { ComponentsManager.catalog(activity, force) }.getOrNull()
|
||||
ui.post {
|
||||
compChecking = false
|
||||
if (cat == null || cat.items.isEmpty()) android.widget.Toast.makeText(activity, activity.getString(R.string.comp_nightlies_unreachable), android.widget.Toast.LENGTH_LONG).show()
|
||||
else { compCatalog = cat.items; compCatalogAt = cat.fetchedAt }
|
||||
if (cat != null && cat.items.isNotEmpty()) { compCatalog = cat.items; compCatalogAt = cat.fetchedAt }
|
||||
else if (force) android.widget.Toast.makeText(activity, activity.getString(R.string.comp_nightlies_unreachable), android.widget.Toast.LENGTH_LONG).show()
|
||||
}
|
||||
}, "components-catalog").start()
|
||||
}
|
||||
@@ -95,6 +98,7 @@ internal class ComponentsMenu(private val activity: android.app.Activity, privat
|
||||
}.getOrElse { e -> activity.getString(R.string.comp_download_failed, e.message ?: e.javaClass.simpleName) }
|
||||
ui.post {
|
||||
compDownloads = compDownloads - item.file
|
||||
downloadRevision++
|
||||
android.widget.Toast.makeText(activity, message, android.widget.Toast.LENGTH_SHORT).show()
|
||||
refreshComponents()
|
||||
}
|
||||
@@ -102,6 +106,10 @@ internal class ComponentsMenu(private val activity: android.app.Activity, privat
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val TAG = "MainActivity"
|
||||
const val TAG = "ComponentsMenu"
|
||||
// Both screens use the same package store and .part files. Keep the in-flight registry
|
||||
// across menu/activity instances so a package cannot be downloaded twice at once.
|
||||
var downloads by mutableStateOf<Map<String, Int>>(emptyMap())
|
||||
var downloadRevision by mutableStateOf(0L)
|
||||
}
|
||||
}
|
||||
@@ -163,6 +163,7 @@ class MainActivity : ComponentActivity() {
|
||||
private var orientation by mutableStateOf(android.content.pm.ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE)
|
||||
private var launcherFullscreen by mutableStateOf(true)
|
||||
private var animationsEnabled by mutableStateOf(true)
|
||||
private var gameStoresEnabled by mutableStateOf(true)
|
||||
private var gameStoresSpeedTier by mutableStateOf("fast")
|
||||
private var storesOpenTab by mutableStateOf(SessionPrefs.STORES_OPEN_LIBRARY)
|
||||
/** A page a notification asked for ("stores:downloads", "app:<id>"), until the front end has gone there. */
|
||||
@@ -534,6 +535,7 @@ class MainActivity : ComponentActivity() {
|
||||
requestedOrientation = orientation
|
||||
launcherFullscreen = SessionPrefs.launcherFullscreen(this)
|
||||
animationsEnabled = SessionPrefs.animationsEnabled(this)
|
||||
gameStoresEnabled = SessionPrefs.gameStoresEnabled(this)
|
||||
gameStoresSpeedTier = SessionPrefs.gameStoresSpeedTier(this)
|
||||
storesOpenTab = SessionPrefs.storesOpenTab(this)
|
||||
storesShowMature = SessionPrefs.storesShowMature(this)
|
||||
@@ -587,6 +589,7 @@ class MainActivity : ComponentActivity() {
|
||||
orientation = orientation,
|
||||
launcherFullscreen = launcherFullscreen,
|
||||
animationsEnabled = animationsEnabled,
|
||||
gameStoresEnabled = gameStoresEnabled,
|
||||
gameStoresSpeedTier = gameStoresSpeedTier,
|
||||
storesOpenTab = storesOpenTab,
|
||||
navigate = navRequest,
|
||||
@@ -727,6 +730,7 @@ class MainActivity : ComponentActivity() {
|
||||
offline = OfflineMode.enabled(this)
|
||||
},
|
||||
onPageBack = { showPerformance = false; showComponents = false; showMapping = false },
|
||||
onGameStoresEnabled = { on -> SessionPrefs.setGameStoresEnabled(this, on); gameStoresEnabled = on },
|
||||
onTheme = { id -> SessionPrefs.setTheme(this, id); theme = id },
|
||||
onLanguage = { tag ->
|
||||
if (tag != com.droiddeck.launcher.core.AppLanguage.chosen(this)) {
|
||||
@@ -1226,6 +1230,8 @@ class MainActivity : ComponentActivity() {
|
||||
)
|
||||
},
|
||||
)
|
||||
// A download can finish in the session drawer while this page is visible.
|
||||
androidx.compose.runtime.LaunchedEffect(components.compDownloadRevision) { components.refreshComponents() }
|
||||
// A Proton installed or removed changes the stack's list of Protons.
|
||||
androidx.compose.runtime.LaunchedEffect(protons.protonBusyId) { if (protons.protonBusyId == null) components.refreshComponents() }
|
||||
}
|
||||
|
||||
@@ -28,10 +28,12 @@ import android.widget.Toast
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.runtime.withFrameNanos
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.ComposeView
|
||||
import androidx.compose.ui.graphics.toArgb
|
||||
@@ -41,6 +43,12 @@ import com.droiddeck.launcher.core.TextureFiltering
|
||||
import com.droiddeck.launcher.files.InAppFilePicker
|
||||
import com.droiddeck.launcher.frontend.Library
|
||||
import com.droiddeck.launcher.agent.AgentGuest
|
||||
import com.droiddeck.launcher.frontend.LibraryCache
|
||||
import com.droiddeck.launcher.stores.Store
|
||||
import com.droiddeck.launcher.stores.StoreAchievements
|
||||
import com.droiddeck.launcher.stores.StoreGameSidecar
|
||||
import com.droiddeck.launcher.stores.StoreLaunchRequests
|
||||
import com.droiddeck.launcher.ui.SessionAchievements
|
||||
import com.droiddeck.launcher.gpu.FrameGen
|
||||
import com.droiddeck.launcher.gpu.ScreenEffectLooks
|
||||
import com.droiddeck.launcher.gpu.ScreenEffects
|
||||
@@ -255,10 +263,12 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
private var closeAtOnce = false
|
||||
/** The drawer's Components tab: the Protons as last read (ComponentsManager). */
|
||||
private var drawerComponents by mutableStateOf<ComponentsManager.Snapshot?>(null)
|
||||
private val drawerComponentMenu by lazy { ComponentsMenu(this, uiHandler) }
|
||||
private var drawerGameProfileId by mutableStateOf<Long?>(null)
|
||||
private val drawerGameInventory = GameProfileInventoryCache<Library.SteamGame>()
|
||||
private var drawerGameInventoryRevision = 0L
|
||||
private var drawerGameFexPresetSaving by mutableStateOf(false)
|
||||
private var drawerGameNoSteamSaving by mutableStateOf(false)
|
||||
private val drawerGameProfileFollowState = GameProfileFollowState()
|
||||
private data class DrawerGameProfileRefresh(
|
||||
val followsSteam: Boolean,
|
||||
@@ -280,6 +290,9 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
private var padType by mutableStateOf(SessionPrefs.CONTROLLER_DECK)
|
||||
/** The on-screen PC keyboard (ui/PcKeyboard): real key presses, Esc and F1 included. */
|
||||
private var pcKeyboardOpen by mutableStateOf(false)
|
||||
/** The game in front, when its source has achievements. */
|
||||
private var achievementsInFront by mutableStateOf<AchievementsInFront?>(null)
|
||||
private var achievementsOpen by mutableStateOf(false)
|
||||
private var hudOn by mutableStateOf(true)
|
||||
private var upscaler by mutableStateOf(0)
|
||||
private var upscaleSharpness by mutableStateOf(75)
|
||||
@@ -338,6 +351,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
private val deviceListener = object : InputManager.InputDeviceListener {
|
||||
override fun onInputDeviceAdded(deviceId: Int) {
|
||||
logInputDevice("connected", deviceId)
|
||||
padBridge?.syncConnectedControllers()
|
||||
updateOnScreenControls()
|
||||
updatePointerCapture()
|
||||
}
|
||||
@@ -354,7 +368,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
requestedOrientation = SessionPrefs.orientation(this)
|
||||
if (com.droiddeck.launcher.runtime.LinuxRuntimeInstaller.isRemoving() ||
|
||||
com.droiddeck.launcher.runtime.LinuxRuntimeInstaller.isMaintaining()) {
|
||||
runtimeRemovalBlocked = true
|
||||
@@ -494,6 +507,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
when {
|
||||
::loading.isInitialized && loading.ended -> finish()
|
||||
drawerOpen -> drawerOpen = false
|
||||
achievementsOpen -> closeAchievements()
|
||||
pcKeyboardOpen -> pcKeyboardOpen = false
|
||||
else -> routeBackAction()
|
||||
}
|
||||
@@ -514,7 +528,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
defaultFocusHighlightEnabled = false
|
||||
setContent {
|
||||
// The drawer, the PC keyboard and picture in picture take the mouse back.
|
||||
androidx.compose.runtime.LaunchedEffect(drawerOpen, pcKeyboardOpen, pipUi) { updatePointerCapture() }
|
||||
androidx.compose.runtime.LaunchedEffect(drawerOpen, pcKeyboardOpen, achievementsOpen, pipUi) { updatePointerCapture() }
|
||||
DroidDeckTheme {
|
||||
if (pipUi) {
|
||||
if (SessionState.suspended) androidx.compose.foundation.layout.Box(
|
||||
@@ -557,6 +571,15 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
releaseDrawerDirection()
|
||||
}
|
||||
}
|
||||
LaunchedEffect(drawerOpen, achievementsOpen, AgentGuest.focusRevision, StoreAchievements.revision) {
|
||||
if (!drawerOpen && !achievementsOpen) return@LaunchedEffect
|
||||
val found = kotlinx.coroutines.withContext(kotlinx.coroutines.Dispatchers.IO) {
|
||||
runCatching { resolveAchievementsInFront() }
|
||||
.onFailure { Log.w(TAG, "achievements in front: ${it.javaClass.simpleName}") }.getOrNull()
|
||||
}
|
||||
achievementsInFront = found
|
||||
if (found == null) achievementsOpen = false
|
||||
}
|
||||
// The PC keyboard takes it too, for moving over the keys; the drawer opens over it.
|
||||
androidx.compose.runtime.LaunchedEffect(pcKeyboardOpen) { if (pcKeyboardOpen) padBridge?.releaseAll() }
|
||||
if (pcKeyboardOpen) com.droiddeck.launcher.ui.PcKeyboard(
|
||||
@@ -635,6 +658,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
onKeyboardButton = { on -> updateControllerPrefs { ControllerPrefs.setKeyboardButton(this@SessionActivity, on) } },
|
||||
onSteamMenu = if (SessionState.mode == SessionService.MODE_STEAM) ({ sendSteamGuide() }) else null,
|
||||
onQam = if (SessionState.mode == SessionService.MODE_STEAM) ({ triggerSteamQam() }) else null,
|
||||
onAchievements = achievementsInFront?.let { { drawerOpen = false; achievementsOpen = true } },
|
||||
achievementsProgress = achievementsInFront?.progress,
|
||||
// Only where the session set the pad up to be switched (SessionService: deckPad).
|
||||
padType = if (SessionState.mode == SessionService.MODE_STEAM && SessionState.deckPad) padType else null,
|
||||
onPadType = { id ->
|
||||
@@ -711,7 +736,17 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
},
|
||||
onClose = { drawerOpen = false },
|
||||
components = drawerComponents,
|
||||
onComponentsRefresh = { refreshDrawerComponents() },
|
||||
onComponentsRefresh = {
|
||||
refreshDrawerComponents()
|
||||
drawerComponentMenu.refreshComponentCatalog(force = false)
|
||||
},
|
||||
componentCatalog = drawerComponentMenu.compCatalog,
|
||||
componentCatalogAt = drawerComponentMenu.compCatalogAt,
|
||||
componentCatalogChecking = drawerComponentMenu.compChecking,
|
||||
componentDownloads = drawerComponentMenu.compDownloads,
|
||||
componentDownloadRevision = drawerComponentMenu.compDownloadRevision,
|
||||
onComponentCatalogRefresh = { drawerComponentMenu.refreshComponentCatalog() },
|
||||
onComponentDownload = drawerComponentMenu::downloadComponent,
|
||||
gameProfiles = drawerGameProfileRefresh.data?.profiles.orEmpty(),
|
||||
selectedGameProfileId = drawerGameProfileId,
|
||||
selectedGameProfile = drawerGameProfileRefresh.data
|
||||
@@ -726,9 +761,23 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
onSelectedGameProfileRefresh = ::refreshDrawerGameProfile,
|
||||
gameFexPresetSaving = drawerGameFexPresetSaving,
|
||||
onGameFexPreset = ::setDrawerGameFexPreset,
|
||||
gameNoSteamSaving = drawerGameNoSteamSaving,
|
||||
onGameNoSteam = ::setDrawerGameNoSteam,
|
||||
onComponentSwap = { pid, comp, value -> swapDrawerComponent(pid, comp, value) },
|
||||
onGameComponent = ::setDrawerGameComponent,
|
||||
))
|
||||
// The panel takes the pad, as the PC keyboard does.
|
||||
LaunchedEffect(achievementsOpen) {
|
||||
if (achievementsOpen) {
|
||||
padBridge?.releaseAll()
|
||||
withFrameNanos { }
|
||||
sessionOverlay.requestFocus()
|
||||
}
|
||||
}
|
||||
achievementsInFront?.takeIf { achievementsOpen }?.let { inFront ->
|
||||
SessionAchievements(inFront.game, inFront.title, onClose = ::closeAchievements)
|
||||
}
|
||||
com.droiddeck.launcher.ui.AchievementNotificationOverlay()
|
||||
if (SessionState.suspended) SessionPausedOverlay(
|
||||
title = pausedTitle(),
|
||||
onResume = { SessionService.resume(this@SessionActivity) },
|
||||
@@ -769,6 +818,28 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
padBridge?.triggerQam()
|
||||
}
|
||||
|
||||
private fun closeAchievements() { achievementsOpen = false }
|
||||
|
||||
/** A live game window only; Steam's overlay may be in front of that window. */
|
||||
private fun resolveAchievementsInFront(): AchievementsInFront? {
|
||||
if (!SessionState.running || SessionState.mode != SessionService.MODE_STEAM) return null
|
||||
val snapshot = AgentGuest.focus(this) ?: return null
|
||||
val games = LibraryCache.load(this)
|
||||
val byKey = games.mapNotNull { g -> g.profileKey.toLongOrNull()?.let { it to g } }.toMap()
|
||||
val windows = snapshot.optJSONArray("focusableApps")?.let { list -> List(list.length()) { list.optLong(it) } }.orEmpty()
|
||||
val focusedId = snapshot.optLong("focusedApp").takeUnless { snapshot.isNull("focusedApp") }
|
||||
val appId = com.droiddeck.launcher.session.SessionAchievementGame.activeAppId(focusedId, windows, byKey.keys) ?: return null
|
||||
val focused = byKey[appId] ?: return null
|
||||
val store = Store.byId(focused.source) ?: return null
|
||||
val id = focused.storeId ?: return null
|
||||
val source = StoreAchievements.forSource(store.id) ?: return null
|
||||
val sidecar = StoreGameSidecar.find(this, store, id) ?: return null
|
||||
val game = StoreAchievements.Game.of(sidecar)
|
||||
val list = source.cached(this, game) ?: (source.fetch(this, game) as? StoreAchievements.Result.Found)?.list ?: return null
|
||||
if (list.isEmpty()) return null
|
||||
return AchievementsInFront(game, sidecar.title, list.count { it.unlocked } to list.size)
|
||||
}
|
||||
|
||||
private fun togglePcKeyboard() {
|
||||
drawerOpen = false
|
||||
keyboard?.hide()
|
||||
@@ -983,6 +1054,26 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
}, "drawer-game-fex-preset").start()
|
||||
}
|
||||
|
||||
private fun setDrawerGameNoSteam(appId: Long, on: Boolean) {
|
||||
if (drawerGameNoSteamSaving) return
|
||||
drawerGameNoSteamSaving = true
|
||||
val name = drawerGameProfileRefresh.data?.profiles?.firstOrNull { it.first == appId }?.second ?: appId.toString()
|
||||
Thread({
|
||||
val message = try {
|
||||
GameEnvironmentStore.setGameNoSteam(this, appId.toString(), on)
|
||||
getString(R.string.comp_game_saved_next, name)
|
||||
} catch (error: Exception) {
|
||||
Log.w(TAG, "Could not save Start without Steam for $appId", error)
|
||||
getString(R.string.session_profile_save_failed, error.message ?: error.javaClass.simpleName)
|
||||
}
|
||||
uiHandler.post {
|
||||
drawerGameNoSteamSaving = false
|
||||
Toast.makeText(this, message, Toast.LENGTH_LONG).show()
|
||||
refreshDrawerGameProfile()
|
||||
}
|
||||
}, "drawer-game-no-steam").start()
|
||||
}
|
||||
|
||||
/** The session this screen is bringing up: the live one when re-attached, else the intent's. */
|
||||
private fun loadingMode(): String =
|
||||
if (SessionState.running) SessionState.mode
|
||||
@@ -1345,12 +1436,14 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
/**
|
||||
* Follow screen on a large panel (a Fold's inner screen) may turn with the device: a window
|
||||
* locked to landscape on a squarer panel is letterboxed by the system itself, which no output
|
||||
* size can undo. A phone-sized panel (the cover screen) stays landscape as before.
|
||||
* size can undo. Every other case keeps the landscape orientation picked in Setup.
|
||||
*/
|
||||
private fun applyFollowOrientation(config: android.content.res.Configuration) {
|
||||
if (!SessionState.followScreen) return
|
||||
val wanted = if (config.smallestScreenWidthDp >= 600) android.content.pm.ActivityInfo.SCREEN_ORIENTATION_USER
|
||||
else android.content.pm.ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
|
||||
val wanted = if (SessionState.followScreen && config.smallestScreenWidthDp >= 600) {
|
||||
android.content.pm.ActivityInfo.SCREEN_ORIENTATION_USER
|
||||
} else {
|
||||
SessionPrefs.orientation(this)
|
||||
}
|
||||
if (requestedOrientation != wanted) requestedOrientation = wanted
|
||||
}
|
||||
|
||||
@@ -1637,7 +1730,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
}
|
||||
return true
|
||||
}
|
||||
if (pcKeyboardOpen && fromController) return super.dispatchKeyEvent(event)
|
||||
if ((pcKeyboardOpen || achievementsOpen) && fromController) return super.dispatchKeyEvent(event)
|
||||
if (event.keyCode != KeyEvent.KEYCODE_BACK && padBridge?.onKeyEvent(event) == true) return true
|
||||
// A hardware keyboard, forwarded to the compositor's wl_keyboard. Back is left to the
|
||||
// activity, which opens the drawer.
|
||||
@@ -1690,7 +1783,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
return true
|
||||
}
|
||||
if (drawerDirectionKey != KeyEvent.KEYCODE_UNKNOWN) releaseDrawerDirection()
|
||||
if (pcKeyboardOpen && PadBridge.isControllerMotionEvent(event)) return super.dispatchGenericMotionEvent(event)
|
||||
if ((pcKeyboardOpen || achievementsOpen) && PadBridge.isControllerMotionEvent(event)) return super.dispatchGenericMotionEvent(event)
|
||||
if (padBridge?.onMotionEvent(event) == true) return true
|
||||
if (event.isFromSource(android.view.InputDevice.SOURCE_MOUSE) && !drawerOpen && onMouse(event)) return true
|
||||
return super.dispatchGenericMotionEvent(event)
|
||||
@@ -2128,7 +2221,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
private fun updatePointerCapture() {
|
||||
if (!::surfaceView.isInitialized) return
|
||||
val view = window.decorView
|
||||
val want = pointerLocked && resumed && hasWindowFocus() && !drawerOpen && !pcKeyboardOpen && !pipUi && mouseAttached()
|
||||
val want = pointerLocked && resumed && hasWindowFocus() && !drawerOpen && !pcKeyboardOpen && !achievementsOpen && !pipUi && mouseAttached()
|
||||
if (want == view.hasPointerCapture()) return
|
||||
if (want) view.requestPointerCapture() else view.releasePointerCapture()
|
||||
}
|
||||
@@ -2300,6 +2393,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
if (show) {
|
||||
drawerOpen = false
|
||||
pcKeyboardOpen = false
|
||||
achievementsOpen = false
|
||||
pendingBackAction?.let(uiHandler::removeCallbacks)
|
||||
pendingBackAction = null
|
||||
releaseDrawerDirection()
|
||||
@@ -2397,7 +2491,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
requestedOrientation = SessionPrefs.orientation(this)
|
||||
applyFollowOrientation(resources.configuration)
|
||||
if (runtimeRemovalBlocked) return
|
||||
com.droiddeck.launcher.ui.Motion.refresh(this)
|
||||
refreshHomeApp()
|
||||
@@ -2407,6 +2501,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
}
|
||||
(getSystemService(INPUT_SERVICE) as? InputManager)
|
||||
?.registerInputDeviceListener(deviceListener, Handler(Looper.getMainLooper()))
|
||||
if (SessionState.guestPid > 1) padBridge?.syncConnectedControllers()
|
||||
onScreenControls?.reload()
|
||||
controllerSettings = ControllerPrefs.read(this)
|
||||
updateOnScreenControls()
|
||||
@@ -2426,6 +2521,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
// drawer's dim layer can otherwise remain over Steam when this activity returns.
|
||||
drawerOpen = false
|
||||
pcKeyboardOpen = false
|
||||
achievementsOpen = false
|
||||
(getSystemService(INPUT_SERVICE) as? InputManager)?.unregisterInputDeviceListener(deviceListener)
|
||||
releaseDrawerDirection()
|
||||
// A button held when the app goes away would stay held in the ring for the whole session.
|
||||
@@ -2600,3 +2696,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/** [progress]: (unlocked, total) from the cached list. */
|
||||
private class AchievementsInFront(val game: StoreAchievements.Game, val title: String, val progress: Pair<Int, Int>?)
|
||||
@@ -1,6 +1,11 @@
|
||||
package com.droiddeck.launcher.agent
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import android.os.FileObserver
|
||||
import android.util.Log
|
||||
import com.droiddeck.launcher.runtime.LinuxRuntime
|
||||
@@ -16,6 +21,9 @@ import java.util.UUID
|
||||
* whatever runs does so inside the live session with its own environment.
|
||||
*/
|
||||
object AgentGuest {
|
||||
private val main by lazy { Handler(Looper.getMainLooper()) }
|
||||
var focusRevision by mutableIntStateOf(0)
|
||||
private set
|
||||
private const val TAG = "AgentGuest"
|
||||
private const val POLL_MS = 50L
|
||||
private val lock = Any()
|
||||
@@ -70,6 +78,7 @@ object AgentGuest {
|
||||
if (key == lastFocusKey) return
|
||||
lastFocusKey = key
|
||||
}
|
||||
main.post { focusRevision++ }
|
||||
SessionEvents.record("focus.changed", fields + ("seq" to snapshot.optInt("seq")))
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.droiddeck.launcher.core
|
||||
|
||||
import com.droiddeck.launcher.gpu.GpuInfo
|
||||
import com.droiddeck.launcher.gpu.SocNames
|
||||
|
||||
/** Device defaults only: affinity does not reserve cores or lock their clocks. */
|
||||
object CpuAllocationDefaults {
|
||||
data class Allocation(val client: String, val game: String)
|
||||
|
||||
val device: Allocation? by lazy {
|
||||
forDevice(SocNames.model(), GpuInfo.systemProperty("ro.board.platform"),
|
||||
CpuCores.all.associateWith(CpuCores::maxGhz))
|
||||
}
|
||||
|
||||
/** Select by topology, including faster SM8550 variants; never guess core indices. */
|
||||
fun forDevice(model: String, platform: String, frequencies: Map<Int, Double?>): Allocation? {
|
||||
val chip = model.trim().uppercase().substringBefore('-')
|
||||
val gen2 = chip in setOf("SM8550", "QCS8550") ||
|
||||
(chip.isEmpty() && platform.trim().equals("kalama", ignoreCase = true))
|
||||
if (!gen2 || frequencies.size != 8 || frequencies.keys.any { it < 0 } ||
|
||||
frequencies.values.any { it == null || !it.isFinite() || it <= 0.0 }) return null
|
||||
val clusters = frequencies.entries.groupBy { it.value }.toSortedMap(compareBy { it ?: 0.0 }).values.toList()
|
||||
if (clusters.map { it.size } != listOf(3, 4, 1)) return null
|
||||
return Allocation(
|
||||
client = CpuCores.format(clusters[2].map { it.key }.toSet()),
|
||||
game = CpuCores.format(clusters[1].map { it.key }.toSet()),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,10 @@ object CpuCores {
|
||||
return format(if (cores.isEmpty()) all.toSet() else cores)
|
||||
}
|
||||
|
||||
/** An all-core game must undo the affinity inherited from a pinned Steam client. */
|
||||
fun gameLaunchList(list: String, clientPinned: Boolean): String =
|
||||
restrictionOrEmpty(list).ifEmpty { if (clientPinned) listOrAll("") else "" }
|
||||
|
||||
/**
|
||||
* The list only when it is a real restriction, else "". Empty, absent, or naming every core
|
||||
* all mean "no preference": pinning a process to all cores is what the scheduler does
|
||||
|
||||
@@ -147,7 +147,7 @@ object DeviceReport {
|
||||
h("Settings in effect")
|
||||
k("Client core override", SessionPrefs.clientCpusOverride(context))
|
||||
k(" client cores", CpuCores.listOrAll(SessionPrefs.clientCpus(context)))
|
||||
k(" game cores", CpuCores.restrictionOrEmpty(SessionPrefs.gameCpus(context)).ifEmpty { "every core (nothing sent)" })
|
||||
k(" game cores", CpuCores.restrictionOrEmpty(SessionPrefs.gameCpus(context)).ifEmpty { "every core" })
|
||||
k("Turnip sysmem", SessionPrefs.tuSysmem(context))
|
||||
k("Zink lazy descriptors", SessionPrefs.zinkLazy(context))
|
||||
k("Threaded GL (glthread)", SessionPrefs.glThread(context))
|
||||
|
||||
@@ -44,6 +44,20 @@ object GameEnvironment {
|
||||
|
||||
const val FORCE_SSBS = "DROIDDECK_FORCE_SSBS"
|
||||
|
||||
/**
|
||||
* A game's Start without Steam: droiddeck-game-env launches it without Proton's steam.exe (umu's
|
||||
* launch where the Proton has it, else runinprefix), for games that close right away.
|
||||
*/
|
||||
const val NO_STEAM = "DROIDDECK_NO_STEAM"
|
||||
|
||||
fun gameNoSteam(config: Config, scope: String): Boolean =
|
||||
scope.isNotEmpty() && config.games[scope]?.get(NO_STEAM)?.lowercase() in setOf("1", "on", "true", "yes")
|
||||
|
||||
fun withGameNoSteam(config: Config, scope: String, on: Boolean): Config {
|
||||
require(scope.isNotEmpty() && validScope(scope))
|
||||
return withScopeValue(config, scope, NO_STEAM, if (on) "1" else null)
|
||||
}
|
||||
|
||||
fun effective(config: Config, preset: String, scope: String, forceSsbs: Boolean = false): Map<String, String?> =
|
||||
defaults(preset, forceSsbs) + config.shared + if (scope.isEmpty()) emptyMap() else config.games[scope].orEmpty()
|
||||
|
||||
|
||||
@@ -50,7 +50,8 @@ public final class TurnipDriver {
|
||||
/** Adreno 8xx (8 Elite, e.g. a Fold 8's A830). */
|
||||
private static final String DRIVER_A8XX = "turnip-sdk36";
|
||||
/** The two the apk carries; never removable, unpacked on demand. */
|
||||
public static final List<String> BUNDLED = Collections.unmodifiableList(Arrays.asList(DRIVER_A7XX, DRIVER_A8XX));
|
||||
public static final List<String> BUNDLED = Collections.unmodifiableList(Arrays.asList(
|
||||
DRIVER_A7XX, DRIVER_A8XX, com.droiddeck.launcher.session.QuestExperimental.DRIVER));
|
||||
/** Overrides the pick, for a device we cannot reach: a7xx, a8xx or system. */
|
||||
private static final String OVERRIDE_FILE = "Download/droiddeck-driver";
|
||||
/** Bundled drivers the user deleted: hidden from the list, their unpacked copy removed. */
|
||||
|
||||
@@ -566,6 +566,16 @@ public class FakeInputWriter {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the pad, as the Steam client now sees it, has a Quick Access button: a Deck's or a
|
||||
* Steam Controller's does, an Xbox or PlayStation pad's does not (libfakeinput drops the bit).
|
||||
* Unset is the Deck, libfakeinput's default.
|
||||
*/
|
||||
public static boolean padHasQam() {
|
||||
int type = padType;
|
||||
return type < 0 || type == PAD_TYPE_DECK || type == PAD_TYPE_STEAM;
|
||||
}
|
||||
|
||||
/**
|
||||
* Switches what the pad is to the Steam client while the session runs ([PAD_TYPE_DECK],
|
||||
* [PAD_TYPE_STEAM] or [PAD_TYPE_XBOX]); libfakeinput unplugs the old device and plugs in the new.
|
||||
|
||||
@@ -257,6 +257,14 @@ public final class PadBridge {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Publishes every currently connected controller so the client can enumerate all players. */
|
||||
public synchronized void syncConnectedControllers() {
|
||||
for (int deviceId : InputDevice.getDeviceIds()) {
|
||||
InputDevice device = InputDevice.getDevice(deviceId);
|
||||
if (isFromController(device)) publish(slotFor(device));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called (main thread) when a player presses a button, pushes a stick, trigger or d-pad past
|
||||
* halfway, or uses the on-screen controls - the session hides its mouse cursor then. Resting
|
||||
@@ -392,8 +400,8 @@ public final class PadBridge {
|
||||
boolean qamStarted = qamPressed && !systemQamPressed;
|
||||
systemGuidePressed = guidePressed;
|
||||
systemQamPressed = qamPressed;
|
||||
// A Deck controller's QAM button is held for as long as the touch one is.
|
||||
if (qamStarted && !SessionState.getDeckPad()) startQamChord();
|
||||
// A Deck or Steam Controller's QAM button is held for as long as the touch one is.
|
||||
if (qamStarted && !nativeQam()) startQamChord();
|
||||
else publish();
|
||||
}
|
||||
|
||||
@@ -418,9 +426,18 @@ public final class PadBridge {
|
||||
}
|
||||
}
|
||||
|
||||
/** Opens the client's Quick Access menu: a tap of the Deck's button, or the Guide-then-A chord. */
|
||||
/**
|
||||
* Whether the client's pad has its own QAM button to press. The Deck's sysfs being up is not
|
||||
* enough: the drawer can make the pad an Xbox or PlayStation one, which has none, and a press
|
||||
* of it never reaches the client.
|
||||
*/
|
||||
private static boolean nativeQam() {
|
||||
return SessionState.getDeckPad() && FakeInputWriter.padHasQam();
|
||||
}
|
||||
|
||||
/** Opens the client's Quick Access menu: a tap of the pad's button, or the Guide-then-A chord. */
|
||||
public synchronized void triggerQam() {
|
||||
if (!SessionState.getDeckPad()) {
|
||||
if (!nativeQam()) {
|
||||
startQamChord();
|
||||
return;
|
||||
}
|
||||
@@ -563,7 +580,7 @@ public final class PadBridge {
|
||||
return;
|
||||
}
|
||||
boolean guide = systemGuidePressed || qamChordActive;
|
||||
boolean qam = SessionState.getDeckPad() && (systemQamPressed || qamTapPressed);
|
||||
boolean qam = nativeQam() && (systemQamPressed || qamTapPressed);
|
||||
if (!guide && !qam) {
|
||||
writer.writePad(state);
|
||||
return;
|
||||
|
||||
@@ -59,15 +59,31 @@ class TouchpadGestures(
|
||||
private var moverLastX = 0f
|
||||
private var moverLastY = 0f
|
||||
private var holdDrag = false
|
||||
private var clicked = 0
|
||||
private val longPress = Runnable {
|
||||
held = true
|
||||
dragging = true
|
||||
listener.onLongPress()
|
||||
listener.onButton(PointerGestures.BTN_LEFT, true, x, y)
|
||||
}
|
||||
private val clickUp = Runnable { releaseClick() }
|
||||
|
||||
private fun click(button: Int) {
|
||||
releaseClick()
|
||||
listener.onButton(button, true, x, y)
|
||||
clicked = button
|
||||
handler.postDelayed(clickUp, CLICK_MS)
|
||||
}
|
||||
|
||||
private fun releaseClick() {
|
||||
handler.removeCallbacks(clickUp)
|
||||
if (clicked != 0) listener.onButton(clicked, false, x, y)
|
||||
clicked = 0
|
||||
}
|
||||
|
||||
fun cancel() {
|
||||
handler.removeCallbacks(longPress)
|
||||
releaseClick()
|
||||
if (dragging) listener.onButton(PointerGestures.BTN_LEFT, false, x, y)
|
||||
dragging = false
|
||||
held = false
|
||||
@@ -85,6 +101,7 @@ class TouchpadGestures(
|
||||
fun onTouch(event: MotionEvent): Boolean {
|
||||
when (event.actionMasked) {
|
||||
MotionEvent.ACTION_DOWN -> {
|
||||
releaseClick()
|
||||
lastX = event.x; lastY = event.y
|
||||
downAt = event.eventTime
|
||||
travelled = 0f; held = false; twoFingers = false; scrolled = false; secondWasTap = false
|
||||
@@ -204,8 +221,7 @@ class TouchpadGestures(
|
||||
}
|
||||
// The second finger lifting quickly, with nothing scrolled: a right click.
|
||||
if (twoFingers && secondWasTap && event.eventTime - secondDownAt < TAP_MS && !scrolled) {
|
||||
listener.onButton(PointerGestures.BTN_RIGHT, true, x, y)
|
||||
listener.onButton(PointerGestures.BTN_RIGHT, false, x, y)
|
||||
click(PointerGestures.BTN_RIGHT)
|
||||
secondWasTap = false
|
||||
}
|
||||
return true
|
||||
@@ -218,13 +234,11 @@ class TouchpadGestures(
|
||||
twoFingers -> {
|
||||
// Both fingers down and up together, no scroll: a right click.
|
||||
if (secondWasTap && !scrolled && !cancelled && event.eventTime - downAt < TAP_MS * 2) {
|
||||
listener.onButton(PointerGestures.BTN_RIGHT, true, x, y)
|
||||
listener.onButton(PointerGestures.BTN_RIGHT, false, x, y)
|
||||
click(PointerGestures.BTN_RIGHT)
|
||||
}
|
||||
}
|
||||
!cancelled && travelled <= slopPx && event.eventTime - downAt < TAP_MS -> {
|
||||
listener.onButton(PointerGestures.BTN_LEFT, true, x, y)
|
||||
listener.onButton(PointerGestures.BTN_LEFT, false, x, y)
|
||||
click(PointerGestures.BTN_LEFT)
|
||||
lastTapAt = event.eventTime
|
||||
}
|
||||
}
|
||||
@@ -239,6 +253,7 @@ class TouchpadGestures(
|
||||
companion object {
|
||||
private const val HOLD_MS = 500L
|
||||
private const val TAP_MS = 300L
|
||||
private const val CLICK_MS = 50L
|
||||
private const val DOUBLE_TAP_MS = 300L
|
||||
private const val SCROLL_STEP_PX = 36f
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ import java.util.concurrent.atomic.AtomicInteger
|
||||
*/
|
||||
object BwrapSpawner {
|
||||
private const val TAG = "BwrapSpawner"
|
||||
const val SOCKET = "com.droiddeck.launcher.bwrap"
|
||||
fun socket(context: Context): String = "${context.packageName}.bwrap"
|
||||
private val seq = AtomicInteger()
|
||||
@Volatile private var server: LocalServerSocket? = null
|
||||
|
||||
@@ -42,10 +42,11 @@ object BwrapSpawner {
|
||||
fun start(context: Context) {
|
||||
if (server != null) return
|
||||
val app = context.applicationContext
|
||||
val name = socket(app)
|
||||
val socket = try {
|
||||
LocalServerSocket(SOCKET)
|
||||
LocalServerSocket(name)
|
||||
} catch (e: IOException) {
|
||||
Log.e(TAG, "cannot listen on $SOCKET", e)
|
||||
Log.e(TAG, "cannot listen on $name", e)
|
||||
return
|
||||
}
|
||||
server = socket
|
||||
|
||||
@@ -51,6 +51,7 @@ object GuestCommand {
|
||||
"/usr/bin/env", "-i", "HOME=/root", "USER=root", "LANG=C.UTF-8",
|
||||
"PATH=/usr/local/bin:/usr/bin:/bin", "XDG_RUNTIME_DIR=${LinuxRuntime.GUEST_RUNTIME_DIR}",
|
||||
"XDG_DATA_HOME=/root/.local/share", "FLATPAK_BWRAP=${FlatpakManager.BWRAP}",
|
||||
"DROIDDECK_BWRAP_SOCKET=${BwrapSpawner.socket(context)}",
|
||||
"XDG_DATA_DIRS=/root/.local/share/flatpak/exports/share:/usr/local/share:/usr/share",
|
||||
)
|
||||
cmd += argv
|
||||
|
||||
@@ -406,9 +406,11 @@ object ComponentsManager {
|
||||
return Package(f.name, comp, prof.optString("versionName", f.nameWithoutExtension), prof.optString("description"), f.length())
|
||||
}
|
||||
|
||||
/** The stored packages, newest version first. */
|
||||
fun packages(context: Context): List<Package> = packagesDir(context).listFiles()
|
||||
?.filter { it.isFile && it.name.endsWith(".wcp") }?.sortedBy { it.name }
|
||||
?.filter { it.isFile && it.name.endsWith(".wcp") }
|
||||
?.mapNotNull { f -> runCatching { packageInfo(context, f) }.onFailure { Log.w(TAG, "skipping ${f.name}", it) }.getOrNull() }
|
||||
?.sortedWith(newestFirst { it.version.ifEmpty { it.file } })
|
||||
?: emptyList()
|
||||
|
||||
/** Unpacks a package's files/ into a Proton; for DXVK/VKD3D the component's own DLLs are replaced as a set. */
|
||||
@@ -852,10 +854,14 @@ object ComponentsManager {
|
||||
val arr = o.optJSONArray("items") ?: JSONArray()
|
||||
val items = (0 until arr.length()).map { arr.getJSONObject(it) }.map {
|
||||
CatalogItem(it.optString("file"), it.optString("comp"), it.optString("release"), it.optString("url"), it.optLong("size"), it.optString("digest"))
|
||||
}.sortedWith(compareBy({ it.comp }, { it.release }, { it.file }))
|
||||
}.sortedWith(compareBy<CatalogItem> { it.comp }.then(newestFirst { it.file }))
|
||||
return Catalog(items, o.optLong("fetchedAt"))
|
||||
}
|
||||
|
||||
/** By the version in [of], highest first: the newest builds lead a list, as they are what is picked. */
|
||||
private fun <T> newestFirst(of: (T) -> String): Comparator<T> =
|
||||
Comparator { a, b -> ProtonExtras.compareVersions(of(b), of(a)) }
|
||||
|
||||
/**
|
||||
* A package Proton does not ship, required on the GPUs listed here. An empty [models] set
|
||||
* means every model in [families]. A row the user already chose in Components is left alone;
|
||||
|
||||
@@ -24,6 +24,12 @@ object CrashHandler {
|
||||
Thread.setDefaultUncaughtExceptionHandler { thread, error ->
|
||||
try {
|
||||
Log.e(TAG, "uncaught on ${thread.name}", error)
|
||||
if (QuestExperimental.isSupported()) runCatching {
|
||||
File(context.filesDir, "quest-last-crash.txt").writeText(
|
||||
"${java.time.Instant.now()} thread=${thread.name}\n" +
|
||||
StringWriter().also { error.printStackTrace(PrintWriter(it)) }.toString()
|
||||
)
|
||||
}
|
||||
val dir = SessionPaths.current()
|
||||
if (dir != null && dir.isDirectory) {
|
||||
val trace = StringWriter().also { error.printStackTrace(PrintWriter(it)) }.toString()
|
||||
|
||||
@@ -65,6 +65,13 @@ object GameEnvironmentStore {
|
||||
return config
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun setGameNoSteam(context: Context, scope: String, on: Boolean): GameEnvironment.Config {
|
||||
val config = GameEnvironment.withGameNoSteam(read(context), scope, on)
|
||||
save(context, config)
|
||||
return config
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun publish(context: Context, config: GameEnvironment.Config = read(context)) {
|
||||
val resolved = config.copy(shared = GameEnvironment.defaults(SessionPrefs.fexPreset(context), SessionPrefs.forceSsbs(context)) + config.shared)
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import com.droiddeck.launcher.BuildConfig
|
||||
import java.io.File
|
||||
|
||||
/** Device-detected defaults and launch evidence for experimental Quest compatibility. */
|
||||
object QuestExperimental {
|
||||
private const val TAG = "QuestExperimental"
|
||||
const val DRIVER = "turnip25.1.0-quest1"
|
||||
|
||||
// Quest 2 has an A6xx GPU and cannot use this bundled A7xx driver.
|
||||
internal fun supported(model: String, device: String, manufacturer: String): Boolean =
|
||||
model.equals("Quest 3", ignoreCase = true) || model.equals("Quest 3S", ignoreCase = true) ||
|
||||
((manufacturer.equals("Oculus", ignoreCase = true) || manufacturer.equals("Meta", ignoreCase = true)) &&
|
||||
(device == "eureka" || device == "panther"))
|
||||
|
||||
fun isSupported(): Boolean = supported(Build.MODEL, Build.DEVICE, Build.MANUFACTURER)
|
||||
|
||||
fun initialize(context: Context) {
|
||||
if (!isSupported()) return
|
||||
val prefs = context.getSharedPreferences("session", Context.MODE_PRIVATE)
|
||||
if (!prefs.getBoolean("questDefaultsV1", false)) {
|
||||
// Auto would download an unwrapped display driver and lose the compatibility path.
|
||||
// Apply once so deliberate changes made during headset testing remain possible.
|
||||
prefs.edit()
|
||||
.putString("gpuDriverMode", SessionPrefs.GPU_DRIVERS_MANUAL)
|
||||
.putString("androidDriver", DRIVER)
|
||||
.putString("linuxDriver", "")
|
||||
// The existing HDR option uses SurfaceControl presentation. This is a
|
||||
// corruption workaround from upstream issue #245, not a claim of HDR accuracy.
|
||||
.putBoolean("hdr.steam", true)
|
||||
.putBoolean("questDefaultsV1", true)
|
||||
.apply()
|
||||
}
|
||||
val report = buildString {
|
||||
appendLine("DroidDeck Quest Experimental ${BuildConfig.VERSION_NAME}")
|
||||
appendLine("package=${context.packageName}")
|
||||
appendLine("manufacturer=${Build.MANUFACTURER} model=${Build.MODEL}")
|
||||
appendLine("device=${Build.DEVICE} board=${Build.BOARD} hardware=${Build.HARDWARE}")
|
||||
appendLine("android=${Build.VERSION.RELEASE} sdk=${Build.VERSION.SDK_INT}")
|
||||
appendLine("abis=${Build.SUPPORTED_ABIS.joinToString()}")
|
||||
for (name in listOf("gpu_model", "gpu_chipid")) {
|
||||
val value = runCatching { File("/sys/class/kgsl/kgsl-3d0/$name").readText().trim() }
|
||||
.getOrDefault("unavailable")
|
||||
appendLine("$name=$value")
|
||||
}
|
||||
appendLine("driverMode=${SessionPrefs.gpuDriverMode(context)}")
|
||||
appendLine("androidDriver=${SessionPrefs.androidDriver(context)}")
|
||||
appendLine("steamSurfaceControlWorkaround=${SessionPrefs.hdr(context, "steam")}")
|
||||
appendLine("GPUOBJ fallback installed in Android driver and ARM64 libblsession")
|
||||
appendLine("Experimental Quest 3/3S compatibility; 2D panel application")
|
||||
}
|
||||
Log.i(TAG, report)
|
||||
runCatching { File(context.filesDir, "quest-startup.txt").writeText(report) }
|
||||
.onFailure { Log.w(TAG, "Could not write startup report", it) }
|
||||
}
|
||||
}
|
||||
@@ -16,13 +16,16 @@ data class SelectedGameProfile(
|
||||
val componentFiles: Map<String, String>,
|
||||
val environmentOverrides: Int,
|
||||
val windowsComponentNames: List<String>,
|
||||
/** Start without Steam (GameEnvironment.NO_STEAM) is on for this game. */
|
||||
val startWithoutSteam: Boolean = false,
|
||||
) {
|
||||
val hasOverrides: Boolean
|
||||
get() = !fexPreset.inherited ||
|
||||
!proton.inherited ||
|
||||
components.values.any { !it.inherited } ||
|
||||
environmentOverrides > 0 ||
|
||||
windowsComponentNames.isNotEmpty()
|
||||
windowsComponentNames.isNotEmpty() ||
|
||||
startWithoutSteam
|
||||
|
||||
companion object {
|
||||
fun resolve(
|
||||
@@ -50,7 +53,9 @@ data class SelectedGameProfile(
|
||||
inherited = override == null,
|
||||
)
|
||||
}
|
||||
val otherEnvironment = environment.games[game.profileKey].orEmpty().keys - FexPreset.environmentKeys
|
||||
// Start without Steam is a switch of its own on the Games page, listed by name.
|
||||
val otherEnvironment = environment.games[game.profileKey].orEmpty().keys - FexPreset.environmentKeys -
|
||||
GameEnvironment.NO_STEAM
|
||||
return SelectedGameProfile(
|
||||
appId = selectedAppId,
|
||||
name = game.name,
|
||||
@@ -64,6 +69,7 @@ data class SelectedGameProfile(
|
||||
componentFiles = gameComponents,
|
||||
environmentOverrides = otherEnvironment.size,
|
||||
windowsComponentNames = gameWindowsComponents.map(WinComponentNames::of),
|
||||
startWithoutSteam = GameEnvironment.gameNoSteam(environment, game.profileKey),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
/** An active game needs a live window; a launch URL or stale Steam base layer is insufficient. */
|
||||
internal object SessionAchievementGame {
|
||||
fun activeAppId(focused: Long?, windows: List<Long>, installed: Set<Long>): Long? {
|
||||
if (focused != null && focused > 0 && focused != 769L) {
|
||||
return focused.takeIf { it in windows && it in installed }
|
||||
}
|
||||
return windows.filter { it != 769L && it in installed }.distinct().singleOrNull()
|
||||
}
|
||||
}
|
||||
@@ -140,7 +140,7 @@ object SessionFiles {
|
||||
"usr/local/bin/gamescope" to "usr/local/bin/gamescope",
|
||||
"usr/local/lib/droiddeck/uruntime" to "usr/local/lib/droiddeck/uruntime",
|
||||
"usr/local/share/licenses/uruntime/LICENSE" to "usr/local/share/licenses/uruntime/LICENSE",
|
||||
) + mangoapp + msitools.map { it to it } + fexPreloads).filter { (asset, _) ->
|
||||
) + mangoapp + listOf("comet", "GalaxyCommunication.exe", "update-permissions.exe", "LICENSE", "version").map { "usr/local/lib/droiddeck-comet/$it" to "usr/local/lib/droiddeck-comet/$it" } + msitools.map { it to it } + fexPreloads).filter { (asset, _) ->
|
||||
val dir = asset.substringBeforeLast('/')
|
||||
runCatching { context.assets.list("linuxfs/$dir")?.contains(asset.substringAfterLast('/')) == true }.getOrDefault(false)
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.content.Context
|
||||
import android.content.pm.ActivityInfo
|
||||
import androidx.annotation.StringRes
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.core.CpuAllocationDefaults
|
||||
import com.droiddeck.launcher.core.GameEnvironment
|
||||
import com.droiddeck.launcher.core.TextureFiltering
|
||||
import com.droiddeck.launcher.gpu.ScreenEffects
|
||||
@@ -71,6 +72,12 @@ object SessionPrefs {
|
||||
prefs(context).edit().putBoolean("animations", on).apply()
|
||||
}
|
||||
|
||||
fun gameStoresEnabled(context: Context): Boolean = prefs(context).getBoolean("gameStoresEnabled", true)
|
||||
|
||||
fun setGameStoresEnabled(context: Context, on: Boolean) {
|
||||
prefs(context).edit().putBoolean("gameStoresEnabled", on).apply()
|
||||
}
|
||||
|
||||
/** The store download engine's speed tier (stores/download/StoreDownloadTier ids); Fast unless chosen otherwise. */
|
||||
fun gameStoresSpeedTier(context: Context): String = prefs(context).getString("gameStoresSpeedTier", "fast") ?: "fast"
|
||||
|
||||
@@ -265,26 +272,34 @@ object SessionPrefs {
|
||||
prefs(context).edit().putBoolean("wifiDiscoveryAsked", true).apply()
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the client's own core pick is overridden. When on, BL_CLIENT_CPUS is sent even when
|
||||
* it names every core - unlike a game mask, the point here is to undo a pin Steam applies to
|
||||
* itself, and the scheduler's default is exactly what Steam's choice takes away.
|
||||
*/
|
||||
fun clientCpusOverride(context: Context): Boolean = prefs(context).getBoolean("clientCpusOverride", false)
|
||||
internal data class CoreAllocation(val clientOverride: Boolean, val clientCpus: String, val gameCpus: String)
|
||||
|
||||
/** Defaults are read only for absent keys; even a saved empty/all-core choice wins. */
|
||||
internal fun coreAllocation(context: Context, defaults: CpuAllocationDefaults.Allocation? = CpuAllocationDefaults.device): CoreAllocation {
|
||||
val saved = prefs(context)
|
||||
return CoreAllocation(
|
||||
saved.getBoolean("clientCpusOverride", defaults != null && !saved.contains("clientCpus")),
|
||||
saved.getString("clientCpus", defaults?.client.orEmpty()).orEmpty(),
|
||||
saved.getString("gameCpus", defaults?.game.orEmpty()).orEmpty(),
|
||||
)
|
||||
}
|
||||
|
||||
/** Use the device default until the user saves an override or a client mask. */
|
||||
fun clientCpusOverride(context: Context): Boolean = coreAllocation(context).clientOverride
|
||||
|
||||
fun setClientCpusOverride(context: Context, on: Boolean) {
|
||||
prefs(context).edit().putBoolean("clientCpusOverride", on).apply()
|
||||
}
|
||||
|
||||
/** Comma-separated core list for the client (taskset -c syntax); "" = every core. */
|
||||
fun clientCpus(context: Context): String = prefs(context).getString("clientCpus", "") ?: ""
|
||||
fun clientCpus(context: Context): String = coreAllocation(context).clientCpus
|
||||
|
||||
fun setClientCpus(context: Context, list: String) {
|
||||
prefs(context).edit().putString("clientCpus", list).apply()
|
||||
}
|
||||
|
||||
/** Comma-separated core list for games (taskset -c syntax); "" = every core = nothing sent. */
|
||||
fun gameCpus(context: Context): String = prefs(context).getString("gameCpus", "") ?: ""
|
||||
/** Comma-separated core list for games (taskset -c syntax); "" = every core (explicitly restored when the client is pinned). */
|
||||
fun gameCpus(context: Context): String = coreAllocation(context).gameCpus
|
||||
|
||||
fun setGameCpus(context: Context, list: String) {
|
||||
prefs(context).edit().putString("gameCpus", list).apply()
|
||||
|
||||
@@ -334,6 +334,7 @@ class SessionService : Service() {
|
||||
SessionFiles.stage(this, root)
|
||||
com.droiddeck.launcher.agent.AgentGuest.reset(this)
|
||||
// The compat tool asks for an Epic game's sign-in code at every launch, the client's Play button included.
|
||||
com.droiddeck.launcher.stores.gog.GogComet.begin()
|
||||
com.droiddeck.launcher.stores.StoreLaunchRequests.start(this)
|
||||
|
||||
val sessionDir = openSessionFolder()
|
||||
@@ -381,7 +382,12 @@ class SessionService : Service() {
|
||||
val controllersOn = !File(Environment.getExternalStorageDirectory(), NO_PAD_SWITCH).exists()
|
||||
SessionState.deckPad = false
|
||||
deckBinds = emptyList()
|
||||
if (controllersOn) addControllerEnvironment(guest, fakeInputDir, sessionDir)
|
||||
if (controllersOn) {
|
||||
addControllerEnvironment(guest, fakeInputDir, sessionDir)
|
||||
// Steam enumerates /dev/input while it starts. Make every attached controller's
|
||||
// discovery node exist after the rings and guest environment are ready.
|
||||
SessionState.padBridge?.syncConnectedControllers()
|
||||
}
|
||||
// The user's own games, for the runtime's shortcuts writer to put in the client's library
|
||||
// before the client starts (see frontend/AddedGames and droiddeck-steam-shortcuts).
|
||||
if (steamHere) {
|
||||
@@ -579,6 +585,8 @@ class SessionService : Service() {
|
||||
private fun addClientEnvironment(guest: MutableList<String>, steamHere: Boolean) {
|
||||
guest.add("/usr/bin/env")
|
||||
guest.add("-i")
|
||||
// PRoot executes guest[0] directly; assignments belong after env -i.
|
||||
guest.add("DROIDDECK_BWRAP_SOCKET=" + com.droiddeck.launcher.runtime.BwrapSpawner.socket(this))
|
||||
guest.add("HOME=/root")
|
||||
guest.add("USER=root")
|
||||
guest.add("PATH=/usr/local/bin:/usr/bin:/bin")
|
||||
@@ -661,16 +669,15 @@ class SessionService : Service() {
|
||||
extraEnv().forEach { guest.add(it) }
|
||||
// The agent bridge's experiment lines (AgentEnv), after the user's so an agent's win.
|
||||
com.droiddeck.launcher.agent.AgentEnv.beginSession(this).forEach { guest.add(it) }
|
||||
// Core masks, Bannerlator's two (cfca3912). The client's is sent whenever the override is
|
||||
// on, even naming every core: it exists to undo the pin Steam applies to its own interface
|
||||
// renderer, and the scheduler's default is exactly what that pin takes away. A game's is
|
||||
// sent only when it is a real restriction - a game has no pin of its own to undo.
|
||||
if (steamHere && SessionPrefs.clientCpusOverride(this)) {
|
||||
// A game launched by pinned Steam inherits its mask. Explicitly restore all game cores
|
||||
// when requested, as well as applying restricted game choices in the Proton wrapper.
|
||||
val clientPinned = steamHere && SessionPrefs.clientCpusOverride(this)
|
||||
if (clientPinned) {
|
||||
guest.add("BL_CLIENT_CPUS=" + CpuCores.listOrAll(SessionPrefs.clientCpus(this)))
|
||||
}
|
||||
// The game cores also pin the desktop and a program from the rail; without a choice the
|
||||
// session script picks every core but the slowest cluster for those (program_cores).
|
||||
CpuCores.restrictionOrEmpty(SessionPrefs.gameCpus(this))
|
||||
CpuCores.gameLaunchList(SessionPrefs.gameCpus(this), clientPinned)
|
||||
.takeIf { it.isNotEmpty() }?.let { guest.add("BL_GAME_CPUS=$it") }
|
||||
}
|
||||
|
||||
@@ -1536,6 +1543,7 @@ class SessionService : Service() {
|
||||
}
|
||||
updateDownloadMonitoring()
|
||||
val stoppedGen = sessionGen
|
||||
val stoppedSession = SessionState.sessionId
|
||||
SessionState.stopRequested = false
|
||||
SessionEvents.record("guest.exited", mapOf("status" to status))
|
||||
GpuClockPin.stop(this)
|
||||
@@ -1582,13 +1590,14 @@ class SessionService : Service() {
|
||||
if (prootPid > 1 || auxiliary.isNotEmpty()) {
|
||||
Thread({
|
||||
if (prootPid > 1 && steamClientMayRun) askSteamToExit(prootPid)
|
||||
com.droiddeck.launcher.stores.gog.GogComet.end(stoppedSession)
|
||||
auxiliary.forEach { (pid, started) -> teardown(pid, started) }
|
||||
if (prootPid > 1) teardown(prootPid)
|
||||
killGuestLeftovers()
|
||||
finishSessionStop(status, stoppedGen)
|
||||
}, "session-teardown").start()
|
||||
} else {
|
||||
finishSessionStop(status, stoppedGen)
|
||||
Thread({ com.droiddeck.launcher.stores.gog.GogComet.end(stoppedSession); finishSessionStop(status, stoppedGen) }, "gog-session-stop").start()
|
||||
}
|
||||
}
|
||||
if (prootPid > 1) acquireLocks()
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.droiddeck.launcher.stores
|
||||
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import org.json.JSONObject
|
||||
|
||||
/** Session-owned unlocks; history reads and upload acknowledgements never create notifications. */
|
||||
object AchievementNotifications {
|
||||
data class Unlock(val client: String, val id: String, val name: String, val description: String, val icon: String?, val game: String)
|
||||
|
||||
private var session: String? = null
|
||||
private val seen = HashSet<String>()
|
||||
var pending by mutableStateOf<List<Unlock>>(emptyList())
|
||||
private set
|
||||
|
||||
fun begin(owner: String?) = StoresState.post {
|
||||
session = owner
|
||||
seen.clear()
|
||||
pending = emptyList()
|
||||
}
|
||||
|
||||
fun end(owner: String?) = StoresState.post {
|
||||
if (session == owner) {
|
||||
session = null
|
||||
seen.clear()
|
||||
pending = emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
fun unlock(owner: String, unlock: Unlock) = StoresState.post {
|
||||
if (session == owner && seen.add("${unlock.client}:${unlock.id}")) {
|
||||
pending = (pending + unlock).take(16)
|
||||
}
|
||||
}
|
||||
|
||||
fun dismiss(unlock: Unlock) {
|
||||
if (pending.firstOrNull() === unlock) pending = pending.drop(1)
|
||||
}
|
||||
|
||||
/** Only presentation fields from the owned daemon, bounded before entering Compose. */
|
||||
fun parse(event: JSONObject, game: String): Unlock? {
|
||||
val client = event.optString("client_id")
|
||||
val id = event.optString("id")
|
||||
val name = event.optString("name").trim()
|
||||
if (!client.matches(Regex("[0-9]{1,32}")) || id.isBlank() || id.length > 256 || name.isEmpty()) return null
|
||||
val icon = event.optString("icon").takeIf { it.length <= 2048 && it.startsWith("https://") }
|
||||
return Unlock(client, id, name.take(256), event.optString("description").take(1024), icon, game.take(256))
|
||||
}
|
||||
}
|
||||
@@ -137,7 +137,7 @@ object CloudSaves {
|
||||
val galaxy = GogAuth.validToken(context)
|
||||
val clientId = gogClientId(context, id, folder)
|
||||
if (userId.isEmpty() || galaxy == null || clientId == null) null
|
||||
else GogCloud(userId, clientId, gogScopedToken(context, id, clientId, account?.optString("refresh_token").orEmpty()) ?: galaxy)
|
||||
else GogCloud(userId, clientId, gogScopedToken(context, id, clientId) ?: galaxy)
|
||||
}
|
||||
Store.EPIC -> {
|
||||
val token = EpicCredentialStore.getValidAccessToken(context)
|
||||
@@ -148,17 +148,9 @@ object CloudSaves {
|
||||
}
|
||||
|
||||
/** GOG cloud storage wants a token issued to the game's own client: the Galaxy refresh token, exchanged with the game's id and secret. */
|
||||
private fun gogScopedToken(context: Context, id: String, clientId: String, refresh: String): String? {
|
||||
private fun gogScopedToken(context: Context, id: String, clientId: String): String? {
|
||||
val secret = GogPrefs.get(context).getString("client_secret_$id", null)?.ifEmpty { null } ?: return null
|
||||
if (refresh.isEmpty()) return null
|
||||
return try {
|
||||
val enc = { s: String -> java.net.URLEncoder.encode(s, "UTF-8") }
|
||||
val c = URL("https://auth.gog.com/token?client_id=${enc(clientId)}&client_secret=${enc(secret)}&grant_type=refresh_token&refresh_token=${enc(refresh)}").openConnection() as HttpURLConnection
|
||||
c.connectTimeout = 15_000; c.readTimeout = 15_000
|
||||
c.setRequestProperty("User-Agent", "GOG Galaxy")
|
||||
if (c.responseCode != 200) { c.disconnect(); return null }
|
||||
JSONObject(c.inputStream.bufferedReader().readText()).optString("access_token").ifEmpty { null }.also { c.disconnect() }
|
||||
} catch (e: Exception) { null }
|
||||
return GogAuth.gameToken(context, clientId, secret)?.accessToken
|
||||
}
|
||||
|
||||
// ---- sync -----------------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
package com.droiddeck.launcher.stores
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.setValue
|
||||
import com.droiddeck.launcher.stores.epic.EpicAchievements
|
||||
import com.droiddeck.launcher.stores.gog.GogAchievements
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
import java.io.File
|
||||
import java.time.Instant
|
||||
import java.time.OffsetDateTime
|
||||
import java.util.Locale
|
||||
|
||||
/**
|
||||
* A source's achievements with the account's progress, the last good answer cached on disk. Blocking.
|
||||
* [source] is the library's id for where a game came from ("gog", "epic"; "steam" once it has one).
|
||||
*/
|
||||
abstract class StoreAchievements(val source: String, val label: String) {
|
||||
|
||||
/** [extra]: what the source needs to find the game (Epic: "namespace"). */
|
||||
data class Game(val source: String, val id: String, val extra: Map<String, String> = emptyMap()) {
|
||||
companion object {
|
||||
fun of(item: CatalogItem) = Game(item.store.id, item.id, item.extra)
|
||||
fun of(sidecar: StoreGameSidecar) = Game(sidecar.store.id, sidecar.id, sidecar.extra)
|
||||
}
|
||||
}
|
||||
|
||||
class Achievement(
|
||||
val id: String,
|
||||
val name: String,
|
||||
val description: String,
|
||||
val hidden: Boolean,
|
||||
val unlocked: Boolean,
|
||||
/** Unix seconds; 0 when locked or unknown. */
|
||||
val unlockedAt: Long,
|
||||
val icon: String?,
|
||||
val iconLocked: String?,
|
||||
)
|
||||
|
||||
sealed class Result {
|
||||
class Found(val list: List<Achievement>) : Result()
|
||||
class Failed(val reason: Reason) : Result()
|
||||
}
|
||||
|
||||
enum class Reason { SIGNED_OUT, UNREACHABLE, NO_SERVICE }
|
||||
|
||||
protected abstract fun request(context: Context, game: Game): Result
|
||||
|
||||
fun fetch(context: Context, game: Game): Result {
|
||||
val result = runCatching { request(context, game) }.getOrElse { e ->
|
||||
Log.w(TAG, "$source:${game.id}: ${e.javaClass.simpleName}")
|
||||
Result.Failed(Reason.UNREACHABLE)
|
||||
}
|
||||
if (result is Result.Found) runCatching {
|
||||
cacheFile(context, game).apply { parentFile?.mkdirs() }.writeText(toJson(result.list).toString())
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
fun cached(context: Context, game: Game): List<Achievement>? = runCatching {
|
||||
val file = cacheFile(context, game)
|
||||
if (!file.exists()) null else fromJson(JSONArray(file.readText()))
|
||||
}.getOrNull()
|
||||
|
||||
private fun cacheFile(context: Context, game: Game) =
|
||||
File(context.filesDir, "achievements/$source/${game.id.replace(Regex("[^A-Za-z0-9._-]"), "_")}.json")
|
||||
|
||||
protected fun locale(): String = Locale.getDefault().toLanguageTag()
|
||||
|
||||
/** ISO-8601 (including GOG's "+0000" offsets) to Unix seconds; 0 if unreadable. */
|
||||
protected fun epochSeconds(iso: String?): Long {
|
||||
if (iso.isNullOrBlank()) return 0
|
||||
val normalized = iso.replace(Regex("([+-]\\d{2})(\\d{2})$"), "$1:$2")
|
||||
return runCatching { OffsetDateTime.parse(normalized).toEpochSecond() }
|
||||
.recoverCatching { Instant.parse(normalized).epochSecond }
|
||||
.getOrDefault(0)
|
||||
}
|
||||
|
||||
private fun toJson(list: List<Achievement>) = JSONArray().apply {
|
||||
for (a in list) put(
|
||||
JSONObject().put("id", a.id).put("name", a.name).put("description", a.description).put("hidden", a.hidden)
|
||||
.put("unlocked", a.unlocked).put("unlockedAt", a.unlockedAt).put("icon", a.icon ?: "").put("iconLocked", a.iconLocked ?: ""),
|
||||
)
|
||||
}
|
||||
|
||||
private fun fromJson(arr: JSONArray) = List(arr.length()) { i ->
|
||||
val o = arr.getJSONObject(i)
|
||||
Achievement(
|
||||
id = o.getString("id"), name = o.optString("name"), description = o.optString("description"),
|
||||
hidden = o.optBoolean("hidden"), unlocked = o.optBoolean("unlocked"), unlockedAt = o.optLong("unlockedAt"),
|
||||
icon = o.optString("icon").ifEmpty { null }, iconLocked = o.optString("iconLocked").ifEmpty { null },
|
||||
)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val TAG = "StoreAchievements"
|
||||
var revision by androidx.compose.runtime.mutableIntStateOf(0)
|
||||
private set
|
||||
fun invalidate() { revision++ }
|
||||
|
||||
private val all: List<StoreAchievements> by lazy { listOf(GogAchievements, EpicAchievements) }
|
||||
|
||||
/** Null for a source without achievements. */
|
||||
fun forSource(source: String?): StoreAchievements? = all.firstOrNull { it.source == source }
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.droiddeck.launcher.stores
|
||||
|
||||
import android.content.Context
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
import java.io.File
|
||||
@@ -42,6 +43,7 @@ class StoreGameSidecar(
|
||||
val epic: EpicOptions = EpicOptions(),
|
||||
/** GOG / Epic cloud saves for this game: down before a launch, up after it (the game card's switch). */
|
||||
val cloud: Boolean = true,
|
||||
val achievements: Boolean = true,
|
||||
) {
|
||||
val isInstalled: Boolean get() = state == STATE_INSTALLED
|
||||
|
||||
@@ -52,8 +54,8 @@ class StoreGameSidecar(
|
||||
exe: String = this.exe, launcher: String? = this.launcher, args: List<String> = this.args,
|
||||
env: Map<String, String> = this.env, installVersion: String = this.installVersion,
|
||||
installedAt: Long = this.installedAt, cover: String? = this.cover, hero: String? = this.hero,
|
||||
extra: Map<String, String> = this.extra, state: String = this.state, epic: EpicOptions = this.epic, cloud: Boolean = this.cloud,
|
||||
) = StoreGameSidecar(store, id, title, exe, launcher, args, env, installVersion, installedAt, cover, hero, extra, state, epic, cloud)
|
||||
extra: Map<String, String> = this.extra, state: String = this.state, epic: EpicOptions = this.epic, cloud: Boolean = this.cloud, achievements: Boolean = this.achievements,
|
||||
) = StoreGameSidecar(store, id, title, exe, launcher, args, env, installVersion, installedAt, cover, hero, extra, state, epic, cloud, achievements)
|
||||
|
||||
fun toJson(): JSONObject = JSONObject().apply {
|
||||
put("version", VERSION)
|
||||
@@ -64,6 +66,7 @@ class StoreGameSidecar(
|
||||
if (state != STATE_INSTALLED) put("state", state)
|
||||
if (store == Store.EPIC) put("epic", JSONObject().put("eos", epic.eos).put("offline", epic.offline))
|
||||
if (store != Store.AMAZON) put("cloud", cloud)
|
||||
if (store == Store.GOG) put("achievements", achievements)
|
||||
if (!launcher.isNullOrEmpty()) put("launcher", launcher)
|
||||
if (args.isNotEmpty()) put("args", JSONArray(args))
|
||||
if (env.isNotEmpty()) put("env", JSONObject(env as Map<*, *>))
|
||||
@@ -90,6 +93,12 @@ class StoreGameSidecar(
|
||||
|
||||
fun file(folder: File): File = File(folder, FILE_NAME)
|
||||
|
||||
/** An installed game's sidecar; walks the install folders. */
|
||||
fun find(context: Context, store: Store, id: String): StoreGameSidecar? =
|
||||
StoreInstallRoot.gameFolders(context.applicationContext).asSequence()
|
||||
.mapNotNull { read(it) }
|
||||
.firstOrNull { it.store == store && it.id == id }
|
||||
|
||||
/**
|
||||
* Changes an Epic game's launch choices on disk: reads the sidecar fresh (never a copy held
|
||||
* by a screen), applies [change], writes it, and reads it back. The written sidecar, or null
|
||||
@@ -109,6 +118,12 @@ class StoreGameSidecar(
|
||||
return read(folder)?.takeIf { it.cloud == on }
|
||||
}
|
||||
|
||||
fun updateAchievements(folder: File, on: Boolean): StoreGameSidecar? {
|
||||
val current = read(folder) ?: return null
|
||||
current.copy(achievements = on).write(folder)
|
||||
return read(folder)?.takeIf { it.achievements == on }
|
||||
}
|
||||
|
||||
/** The sidecar in [folder], or null when there is none or it cannot be read. */
|
||||
fun read(folder: File): StoreGameSidecar? {
|
||||
val f = file(folder)
|
||||
@@ -146,6 +161,7 @@ class StoreGameSidecar(
|
||||
// An "overlay" (or "v") field from an earlier build is read past: there is no overlay.
|
||||
epic = o.optJSONObject("epic")?.let { e -> EpicOptions(eos = e.optBoolean("eos", true), offline = e.optBoolean("offline", false)) } ?: EpicOptions(),
|
||||
cloud = o.optBoolean("cloud", true),
|
||||
achievements = o.optBoolean("achievements", true),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.droiddeck.launcher.stores
|
||||
|
||||
import com.droiddeck.launcher.session.SessionPrefs
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import com.droiddeck.launcher.frontend.AddedGames
|
||||
@@ -44,7 +45,7 @@ object StoreInstalls {
|
||||
onStep?.invoke(0, STEPS)
|
||||
// The user's launch choices survive an update or a repair.
|
||||
val before = StoreGameSidecar.read(folder)
|
||||
val finished = StoreLaunch.writeLauncher(folder, sidecar.copy(state = StoreGameSidecar.STATE_INSTALLED, epic = before?.epic ?: sidecar.epic, cloud = before?.cloud ?: sidecar.cloud))
|
||||
val finished = StoreLaunch.writeLauncher(folder, sidecar.copy(state = StoreGameSidecar.STATE_INSTALLED, epic = before?.epic ?: sidecar.epic, cloud = before?.cloud ?: sidecar.cloud, achievements = before?.achievements ?: sidecar.achievements))
|
||||
finished.write(folder)
|
||||
if (StoreGameSidecar.read(folder)?.isInstalled != true) throw java.io.IOException("the install record could not be written in ${folder.name}")
|
||||
onStep?.invoke(1, STEPS)
|
||||
@@ -76,14 +77,26 @@ object StoreInstalls {
|
||||
|
||||
/**
|
||||
* Removes a store game: its folder with the sidecar, then the shortcut (the listing without
|
||||
* it makes the writer drop the entry; the live client is asked too). Blocking.
|
||||
* it makes the writer drop the entry; the live client is asked too). Blocking. [removed] runs
|
||||
* once the files are gone, before the shortcut list is rebuilt (which reads every added game).
|
||||
*/
|
||||
fun uninstall(context: Context, game: InstalledStoreGame) {
|
||||
fun uninstall(context: Context, game: InstalledStoreGame, progress: (Float) -> Unit = {}, removed: () -> Unit = {}) {
|
||||
val app = context.applicationContext
|
||||
val appId = AddedGames.scan(app).firstOrNull { it.folder.absolutePath == game.folder.absolutePath }?.appId
|
||||
// The shortcut's id as stored for the folder: scanning every added game for it first held
|
||||
// the bar at 0% for seconds before a file went.
|
||||
val appId = SessionPrefs.addedGameStoredAppId(app, game.folder.path)
|
||||
// File by file, deepest first, saying how far it has got: a big game takes a while to go.
|
||||
val files = game.folder.walkBottomUp().toList()
|
||||
val step = (files.size / 100).coerceAtLeast(1)
|
||||
files.forEachIndexed { i, f ->
|
||||
f.delete()
|
||||
if (i % step == 0) progress((i + 1).toFloat() / files.size)
|
||||
}
|
||||
deleteTree(game.folder)
|
||||
progress(1f)
|
||||
// The scratch cache an install on a card may have left in the app's cache.
|
||||
deleteTree(StoreInstallRoot.scratchDir(app, game.sidecar.store, game.sidecar.id))
|
||||
removed()
|
||||
register(app)
|
||||
if (appId != null) SteamLiveShortcuts.remove(app, appId)
|
||||
StoresState.logLine("uninstalled \"${game.sidecar.title}\"")
|
||||
|
||||
@@ -19,6 +19,9 @@ object StoreLaunchRequests {
|
||||
private val lock = Any()
|
||||
private var observer: FileObserver? = null
|
||||
|
||||
/** The store game this session last started; covers Steam's own Play button. */
|
||||
@Volatile var lastLaunched: Pair<Store, String>? = null
|
||||
|
||||
fun dir(context: Context) = File(LinuxRuntime.sessionRoot(context), "stores")
|
||||
|
||||
/** Before each session: nothing of the last one's requests; then watch for new ones. */
|
||||
@@ -28,6 +31,7 @@ object StoreLaunchRequests {
|
||||
observer?.stopWatching()
|
||||
val root = dir(app)
|
||||
root.deleteRecursively()
|
||||
lastLaunched = null
|
||||
val req = File(root, "req").apply { mkdirs() }
|
||||
File(root, "resp").mkdirs()
|
||||
@Suppress("DEPRECATION")
|
||||
@@ -55,10 +59,13 @@ object StoreLaunchRequests {
|
||||
return // withdrawn already, or not complete yet (the rename brings it again)
|
||||
}
|
||||
val reply = when (request.optString("op")) {
|
||||
"gog-achievements" -> runCatching { com.droiddeck.launcher.stores.gog.GogComet.prepare(app, request.optString("id")) }
|
||||
.getOrElse { JSONObject().put("ok", false).put("ready", false).put("reason", "service-unavailable") }
|
||||
"epic-code" -> {
|
||||
val id = request.optString("id")
|
||||
if (id.isEmpty()) JSONObject().put("ok", false).put("reason", "no-id")
|
||||
else {
|
||||
lastLaunched = Store.EPIC to id
|
||||
val code = StoreLaunch.epicCode(app, id)
|
||||
JSONObject().put("ok", true).put("code", code.written).put("reason", code.reason)
|
||||
}
|
||||
@@ -70,6 +77,7 @@ object StoreLaunchRequests {
|
||||
val id = request.optString("id")
|
||||
if (store == null || id.isEmpty()) JSONObject().put("ok", false).put("reason", "no-game")
|
||||
else {
|
||||
lastLaunched = store to id
|
||||
// Marked before the game runs: whatever ends it, an upload follows (CloudSaves.uploadDirty).
|
||||
CloudSaves.markDirty(app, store, id)
|
||||
CloudSaves.downloadOrDefer(app, store, id).let { JSONObject().put("ok", it.ok).put("result", it.result).put("files", it.files).put("reason", it.reason) }
|
||||
|
||||
@@ -99,6 +99,8 @@ object StoresState {
|
||||
/** Reads what is on disk for every store: sign-ins, installed games, the engine probe. Off the main thread. */
|
||||
fun refresh(context: Context) {
|
||||
val app = context.applicationContext
|
||||
// The first refresh after the app starts brings back what was in the download queue.
|
||||
com.droiddeck.launcher.stores.download.SavedQueue.restore(app)
|
||||
Thread({
|
||||
val found = Store.entries.mapNotNull { store -> StoreAccounts.signedInAs(app, store)?.let { store to it } }
|
||||
val onDisk = StoreInstallRoot.gameFolders(app).mapNotNull { folder ->
|
||||
@@ -172,7 +174,8 @@ object StoresState {
|
||||
val app = context.applicationContext
|
||||
Thread({
|
||||
backends[store]?.signOut(app)
|
||||
StoreAccounts.clear(app, store)
|
||||
if (store == Store.GOG) com.droiddeck.launcher.stores.gog.GogComet.replaceAccount { StoreAccounts.clear(app, store) }
|
||||
else StoreAccounts.clear(app, store)
|
||||
main.post {
|
||||
accounts.remove(store); library.remove(store); status.remove(store); problems.remove(store)
|
||||
logLine("${store.label}: signed out")
|
||||
@@ -217,15 +220,30 @@ object StoresState {
|
||||
fun install(context: Context, item: CatalogItem, root: java.io.File? = null) {
|
||||
val app = context.applicationContext
|
||||
val target = root ?: StoreInstallRoot.installRoot(app)
|
||||
com.droiddeck.launcher.stores.download.SavedQueue.remember(app, item, target)
|
||||
backends[item.store]?.install(app, item, target) ?: logLine("${item.store.label}: this build cannot install yet")
|
||||
}
|
||||
|
||||
/** Removes the game's folder and its shortcut, then [onDone] on the main thread. */
|
||||
/** Games being removed, by key ("store:id"), and how far along (0..1): their page shows it. */
|
||||
val uninstalling = mutableStateMapOf<String, Float>()
|
||||
|
||||
/**
|
||||
* Removes the game's folder and its shortcut, then [onDone] on the main thread. The game reads
|
||||
* as removed the moment it is gone (its page shows Install, its card its size), not once the
|
||||
* whole library has been read again.
|
||||
*/
|
||||
fun uninstall(context: Context, game: InstalledStoreGame, onDone: () -> Unit = {}) {
|
||||
val app = context.applicationContext
|
||||
val key = "${game.sidecar.store.id}:${game.sidecar.id}"
|
||||
uninstalling[key] = 0f
|
||||
Thread({
|
||||
runCatching { backends[game.sidecar.store]?.uninstall(app, game) }
|
||||
StoreInstalls.uninstall(app, game)
|
||||
StoreInstalls.uninstall(app, game, progress = { f -> main.post { if (key in uninstalling) uninstalling[key] = f } }, removed = {
|
||||
main.post {
|
||||
installed = installed.filterNot { it.folder.absolutePath == game.folder.absolutePath }
|
||||
uninstalling.remove(key)
|
||||
}
|
||||
})
|
||||
main.post(onDone)
|
||||
}, "stores-uninstall").start()
|
||||
}
|
||||
|
||||
@@ -137,6 +137,11 @@ object DownloadQueue {
|
||||
|
||||
private val lock = Any()
|
||||
private val items = LinkedHashMap<String, Item>()
|
||||
/** Keys a restart brings back paused: queued as paused, not started. */
|
||||
private val heldPaused = HashSet<String>()
|
||||
|
||||
/** [key]'s next [enqueue] comes in paused (a paused download restored after a restart). */
|
||||
fun holdPaused(key: String) = synchronized(lock) { heldPaused.add(key) }
|
||||
private var running = 0
|
||||
|
||||
fun parallel(context: Context): Int = SessionPrefs.gameStoresParallel(context)
|
||||
@@ -171,7 +176,8 @@ object DownloadQueue {
|
||||
synchronized(lock) {
|
||||
items[entry.key]?.let { if (it.entry.isActive) { Log.i(TAG, "${entry.key}: already queued"); return } }
|
||||
items.remove(entry.key)
|
||||
items[entry.key] = Item(entry.copy(state = DownloadState.QUEUED, stage = DownloadStage.MANIFEST, startedAt = System.currentTimeMillis()), factory)
|
||||
val state = if (heldPaused.remove(entry.key)) DownloadState.PAUSED else DownloadState.QUEUED
|
||||
items[entry.key] = Item(entry.copy(state = state, stage = DownloadStage.MANIFEST, startedAt = System.currentTimeMillis()), factory)
|
||||
renumber()
|
||||
}
|
||||
StoresState.logLine("${entry.store.label}: queued \"${entry.name}\"" + if (entry.bytesTotal > 0) " (${com.droiddeck.launcher.stores.formatBytes(entry.bytesTotal)})" else "")
|
||||
@@ -306,6 +312,8 @@ object DownloadQueue {
|
||||
}
|
||||
}
|
||||
lastPublishAt = now
|
||||
// A state change (not progress) is written down, so the queue outlives the app.
|
||||
if (!progressOnly) SavedQueue.save(items.values.map { it.entry })
|
||||
val list = items.values.map { it.entry }.sortedByDescending { it.startedAt }
|
||||
StoresState.post { StoresState.publishDownloads(list) }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
package com.droiddeck.launcher.stores.download
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import com.droiddeck.launcher.stores.CatalogItem
|
||||
import com.droiddeck.launcher.stores.Store
|
||||
import com.droiddeck.launcher.stores.StoresState
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
import java.io.File
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
/**
|
||||
* The download queue kept on disk, so what was queued, running or paused comes back after the app
|
||||
* closes or is killed: the queue itself lives in memory, and a queued game that never started has
|
||||
* nothing on disk to find. Each install records the game and where it goes ([remember]); every
|
||||
* change of state writes the active rows in queue order ([save]); the first refresh after the app
|
||||
* starts asks the stores for them again ([restore]) - running and queued ones carry on, paused ones
|
||||
* come back paused.
|
||||
*/
|
||||
object SavedQueue {
|
||||
private const val TAG = "StoreDownloads"
|
||||
private const val FILE = "store-queue.json"
|
||||
|
||||
private class Wanted(val item: CatalogItem, val root: File?)
|
||||
|
||||
private val wanted = HashMap<String, Wanted>()
|
||||
private val writer = Executors.newSingleThreadExecutor { r -> Thread(r, "store-queue-save") }
|
||||
@Volatile private var app: Context? = null
|
||||
private var restored = false
|
||||
|
||||
private fun key(item: CatalogItem) = "${item.store.id}:${item.id}"
|
||||
|
||||
/** An install is asked for: what to ask the store for again after a restart. */
|
||||
@Synchronized
|
||||
fun remember(context: Context, item: CatalogItem, root: File?) {
|
||||
app = context.applicationContext
|
||||
wanted[key(item)] = Wanted(item, root)
|
||||
}
|
||||
|
||||
/** The active rows, in queue order, as they are now. Any thread; written off it. */
|
||||
fun save(entries: List<DownloadEntry>) {
|
||||
val context = app ?: return
|
||||
val rows = synchronized(this) {
|
||||
entries.filter { it.isActive }.mapNotNull { e -> wanted[e.key]?.let { e to it } }
|
||||
}
|
||||
val out = JSONArray()
|
||||
for ((e, w) in rows) out.put(JSONObject().apply {
|
||||
put("paused", e.state == DownloadState.PAUSED)
|
||||
put("root", w.root?.absolutePath ?: "")
|
||||
put("item", itemJson(w.item))
|
||||
})
|
||||
writer.execute {
|
||||
runCatching {
|
||||
val f = File(context.filesDir, FILE)
|
||||
val tmp = File(context.filesDir, "$FILE.tmp")
|
||||
tmp.writeText(out.toString())
|
||||
tmp.renameTo(f)
|
||||
}.onFailure { Log.w(TAG, "could not save the queue", it) }
|
||||
}
|
||||
}
|
||||
|
||||
/** Once per process: queues again what was in the queue when the app last closed. */
|
||||
fun restore(context: Context) {
|
||||
synchronized(this) { if (restored) return; restored = true }
|
||||
val app = context.applicationContext
|
||||
// Read before anything may write it: an install started at once must not save over it.
|
||||
val rows = runCatching { JSONArray(File(app.filesDir, FILE).readText()) }.getOrNull()
|
||||
this.app = app
|
||||
rows ?: return
|
||||
Thread({
|
||||
val back = (0 until rows.length()).mapNotNull { i ->
|
||||
runCatching {
|
||||
val o = rows.getJSONObject(i)
|
||||
Triple(itemOf(o.getJSONObject("item")), o.optString("root").takeIf { it.isNotEmpty() }?.let(::File), o.optBoolean("paused"))
|
||||
}.getOrNull()
|
||||
}
|
||||
if (back.isEmpty()) return@Thread
|
||||
StoresState.post {
|
||||
for ((item, root, paused) in back) {
|
||||
if (DownloadQueue.entry(key(item)) != null) continue
|
||||
if (paused) DownloadQueue.holdPaused(key(item))
|
||||
StoresState.install(app, item, root)
|
||||
}
|
||||
}
|
||||
}, "store-queue-restore").start()
|
||||
}
|
||||
|
||||
private fun itemJson(i: CatalogItem) = JSONObject().apply {
|
||||
put("store", i.store.id); put("id", i.id); put("title", i.title)
|
||||
put("image", i.imageUrl ?: ""); put("tall", i.tallImageUrl ?: "")
|
||||
put("tags", i.tags); put("developer", i.developer); put("description", i.description)
|
||||
put("size", i.sizeBytes); put("owned", i.owned)
|
||||
put("extra", JSONObject(i.extra))
|
||||
}
|
||||
|
||||
private fun itemOf(o: JSONObject): CatalogItem {
|
||||
val extra = o.optJSONObject("extra")
|
||||
return CatalogItem(
|
||||
store = Store.byId(o.getString("store")) ?: error("unknown store"),
|
||||
id = o.getString("id"), title = o.getString("title"),
|
||||
imageUrl = o.optString("image").ifEmpty { null }, tallImageUrl = o.optString("tall").ifEmpty { null },
|
||||
tags = o.optString("tags"), developer = o.optString("developer"), description = o.optString("description"),
|
||||
owned = o.optBoolean("owned", true), sizeBytes = o.optLong("size"),
|
||||
extra = extra?.keys()?.asSequence()?.associateWith { extra.getString(it) } ?: emptyMap(),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.droiddeck.launcher.stores.epic
|
||||
|
||||
import android.content.Context
|
||||
import com.droiddeck.launcher.stores.Store
|
||||
import com.droiddeck.launcher.stores.StoreAchievements
|
||||
import com.droiddeck.launcher.stores.StoreNet
|
||||
import org.json.JSONObject
|
||||
|
||||
/** Epic's GraphQL: the sandbox's achievements, then the player's records in it. */
|
||||
object EpicAchievements : StoreAchievements(Store.EPIC.id, Store.EPIC.shortLabel) {
|
||||
private const val GRAPHQL = "https://launcher.store.epicgames.com/graphql"
|
||||
private const val USER_AGENT = "EpicGamesLauncher/14.0.8-22004686+++Portal+Release-Live"
|
||||
|
||||
override fun request(context: Context, game: Game): Result {
|
||||
val namespace = game.extra["namespace"].orEmpty()
|
||||
if (namespace.isEmpty()) return Result.Failed(Reason.NO_SERVICE)
|
||||
val token = EpicCredentialStore.getValidAccessToken(context) ?: return Result.Failed(Reason.SIGNED_OUT)
|
||||
val account = EpicCredentialStore.load(context)?.accountId.orEmpty()
|
||||
val defs = query(token, GAME_ACHIEVEMENTS, JSONObject().put("sandboxId", namespace).put("locale", locale()))
|
||||
?: return Result.Failed(Reason.UNREACHABLE)
|
||||
val list = defs.optJSONObject("data")?.optJSONObject("Achievement")?.optJSONObject("productAchievementsRecordBySandbox")
|
||||
?.optJSONArray("achievements") ?: return Result.Found(emptyList())
|
||||
val unlocked = if (account.isEmpty()) emptyMap() else unlockTimes(token, account, namespace)
|
||||
val out = ArrayList<Achievement>()
|
||||
for (i in 0 until list.length()) {
|
||||
val a = list.optJSONObject(i)?.optJSONObject("achievement") ?: continue
|
||||
val id = a.optString("name")
|
||||
if (id.isEmpty()) continue
|
||||
val at = unlocked[id]
|
||||
val done = at != null
|
||||
out += Achievement(
|
||||
id = id,
|
||||
name = (if (done) a.optString("unlockedDisplayName") else a.optString("lockedDisplayName"))
|
||||
.ifEmpty { a.optString("unlockedDisplayName") }.ifEmpty { id },
|
||||
description = (if (done) a.optString("unlockedDescription") else a.optString("lockedDescription"))
|
||||
.ifEmpty { a.optString("unlockedDescription") },
|
||||
hidden = a.optBoolean("hidden"),
|
||||
unlocked = done,
|
||||
unlockedAt = at ?: 0,
|
||||
icon = a.optString("unlockedIconLink").ifEmpty { null },
|
||||
iconLocked = a.optString("lockedIconLink").ifEmpty { null },
|
||||
)
|
||||
}
|
||||
return Result.Found(out)
|
||||
}
|
||||
|
||||
/** Achievement name to unlock time, for the ones the player has. */
|
||||
private fun unlockTimes(token: String, account: String, namespace: String): Map<String, Long> {
|
||||
val out = HashMap<String, Long>()
|
||||
val records = query(token, PLAYER_ACHIEVEMENTS, JSONObject().put("epicAccountId", account).put("sandboxId", namespace))
|
||||
?.optJSONObject("data")?.optJSONObject("PlayerAchievement")?.optJSONObject("playerAchievementGameRecordsBySandbox")
|
||||
?.optJSONArray("records") ?: return out
|
||||
for (r in 0 until records.length()) {
|
||||
val player = records.optJSONObject(r)?.optJSONArray("playerAchievements") ?: continue
|
||||
for (i in 0 until player.length()) {
|
||||
val pa = player.optJSONObject(i)?.optJSONObject("playerAchievement") ?: continue
|
||||
if (pa.optBoolean("unlocked")) out[pa.optString("achievementName")] = epochSeconds(pa.optString("unlockDate"))
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
private fun query(token: String, query: String, variables: JSONObject): JSONObject? =
|
||||
StoreNet.postJson(GRAPHQL, JSONObject().put("query", query).put("variables", variables).toString(), bearer = token, userAgent = USER_AGENT)
|
||||
?.let(::JSONObject)
|
||||
|
||||
private val GAME_ACHIEVEMENTS = """
|
||||
query Achievement(${'$'}sandboxId: String!, ${'$'}locale: String!) {
|
||||
Achievement {
|
||||
productAchievementsRecordBySandbox(sandboxId: ${'$'}sandboxId, locale: ${'$'}locale) {
|
||||
achievements {
|
||||
achievement {
|
||||
name hidden unlockedDisplayName lockedDisplayName unlockedDescription lockedDescription
|
||||
unlockedIconLink lockedIconLink XP
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
|
||||
private val PLAYER_ACHIEVEMENTS = """
|
||||
query PlayerAchievement(${'$'}epicAccountId: String!, ${'$'}sandboxId: String!) {
|
||||
PlayerAchievement {
|
||||
playerAchievementGameRecordsBySandbox(epicAccountId: ${'$'}epicAccountId, sandboxId: ${'$'}sandboxId) {
|
||||
records { playerAchievements { playerAchievement { achievementName unlocked unlockDate XP } } }
|
||||
}
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.droiddeck.launcher.stores.gog
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import com.droiddeck.launcher.stores.Store
|
||||
import com.droiddeck.launcher.stores.StoreAchievements
|
||||
import com.droiddeck.launcher.stores.StoreLog
|
||||
import com.droiddeck.launcher.stores.StoreNet
|
||||
import org.json.JSONObject
|
||||
import java.net.HttpURLConnection
|
||||
import java.net.URL
|
||||
import java.util.zip.InflaterInputStream
|
||||
|
||||
/** gameplay.gog.com, with a token scoped to the game's own client. */
|
||||
object GogAchievements : StoreAchievements(Store.GOG.id, Store.GOG.shortLabel) {
|
||||
private const val TAG = "GogAchievements"
|
||||
|
||||
override fun request(context: Context, game: Game): Result {
|
||||
val galaxy = GogAuth.validToken(context) ?: return Result.Failed(Reason.SIGNED_OUT)
|
||||
val (clientId, clientSecret) = client(context, game.id, galaxy) ?: return Result.Failed(Reason.NO_SERVICE)
|
||||
val scoped = GogAuth.gameToken(context, clientId, clientSecret) ?: return Result.Failed(Reason.UNREACHABLE)
|
||||
val body = StoreNet.get(
|
||||
"https://gameplay.gog.com/clients/$clientId/users/${scoped.userId}/achievements",
|
||||
bearer = scoped.accessToken, userAgent = GogAuth.GALAXY_UA, headers = mapOf("X-Gog-Lc" to locale()),
|
||||
) ?: return Result.Failed(Reason.UNREACHABLE)
|
||||
val items = body.takeIf { it.isNotBlank() }?.let(::JSONObject)?.optJSONArray("items") ?: return Result.Found(emptyList())
|
||||
val out = ArrayList<Achievement>()
|
||||
for (i in 0 until items.length()) {
|
||||
val item = items.optJSONObject(i) ?: continue
|
||||
val id = item.optString("achievement_key").ifEmpty { item.optString("achievement_id") }
|
||||
if (id.isEmpty()) continue
|
||||
val date = item.optString("date_unlocked").takeIf { it.isNotBlank() && it != "null" }
|
||||
out += Achievement(
|
||||
id = id,
|
||||
name = item.optString("name").ifEmpty { id },
|
||||
description = item.optString("description"),
|
||||
hidden = !item.optBoolean("visible", true),
|
||||
unlocked = date != null,
|
||||
unlockedAt = date?.let(::epochSeconds) ?: 0,
|
||||
icon = item.optString("image_url_unlocked").ifEmpty { item.optString("image_url_locked") }.ifEmpty { null },
|
||||
iconLocked = item.optString("image_url_locked").ifEmpty { null },
|
||||
)
|
||||
}
|
||||
return Result.Found(out)
|
||||
}
|
||||
|
||||
/** The game's client id and secret: saved at install, else from the newest build's manifest. */
|
||||
private fun client(context: Context, productId: String, token: String): Pair<String, String>? {
|
||||
val prefs = GogPrefs.get(context)
|
||||
val savedId = prefs.getString("client_id_$productId", null)?.ifEmpty { null }
|
||||
val savedSecret = prefs.getString("client_secret_$productId", null)?.ifEmpty { null }
|
||||
if (savedId != null && savedSecret != null) return savedId to savedSecret
|
||||
val builds = StoreNet.get("https://content-system.gog.com/products/$productId/os/windows/builds?generation=2", bearer = token)
|
||||
?.let(::JSONObject) ?: return null
|
||||
val link = builds.optJSONArray("items")?.optJSONObject(0)?.optString("link")?.ifEmpty { null } ?: return null
|
||||
val manifest = bytes(link, token)?.let { JSONObject(inflate(it)) } ?: return null
|
||||
val id = manifest.optString("clientId").ifEmpty { return null }
|
||||
val secret = manifest.optString("clientSecret").ifEmpty { return null }
|
||||
prefs.edit().putString("client_id_$productId", id).putString("client_secret_$productId", secret).apply()
|
||||
return id to secret
|
||||
}
|
||||
|
||||
private fun bytes(url: String, bearer: String): ByteArray? {
|
||||
var conn: HttpURLConnection? = null
|
||||
return try {
|
||||
conn = (URL(url).openConnection() as HttpURLConnection).apply {
|
||||
connectTimeout = 20_000; readTimeout = 20_000
|
||||
setRequestProperty("Authorization", "Bearer $bearer")
|
||||
}
|
||||
if (conn.responseCode !in 200..299) null else conn.inputStream.use { it.readBytes() }
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "GET failed ${StoreLog.redactUrl(url)}: ${e.javaClass.simpleName}")
|
||||
null
|
||||
} finally {
|
||||
runCatching { conn?.disconnect() }
|
||||
}
|
||||
}
|
||||
|
||||
/** Gen2 manifests are zlib-compressed; plain JSON passes through. */
|
||||
private fun inflate(data: ByteArray): String =
|
||||
if (data.isNotEmpty() && data[0] == '{'.code.toByte()) String(data, Charsets.UTF_8)
|
||||
else InflaterInputStream(data.inputStream()).use { String(it.readBytes(), Charsets.UTF_8) }
|
||||
}
|
||||
@@ -33,7 +33,12 @@ object GogAuth {
|
||||
fun isSignedIn(context: Context): Boolean = StoreAccounts.read(context, Store.GOG)?.optString("access_token", "")?.isNotEmpty() == true
|
||||
|
||||
/** Saves a fresh sign-in and looks the account's name up for the chip. Blocking. */
|
||||
fun saveLogin(context: Context, accessToken: String, refreshToken: String?, userId: String?) {
|
||||
fun saveLogin(context: Context, accessToken: String, refreshToken: String?, userId: String?) = GogComet.replaceAccount {
|
||||
saveAccount(context, accessToken, refreshToken, userId)
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
private fun saveAccount(context: Context, accessToken: String, refreshToken: String?, userId: String?) {
|
||||
var username = ""
|
||||
runCatching {
|
||||
val body = StoreNet.get("https://embed.gog.com/userData.json", bearer = accessToken, userAgent = GALAXY_UA)
|
||||
@@ -52,6 +57,7 @@ object GogAuth {
|
||||
|
||||
/** A usable access token, refreshed when the recorded login time says it has expired; null when signed out or the refresh failed. */
|
||||
@JvmStatic
|
||||
@Synchronized
|
||||
fun validToken(context: Context): String? {
|
||||
val json = StoreAccounts.read(context, Store.GOG) ?: return null
|
||||
val token = json.optString("access_token", "").ifEmpty { return null }
|
||||
@@ -63,6 +69,7 @@ object GogAuth {
|
||||
|
||||
/** Refreshes the access token; the new one, or null on any failure. Blocking. */
|
||||
@JvmStatic
|
||||
@Synchronized
|
||||
fun refresh(context: Context): String? {
|
||||
val json = StoreAccounts.read(context, Store.GOG) ?: return null
|
||||
val refreshToken = json.optString("refresh_token", "").ifEmpty { return null }
|
||||
@@ -87,6 +94,51 @@ object GogAuth {
|
||||
}
|
||||
}
|
||||
|
||||
/** A complete companion snapshot. Never exported through the guest request channel. */
|
||||
@Synchronized
|
||||
fun cometCredentials(context: Context): JSONObject? {
|
||||
val access = validToken(context) ?: return null
|
||||
val saved = StoreAccounts.read(context, Store.GOG) ?: return null
|
||||
val refresh = saved.optString("refresh_token").ifEmpty { return null }
|
||||
var user = saved.optString("user_id")
|
||||
var username = saved.optString("username")
|
||||
if (!user.matches(Regex("[0-9]+")) || username.isEmpty()) {
|
||||
val body = StoreNet.get("https://embed.gog.com/userData.json", bearer = access, userAgent = GALAXY_UA, timeoutMs = 5_000) ?: return null
|
||||
val info = runCatching { JSONObject(body) }.getOrNull() ?: return null
|
||||
user = info.optString("galaxyUserId", info.optString("userId", user))
|
||||
username = info.optString("username", username)
|
||||
if (!user.matches(Regex("[0-9]+")) || username.isEmpty()) return null
|
||||
saved.put("user_id", user).put("username", username)
|
||||
StoreAccounts.write(context, Store.GOG, saved)
|
||||
}
|
||||
return JSONObject().put("access_token", access).put("refresh_token", refresh)
|
||||
.put("user_id", user).put("username", username)
|
||||
}
|
||||
|
||||
class GameToken(val accessToken: String, val userId: String)
|
||||
|
||||
/** The Galaxy refresh token exchanged for one scoped to a game's own client. Blocking. */
|
||||
fun gameToken(context: Context, clientId: String, clientSecret: String): GameToken? {
|
||||
val json = StoreAccounts.read(context, Store.GOG) ?: return null
|
||||
val refresh = json.optString("refresh_token", "").ifEmpty { return null }
|
||||
var conn: HttpURLConnection? = null
|
||||
return try {
|
||||
val enc = { s: String -> java.net.URLEncoder.encode(s, "UTF-8") }
|
||||
conn = (URL("https://auth.gog.com/token?client_id=${enc(clientId)}&client_secret=${enc(clientSecret)}&grant_type=refresh_token&refresh_token=${enc(refresh)}")
|
||||
.openConnection() as HttpURLConnection).apply { connectTimeout = 15_000; readTimeout = 15_000 }
|
||||
conn.setRequestProperty("User-Agent", "GOG Galaxy")
|
||||
if (conn.responseCode != 200) { Log.w(TAG, "game token: HTTP ${conn.responseCode}"); return null }
|
||||
val o = JSONObject(conn.inputStream.bufferedReader().readText())
|
||||
val access = o.optString("access_token").ifEmpty { return null }
|
||||
GameToken(access, o.optString("user_id").ifEmpty { json.optString("user_id") })
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "game token failed: ${e.javaClass.simpleName}")
|
||||
null
|
||||
} finally {
|
||||
runCatching { conn?.disconnect() }
|
||||
}
|
||||
}
|
||||
|
||||
/** Hosts the GOG login page hands off to for a social sign-in; they refuse an embedded browser's identity. */
|
||||
fun isIdentityProviderHost(host: String?): Boolean {
|
||||
val h = host?.lowercase() ?: return false
|
||||
|
||||
@@ -0,0 +1,189 @@
|
||||
package com.droiddeck.launcher.stores.gog
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Environment
|
||||
import android.util.Log
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import com.droiddeck.launcher.runtime.LinuxRuntime
|
||||
import com.droiddeck.launcher.session.SessionEvents
|
||||
import com.droiddeck.launcher.session.SessionPrefs
|
||||
import com.droiddeck.launcher.session.SessionState
|
||||
import com.droiddeck.launcher.stores.Store
|
||||
import com.droiddeck.launcher.stores.AchievementNotifications
|
||||
import com.droiddeck.launcher.stores.StoreAchievements
|
||||
import com.droiddeck.launcher.stores.StoreAccounts
|
||||
import com.droiddeck.launcher.stores.StoreGameSidecar
|
||||
import com.droiddeck.launcher.stores.StoreInstallRoot
|
||||
import com.droiddeck.launcher.stores.StoresState
|
||||
import org.json.JSONObject
|
||||
import java.io.File
|
||||
import java.util.concurrent.CountDownLatch
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
/** Owns one Galaxy companion; only its structured, secret-free events reach Android logs. */
|
||||
object GogComet {
|
||||
private const val TAG = "GogComet"
|
||||
private const val BIN = "/usr/local/lib/droiddeck-comet/comet"
|
||||
private val lock = Any()
|
||||
@Volatile private var process: Process? = null
|
||||
private var pid = -1
|
||||
private var started: String? = null
|
||||
private var account = ""
|
||||
private var session: String? = null
|
||||
private var accepting = false
|
||||
private var generation: String? = null
|
||||
@Volatile private var gamesByClient: Map<String, StoreGameSidecar> = emptyMap()
|
||||
var status by mutableStateOf("off")
|
||||
private set
|
||||
|
||||
fun enabled(context: Context) = GogPrefs.get(context).getBoolean("achievements", false)
|
||||
|
||||
fun setEnabled(context: Context, on: Boolean) {
|
||||
GogPrefs.get(context).edit().putBoolean("achievements", on).apply()
|
||||
|
||||
}
|
||||
|
||||
fun begin() = synchronized(lock) {
|
||||
stopLocked()
|
||||
accepting = true
|
||||
generation = SessionState.sessionId
|
||||
AchievementNotifications.begin(generation)
|
||||
}
|
||||
|
||||
/** Account replacement and launch preparation use the same lock, preventing stale restarts. */
|
||||
fun replaceAccount(change: () -> Unit) = synchronized(lock) {
|
||||
stopLocked()
|
||||
AchievementNotifications.begin(generation)
|
||||
change()
|
||||
}
|
||||
|
||||
fun stop() = synchronized(lock) {
|
||||
stopLocked()
|
||||
}
|
||||
|
||||
fun end(expected: String?) = synchronized(lock) {
|
||||
if (generation == expected) {
|
||||
accepting = false
|
||||
stopLocked()
|
||||
AchievementNotifications.end(expected)
|
||||
generation = null
|
||||
}
|
||||
}
|
||||
|
||||
private fun report(value: String) {
|
||||
StoresState.post { status = value }
|
||||
Log.i(TAG, value)
|
||||
SessionEvents.record("gog.achievements", mapOf("status" to value))
|
||||
}
|
||||
|
||||
private fun publishPolicy(context: Context): File {
|
||||
val dir = File(context.filesDir, "gog-achievements").apply { mkdirs() }
|
||||
val games = if (!enabled(context)) emptyMap() else StoreInstallRoot.gameFolders(context).mapNotNull { folder ->
|
||||
val game = StoreGameSidecar.read(folder) ?: return@mapNotNull null
|
||||
if (game.store != Store.GOG || !game.achievements) return@mapNotNull null
|
||||
val client = GogPrefs.get(context).getString("client_id_${game.id}", null)
|
||||
?: runCatching { JSONObject(File(folder, "goggame-${game.id}.info").readText()).optString("clientId") }.getOrNull()
|
||||
client?.takeIf { it.matches(Regex("[0-9]+")) }?.let { it to game }
|
||||
}.toMap()
|
||||
gamesByClient = games
|
||||
val file = File(dir, "clients.json")
|
||||
val tmp = File(dir, "clients.json.tmp")
|
||||
tmp.writeText(org.json.JSONArray(games.keys.toList()).toString())
|
||||
check(tmp.renameTo(file))
|
||||
return file
|
||||
}
|
||||
|
||||
/** No arbitrary paths or credentials from the guest are accepted. */
|
||||
fun prepare(context: Context, id: String): JSONObject = synchronized(lock) {
|
||||
fun reply(ready: Boolean, reason: String): JSONObject {
|
||||
report(reason)
|
||||
return JSONObject().put("ok", ready).put("ready", ready).put("reason", reason)
|
||||
}
|
||||
if (!accepting || !SessionState.running || generation != SessionState.sessionId) return reply(false, "no-session")
|
||||
val folder = StoreInstallRoot.gameFolders(context).firstOrNull { f -> StoreGameSidecar.read(f)?.let { it.store == Store.GOG && it.id == id } == true }
|
||||
val sidecar = folder?.let { StoreGameSidecar.read(it) }
|
||||
if (sidecar?.store != Store.GOG || sidecar.id != id) return reply(false, "no-game")
|
||||
val policy = publishPolicy(context)
|
||||
if (!enabled(context) || !sidecar.achievements) return reply(false, "off")
|
||||
val credentials = GogAuth.cometCredentials(context) ?: return reply(false,
|
||||
if (StoreAccounts.isUnavailable(Store.GOG)) "credentials-unavailable"
|
||||
else if (StoreAccounts.read(context, Store.GOG)?.optString("refresh_token").isNullOrEmpty()) "sign-in-needed" else "credentials-unavailable")
|
||||
if (!SessionState.running || generation != SessionState.sessionId) return reply(false, "no-session")
|
||||
val user = credentials.getString("user_id")
|
||||
if (process?.isAlive == true && account == user && session == SessionState.sessionId && identity(pid) == started) {
|
||||
return JSONObject().put("ok", true).put("ready", true).put("reason", "ready")
|
||||
}
|
||||
stopLocked()
|
||||
if (!File(LinuxRuntime.rootDir(context), BIN.removePrefix("/")).isFile) return reply(false, "not-installed")
|
||||
val data = File(context.filesDir, "gog-achievements").apply { mkdirs() }
|
||||
val ready = CountDownLatch(1)
|
||||
val command = LinuxRuntime.command(context, null, null, Environment.getExternalStorageDirectory(),
|
||||
listOf("/usr/bin/env", "HOME=/root", "XDG_DATA_HOME=${data.path}/data", "XDG_CONFIG_HOME=${data.path}/config", "COMET_LOG=off", "COMET_ALLOWED_CLIENTS=${policy.path}", BIN, "--credentials-stdin"))
|
||||
val pb = ProcessBuilder(command).redirectErrorStream(true)
|
||||
pb.environment().apply {
|
||||
remove("LD_PRELOAD"); remove("LD_AUDIT"); remove("LD_LIBRARY_PATH")
|
||||
put("PROOT_LOADER", LinuxRuntime.prootLoader(context).path)
|
||||
put("PROOT_TMP_DIR", context.cacheDir.path)
|
||||
if (SessionPrefs.prootNoSeccomp(context)) put("PROOT_NO_SECCOMP", "1")
|
||||
LinuxRuntime.prootLibraryPath(context).takeIf { it.isNotEmpty() }?.let { put("LD_LIBRARY_PATH", it) }
|
||||
}
|
||||
try {
|
||||
val child = pb.start()
|
||||
process = child; account = user; session = SessionState.sessionId
|
||||
Thread({
|
||||
runCatching { child.inputStream.bufferedReader().useLines { lines -> lines.forEach { line ->
|
||||
// Raw upstream errors/payloads can contain tokens. Never forward them.
|
||||
when {
|
||||
line.startsWith("DROIDDECK_COMET_READY:") -> {
|
||||
val childPid = line.substringAfter(':').toIntOrNull() ?: -1
|
||||
if (childPid > 1 && process === child) {
|
||||
pid = childPid; started = identity(childPid); ready.countDown()
|
||||
}
|
||||
}
|
||||
line.startsWith("DROIDDECK_COMET_UNLOCKED:") -> if (process === child) {
|
||||
val event = runCatching { JSONObject(line.substringAfter(':')) }.getOrNull()
|
||||
val game = event?.optString("client_id")?.let { gamesByClient[it] }
|
||||
val unlock = event?.let { AchievementNotifications.parse(it, game?.title.orEmpty()) }
|
||||
val owner = session
|
||||
if (game != null && unlock != null && owner != null && owner == SessionState.sessionId && SessionState.running) {
|
||||
report("unlocked-locally")
|
||||
AchievementNotifications.unlock(owner, unlock)
|
||||
SessionEvents.record("achievement.unlocked", mapOf("store" to "gog", "gameId" to game.id, "achievementId" to unlock.id))
|
||||
}
|
||||
}
|
||||
line == "DROIDDECK_COMET_PENDING" -> if (process === child) report("pending-upload")
|
||||
line.startsWith("DROIDDECK_COMET_UPLOADED:") -> if (process === child && line.substringAfter(':').toIntOrNull()?.let { it > 0 } == true) { report("uploaded"); StoresState.post { StoreAchievements.invalidate() } }
|
||||
}
|
||||
} } }
|
||||
if (process === child) report("service-unavailable")
|
||||
ready.countDown()
|
||||
}, "gog-comet-output").start()
|
||||
child.outputStream.bufferedWriter().use { it.write(credentials.toString()) }
|
||||
if (!ready.await(5, TimeUnit.SECONDS) || pid <= 1 || started == null || !child.isAlive) {
|
||||
stopLocked(); return reply(false, "service-unavailable")
|
||||
}
|
||||
reply(true, "ready")
|
||||
} catch (e: Exception) {
|
||||
stopLocked()
|
||||
reply(false, "service-unavailable")
|
||||
}
|
||||
}
|
||||
|
||||
private fun identity(pid: Int): String? = if (pid <= 1) null else runCatching {
|
||||
File("/proc/$pid/stat").readText().substringAfterLast(") ").split(' ')[19]
|
||||
}.getOrNull()
|
||||
|
||||
private fun stopLocked() {
|
||||
val child = process ?: return
|
||||
// Signal the announced daemon, not proot; start time prevents signalling a reused PID.
|
||||
if (started != null && identity(pid) == started) android.os.Process.sendSignal(pid, 2)
|
||||
if (!child.waitFor(5, TimeUnit.SECONDS)) {
|
||||
if (started != null && identity(pid) == started) android.os.Process.sendSignal(pid, 15)
|
||||
child.destroy()
|
||||
}
|
||||
process = null; pid = -1; started = null; account = ""; session = null
|
||||
report("stopped")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.fadeIn
|
||||
import androidx.compose.animation.fadeOut
|
||||
import androidx.compose.animation.slideInVertically
|
||||
import androidx.compose.animation.slideOutVertically
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.widthIn
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
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.layout.ContentScale
|
||||
import androidx.compose.ui.platform.testTag
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import coil.compose.AsyncImage
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.session.SessionEvents
|
||||
import com.droiddeck.launcher.stores.AchievementNotifications
|
||||
import kotlinx.coroutines.delay
|
||||
|
||||
@Composable
|
||||
internal fun AchievementNotificationOverlay() {
|
||||
val unlock = AchievementNotifications.pending.firstOrNull()
|
||||
var visible by remember(unlock) { mutableStateOf(false) }
|
||||
LaunchedEffect(unlock) {
|
||||
if (unlock == null) return@LaunchedEffect
|
||||
visible = true
|
||||
SessionEvents.record("achievement.notification-shown", mapOf("achievementId" to unlock.id))
|
||||
delay(5_000)
|
||||
visible = false
|
||||
delay(Motion.ms(220).toLong())
|
||||
AchievementNotifications.dismiss(unlock)
|
||||
}
|
||||
Box(Modifier.fillMaxSize().padding(20.dp), contentAlignment = Alignment.BottomEnd) {
|
||||
AnimatedVisibility(
|
||||
visible, enter = fadeIn(Motion.tw(220)) + slideInVertically(Motion.tw(300)) { it / 2 },
|
||||
exit = fadeOut(Motion.tw(180)) + slideOutVertically(Motion.tw(220)) { it / 3 },
|
||||
) { if (unlock != null) AchievementNotificationCard(unlock) }
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun AchievementNotificationCard(unlock: AchievementNotifications.Unlock) {
|
||||
val pal = LocalPalette.current
|
||||
val shape = RoundedCornerShape(16.dp)
|
||||
Row(
|
||||
Modifier.widthIn(max = 360.dp).clip(shape).background(pal.surface.copy(alpha = 0.97f))
|
||||
.border(1.dp, pal.signal.copy(alpha = 0.65f), shape).padding(14.dp)
|
||||
.testTag("achievement-notification"),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||
) {
|
||||
Box(Modifier.size(48.dp).clip(RoundedCornerShape(10.dp)).background(pal.surfaceVariant), contentAlignment = Alignment.Center) {
|
||||
Trophy(26.dp, description = null)
|
||||
if (unlock.icon != null) AsyncImage(unlock.icon, null, contentScale = ContentScale.Crop, modifier = Modifier.fillMaxSize())
|
||||
}
|
||||
Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(3.dp)) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(5.dp)) {
|
||||
Trophy(13.dp, description = null)
|
||||
Text(stringResource(R.string.achievement_unlocked).uppercase(), fontSize = 10.sp, fontWeight = FontWeight.SemiBold, letterSpacing = 0.8.sp, color = pal.signal)
|
||||
}
|
||||
Text(unlock.name, color = pal.onBackground, fontSize = 15.sp, fontWeight = FontWeight.Bold, maxLines = 2, overflow = TextOverflow.Ellipsis)
|
||||
if (unlock.game.isNotBlank()) Text(unlock.game, color = pal.onSurfaceVariant, fontSize = 12.sp, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview(widthDp = 420, heightDp = 150)
|
||||
@Composable
|
||||
private fun AchievementNotificationPreview() = DroidDeckTheme {
|
||||
Box(Modifier.padding(20.dp)) {
|
||||
AchievementNotificationCard(AchievementNotifications.Unlock("1", "first", "First Steps", "", null, "Hollow Valley"))
|
||||
}
|
||||
}
|
||||
@@ -739,7 +739,15 @@ fun ComponentsPage(
|
||||
Column(Modifier.fillMaxSize()) {
|
||||
// The in-use bar keeps its place; only its words change.
|
||||
AnimatedContent(l, transitionSpec = { fadeIn(Motion.tw(240)) togetherWith fadeOut(Motion.tw(160)) }, label = "inUse") { k -> bar(k) }
|
||||
Column(Modifier.weight(1f).fillMaxWidth().verticalScroll(rememberScrollState()).padding(top = 12.dp, bottom = 16.dp)) {
|
||||
val detailScroll = androidx.compose.runtime.key(l) { rememberScrollState() }
|
||||
Column(Modifier.weight(1f).fillMaxWidth().verticalScroll(detailScroll).padding(top = 12.dp, bottom = 16.dp)) {
|
||||
// Shared performance settings stay visible before the downloadable catalog.
|
||||
if (l == PROTON_TAB) {
|
||||
if (!protons.runtimeReady) EmptyLine(stringResource(R.string.content_needs_runtime))
|
||||
if (protons.sessionRunning) EmptyLine(stringResource(R.string.proton_stop_first))
|
||||
SettingsGroup(stringResource(R.string.comp_for_every_proton)) { protonOptions() }
|
||||
Spacer(Modifier.height(12.dp))
|
||||
}
|
||||
val slide: @Composable (@Composable (String) -> Unit) -> Unit = { body ->
|
||||
AnimatedContent(
|
||||
l,
|
||||
@@ -777,10 +785,6 @@ fun ComponentsPage(
|
||||
}
|
||||
}
|
||||
if (l == PROTON_TAB) {
|
||||
Spacer(Modifier.height(10.dp))
|
||||
if (!protons.runtimeReady) EmptyLine(stringResource(R.string.content_needs_runtime))
|
||||
if (protons.sessionRunning) EmptyLine(stringResource(R.string.proton_stop_first))
|
||||
SettingsGroup(stringResource(R.string.comp_for_every_proton)) { protonOptions() }
|
||||
Spacer(Modifier.height(12.dp))
|
||||
Note(stringResource(R.string.comp_about_text))
|
||||
}
|
||||
@@ -815,41 +819,37 @@ fun ComponentsPage(
|
||||
if (narrow) Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.padding(top = 6.dp)) { DeviceChip(gpu) }
|
||||
Spacer(Modifier.height(14.dp))
|
||||
if (games.isNotEmpty()) {
|
||||
SettingsGroup(stringResource(R.string.comp_profile_configure)) {
|
||||
SettingsRow(
|
||||
stringResource(R.string.comp_profile),
|
||||
if (selectedGame == null) {
|
||||
stringResource(R.string.comp_scope_general_detail)
|
||||
} else {
|
||||
stringResource(R.string.comp_profile_game_detail, selectedGame.name)
|
||||
},
|
||||
) {
|
||||
Box {
|
||||
ValueChip(
|
||||
selectedGame?.name ?: stringResource(R.string.comp_scope_general),
|
||||
scopeMenu,
|
||||
modifier = Modifier.widthIn(max = 320.dp).heightIn(min = 44.dp),
|
||||
) { scopeMenu = !scopeMenu }
|
||||
AnchoredMenu(
|
||||
scopeMenu,
|
||||
onDismiss = { scopeMenu = false },
|
||||
title = stringResource(R.string.comp_profile_configure),
|
||||
) { first ->
|
||||
MenuItem(
|
||||
stringResource(R.string.comp_scope_general),
|
||||
checked = selectedGame == null,
|
||||
detail = stringResource(R.string.comp_scope_general_detail),
|
||||
focusRequester = first,
|
||||
) {
|
||||
selectedGameKey = null
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||
modifier = Modifier.fillMaxWidth().padding(bottom = 10.dp),
|
||||
) {
|
||||
Text(stringResource(R.string.comp_profile), fontSize = 14.sp, color = colors.onSurfaceVariant)
|
||||
Box(Modifier.weight(1f, fill = false)) {
|
||||
ValueChip(
|
||||
selectedGame?.name ?: stringResource(R.string.comp_scope_general),
|
||||
scopeMenu,
|
||||
modifier = Modifier.widthIn(max = 320.dp).heightIn(min = 44.dp),
|
||||
) { scopeMenu = !scopeMenu }
|
||||
AnchoredMenu(
|
||||
scopeMenu,
|
||||
onDismiss = { scopeMenu = false },
|
||||
title = stringResource(R.string.comp_profile_configure),
|
||||
) { first ->
|
||||
MenuItem(
|
||||
stringResource(R.string.comp_scope_general),
|
||||
checked = selectedGame == null,
|
||||
detail = stringResource(R.string.comp_scope_general_detail),
|
||||
focusRequester = first,
|
||||
) {
|
||||
selectedGameKey = null
|
||||
scopeMenu = false
|
||||
}
|
||||
games.sortedBy { it.name.lowercase() }.forEach { game ->
|
||||
MenuItem(game.name, checked = selectedGameKey == game.profileKey) {
|
||||
selectedGameKey = game.profileKey
|
||||
scopeMenu = false
|
||||
}
|
||||
games.sortedBy { it.name.lowercase() }.forEach { game ->
|
||||
MenuItem(game.name, checked = selectedGameKey == game.profileKey) {
|
||||
selectedGameKey = game.profileKey
|
||||
scopeMenu = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -901,7 +901,6 @@ fun ComponentsPage(
|
||||
) {
|
||||
val tint = rememberUpdatedState(pal.signal)
|
||||
val local = cardsAt[layer]?.translate(-stackAt)
|
||||
ChipGlide(LAYERS.indexOf(layer), local, tint, GlideAxis.Vertical, corner = 12.dp)
|
||||
Stack(
|
||||
layer, view, gpu, focus = layerFocus, landed = landed, rings = rings,
|
||||
onPlaced = { l, r -> cardsAt[l] = r },
|
||||
@@ -912,6 +911,8 @@ fun ComponentsPage(
|
||||
else runCatching { firstRow.requestFocus() }
|
||||
},
|
||||
)
|
||||
// Over the cards: under them, their rest fill hid it as it crossed them.
|
||||
ChipGlide(LAYERS.indexOf(layer), local, tint, GlideAxis.Vertical, corner = 12.dp)
|
||||
}
|
||||
if (!narrow) {
|
||||
Spacer(Modifier.width(16.dp))
|
||||
@@ -1105,14 +1106,17 @@ private fun LayerCard(
|
||||
val pal = LocalPalette.current
|
||||
val src = remember { MutableInteractionSource() }
|
||||
val hot = rememberHot(src)
|
||||
// The stack's glide draws the picked card's look by touch only; with a pad, its rest look and the bar.
|
||||
val under = selected && androidx.compose.ui.platform.LocalInputModeManager.current.inputMode != androidx.compose.ui.input.InputMode.Keyboard
|
||||
Box(Modifier.fillMaxWidth().heightIn(min = 44.dp), contentAlignment = Alignment.Center) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
modifier = modifier.fillMaxWidth().height(40.dp)
|
||||
.landingPop(landed).pulseRing(ring, pal.signal)
|
||||
.clip(LAYER_SHAPE)
|
||||
.background(if (selected) Color.Transparent else colors.surface)
|
||||
.glideBorder(hot, LAYER_SHAPE, pal.signal, if (selected) Color.Transparent else pal.line)
|
||||
.background(if (under) Color.Transparent else colors.surface)
|
||||
.shownBar(selected, pal.signal, vertical = true)
|
||||
.glideBorder(hot, LAYER_SHAPE, pal.signal, if (under) Color.Transparent else pal.line)
|
||||
.onFocusChanged { if (it.isFocused) onFocus() }
|
||||
.hoverable(src).clickable(interactionSource = src, indication = null, role = Role.Tab, onClick = onClick)
|
||||
.controllerConfirm(onClick = onClick)
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.droiddeck.launcher.ui
|
||||
import com.droiddeck.launcher.R
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.focusGroup
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.hoverable
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
@@ -42,6 +43,11 @@ import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.focus.onFocusChanged
|
||||
import androidx.compose.ui.input.InputMode
|
||||
import androidx.compose.ui.platform.LocalInputModeManager
|
||||
import androidx.compose.runtime.snapshotFlow
|
||||
import kotlinx.coroutines.flow.first
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
@@ -84,11 +90,19 @@ fun DriverPage(
|
||||
// D-pad: up from the first driver lands on refresh; the page opens with the driver in use focused.
|
||||
val refreshFocus = remember { FocusRequester() }
|
||||
val selectedFocus = remember { FocusRequester() }
|
||||
LaunchedEffect(Unit) { runCatching { selectedFocus.requestFocus() } }
|
||||
val inputMode = LocalInputModeManager.current
|
||||
var pageFocused by remember { mutableStateOf(false) }
|
||||
LaunchedEffect(inputMode.inputMode) {
|
||||
if (inputMode.inputMode != InputMode.Keyboard) return@LaunchedEffect
|
||||
// The chooser holds controller focus until its closing animation finishes.
|
||||
snapshotFlow { Steps.step }.first { it == null }
|
||||
focusWithinFrames({ pageFocused }) { selectedFocus }
|
||||
}
|
||||
val refreshSrc = remember { MutableInteractionSource() }
|
||||
val refreshHot = refreshSrc.collectIsFocusedAsState().value || refreshSrc.collectIsHoveredAsState().value
|
||||
SettingsPage(
|
||||
host, title = title, onBack = onBack, lede = "$hint\n$status",
|
||||
modifier = Modifier.onFocusChanged { pageFocused = it.hasFocus }.focusGroup(),
|
||||
action = {
|
||||
Box(
|
||||
contentAlignment = Alignment.Center,
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.droiddeck.launcher.ui
|
||||
import android.view.View
|
||||
import androidx.compose.animation.animateColorAsState
|
||||
import androidx.compose.animation.core.Animatable
|
||||
import androidx.compose.animation.core.AnimationSpec
|
||||
import androidx.compose.animation.core.FastOutSlowInEasing
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.layout.Box
|
||||
@@ -23,6 +22,7 @@ import androidx.compose.runtime.staticCompositionLocalOf
|
||||
import androidx.compose.runtime.withFrameNanos
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.drawWithContent
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.geometry.CornerRadius
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.geometry.Rect
|
||||
@@ -58,6 +58,8 @@ internal class GlideSource {
|
||||
var shape: Shape by mutableStateOf<Shape>(androidx.compose.ui.graphics.RectangleShape)
|
||||
var color by mutableStateOf(Color.Transparent)
|
||||
var width by mutableStateOf(2.dp)
|
||||
/** Focuses the control again: a step-out hands focus back to the control it came out of. */
|
||||
val requester = androidx.compose.ui.focus.FocusRequester()
|
||||
}
|
||||
|
||||
internal class FocusGlide(val view: View) {
|
||||
@@ -135,15 +137,18 @@ internal fun Modifier.glideBorder(
|
||||
onDispose { glide.release(src) }
|
||||
}
|
||||
val base = if (restColor.alpha > 0f) border(restWidth, restColor, shape) else this
|
||||
return base.onGloballyPositioned { src.coords = it; glide.moved(src) }
|
||||
return base.focusRequester(src.requester).onGloballyPositioned { src.coords = it; glide.moved(src) }
|
||||
}
|
||||
|
||||
/** Leading edge on a focus move: quick and a little loose. */
|
||||
private fun lead(): AnimationSpec<Float> = Motion.sp(0.62f, 700f)
|
||||
/** A spring an edge chases its target on: damping ratio and stiffness, as Compose's. */
|
||||
private class Edge(val damping: Float, val stiffness: Float)
|
||||
|
||||
private fun lead() = Edge(0.62f, 700f)
|
||||
/** Trailing edge: slower, settles without a bounce to speak of. */
|
||||
private fun trail(): AnimationSpec<Float> = Motion.sp(0.78f, 360f)
|
||||
private fun trail() = Edge(0.78f, 360f)
|
||||
/** Following a control that moves under the ring (a scroll): tight, no wobble. */
|
||||
private fun follow(): AnimationSpec<Float> = Motion.sp(1f, 2400f)
|
||||
private fun follow() = Edge(1f, 2400f)
|
||||
|
||||
/** How long after a focus move the ring keeps its stretchy springs and keeps checking where it is. */
|
||||
private const val SETTLE_MS = 450L
|
||||
@@ -152,6 +157,9 @@ private const val STILL_MS = 120L
|
||||
/** The longest the ring keeps checking after a move, for a control that never stands still. */
|
||||
private const val TRACK_MAX_MS = 2_000L
|
||||
|
||||
/** How strongly the ring tints what it holds. */
|
||||
private const val RING_FILL = 0.14f
|
||||
|
||||
/** Moves closer together than this are a held direction: the ring runs along as one, no stretch. */
|
||||
private const val REPEAT_MS = 180L
|
||||
|
||||
@@ -174,8 +182,16 @@ internal fun FocusGlideHost(modifier: Modifier = Modifier, content: @Composable
|
||||
val solid = remember { Animatable(0f) }
|
||||
val alpha = remember { Animatable(0f) }
|
||||
val scope = rememberCoroutineScope()
|
||||
// An edge each, the corner, and a droplet carrying all of them.
|
||||
val jobs = remember { arrayOfNulls<Job>(6) }
|
||||
// An edge each, the corner, a droplet carrying all of them, its solid fill, and the chase.
|
||||
val jobs = remember { arrayOfNulls<Job>(8) }
|
||||
// The chase: each edge on a spring of its own toward where focus is now. A new target only
|
||||
// moves where it is heading - restarting an animation on every focus move started it from
|
||||
// its first frame (which does not move), so a held direction over a busy page (each rail item
|
||||
// swaps the page) left the ring standing while focus ran on ahead.
|
||||
val target = remember { FloatArray(4) }
|
||||
val vel = remember { FloatArray(4) }
|
||||
val springs = remember { Array(4) { follow() } }
|
||||
val startAt = remember { LongArray(4) }
|
||||
val cur = glide.current
|
||||
var lastColor by remember { mutableStateOf(Color.Transparent) }
|
||||
if (cur != null) lastColor = cur.color
|
||||
@@ -186,20 +202,53 @@ internal fun FocusGlideHost(modifier: Modifier = Modifier, content: @Composable
|
||||
LaunchedEffect(glide, Motion.scale) {
|
||||
var shown: GlideSource? = null
|
||||
var movedAt = 0L
|
||||
var dirSpecs: List<AnimationSpec<Float>> = List(4) { follow() }
|
||||
var dirSpecs: List<Edge> = List(4) { follow() }
|
||||
var delays = LongArray(4)
|
||||
var lastMove = 0L
|
||||
fun go(i: Int, v: Float, spec: AnimationSpec<Float>, wait: Long) {
|
||||
fun go(i: Int, v: Float, spec: Edge, wait: Long) {
|
||||
// A drop cut short by another move turns back into an outline on the way.
|
||||
if (jobs[5]?.isActive == true || solid.targetValue > 0f) scope.launch { solid.animateTo(0f, Motion.tw(120)) }
|
||||
jobs[5]?.cancel()
|
||||
// Picks up the speed it is going at: restarting from rest on every step of a held
|
||||
// direction is what made it stutter.
|
||||
val speed = edges[i].velocity
|
||||
jobs[i]?.cancel()
|
||||
jobs[i] = scope.launch {
|
||||
if (wait > 0) delay(Motion.ms(wait.toInt()).toLong())
|
||||
edges[i].animateTo(v, spec, initialVelocity = if (wait > 0) 0f else speed)
|
||||
if (jobs[5]?.isActive == true || solid.targetValue > 0f) {
|
||||
jobs[5]?.cancel()
|
||||
jobs[6]?.cancel()
|
||||
jobs[6] = scope.launch { solid.animateTo(0f, Motion.tw(120)) }
|
||||
}
|
||||
val chasing = jobs[7]?.isActive == true
|
||||
// An edge some other animation was moving (the appear, a drop's opening) is taken over
|
||||
// at the speed it was going.
|
||||
jobs[i]?.let { if (it.isActive) { it.cancel(); vel[i] = edges[i].velocity } }
|
||||
if (!chasing) for (j in 0..3) if (jobs[j]?.isActive != true) vel[j] = edges[j].velocity
|
||||
target[i] = v
|
||||
springs[i] = spec
|
||||
startAt[i] = System.nanoTime() + Motion.ms(wait.toInt()) * 1_000_000L
|
||||
if (chasing) return
|
||||
jobs[7] = scope.launch {
|
||||
var last = withFrameNanos { it }
|
||||
while (true) {
|
||||
val frame = withFrameNanos { it }
|
||||
// Real time, however long the frame took, in small steps so a stiff spring holds.
|
||||
val dt = ((frame - last) / 1e9f).coerceAtMost(0.1f) / Motion.scale.coerceAtLeast(0.01f)
|
||||
last = frame
|
||||
val now = System.nanoTime()
|
||||
var settled = true
|
||||
for (j in 0..3) {
|
||||
if (now < startAt[j]) { settled = false; continue }
|
||||
val k = springs[j].stiffness
|
||||
val c = 2f * springs[j].damping * kotlin.math.sqrt(k)
|
||||
var x = edges[j].value
|
||||
var u = vel[j]
|
||||
var left = dt
|
||||
while (left > 0f) {
|
||||
val h = minOf(left, 0.004f)
|
||||
u += (-k * (x - target[j]) - c * u) * h
|
||||
x += u * h
|
||||
left -= h
|
||||
}
|
||||
if (abs(x - target[j]) < 0.3f && abs(u) < 3f) { x = target[j]; u = 0f } else settled = false
|
||||
vel[j] = u
|
||||
edges[j].snapTo(x)
|
||||
}
|
||||
if (settled) break
|
||||
}
|
||||
}
|
||||
}
|
||||
/** Pinch into a solid dot where it is, carry it over, and open it into [b] as it arrives. */
|
||||
@@ -270,6 +319,8 @@ internal fun FocusGlideHost(modifier: Modifier = Modifier, content: @Composable
|
||||
// Focus passing between two controls can let go of one a moment before the next
|
||||
// takes it: wait a beat, so that reads as a move and not a fade out and back in.
|
||||
delay(60)
|
||||
jobs.forEach { it?.cancel() }
|
||||
solid.snapTo(0f)
|
||||
scope.launch { alpha.animateTo(0f, Motion.tw(140)) }
|
||||
shown = null
|
||||
return@collectLatest
|
||||
@@ -296,7 +347,7 @@ internal fun FocusGlideHost(modifier: Modifier = Modifier, content: @Composable
|
||||
val grown = listOf(b.left - out, b.top - out, b.right + out, b.bottom + out)
|
||||
jobs.forEach { it?.cancel() }
|
||||
scope.launch { solid.snapTo(0f); edges.forEachIndexed { i, e -> e.snapTo(grown[i]) } }.join()
|
||||
dirSpecs = List(4) { Motion.sp(0.6f, 700f) }
|
||||
dirSpecs = List(4) { Edge(0.6f, 700f) }
|
||||
delays = LongArray(4)
|
||||
cornerTo(src, b, snap = true)
|
||||
scope.launch { alpha.animateTo(1f, Motion.tw(140)) }
|
||||
@@ -315,8 +366,8 @@ internal fun FocusGlideHost(modifier: Modifier = Modifier, content: @Composable
|
||||
if (dropped) droplet(src, b)
|
||||
else {
|
||||
// A held direction runs along as one piece; a single press stretches.
|
||||
dirSpecs = if (held) List(4) { Motion.sp(0.9f, 900f) }
|
||||
else List(4) { i -> when (i) { leadIdx -> lead(); trailIdx -> trail(); else -> Motion.sp(0.7f, 520f) } }
|
||||
dirSpecs = if (held) List(4) { Edge(0.9f, 900f) }
|
||||
else List(4) { i -> when (i) { leadIdx -> lead(); trailIdx -> trail(); else -> Edge(0.7f, 520f) } }
|
||||
delays = LongArray(4) { i -> if (i == trailIdx && !held) 30L else 0L }
|
||||
cornerTo(src, b, snap = false)
|
||||
}
|
||||
@@ -359,10 +410,18 @@ internal fun FocusGlideHost(modifier: Modifier = Modifier, content: @Composable
|
||||
color, topLeft = Offset(l, t), size = Size(r - l, b - t),
|
||||
cornerRadius = CornerRadius(corner.value), alpha = a * f,
|
||||
)
|
||||
if (f < 0.99f) drawRoundRect(
|
||||
color, topLeft = Offset(l + w / 2f, t + w / 2f), size = Size(sw, sh),
|
||||
cornerRadius = CornerRadius(rad), style = Stroke(w), alpha = a,
|
||||
)
|
||||
if (f < 0.99f) {
|
||||
// The ring's own infill: the only fill a pad sees, so it is always exactly what
|
||||
// the ring holds and moves with it (a row's own sliding fill trailed it).
|
||||
drawRoundRect(
|
||||
color, topLeft = Offset(l + w / 2f, t + w / 2f), size = Size(sw, sh),
|
||||
cornerRadius = CornerRadius(rad), alpha = a * (1f - f) * RING_FILL,
|
||||
)
|
||||
drawRoundRect(
|
||||
color, topLeft = Offset(l + w / 2f, t + w / 2f), size = Size(sw, sh),
|
||||
cornerRadius = CornerRadius(rad), style = Stroke(w), alpha = a,
|
||||
)
|
||||
}
|
||||
},
|
||||
) {
|
||||
CompositionLocalProvider(LocalFocusGlide provides glide) { content() }
|
||||
|
||||
@@ -106,14 +106,14 @@ internal fun SideRail(
|
||||
modifier = modifier.width(if (iconOnly) 64.dp else 92.dp).background(colors.surface).padding(vertical = if (compact) 8.dp else 12.dp),
|
||||
) {
|
||||
// Every section on screen at once: items shrink (to 44dp, still a touch target) before the rail scrolls.
|
||||
val count = 7 + (if (s.isHomeApp) 1 else 0)
|
||||
val count = 6 + (if (s.gameStoresEnabled) 1 else 0) + (if (s.isHomeApp) 1 else 0)
|
||||
BoxWithConstraints(Modifier.weight(1f).fillMaxWidth()) {
|
||||
val fit = (maxHeight / count - 4.dp).coerceIn(44.dp, if (iconOnly) 48.dp else if (compact) 52.dp else 60.dp)
|
||||
// A hop in flight moves the selection ahead of the page it is bringing.
|
||||
val shown = Hops.railPreview ?: selected
|
||||
val keys = buildList {
|
||||
add("steam"); add("games")
|
||||
add("stores")
|
||||
if (s.gameStoresEnabled) add("stores")
|
||||
add("desktop")
|
||||
add("components")
|
||||
if (s.isHomeApp) add("android-apps")
|
||||
@@ -145,7 +145,7 @@ internal fun SideRail(
|
||||
// The game stores, right under Games: what they install lands there. Its badge counts
|
||||
// the downloads in flight, so a download started here is never out of sight.
|
||||
// A section switched on in Setup comes in as the rail's own entrance; off, it folds away.
|
||||
RailItem(stringResource(R.string.rail_stores), Icons.Outlined.LocalMall, "stores", shown == "stores", compact, iconOnly, fit, count = s.storeDownloadsActive, place = place, onFocus = { onFocusSelect("stores") }) { onSelect("stores") }
|
||||
if (s.gameStoresEnabled) RailItem(stringResource(R.string.rail_stores), Icons.Outlined.LocalMall, "stores", shown == "stores", compact, iconOnly, fit, count = s.storeDownloadsActive, place = place, onFocus = { onFocusSelect("stores") }) { onSelect("stores") }
|
||||
RailItem(stringResource(R.string.rail_desktop), Icons.Outlined.DesktopWindows, "desktop", shown == "desktop", compact, iconOnly, fit, place = place, onFocus = { onFocusSelect("desktop") }) { onSelect("desktop") }
|
||||
RailItem(stringResource(R.string.rail_components), Icons.Outlined.Layers, "components", shown == "components", compact, iconOnly, fit, place = place, onFocus = { onFocusSelect("components") }) { onSelect("components") }
|
||||
// Home mode's extra section goes last, so it shifts nothing above it.
|
||||
|
||||
@@ -134,6 +134,7 @@ class FrontEndState(
|
||||
val orientation: Int = android.content.pm.ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE,
|
||||
val launcherFullscreen: Boolean = true,
|
||||
val animationsEnabled: Boolean = true,
|
||||
val gameStoresEnabled: Boolean = true,
|
||||
/** Setup › Stores: the download engine's speed tier (stores/download/StoreDownloadTier ids). */
|
||||
val gameStoresSpeedTier: String = "fast",
|
||||
/** Setup › Stores: the tab a signed-in store opens on (SessionPrefs.STORES_OPEN_LIBRARY / STORE). */
|
||||
@@ -212,6 +213,7 @@ class FrontEndActions(
|
||||
val onOrientation: (Int) -> Unit = {},
|
||||
val onLauncherFullscreen: (Boolean) -> Unit = {},
|
||||
val onAnimationsEnabled: (Boolean) -> Unit = {},
|
||||
val onGameStoresEnabled: (Boolean) -> Unit = {},
|
||||
val onGameStoresSpeedTier: (String) -> Unit = {},
|
||||
val onStoresOpenTab: (String) -> Unit = {},
|
||||
val onNavigated: () -> Unit = {},
|
||||
@@ -339,6 +341,8 @@ internal class FrontFocus {
|
||||
/** Down from this button goes to the first tile of the page's grid, when there is one. */
|
||||
@Composable
|
||||
internal fun Modifier.downToFirstTile(): Modifier {
|
||||
// Sheet rows walk their settings; Desktop's dock stays composed behind the sheet.
|
||||
if (LocalSheetBeat.current != null) return this
|
||||
val ff = LocalFrontFocus.current ?: return this
|
||||
return this.focusProperties { down = if (ff.firstTileAttached > 0) ff.firstTile else FocusRequester.Default }
|
||||
}
|
||||
@@ -499,6 +503,7 @@ private fun FrontEndScreenBody(s: FrontEndState, a: FrontEndActions, page: (@Com
|
||||
}
|
||||
val inputModeManager = LocalInputModeManager.current
|
||||
val window = LocalWindowInfo.current
|
||||
val androidContext = androidx.compose.ui.platform.LocalContext.current
|
||||
var anyFocused by remember { mutableStateOf(false) }
|
||||
Box(
|
||||
modifier = Modifier.fillMaxSize().background(colors.background)
|
||||
@@ -530,7 +535,15 @@ private fun FrontEndScreenBody(s: FrontEndState, a: FrontEndActions, page: (@Com
|
||||
if (processSettingsPageVisible) return@LaunchedEffect
|
||||
// Past the old page's exit (170ms), then the first frame the new page takes focus.
|
||||
kotlinx.coroutines.delay(Motion.ms(PAGE_EXIT_MS).toLong())
|
||||
if (anyFocused || inputModeManager.inputMode != InputMode.Keyboard) return@LaunchedEffect
|
||||
if (inputModeManager.inputMode != InputMode.Keyboard) return@LaunchedEffect
|
||||
if (s.pageKey == "performance") {
|
||||
val back = "back:${androidContext.getString(R.string.mode_back)}"
|
||||
focusWithinFrames({ frontFocus.last == back && anyFocused && frontFocus.focusedRail == null }) {
|
||||
frontFocus.items[back] ?: FocusRequester.Default
|
||||
}
|
||||
return@LaunchedEffect
|
||||
}
|
||||
if (anyFocused) return@LaunchedEffect
|
||||
focusWithinFrames({ anyFocused }) { if (frontFocus.primaryAttached > 0) frontFocus.primary else frontFocus.railFor(railSelection) }
|
||||
}
|
||||
// A rail item picked with a controller moves on into its page, once the page is in.
|
||||
|
||||
@@ -321,14 +321,6 @@ internal fun SetupPanel(
|
||||
}
|
||||
}
|
||||
}
|
||||
SettingsGroup(stringResource(R.string.setup_account)) {
|
||||
accountCheck(true)
|
||||
ToggleRow(
|
||||
host, "offline", stringResource(R.string.setup_offline),
|
||||
s.offlineAccount?.let { if (it.isEmpty()) stringResource(R.string.setup_signed_in_unnamed) else stringResource(R.string.setup_signed_in, it) } ?: stringResource(R.string.setup_sign_in_first),
|
||||
s.offline, enabled = s.offlineAccount != null,
|
||||
) { a.onOffline() }
|
||||
}
|
||||
SettingsGroup(stringResource(R.string.setup_runtime)) { runtimeCheck(false) }
|
||||
}
|
||||
1 -> {
|
||||
@@ -366,6 +358,7 @@ internal fun SetupPanel(
|
||||
ToggleRow(host, "launcher-animations", stringResource(R.string.setup_animations), null,
|
||||
s.animationsEnabled, onChange = a.onAnimationsEnabled)
|
||||
LanguageRow(host, s.language, a.onLanguage)
|
||||
ToggleRow(host, "show-stores", stringResource(R.string.setup_stores), null, s.gameStoresEnabled, onChange = a.onGameStoresEnabled)
|
||||
}
|
||||
}
|
||||
val device: @Composable () -> Unit = {
|
||||
@@ -502,8 +495,8 @@ internal fun LaunchSettings(s: FrontEndState, a: FrontEndActions, host: MenuHost
|
||||
if (controller != null) add { m -> SettingCard(stringResource(R.string.setup_card_controls), stringResource(R.string.setup_card_controls_hint), "card:controls", m, controller.onMapping) }
|
||||
// An Epic game's own launch choices, kept in its sidecar so a launch from the Steam client
|
||||
// honours them too (droiddeck-store-launch reads the same file).
|
||||
// Epic's launch choices; cloud saves live in the game's Cloud saves view, so a GOG game has no card.
|
||||
val cardStore = com.droiddeck.launcher.stores.Store.byId(game?.source.orEmpty())?.takeIf { it == com.droiddeck.launcher.stores.Store.EPIC }
|
||||
// Store launch choices; cloud saves have their own view.
|
||||
val cardStore = com.droiddeck.launcher.stores.Store.byId(game?.source.orEmpty())?.takeIf { it == com.droiddeck.launcher.stores.Store.EPIC || it == com.droiddeck.launcher.stores.Store.GOG }
|
||||
if (cardStore != null && game?.gameFiles != null) add { m ->
|
||||
Box(m) {
|
||||
StoreLaunchCard(host, game.gameFiles!!, cardStore)
|
||||
@@ -544,7 +537,14 @@ private fun StoreLaunchCard(host: MenuHost, folder: java.io.File, store: com.dro
|
||||
val options = sidecar?.epic ?: com.droiddeck.launcher.stores.EpicOptions()
|
||||
val epic = store == com.droiddeck.launcher.stores.Store.EPIC
|
||||
val key = "store-" + store.id
|
||||
val value = buildList {
|
||||
val value = if (!epic) stringResource(when {
|
||||
!com.droiddeck.launcher.stores.gog.GogComet.enabled(appContext) || sidecar?.achievements == false -> R.string.gog_achievements_off
|
||||
com.droiddeck.launcher.stores.gog.GogComet.status == "sign-in-needed" -> R.string.gog_achievements_signin
|
||||
com.droiddeck.launcher.stores.gog.GogComet.status in listOf("service-unavailable", "credentials-unavailable", "not-installed") -> R.string.gog_achievements_unavailable
|
||||
com.droiddeck.launcher.stores.gog.GogComet.status == "uploaded" -> R.string.gog_achievements_uploaded
|
||||
com.droiddeck.launcher.stores.gog.GogComet.status == "pending-upload" || com.droiddeck.launcher.stores.gog.GogComet.status == "unlocked-locally" -> R.string.gog_achievements_pending
|
||||
else -> R.string.gog_achievements_on
|
||||
}) else buildList {
|
||||
if (epic && options.offline) add(stringResource(R.string.epic_card_offline))
|
||||
else if (epic && options.eos) add(stringResource(R.string.epic_card_eos))
|
||||
}.ifEmpty { listOf(stringResource(R.string.epic_card_none)) }.joinToString(" · ")
|
||||
@@ -563,6 +563,16 @@ private fun StoreLaunchCard(host: MenuHost, folder: java.io.File, store: com.dro
|
||||
host.open = if (host.open == key) null else key
|
||||
}
|
||||
AnchoredMenu(host.open == key, onDismiss = { if (host.open == key) host.open = null }, title = store.shortLabel) { first ->
|
||||
if (!epic) {
|
||||
MenuItem(stringResource(R.string.gog_achievements), checked = sidecar?.achievements != false, focusRequester = first,
|
||||
detail = if (!com.droiddeck.launcher.stores.gog.GogComet.enabled(appContext)) stringResource(R.string.gog_achievements_enable_store) else null) {
|
||||
val on = sidecar?.achievements == false
|
||||
Thread({
|
||||
val written = runCatching { com.droiddeck.launcher.stores.StoreGameSidecar.updateAchievements(folder, on) }.getOrNull()
|
||||
com.droiddeck.launcher.stores.StoresState.post { sidecar = written ?: sidecar }
|
||||
}, "gog-game-achievements").start()
|
||||
}
|
||||
}
|
||||
if (epic) {
|
||||
MenuItem(stringResource(R.string.epic_eos), checked = options.eos, focusRequester = first) { set { it.copy(eos = !it.eos) } }
|
||||
MenuItem(stringResource(R.string.epic_offline), checked = options.offline) { set { it.copy(offline = !it.offline) } }
|
||||
|
||||
@@ -37,10 +37,14 @@ import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.layout.widthIn
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.horizontalScroll
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Close
|
||||
import androidx.compose.material.icons.filled.KeyboardArrowUp
|
||||
import androidx.compose.ui.platform.testTag
|
||||
import kotlinx.coroutines.Job
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
@@ -126,12 +130,12 @@ internal object SheetTab {
|
||||
|
||||
/**
|
||||
* Where the open sheet's top edge sits in a pane [paneH] tall (px), for a button [buttonH] tall
|
||||
* riding it: 82dp down a 360dp pane, the same share of any other, and never so high that the
|
||||
* riding it: 60dp down a 360dp pane, the same share of any other, and never so high that the
|
||||
* button's top comes closer than [minAbove] to the pane's. [ride] is how far below the edge the
|
||||
* button's centre sits.
|
||||
*/
|
||||
internal fun sheetTop(paneH: Float, buttonH: Float, minAbove: Float, ride: Float): Float =
|
||||
maxOf(paneH * 82f / 360f, minAbove + buttonH / 2f - ride)
|
||||
maxOf(paneH * 60f / 360f, minAbove + buttonH / 2f - ride)
|
||||
|
||||
/** A finger's hold on the sheet: where it started (0 rest, 1 open), where it is, whether it has it. */
|
||||
private class SheetDrag {
|
||||
@@ -228,6 +232,7 @@ internal fun LiftHero(
|
||||
// Set as a finger's drag lets go: the sheet is already where it is going.
|
||||
var dragSettled by remember { mutableStateOf(false) }
|
||||
val scope = androidx.compose.runtime.rememberCoroutineScope()
|
||||
var dragJob by remember { mutableStateOf<Job?>(null) }
|
||||
val onOpenNow = rememberUpdatedState(onOpen)
|
||||
val pull = remember { Animatable(0f) }
|
||||
val sink = remember { Animatable(0f) }
|
||||
@@ -243,6 +248,8 @@ internal fun LiftHero(
|
||||
val playSrc = remember { MutableInteractionSource() }
|
||||
val playHovered by playSrc.collectIsHoveredAsState()
|
||||
var playFocused by remember { mutableStateOf(false) }
|
||||
// Set as a pad leaves the sheet to the left for Play, which folds it once Play has focus.
|
||||
val leftForPlay = remember { booleanArrayOf(false) }
|
||||
var heroAt by remember { mutableStateOf(Offset.Zero) }
|
||||
var rest by remember { mutableStateOf<Rect?>(null) }
|
||||
fun focusPlay() { if (ff != null && inputMode.inputMode == InputMode.Keyboard) runCatching { ff.primary.requestFocus() } }
|
||||
@@ -273,6 +280,7 @@ internal fun LiftHero(
|
||||
onDispose { lifecycle.removeObserver(obs) }
|
||||
}
|
||||
LaunchedEffect(open, launching) {
|
||||
if (!dragSettled) { dragJob?.cancel(); dragJob = null }
|
||||
if (dragSettled) {
|
||||
// A finger brought it here and has already animated it: only what opening needs.
|
||||
dragSettled = false
|
||||
@@ -344,6 +352,9 @@ internal fun LiftHero(
|
||||
}
|
||||
}
|
||||
BackHandler(enabled = open && !launching) { close() }
|
||||
// The ring keeps out of the lift and the fold, and comes back on whatever has focus once
|
||||
// they are done: Play rides the sheet on a layer, and the ring hung where Play had been.
|
||||
if (ride.isRunning || (shown && !open)) VeilRing()
|
||||
val openNow = open || shown
|
||||
LaunchedEffect(openNow) { onOpenChange(openNow) }
|
||||
|
||||
@@ -378,6 +389,8 @@ internal fun LiftHero(
|
||||
}
|
||||
/** A finger takes the sheet where it is: up from rest, or down from open. */
|
||||
fun beginDrag() {
|
||||
dragJob?.cancel(); dragJob = null
|
||||
dragSettled = false
|
||||
drag.engaged = true
|
||||
drag.from = if (open) 1f else 0f
|
||||
drag.progress = drag.from
|
||||
@@ -401,7 +414,8 @@ internal fun LiftHero(
|
||||
else -> drag.progress > 0.3f
|
||||
}
|
||||
dragSettled = true
|
||||
scope.launch {
|
||||
dragJob?.cancel()
|
||||
dragJob = scope.launch {
|
||||
val to = if (opens) 1f else 0f
|
||||
coroutineScope {
|
||||
launch { lift.animateTo(to, Motion.sp(if (opens) 0.7f else 1f, 380f)) }
|
||||
@@ -545,8 +559,8 @@ internal fun LiftHero(
|
||||
onPrevious = { if (tab > 0) { travel = -1; tab--; runCatching { chipFocus[tab].requestFocus() } } },
|
||||
onNext = { if (tab < tabs.lastIndex) { travel = 1; tab++; runCatching { chipFocus[tab].requestFocus() } } },
|
||||
)
|
||||
// A pad stays in the sheet until it folds; Left from it reaches Play, the handle.
|
||||
.focusProperties { exit = { dir -> if (!openState.value || launchingState.value) FocusRequester.Default else if (dir == FocusDirection.Left && ff != null) ff.primary else FocusRequester.Cancel } }
|
||||
// A pad stays in the sheet until it folds; Left from it reaches Play, the handle, and folds it.
|
||||
.focusProperties { exit = { dir -> if (!openState.value || launchingState.value) FocusRequester.Default else if (dir == FocusDirection.Left && ff != null) { leftForPlay[0] = true; ff.primary } else FocusRequester.Cancel } }
|
||||
.focusGroup(),
|
||||
) {
|
||||
Box(
|
||||
@@ -554,7 +568,7 @@ internal fun LiftHero(
|
||||
.offset { IntOffset(chipsX.roundToInt(), chipsY.roundToInt()) }
|
||||
// Over the rows, whatever they scroll under them.
|
||||
.zIndex(1f)
|
||||
.width(with(density) { (sheetW - chipsX - 16.dp.toPx()).coerceAtLeast(0f).toDp() })
|
||||
.width(with(density) { (sheetW - chipsX - 64.dp.toPx()).coerceAtLeast(0f).toDp() })
|
||||
.graphicsLayer { val v = pieces[0].value; alpha = v; translationY = (1f - v) * 6.dp.toPx() }
|
||||
// Up from the chips folds the sheet (a finger drags it down, see the hero's drag).
|
||||
.onPreviewKeyEvent { e ->
|
||||
@@ -596,6 +610,18 @@ internal fun LiftHero(
|
||||
}
|
||||
}
|
||||
}
|
||||
val closeSource = remember { MutableInteractionSource() }
|
||||
val closeHot = rememberHot(closeSource)
|
||||
Box(
|
||||
contentAlignment = Alignment.Center,
|
||||
modifier = Modifier
|
||||
.offset { IntOffset((sheetW - 52.dp.toPx()).roundToInt(), chipsY.roundToInt()) }
|
||||
.zIndex(1f).size(44.dp).testTag("sheet-close")
|
||||
.clip(CircleShape).glideBorder(closeHot, CircleShape, pal.signal)
|
||||
.hoverable(closeSource)
|
||||
.clickable(interactionSource = closeSource, indication = LocalIndication.current, enabled = open && !launching, role = Role.Button) { close() }
|
||||
.controllerConfirm(enabled = open && !launching) { close() },
|
||||
) { Icon(Icons.Filled.Close, stringResource(R.string.common_close), tint = colors.onSurfaceVariant, modifier = Modifier.size(20.dp)) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -608,7 +634,11 @@ internal fun LiftHero(
|
||||
Modifier
|
||||
.onGloballyPositioned { rest = it.boundsInRoot() }
|
||||
.graphicsLayer { translationY = raise * ride.value }
|
||||
.onFocusChanged { playFocused = it.hasFocus }
|
||||
.onFocusChanged {
|
||||
// Left out of the sheet (from the chips or a row) folds it, as Up from the chips does.
|
||||
if (it.hasFocus && leftForPlay[0]) { leftForPlay[0] = false; if (openState.value && !launchingState.value) close() }
|
||||
playFocused = it.hasFocus
|
||||
}
|
||||
.hoverable(playSrc)
|
||||
.onPreviewKeyEvent { e ->
|
||||
val k = e.nativeKeyEvent
|
||||
@@ -643,15 +673,15 @@ internal fun LiftHero(
|
||||
// A lip a pad can reach stays composed (unseen at rest) so Down always has it to land on.
|
||||
if (r0 != null && (lipShow.value > 0.01f || pull.value > 0.5f || (!downOpens && !open && !shown))) {
|
||||
var handleW by remember { mutableStateOf(0f) }
|
||||
val lipH = 22.dp + pull.value.dp
|
||||
val lipH = 32.dp + pull.value.dp
|
||||
val lift = { if (!open) open = true }
|
||||
Box(
|
||||
Modifier
|
||||
.offset { IntOffset((r0.center.x - handleW / 2f).roundToInt(), (r0.bottom + raise * ride.value + (lipShow.value - 1f) * 8.dp.toPx()).roundToInt()) }
|
||||
.onSizeChanged { handleW = it.width.toFloat() }
|
||||
.graphicsLayer { alpha = lipShow.value * (1f - lipGone.value) }
|
||||
// 44dp to touch; the tab itself is the top 22.
|
||||
.heightIn(min = 44.dp)
|
||||
// 44dp to touch, with a 32dp visible handle.
|
||||
.heightIn(min = 44.dp).testTag("sheet-open")
|
||||
.semantics { contentDescription = settingsLabel }
|
||||
.then(
|
||||
if (downOpens) Modifier.focusProperties { canFocus = false }
|
||||
@@ -698,7 +728,7 @@ private fun Handle(height: Dp) {
|
||||
.drawBorderSidesAndFoot(pal.line, 12.dp)
|
||||
.padding(start = 14.dp, end = 10.dp),
|
||||
) {
|
||||
Text(stringResource(R.string.drawer_page_settings), fontSize = 12.sp, fontWeight = FontWeight.SemiBold, color = colors.onSurfaceVariant, maxLines = 1)
|
||||
Text(stringResource(R.string.drawer_page_settings), fontSize = 14.sp, fontWeight = FontWeight.SemiBold, color = colors.onSurfaceVariant, maxLines = 1)
|
||||
Icon(
|
||||
Icons.Filled.KeyboardArrowUp, null, tint = colors.onSurfaceVariant,
|
||||
modifier = Modifier.size(16.dp).graphicsLayer { translationY = if (still) 0f else -3.dp.toPx() * lift },
|
||||
@@ -725,9 +755,11 @@ private fun Modifier.drawBorderSidesAndFoot(color: Color, corner: Dp): Modifier
|
||||
|
||||
/**
|
||||
* The sheet's chips: equal capsules with one selection gliding under them (the stores' chip row),
|
||||
* LB and RB a chip at a time, a tap or A on a far one a hop as a drop. [first] takes focus as the
|
||||
* sheet opens. Too narrow for equal chips, the row scrolls.
|
||||
* LB and RB a chip at a time, a tap or A on a far one a hop as a drop. A pad picks a chip by
|
||||
* moving onto it, and comes into the row on the picked one. [first] takes focus as the sheet
|
||||
* opens. Too narrow for equal chips, the row scrolls.
|
||||
*/
|
||||
@OptIn(ExperimentalComposeUiApi::class)
|
||||
@Composable
|
||||
internal fun SheetChips(labels: List<String>, selected: Int, focus: List<FocusRequester>? = null, onPick: (Int) -> Unit) {
|
||||
val pal = LocalPalette.current
|
||||
@@ -743,15 +775,22 @@ internal fun SheetChips(labels: List<String>, selected: Int, focus: List<FocusRe
|
||||
val scroll = rememberScrollState()
|
||||
// Room inside the scroll for the focus ring, which the scroll's clip would otherwise cut.
|
||||
Box(if (equal) Modifier.fillMaxWidth() else Modifier.edgeFade(scroll).horizontalScroll(scroll).padding(3.dp)) {
|
||||
ChipGlide(selected, bounds[selected], tint)
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(6.dp), modifier = if (equal) Modifier.fillMaxWidth() else Modifier) {
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.spacedBy(6.dp),
|
||||
// Up from the rows lands on the picked chip, not whichever sits above: landing picks.
|
||||
modifier = (if (equal) Modifier.fillMaxWidth() else Modifier)
|
||||
.focusProperties { enter = { chips.getOrNull(selected) ?: FocusRequester.Default } }
|
||||
.focusGroup(),
|
||||
) {
|
||||
labels.forEachIndexed { i, label ->
|
||||
val m = (if (equal) Modifier.weight(1f) else Modifier.widthIn(min = 64.dp))
|
||||
.onGloballyPositioned { bounds[i] = it.boundsInParent() }
|
||||
.focusRequester(chips[i])
|
||||
SheetChip(label, i == selected, m) { onPick(i) }
|
||||
SheetChip(label, i == selected, m.onFocusChanged { if (it.isFocused && i != selected) onPick(i) }) { onPick(i) }
|
||||
}
|
||||
}
|
||||
// Over the chips: under them, their rest fill hid it as it crossed them.
|
||||
ChipGlide(selected, bounds[selected], tint)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -763,11 +802,15 @@ private fun SheetChip(label: String, on: Boolean, modifier: Modifier, onClick: (
|
||||
val src = remember { MutableInteractionSource() }
|
||||
val hot = rememberHot(src)
|
||||
val shape = RoundedCornerShape(99.dp)
|
||||
// The row's glide draws the picked chip's look by touch only; with a pad it draws its own rest
|
||||
// look, and the bar says which is picked.
|
||||
val under = on && LocalInputModeManager.current.inputMode != InputMode.Keyboard
|
||||
Box(
|
||||
contentAlignment = Alignment.Center,
|
||||
modifier = modifier.heightIn(min = 44.dp).clip(shape)
|
||||
.background(if (on) Color.Transparent else colors.surfaceVariant.copy(alpha = 0.5f))
|
||||
.glideBorder(hot, shape, pal.signal, if (on) Color.Transparent else pal.line)
|
||||
.background(if (under) Color.Transparent else colors.surfaceVariant.copy(alpha = 0.5f))
|
||||
.shownBar(on, pal.signal)
|
||||
.glideBorder(hot, shape, pal.signal, if (under) Color.Transparent else pal.line)
|
||||
.hoverable(src).clickable(interactionSource = src, indication = LocalIndication.current, role = Role.Tab, onClick = onClick)
|
||||
.controllerConfirm(onClick = onClick)
|
||||
.padding(horizontal = 14.dp, vertical = 8.dp),
|
||||
|
||||
@@ -159,7 +159,7 @@ class ModeSettingsActions(
|
||||
* Session (its Files chip is the Desktop page's own).
|
||||
*/
|
||||
internal fun modeSheetTabs(steam: Boolean): List<String> =
|
||||
if (steam) listOf(SheetTab.DISPLAY, SheetTab.CONTROLS, SheetTab.AUDIO, SheetTab.SESSION, SheetTab.LIBRARY, SheetTab.STEAM)
|
||||
if (steam) listOf(SheetTab.STEAM, SheetTab.DISPLAY, SheetTab.CONTROLS, SheetTab.AUDIO, SheetTab.SESSION, SheetTab.LIBRARY)
|
||||
else listOf(SheetTab.DISPLAY, SheetTab.CONTROLS, SheetTab.SESSION)
|
||||
|
||||
/** A sheet tab's chip label. */
|
||||
@@ -182,6 +182,8 @@ class SheetExtras(
|
||||
val frameGen: @Composable () -> Unit = {},
|
||||
val performance: @Composable () -> Unit = {},
|
||||
val drivers: @Composable (summary: String?) -> Unit = {},
|
||||
/** The Steam tab's account rows (offline mode), from the front end's own state. */
|
||||
val account: @Composable (host: MenuHost) -> Unit = {},
|
||||
)
|
||||
|
||||
/** One tab of a mode's lifted sheet: the rows the settings page had, grouped by what they are for. */
|
||||
@@ -360,6 +362,7 @@ fun ModeSheetRows(s: ModeSettings, a: ModeSettingsActions, tab: String, extras:
|
||||
}
|
||||
}
|
||||
if (tab == SheetTab.STEAM && steam) {
|
||||
extras.account(host)
|
||||
SettingsGroup(stringResource(R.string.mode_decky)) {
|
||||
val updateAvailable = s.deckyInstalled != null && s.deckyLatestRelease != null &&
|
||||
s.deckyInstalled != s.deckyLatestRelease.tag
|
||||
@@ -474,7 +477,7 @@ internal fun ProtonOptions(
|
||||
onSyncBackend: (String) -> Unit, onFexPreset: (String) -> Unit, onForceSsbs: (Boolean) -> Unit,
|
||||
) {
|
||||
val host = rememberMenuHost()
|
||||
SettingsRow(stringResource(R.string.sync_backend_title), stringResource(R.string.sync_backend_hint)) {
|
||||
SettingsRow(stringResource(R.string.sync_backend_title), stringResource(R.string.sync_backend_hint), stacked = true) {
|
||||
SegmentedTabs(
|
||||
listOf(
|
||||
SessionPrefs.SYNC_NTSYNC to stringResource(R.string.sync_backend_ntsync),
|
||||
|
||||
@@ -30,7 +30,9 @@ import androidx.compose.ui.graphics.drawscope.clipPath
|
||||
import androidx.compose.ui.graphics.drawscope.translate
|
||||
import androidx.compose.ui.graphics.painter.Painter
|
||||
import androidx.compose.ui.graphics.graphicsLayer
|
||||
import androidx.compose.ui.layout.onGloballyPositioned
|
||||
import androidx.compose.ui.layout.onSizeChanged
|
||||
import androidx.compose.ui.layout.positionInRoot
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.util.lerp
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
@@ -109,6 +111,14 @@ internal fun PageFlood(
|
||||
/** What the tile shows instead of the control's fill: a game card's art, cropped to the tile as it grows. */
|
||||
art: Painter? = null,
|
||||
sinks: Boolean = false,
|
||||
/**
|
||||
* Where on the page the control's tile lands (root px), when the page has its own picture of
|
||||
* the control - a game page's hero art: the tile grows onto it instead of over the whole pane,
|
||||
* corner to corner ([ontoCorner] there), and the page comes in around it. Back leaves from it.
|
||||
* Null, or off screen: the pane, as any page.
|
||||
*/
|
||||
onto: (() -> Rect?)? = null,
|
||||
ontoCorner: androidx.compose.ui.unit.Dp = 0.dp,
|
||||
content: @Composable () -> Unit,
|
||||
) {
|
||||
val pal = LocalPalette.current
|
||||
@@ -118,6 +128,10 @@ internal fun PageFlood(
|
||||
val shown = remember { Animatable(0f) }
|
||||
val tile = remember { Animatable(1f) }
|
||||
var size by remember { mutableStateOf(Size.Zero) }
|
||||
var at by remember { mutableStateOf(Offset.Zero) }
|
||||
// Where this flood lands (in its own space), read as it opens and again as it leaves.
|
||||
var target by remember { mutableStateOf<Rect?>(null) }
|
||||
val density = androidx.compose.ui.platform.LocalDensity.current
|
||||
LaunchedEffect(size != Size.Zero, leaving, sinks) {
|
||||
if (sinks) {
|
||||
// Whatever the flood in was doing, the page is shown whole and leaves with the pane.
|
||||
@@ -128,6 +142,30 @@ internal fun PageFlood(
|
||||
}
|
||||
if (size == Size.Zero) return@LaunchedEffect
|
||||
glide?.hidden = true
|
||||
// The page lays out under the tile at once, so its picture is there within a frame or two.
|
||||
target = onto?.let { get ->
|
||||
kotlinx.coroutines.withTimeoutOrNull(300) { snapshotFlow { get() }.first { it != null } }
|
||||
}?.translate(-at)?.takeIf { it.height > 1f && it.overlaps(Rect(Offset.Zero, size)) }
|
||||
if (target != null) {
|
||||
coroutineScope {
|
||||
if (!leaving) {
|
||||
// Onto the page's picture, every edge together on one firm spring: no blob, and
|
||||
// nowhere to go past it.
|
||||
val runs = edges.map { launch { it.animateTo(1f, Motion.sp(0.85f, 320f)) } }
|
||||
snapshotFlow { edges.all { it.value >= 0.9f } }.first { it }
|
||||
launch { shown.animateTo(1f, Motion.tw(240)) }
|
||||
launch { delay(Motion.ms(140).toLong()); tile.animateTo(0f, Motion.tw(220)) }
|
||||
runs.forEach { it.join() }
|
||||
} else {
|
||||
launch { shown.animateTo(0f, Motion.tw(160)) }
|
||||
tile.animateTo(1f, Motion.tw(120))
|
||||
edges.map { launch { it.animateTo(0f, Motion.sp(0.9f, 320f)) } }.forEach { it.join() }
|
||||
tile.animateTo(0f, Motion.tw(120))
|
||||
}
|
||||
}
|
||||
glide?.hidden = false
|
||||
return@LaunchedEffect
|
||||
}
|
||||
val b = from.bounds
|
||||
val travel = listOf(b.left, b.top, size.width - b.right, size.height - b.bottom).map { it.coerceAtLeast(0f) }
|
||||
val far = travel.max().coerceAtLeast(1f)
|
||||
@@ -160,10 +198,16 @@ internal fun PageFlood(
|
||||
glide?.hidden = false
|
||||
}
|
||||
DisposableEffect(Unit) { onDispose { glide?.hidden = false } }
|
||||
Box(Modifier.fillMaxSize().clipToBounds().onSizeChanged { size = Size(it.width.toFloat(), it.height.toFloat()) }) {
|
||||
Box(Modifier.fillMaxSize().graphicsLayer { alpha = shown.value; translationY = (1f - shown.value) * 14.dp.toPx() }) { content() }
|
||||
Box(
|
||||
Modifier.fillMaxSize().clipToBounds().onSizeChanged { size = Size(it.width.toFloat(), it.height.toFloat()) }
|
||||
.onGloballyPositioned { at = it.positionInRoot() },
|
||||
) {
|
||||
// Landing on the page's picture, the page must not rise: its picture would move off the tile.
|
||||
val rise = if (onto != null) 0f else 1f
|
||||
Box(Modifier.fillMaxSize().graphicsLayer { alpha = shown.value; translationY = (1f - shown.value) * 14.dp.toPx() * rise }) { content() }
|
||||
val onCorner = with(density) { ontoCorner.toPx() }
|
||||
Canvas(Modifier.fillMaxSize()) {
|
||||
if (tile.value > 0.01f) drawTile(from, edges.map { it.value }, pal.surface, pal.line2, tile.value, art)
|
||||
if (tile.value > 0.01f) drawTile(from, edges.map { it.value }, pal.surface, pal.line2, tile.value, art, target, onCorner)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -172,22 +216,33 @@ internal fun PageFlood(
|
||||
* The control's tile with its edges [v] of the way to the pane's (left, top, right, bottom):
|
||||
* sinking with the page behind, blobby in flight, square once it fills the pane.
|
||||
*/
|
||||
private fun DrawScope.drawTile(from: Origin, v: List<Float>, fill: Color, line: Color, alpha: Float, art: Painter? = null) {
|
||||
private fun DrawScope.drawTile(
|
||||
from: Origin, v: List<Float>, fill: Color, line: Color, alpha: Float, art: Painter? = null,
|
||||
/** Lands on this instead of the pane (a page's picture of the control), corner [toCorner]. */
|
||||
to: Rect? = null, toCorner: Float = 0f,
|
||||
) {
|
||||
val (l, t, r, b) = v
|
||||
val mean = v.sumOf { it.coerceIn(0f, 1f).toDouble() }.toFloat() / 4f
|
||||
// The control sinks with the page behind it (scaled to 0.95 about the pane's centre).
|
||||
val k = 1f - 0.05f * mean
|
||||
val cx = size.width / 2f
|
||||
val cy = size.height / 2f
|
||||
val f = from.bounds
|
||||
val left = lerp(cx + (f.left - cx) * k, 0f, l)
|
||||
val top = lerp(cy + (f.top - cy) * k, 0f, t)
|
||||
val right = lerp(cx + (f.right - cx) * k, size.width, r)
|
||||
val bottom = lerp(cy + (f.bottom - cy) * k, size.height, b)
|
||||
val left: Float; val top: Float; val right: Float; val bottom: Float
|
||||
if (to != null) {
|
||||
left = lerp(f.left, to.left, l); top = lerp(f.top, to.top, t)
|
||||
right = lerp(f.right, to.right, r); bottom = lerp(f.bottom, to.bottom, b)
|
||||
} else {
|
||||
// The control sinks with the page behind it (scaled to 0.95 about the pane's centre).
|
||||
val k = 1f - 0.05f * mean
|
||||
val cx = size.width / 2f
|
||||
val cy = size.height / 2f
|
||||
left = lerp(cx + (f.left - cx) * k, 0f, l)
|
||||
top = lerp(cy + (f.top - cy) * k, 0f, t)
|
||||
right = lerp(cx + (f.right - cx) * k, size.width, r)
|
||||
bottom = lerp(cy + (f.bottom - cy) * k, size.height, b)
|
||||
}
|
||||
val w = (right - left).coerceAtLeast(0f)
|
||||
val h = (bottom - top).coerceAtLeast(0f)
|
||||
val blob = sin(PI * mean).toFloat().coerceAtLeast(0f)
|
||||
val corner = lerp(from.corner * (1f - mean), minOf(w, h) * 0.42f, blob)
|
||||
// Onto a picture it keeps a card's shape, corner to corner; over the pane it blobs in flight.
|
||||
val corner = if (to != null) lerp(from.corner, toCorner, mean).coerceAtMost(minOf(w, h) / 2f)
|
||||
else lerp(from.corner * (1f - mean), minOf(w, h) * 0.42f, sin(PI * mean).toFloat().coerceAtLeast(0f))
|
||||
drawRoundRect(fill, Offset(left, top), Size(w, h), CornerRadius(corner), alpha = alpha)
|
||||
val pic = art?.intrinsicSize?.takeIf { it.isSpecified && it.width > 0f && it.height > 0f }
|
||||
if (art != null && pic != null && w > 0f && h > 0f) {
|
||||
|
||||
@@ -73,6 +73,7 @@ import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.ScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.LinearProgressIndicator
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedButton
|
||||
import androidx.compose.material3.Text
|
||||
@@ -223,6 +224,10 @@ class DrawerActions(
|
||||
val onHardwareKeyboard: () -> Unit,
|
||||
val onSteamMenu: (() -> Unit)?,
|
||||
val onQam: (() -> Unit)?,
|
||||
/** Null hides the achievements row. */
|
||||
val onAchievements: (() -> Unit)? = null,
|
||||
/** (unlocked, total), or null when unknown. */
|
||||
val achievementsProgress: Pair<Int, Int>? = null,
|
||||
val onOsc: (String) -> Unit,
|
||||
/** Edits the Steam touch layout of the game in front, when Steam's controls are up. */
|
||||
val onEditSteamTouch: (() -> Unit)? = null,
|
||||
@@ -261,6 +266,13 @@ class DrawerActions(
|
||||
val components: ComponentsManager.Snapshot? = null,
|
||||
/** Re-reads the Protons (and runs swaps that waited for a game to close). */
|
||||
val onComponentsRefresh: () -> Unit = {},
|
||||
val componentCatalog: List<ComponentsManager.CatalogItem> = emptyList(),
|
||||
val componentCatalogAt: Long = 0,
|
||||
val componentCatalogChecking: Boolean = false,
|
||||
val componentDownloads: Map<String, Int> = emptyMap(),
|
||||
val componentDownloadRevision: Long = 0,
|
||||
val onComponentCatalogRefresh: () -> Unit = {},
|
||||
val onComponentDownload: (ComponentsManager.CatalogItem) -> Unit = {},
|
||||
/** Installed games available for profile inspection in the session drawer. */
|
||||
val gameProfiles: List<Pair<Long, String>> = emptyList(),
|
||||
/** The selected game profile, or null for the Default profile. */
|
||||
@@ -273,6 +285,9 @@ class DrawerActions(
|
||||
val onSelectedGameProfileRefresh: () -> Unit = {},
|
||||
val gameFexPresetSaving: Boolean = false,
|
||||
val onGameFexPreset: (Long, String?) -> Unit = { _, _ -> },
|
||||
/** Saves the selected game's Start without Steam (GameEnvironment.NO_STEAM). */
|
||||
val gameNoSteamSaving: Boolean = false,
|
||||
val onGameNoSteam: (Long, Boolean) -> Unit = { _, _ -> },
|
||||
/** Swaps [value] ("orig:<build>" or a stored package file) into a Proton's component. */
|
||||
val onComponentSwap: (protonId: String, comp: String, value: String) -> Unit = { _, _, _ -> },
|
||||
/** Saves a stored package for a game, or null to inherit that component from the Default profile. */
|
||||
@@ -307,7 +322,7 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont
|
||||
LaunchedEffect(a.selectedGameProfileId) {
|
||||
if (host.open == "fex") host.open = null
|
||||
}
|
||||
LaunchedEffect(open, page) {
|
||||
LaunchedEffect(open, page, a.componentDownloadRevision) {
|
||||
if (open && page == SessionDrawerPage.GAMES) {
|
||||
a.onGameProfilesPageOpened()
|
||||
a.onComponentsRefresh()
|
||||
@@ -406,6 +421,11 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont
|
||||
}
|
||||
StopSessionButton(modifier = focus.track(page, "stop").onGloballyPositioned { stopCoords = it }) { host.open = null; confirmStop = true }
|
||||
}
|
||||
a.onAchievements?.let { show ->
|
||||
DrawerAchievementsRow(a.achievementsProgress, Modifier.padding(top = if (short) 6.dp else 10.dp).then(focus.track(page, "achievements"))) {
|
||||
host.open = null; show()
|
||||
}
|
||||
}
|
||||
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
@@ -515,6 +535,7 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont
|
||||
TextureFilteringGroup(host, a) { key -> focus.track(page, key) }
|
||||
if (a.steam) SettingsGroup(stringResource(R.string.game_settings_title)) {
|
||||
DrawerFexPresetRow(host, a, focus.track(page, "fex"))
|
||||
DrawerNoSteamRow(host, a, focus.track(page, "no-steam"))
|
||||
GameEnvironmentRow(
|
||||
modifier = focus.track(page, "game-env"),
|
||||
showHint = false,
|
||||
@@ -522,6 +543,17 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont
|
||||
)
|
||||
}
|
||||
ComponentsDrawerPage(host, a) { key -> focus.track(page, key) }
|
||||
ComponentDownloadsDrawerGroup(
|
||||
host = host,
|
||||
catalog = a.componentCatalog,
|
||||
catalogAt = a.componentCatalogAt,
|
||||
checking = a.componentCatalogChecking,
|
||||
packages = a.components?.packages.orEmpty(),
|
||||
downloads = a.componentDownloads,
|
||||
onRefresh = a.onComponentCatalogRefresh,
|
||||
onDownload = a.onComponentDownload,
|
||||
track = { key -> focus.track(page, key) },
|
||||
)
|
||||
}
|
||||
SessionDrawerPage.SESSION -> {
|
||||
if (a.isHomeApp) SettingsGroup(stringResource(R.string.drawer_android_apps)) {
|
||||
@@ -940,6 +972,17 @@ private fun DrawerFexPresetRow(host: MenuHost, a: DrawerActions, modifier: Modif
|
||||
}
|
||||
}
|
||||
|
||||
/** A game's Start without Steam; only with a game selected - the Default profile has no such switch. */
|
||||
@Composable
|
||||
private fun DrawerNoSteamRow(host: MenuHost, a: DrawerActions, modifier: Modifier) {
|
||||
val appId = a.selectedGameProfileId ?: return
|
||||
val profile = a.selectedGameProfile?.takeIf { it.appId == appId } ?: return
|
||||
ToggleRow(
|
||||
host, "no-steam", stringResource(R.string.game_no_steam_title), stringResource(R.string.game_no_steam_detail),
|
||||
profile.startWithoutSteam, enabled = !a.gameNoSteamSaving, chipModifier = modifier,
|
||||
) { on -> a.onGameNoSteam(appId, on) }
|
||||
}
|
||||
|
||||
/** Texture filtering on the Games page: DXVK options for the next DirectX 9-11 launch. */
|
||||
@Composable
|
||||
private fun TextureFilteringGroup(host: MenuHost, a: DrawerActions, track: (String) -> Modifier) {
|
||||
@@ -1028,6 +1071,9 @@ private fun SelectedGameProfileGroup(host: MenuHost, a: DrawerActions, track: (S
|
||||
ProfileSummaryRow(ComponentsManager.LABEL.getValue(component), profileValueLabel(value))
|
||||
}
|
||||
}
|
||||
if (profile.startWithoutSteam) {
|
||||
ProfileSummaryRow(stringResource(R.string.game_no_steam_title), stringResource(R.string.game_no_steam_on))
|
||||
}
|
||||
if (profile.environmentOverrides > 0) {
|
||||
ProfileSummaryRow(
|
||||
stringResource(R.string.game_env_title),
|
||||
@@ -1090,8 +1136,8 @@ private fun ProfileSummaryRow(label: String, value: String) {
|
||||
|
||||
/**
|
||||
* The Games tab's components: quick swaps between what is already installed, per Proton. A swap
|
||||
* into the Proton a running game uses waits until that game closes; downloading, importing and
|
||||
* deleting stay on the Components page in the app.
|
||||
* into the Proton a running game uses waits until that game closes. Downloads below share the
|
||||
* launcher's package store; importing and deleting stay on the Components page.
|
||||
*/
|
||||
@Composable
|
||||
private fun ComponentsDrawerPage(host: MenuHost, a: DrawerActions, track: (String) -> Modifier) {
|
||||
@@ -1224,6 +1270,84 @@ private fun ComponentsDrawerPage(host: MenuHost, a: DrawerActions, track: (Strin
|
||||
)
|
||||
}
|
||||
|
||||
/** Downloads only store packages; the profile/Proton choices above apply them separately. */
|
||||
@Composable
|
||||
internal fun ComponentDownloadsDrawerGroup(
|
||||
host: MenuHost,
|
||||
catalog: List<ComponentsManager.CatalogItem>,
|
||||
catalogAt: Long,
|
||||
checking: Boolean,
|
||||
packages: List<ComponentsManager.Package>,
|
||||
downloads: Map<String, Int>,
|
||||
onRefresh: () -> Unit,
|
||||
onDownload: (ComponentsManager.CatalogItem) -> Unit,
|
||||
track: (String) -> Modifier = { Modifier },
|
||||
) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val installed = packages.map { it.file }.toSet()
|
||||
SettingsGroup(stringResource(R.string.drawer_component_downloads)) {
|
||||
Text(stringResource(R.string.drawer_component_downloads_hint), fontSize = 12.sp,
|
||||
color = colors.onSurfaceVariant, modifier = Modifier.padding(horizontal = 14.dp, vertical = 8.dp))
|
||||
SettingsRow(stringResource(R.string.comp_nightlies_checked,
|
||||
if (catalogAt > 0) java.text.DateFormat.getTimeInstance(java.text.DateFormat.SHORT)
|
||||
.format(java.util.Date(catalogAt * 1000)) else stringResource(R.string.comp_never)), null, stacked = true) {
|
||||
ValueChip(stringResource(if (checking) R.string.common_checking else R.string.stores_refresh),
|
||||
false, enabled = !checking, modifier = track("cmp-download-refresh"), onClick = onRefresh)
|
||||
}
|
||||
for (comp in ComponentsManager.COMPONENTS) {
|
||||
val key = "cmp-download-$comp"
|
||||
val items = catalog.filter { it.comp == comp }
|
||||
val open = host.open == key
|
||||
Column(Modifier.fillMaxWidth().padding(horizontal = 14.dp, vertical = 10.dp)) {
|
||||
Text(ComponentsManager.LABEL.getValue(comp), fontSize = 15.sp,
|
||||
fontWeight = FontWeight.SemiBold, color = colors.onBackground)
|
||||
Box(Modifier.fillMaxWidth().padding(top = 6.dp)) {
|
||||
ValueChip(stringResource(R.string.drawer_component_choose_download), open,
|
||||
enabled = items.isNotEmpty(), modifier = track(key).fillMaxWidth()) {
|
||||
host.open = if (open) null else key
|
||||
}
|
||||
AnchoredMenu(open, onDismiss = { if (host.open == key) host.open = null },
|
||||
title = ComponentsManager.LABEL.getValue(comp)) { firstItemFocus ->
|
||||
val firstAvailable = items.firstOrNull { ComponentsManager.safeName(it.file) !in installed && it.file !in downloads }
|
||||
items.forEach { item ->
|
||||
val stored = ComponentsManager.safeName(item.file) in installed
|
||||
val progress = downloads[item.file]
|
||||
MenuItem(item.file.removeSuffix(".wcp"), checked = stored,
|
||||
enabled = !stored && progress == null,
|
||||
detail = when {
|
||||
stored -> stringResource(R.string.wincomp_downloaded)
|
||||
progress != null -> if (progress < 0) stringResource(R.string.wincomp_downloading, item.file.removeSuffix(".wcp")) else "$progress%"
|
||||
else -> item.release + " · " + stringResource(R.string.common_size_mb, item.size / 1048576.0)
|
||||
},
|
||||
focusRequester = if (item == firstAvailable) firstItemFocus else null,
|
||||
) {
|
||||
onDownload(item)
|
||||
host.open = null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (catalog.isEmpty() && !checking) Text(
|
||||
stringResource(if (catalogAt == 0L) R.string.comp_refresh_to_list else R.string.comp_nothing_new),
|
||||
fontSize = 12.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(14.dp),
|
||||
)
|
||||
for ((file, progress) in downloads) {
|
||||
Column(Modifier.fillMaxWidth().padding(horizontal = 14.dp, vertical = 8.dp)) {
|
||||
Text(stringResource(R.string.wincomp_downloading, file.removeSuffix(".wcp")),
|
||||
fontSize = 12.sp, color = colors.onSurfaceVariant)
|
||||
if (progress < 0) LinearProgressIndicator(modifier = Modifier.fillMaxWidth().padding(top = 4.dp))
|
||||
else {
|
||||
Text("$progress%", fontSize = 12.sp, color = colors.onSurfaceVariant)
|
||||
LinearProgressIndicator(progress = { progress / 100f },
|
||||
modifier = Modifier.fillMaxWidth().padding(top = 4.dp))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A choice for the drawer's narrow column: label, then the box across the full width, then the
|
||||
* detail underneath - so a long Proton or package name never squeezes the text beside it.
|
||||
|
||||
@@ -62,6 +62,7 @@ import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
@@ -98,6 +99,7 @@ import androidx.compose.ui.text.style.TextAlign
|
||||
import kotlin.math.roundToInt
|
||||
import androidx.compose.ui.input.InputMode
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.platform.LocalConfiguration
|
||||
import androidx.compose.ui.platform.LocalInputModeManager
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
@@ -281,11 +283,16 @@ fun AnchoredMenu(
|
||||
android.util.Log.i("AnchoredMenu", "requested first option focus")
|
||||
}
|
||||
}
|
||||
val gap = with(LocalDensity.current) { 6.dp.roundToPx() }
|
||||
// Popup installs Android's window density. Keep the app scale from the anchor, including
|
||||
// the matching dp window dimensions used to cap and scroll the menu.
|
||||
val density = LocalDensity.current
|
||||
val configuration = LocalConfiguration.current
|
||||
val gap = with(density) { 6.dp.roundToPx() }
|
||||
val provider = remember(gap, compact) { if (compact) BelowStartProvider(gap) else BelowEndProvider(gap) }
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
Popup(popupPositionProvider = provider, onDismissRequest = onDismiss, properties = PopupProperties(focusable = true)) {
|
||||
CompositionLocalProvider(LocalDensity provides density, LocalConfiguration provides configuration) {
|
||||
AnimatedVisibility(
|
||||
visibleState = state,
|
||||
enter = fadeIn(Motion.tw(180)) + scaleIn(Motion.sp(0.7f), initialScale = 0.94f, transformOrigin = TransformOrigin(if (compact) 0f else 1f, 0f)),
|
||||
@@ -345,6 +352,7 @@ fun AnchoredMenu(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -443,7 +451,7 @@ fun SettingsGroup(title: String, compact: Boolean = false, content: @Composable
|
||||
* under it stay put.
|
||||
*/
|
||||
@Composable
|
||||
fun SettingsRow(label: String, hint: String?, highlighted: Boolean = false, hintLines: Int? = null, control: @Composable () -> Unit) {
|
||||
fun SettingsRow(label: String, hint: String?, highlighted: Boolean = false, hintLines: Int? = null, stacked: Boolean = false, control: @Composable () -> Unit) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
val bg by animateColorAsState(if (highlighted) pal.signal.copy(alpha = 0.10f) else Color.Transparent, Motion.tw(200), label = "rowBg")
|
||||
@@ -452,7 +460,7 @@ fun SettingsRow(label: String, hint: String?, highlighted: Boolean = false, hint
|
||||
minLines = hintLines ?: 1, maxLines = hintLines ?: Int.MAX_VALUE, overflow = TextOverflow.Ellipsis)
|
||||
}
|
||||
// A narrow page stacks the control under its label, so neither squeezes the other.
|
||||
if (LocalNarrowPane.current) Column(
|
||||
if (stacked || LocalNarrowPane.current) Column(
|
||||
modifier = Modifier.fillMaxWidth().background(bg).padding(start = 14.dp, end = 14.dp, top = 11.dp, bottom = 12.dp),
|
||||
) {
|
||||
Text(label, fontSize = 15.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground)
|
||||
|
||||
@@ -13,8 +13,10 @@ import androidx.compose.runtime.key
|
||||
import androidx.compose.runtime.mutableStateListOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberUpdatedState
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.geometry.CornerRadius
|
||||
import androidx.compose.ui.draw.drawWithContent
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.geometry.Rect
|
||||
import androidx.compose.ui.geometry.Size
|
||||
@@ -44,9 +46,10 @@ internal enum class GlideAxis { Horizontal, Vertical }
|
||||
/**
|
||||
* The selection under a row of chips: [at] (in the row) of chip [index], in [tint]. A move to the
|
||||
* next chip stretches it - the leading edge on the focus ring's lead spring, the trailing one a
|
||||
* beat later on its trail spring - and a hop past a chip pinches it to a drop, carries it and
|
||||
* opens it. [axis] runs it down a column instead (the rail, a stack of layers). [corner] is the
|
||||
* chips' own corner; null draws a capsule. [fill] and [outline] are the resting alphas.
|
||||
* beat later on its trail spring - and a hop past chips stretches the same way, across them.
|
||||
* Draw it over the chips: under them, their own rest fill hid it in flight. [axis] runs it down a column instead (the rail, a stack of layers). [corner] is the
|
||||
* chips' own corner; null draws a capsule. [fill] and [outline] are the resting alphas. Not
|
||||
* [visible], it fades away, and comes back on whichever chip it is on by then.
|
||||
*/
|
||||
@Composable
|
||||
internal fun BoxScope.ChipGlide(
|
||||
@@ -57,17 +60,25 @@ internal fun BoxScope.ChipGlide(
|
||||
corner: Dp? = null,
|
||||
fill: Float = 0.16f,
|
||||
outline: Float = 0.7f,
|
||||
visible: Boolean = true,
|
||||
) {
|
||||
val density = androidx.compose.ui.platform.LocalDensity.current
|
||||
// The two edges along the axis (left and right, or top and bottom), and the two across it.
|
||||
val start = remember { Animatable(Float.NaN) }
|
||||
val end = remember { Animatable(0f) }
|
||||
val pinch = remember { Animatable(0f) }
|
||||
// With a pad the focus ring fills what it holds, and is the only fill: a selection of the
|
||||
// row's own, sliding on its own beat, trailed the ring and sat on items the pad had left.
|
||||
val pad = androidx.compose.ui.platform.LocalInputModeManager.current.inputMode == androidx.compose.ui.input.InputMode.Keyboard
|
||||
@Suppress("NAME_SHADOWING") val visible = visible && !pad
|
||||
val shown = remember { Animatable(if (visible) 1f else 0f) }
|
||||
val visibleNow = rememberUpdatedState(visible)
|
||||
LaunchedEffect(visible) { shown.animateTo(if (visible) 1f else 0f, Motion.tw(if (visible) 160 else 120)) }
|
||||
val crossStart = remember { mutableStateOf(0f) }
|
||||
val crossEnd = remember { mutableStateOf(0f) }
|
||||
val was = remember { intArrayOf(-1) }
|
||||
val vertical = axis == GlideAxis.Vertical
|
||||
LaunchedEffect(index, at) {
|
||||
LaunchedEffect(index, at, Motion.scale) {
|
||||
val b = at ?: return@LaunchedEffect
|
||||
val s = if (vertical) b.top else b.left
|
||||
val e = if (vertical) b.bottom else b.right
|
||||
@@ -76,18 +87,21 @@ internal fun BoxScope.ChipGlide(
|
||||
val from = was[0]
|
||||
was[0] = index
|
||||
if (start.value.isNaN() || from == index || from < 0 || Motion.scale == 0f) {
|
||||
start.snapTo(s); end.snapTo(e); pinch.snapTo(0f)
|
||||
if (visibleNow.value) shown.snapTo(1f)
|
||||
return@LaunchedEffect
|
||||
}
|
||||
// Away or on its way back: it goes straight to the chip, unseen.
|
||||
if (!visibleNow.value || shown.value < 0.5f) {
|
||||
start.snapTo(s); end.snapTo(e); pinch.snapTo(0f)
|
||||
return@LaunchedEffect
|
||||
}
|
||||
coroutineScope {
|
||||
if (abs(index - from) > 1) {
|
||||
// Too far to stretch: pinch into a drop where it is, carry it over, open it there.
|
||||
pinch.animateTo(1f, Motion.tw(90))
|
||||
val l = launch { start.animateTo(s, Motion.sp(0.7f, 380f)) }
|
||||
val r = launch { end.animateTo(e, Motion.sp(0.7f, 380f)) }
|
||||
l.join(); r.join()
|
||||
pinch.animateTo(0f, Motion.sp(0.6f, 500f))
|
||||
} else {
|
||||
run {
|
||||
// Every move stretches across, however far: a long one used to go as a drop (which
|
||||
// sat on chips already left) and then as a fade (a flash of no fill at all).
|
||||
launch { pinch.animateTo(0f, Motion.sp(0.6f, 500f)) }
|
||||
launch { shown.animateTo(1f, Motion.tw(120)) }
|
||||
val forward = index > from
|
||||
val (lead, trail) = if (forward) end to start else start to end
|
||||
val leadTo = if (forward) e else s
|
||||
@@ -106,19 +120,42 @@ internal fun BoxScope.ChipGlide(
|
||||
val round = minOf(size.width, size.height) / 2f
|
||||
val r = CornerRadius(corner?.let { lerp(minOf(with(density) { it.toPx() }, round), round, p) } ?: round)
|
||||
// A drop in flight is solid; on a chip it is the chip's tinted fill and outline.
|
||||
drawRoundRect(tint.value.copy(alpha = lerp(fill, 0.9f, p)), at0, size, r)
|
||||
val a = shown.value
|
||||
drawRoundRect(tint.value.copy(alpha = lerp(fill, 0.9f, p) * a), at0, size, r)
|
||||
if (outline > 0f) {
|
||||
// Inside the chip's edge: a stroke on it would lose its outer half to a scrolling row's clip.
|
||||
val w = with(density) { 1.dp.toPx() }
|
||||
val inset = w / 2f
|
||||
drawRoundRect(
|
||||
tint.value.copy(alpha = outline * (1f - p)), at0 + Offset(inset, inset), Size(size.width - w, size.height - w),
|
||||
tint.value.copy(alpha = outline * (1f - p) * a), at0 + Offset(inset, inset), Size(size.width - w, size.height - w),
|
||||
CornerRadius((r.x - inset).coerceAtLeast(0f)), style = Stroke(w),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The chosen one of a row of chips (or a column, [vertical]): a short bar of [color] along its foot
|
||||
* (or its start edge). Not a fill or an outline, so it never reads as focus; with a pad the ring's
|
||||
* own infill is the only fill. Goes inside the chip's clip.
|
||||
*/
|
||||
@Composable
|
||||
internal fun Modifier.shownBar(on: Boolean, color: Color, vertical: Boolean = false): Modifier {
|
||||
val shown = androidx.compose.animation.core.animateFloatAsState(if (on) 1f else 0f, Motion.tw(if (on) 140 else 100), label = "shownBar").value
|
||||
return drawWithContent {
|
||||
drawContent()
|
||||
if (shown <= 0.01f) return@drawWithContent
|
||||
val t = 3.dp.toPx()
|
||||
if (vertical) {
|
||||
val l = size.height * 0.5f
|
||||
drawRect(color, Offset(0f, (size.height - l) / 2f), Size(t, l), alpha = shown)
|
||||
} else {
|
||||
val w = size.width * 0.36f
|
||||
drawRect(color, Offset((size.width - w) / 2f, size.height - t), Size(w, t), alpha = shown)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Where a glide's shape is: its edges along the axis at [start] and [end] (either order), across
|
||||
* it from [crossStart] to [crossEnd], pinched [pinch] of the way (0 to 1) into a drop [drop] each
|
||||
|
||||
@@ -92,6 +92,16 @@ internal fun SteamHome(s: FrontEndState, a: FrontEndActions, modifier: Modifier)
|
||||
frameGen = { FrameGenGroup(s, a) },
|
||||
performance = { PerformanceLink(a, "steam", SheetTab.SESSION) },
|
||||
drivers = { summary -> DriversLink(a, summary, "steam", back) },
|
||||
// Offline mode lives with Steam's other settings; Setup only checks the account.
|
||||
account = { host ->
|
||||
SettingsGroup(stringResource(R.string.setup_account)) {
|
||||
ToggleRow(
|
||||
host, "offline", stringResource(R.string.setup_offline),
|
||||
s.offlineAccount?.let { if (it.isEmpty()) stringResource(R.string.setup_signed_in_unnamed) else stringResource(R.string.setup_signed_in, it) } ?: stringResource(R.string.setup_sign_in_first),
|
||||
s.offline, enabled = s.offlineAccount != null,
|
||||
) { a.onOffline() }
|
||||
}
|
||||
},
|
||||
)
|
||||
LiftHero(
|
||||
key = "steam", tabs = tabs,
|
||||
|
||||
@@ -7,6 +7,8 @@ import androidx.compose.foundation.LocalIndication
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.focusGroup
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.foundation.hoverable
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
@@ -133,7 +135,7 @@ internal enum class StepSide {
|
||||
}
|
||||
|
||||
/** The choices' side of a [StepOut]: each piece fades in on its own beat, and [first] takes focus. */
|
||||
internal class StepOutScope(private val items: List<Animatable<Float, AnimationVector1D>>, val first: FocusRequester, val open: Boolean) {
|
||||
internal class StepOutScope(private val items: List<Animatable<Float, AnimationVector1D>>, val first: FocusRequester, val open: Boolean, val maxHeight: Dp) {
|
||||
/** Piece [i] (0 first) of the box: it fades and rises in after the box has stepped out. */
|
||||
fun Modifier.stepItem(i: Int): Modifier = graphicsLayer {
|
||||
val v = items[i.coerceIn(0, items.lastIndex)].value
|
||||
@@ -179,12 +181,24 @@ internal fun StepOut(
|
||||
var grown by remember { mutableStateOf(false) }
|
||||
var measured by remember { mutableStateOf<IntSize?>(null) }
|
||||
val first = remember { FocusRequester() }
|
||||
// The control focus was on as it opened: focus goes back to it as it folds, not to wherever
|
||||
// the screen puts a pad with nothing focused (the rail).
|
||||
val glide = LocalFocusGlide.current
|
||||
val opener = remember { arrayOfNulls<GlideSource>(1) }
|
||||
val openNow = androidx.compose.runtime.rememberUpdatedState(open)
|
||||
// While the box grows or folds the ring keeps out (it flew across the moving shape) and comes
|
||||
// back on whatever has focus once it has settled: the first choice, or the control again.
|
||||
var moving by remember { mutableStateOf(false) }
|
||||
if (moving) VeilRing()
|
||||
val pull = with(density) { OutPull.toPx() }
|
||||
val corner = pillCorner?.let { with(density) { it.toPx() } } ?: minOf(pill.height, pill.width) / 2f
|
||||
|
||||
BoxWithConstraints(Modifier.fillMaxSize()) {
|
||||
val hostWidth = constraints.maxWidth.toFloat()
|
||||
val hostHeight = constraints.maxHeight.toFloat()
|
||||
val availableHeight = with(density) {
|
||||
maxOf(hostHeight - pill.bottom - pull, pill.top - pull).coerceAtLeast(44.dp.toPx()).toDp()
|
||||
}
|
||||
// No room under the control (a row near the foot of the screen): it steps out upward
|
||||
// instead, the same outline mirrored about the control.
|
||||
val up = measured?.let { pill.bottom + pull + it.height > hostHeight && pill.top - pull - it.height >= 0f } ?: false
|
||||
@@ -199,6 +213,7 @@ internal fun StepOut(
|
||||
val boxBottom = pill.bottom + pull + c.height
|
||||
if (open) {
|
||||
if (!grown) {
|
||||
opener[0] = glide?.current
|
||||
edge.snapTo(rest); bottom.snapTo(pill.bottom); tint.snapTo(0f)
|
||||
pieces.forEach { it.snapTo(0f) }
|
||||
grown = true
|
||||
@@ -206,8 +221,12 @@ internal fun StepOut(
|
||||
coroutineScope {
|
||||
launch { dim.animateTo(1f, Motion.tw(260)) }
|
||||
launch { tint.animateTo(1f, Motion.tw(200)) }
|
||||
launch { bottom.animateTo(boxBottom, Motion.sp(0.7f, 380f)) }
|
||||
launch { delay(Motion.ms(110).toLong()); edge.animateTo(out, Motion.sp(0.55f, 300f)) }
|
||||
// Down and out together, on one spring: down first drew the control as a stick
|
||||
// that then snapped out sideways.
|
||||
moving = true
|
||||
val down = launch { bottom.animateTo(boxBottom, Motion.sp(0.8f, 380f)) }
|
||||
val across = launch { edge.animateTo(out, Motion.sp(0.8f, 380f)) }
|
||||
launch { down.join(); across.join(); moving = false }
|
||||
pieces.forEachIndexed { i, a ->
|
||||
launch { delay(Motion.ms(260 + i * 55).toLong()); a.animateTo(1f, Motion.tw(220)) }
|
||||
}
|
||||
@@ -218,14 +237,20 @@ internal fun StepOut(
|
||||
}
|
||||
}
|
||||
} else {
|
||||
opener[0]?.let { o -> if (inputMode.inputMode == InputMode.Keyboard) runCatching { o.requester.requestFocus() } }
|
||||
opener[0] = null
|
||||
coroutineScope {
|
||||
pieces.forEach { launch { it.animateTo(0f, Motion.tw(90)) } }
|
||||
launch { delay(Motion.ms(60).toLong()); dim.animateTo(0f, Motion.tw(300)) }
|
||||
launch { delay(Motion.ms(60).toLong()); edge.animateTo(rest, Motion.sp(1f, 420f)) }
|
||||
launch { delay(Motion.ms(160).toLong()); bottom.animateTo(pill.bottom, Motion.sp(1f, 380f)) }
|
||||
// In and up together on a timed ease: width first left a tall tail under the
|
||||
// control, and a damped spring's tail kept a nub of it on screen.
|
||||
moving = true
|
||||
launch { delay(Motion.ms(60).toLong()); edge.animateTo(rest, Motion.tw(240)) }
|
||||
launch { delay(Motion.ms(60).toLong()); bottom.animateTo(pill.bottom, Motion.tw(240)) }
|
||||
launch { delay(Motion.ms(200).toLong()); tint.animateTo(0f, Motion.tw(200)) }
|
||||
}
|
||||
grown = false
|
||||
moving = false
|
||||
onClosed()
|
||||
}
|
||||
}
|
||||
@@ -251,8 +276,23 @@ internal fun StepOut(
|
||||
if (side == StepSide.Left) stepPath(path, pill, edge.value, bottom.value, pill.bottom + pull, boxCorner, fillet, corner)
|
||||
else stepPathRight(path, pill, edge.value, bottom.value, pill.bottom + pull, boxCorner, fillet, corner)
|
||||
if (up) path.transform(Matrix().apply { this[1, 1] = -1f; this[3, 1] = pill.top + pill.bottom })
|
||||
drawPath(path, lerp(hotFill, restFill, tint.value))
|
||||
drawPath(path, accent.copy(alpha = lerpF(0.9f, 0.55f, tint.value)), style = Stroke(rim))
|
||||
// Barely out of the control, the pull and its fillet drew a hook off the control's foot:
|
||||
// the outline comes in over the first part of the way out (and goes over the last part
|
||||
// of the way back), by how far along it is. A share of the way, not a distance: a box
|
||||
// no wider than its control (a confirm under a full-width row) never got 24dp out, and
|
||||
// was never drawn at all.
|
||||
val a = measured?.let { c ->
|
||||
val rest = if (side == StepSide.Left) pill.left else pill.right
|
||||
val out = if (side == StepSide.Left) (pill.right - c.width).coerceAtLeast(0f) else (pill.left + c.width).coerceAtMost(hostWidth)
|
||||
val down = pill.bottom + pull + c.height - pill.bottom
|
||||
val across = kotlin.math.abs(out - rest)
|
||||
val fd = if (down < 1f) 1f else (bottom.value - pill.bottom) / down
|
||||
val fa = if (across < 1f) 1f else kotlin.math.abs(edge.value - rest) / across
|
||||
((minOf(fd, fa) - 0.1f) / 0.3f).coerceIn(0f, 1f)
|
||||
} ?: 0f
|
||||
if (a <= 0.01f) return@Canvas
|
||||
drawPath(path, lerp(hotFill, restFill, tint.value), alpha = a)
|
||||
drawPath(path, accent.copy(alpha = lerpF(0.9f, 0.55f, tint.value) * a), style = Stroke(rim))
|
||||
}
|
||||
// The control's label rides on top, as the pull's handle.
|
||||
if (grown) Box(
|
||||
@@ -265,13 +305,15 @@ internal fun StepOut(
|
||||
modifier = Modifier
|
||||
.offset { IntOffset(x.roundToInt(), (if (up) pill.top - pull - (measured?.height ?: 0) else pill.bottom + pull).roundToInt()) }
|
||||
.widthIn(min = with(density) { pill.width.toDp() }, max = with(density) { maxW.toDp() })
|
||||
.heightIn(max = availableHeight)
|
||||
.onSizeChanged { if (measured != it) measured = it }
|
||||
.controllerBack(onDismiss)
|
||||
// A pad stays in the box until it is answered or folded, as it did in Stop's dialog.
|
||||
.focusProperties { exit = { FocusRequester.Cancel } }
|
||||
.focusProperties { exit = { if (openNow.value) FocusRequester.Cancel else FocusRequester.Default } }
|
||||
.focusGroup()
|
||||
.verticalScroll(rememberScrollState())
|
||||
.padding(start = 14.dp, end = 14.dp, top = 12.dp, bottom = 12.dp),
|
||||
) { StepOutScope(pieces, first, open).content() }
|
||||
) { StepOutScope(pieces, first, open, availableHeight).content() }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,381 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.LocalIndication
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.focusable
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.interaction.collectIsFocusedAsState
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.BoxWithConstraints
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.LazyListScope
|
||||
import androidx.compose.foundation.lazy.itemsIndexed
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.EmojiEvents
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.LinearProgressIndicator
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.runtime.withFrameNanos
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.alpha
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import coil.compose.AsyncImage
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.stores.StoreAchievements
|
||||
import com.droiddeck.launcher.stores.StoreAchievements.Achievement
|
||||
import com.droiddeck.launcher.stores.StoreAchievements.Reason
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.text.DateFormat
|
||||
import java.util.Date
|
||||
|
||||
private val TrophyGold = Color(0xFFF5C542)
|
||||
|
||||
internal class AchievementsState(val list: List<Achievement>?, val reason: Reason?, val reading: Boolean) {
|
||||
val done: Int get() = list?.count { it.unlocked } ?: 0
|
||||
val all: Boolean get() = !list.isNullOrEmpty() && list.all { it.unlocked }
|
||||
|
||||
companion object { val READING = AchievementsState(null, null, true) }
|
||||
}
|
||||
|
||||
/** The cached list at once, then the store's answer (the cache stays if the store fails). */
|
||||
@Composable
|
||||
internal fun rememberAchievements(game: StoreAchievements.Game?): AchievementsState? {
|
||||
val ctx = LocalContext.current.applicationContext
|
||||
var state by remember(game) { mutableStateOf(if (game == null) null else AchievementsState.READING) }
|
||||
LaunchedEffect(game, StoreAchievements.revision) {
|
||||
if (game == null) return@LaunchedEffect
|
||||
val source = StoreAchievements.forSource(game.source) ?: return@LaunchedEffect
|
||||
val cached = withContext(Dispatchers.IO) { source.cached(ctx, game) }
|
||||
if (cached != null) state = AchievementsState(cached, null, true)
|
||||
state = when (val r = withContext(Dispatchers.IO) { source.fetch(ctx, game) }) {
|
||||
is StoreAchievements.Result.Found -> AchievementsState(r.list, null, false)
|
||||
is StoreAchievements.Result.Failed -> AchievementsState(cached, r.reason, false)
|
||||
}
|
||||
}
|
||||
return state
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun achievementsNote(state: AchievementsState, label: String): String? = when {
|
||||
!state.list.isNullOrEmpty() -> null
|
||||
state.reading -> stringResource(R.string.achievements_reading)
|
||||
state.reason == Reason.SIGNED_OUT -> stringResource(R.string.achievements_signed_out, label)
|
||||
state.reason == Reason.UNREACHABLE -> stringResource(R.string.achievements_unreachable, label)
|
||||
else -> stringResource(R.string.achievements_none, label)
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun Trophy(size: Dp = 18.dp, modifier: Modifier = Modifier, description: String? = stringResource(R.string.achievements_all)) {
|
||||
Icon(Icons.Filled.EmojiEvents, description, modifier.size(size), tint = TrophyGold)
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun AchievementsProgress(state: AchievementsState, compact: Boolean = false) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
val list = state.list ?: return
|
||||
if (list.isEmpty()) return
|
||||
Column(verticalArrangement = Arrangement.spacedBy(if (compact) 6.dp else 8.dp)) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
Text(stringResource(R.string.achievements_count, state.done, list.size), fontSize = 13.sp, color = colors.onSurfaceVariant)
|
||||
if (state.all) Trophy(16.dp)
|
||||
}
|
||||
LinearProgressIndicator(
|
||||
progress = { state.done / list.size.toFloat() },
|
||||
color = pal.signal, trackColor = pal.line,
|
||||
modifier = Modifier.fillMaxWidth().height(4.dp).clip(RoundedCornerShape(2.dp)),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun AchievementGroupLabel(label: String) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(10.dp), modifier = Modifier.fillMaxWidth().padding(top = 6.dp, bottom = 2.dp)) {
|
||||
Text(label.uppercase(), fontSize = 11.sp, fontWeight = FontWeight.SemiBold, letterSpacing = 1.2.sp, color = colors.onSurfaceVariant)
|
||||
Box(Modifier.weight(1f).height(1.dp).background(pal.line))
|
||||
}
|
||||
}
|
||||
|
||||
/** Unlocked (newest first), locked, then hidden ones not yet unlocked. */
|
||||
private fun groups(list: List<Achievement>): List<Pair<Int, List<Achievement>>> = listOf(
|
||||
R.string.achievements_group_unlocked to list.filter { it.unlocked }.sortedByDescending { it.unlockedAt },
|
||||
R.string.achievements_group_locked to list.filter { !it.unlocked && !it.hidden },
|
||||
R.string.achievements_group_hidden to list.filter { !it.unlocked && it.hidden },
|
||||
).filter { it.second.isNotEmpty() }
|
||||
|
||||
/** Focusable so the pad can scroll the list. */
|
||||
@Composable
|
||||
internal fun AchievementRow(a: Achievement, compact: Boolean, modifier: Modifier = Modifier) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
val interaction = remember { MutableInteractionSource() }
|
||||
val hot = interaction.collectIsFocusedAsState().value
|
||||
val shape = RoundedCornerShape(12.dp)
|
||||
val secret = a.hidden && !a.unlocked
|
||||
val icon = if (compact) 36.dp else 48.dp
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = modifier.fillMaxWidth().clip(shape)
|
||||
.background(if (hot) pal.signal.copy(alpha = 0.10f) else colors.surface)
|
||||
.glideBorder(hot, shape, pal.signal, pal.line)
|
||||
.focusable(interactionSource = interaction)
|
||||
.padding(if (compact) 8.dp else 10.dp),
|
||||
) {
|
||||
Box(Modifier.size(icon).clip(RoundedCornerShape(8.dp)).background(pal.surfaceVariant)) {
|
||||
val url = if (a.unlocked) a.icon else a.iconLocked ?: a.icon
|
||||
if (url != null) AsyncImage(
|
||||
model = url, contentDescription = null, contentScale = ContentScale.Crop,
|
||||
modifier = Modifier.fillMaxSize().alpha(if (a.unlocked) 1f else 0.55f),
|
||||
)
|
||||
}
|
||||
Spacer(Modifier.width(12.dp))
|
||||
Column(Modifier.weight(1f)) {
|
||||
Text(
|
||||
if (secret) stringResource(R.string.achievements_hidden) else a.name,
|
||||
fontSize = if (compact) 14.sp else 15.sp, fontWeight = FontWeight.SemiBold,
|
||||
color = if (a.unlocked) colors.onBackground else colors.onSurfaceVariant,
|
||||
maxLines = if (compact) 1 else 2, overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
val desc = if (secret) stringResource(R.string.achievements_hidden_detail) else a.description
|
||||
if (desc.isNotEmpty()) Text(
|
||||
desc, fontSize = if (compact) 12.sp else 13.sp, lineHeight = if (compact) 16.sp else 18.sp,
|
||||
color = colors.onSurfaceVariant, maxLines = if (compact) 1 else 3, overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
}
|
||||
if (a.unlocked && a.unlockedAt > 0) {
|
||||
Spacer(Modifier.width(10.dp))
|
||||
Text(
|
||||
DateFormat.getDateInstance(DateFormat.MEDIUM).format(Date(a.unlockedAt * 1000)),
|
||||
fontSize = 12.sp, fontWeight = FontWeight.Medium, color = pal.signal,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun StoreAchievementsSection(game: StoreAchievements.Game) {
|
||||
val label = StoreAchievements.forSource(game.source)?.label ?: return
|
||||
StoreAchievementsSectionContent(label, rememberAchievements(game) ?: return)
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun StoreAchievementsSectionContent(label: String, state: AchievementsState) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val list = state.list
|
||||
// Hidden for games without achievements.
|
||||
if (list.isNullOrEmpty() && !state.reading && state.reason != Reason.SIGNED_OUT && state.reason != Reason.UNREACHABLE) return
|
||||
val narrow = LocalNarrowPane.current
|
||||
Column(verticalArrangement = Arrangement.spacedBy(8.dp), modifier = Modifier.fillMaxWidth().padding(top = 18.dp)) {
|
||||
Text(stringResource(R.string.achievements_title), fontSize = 18.sp, fontWeight = FontWeight.Bold, color = colors.onBackground)
|
||||
achievementsNote(state, label)?.let { Text(it, fontSize = 13.sp, color = colors.onSurfaceVariant) }
|
||||
if (!list.isNullOrEmpty()) {
|
||||
AchievementsProgress(state)
|
||||
for ((label, group) in groups(list)) {
|
||||
AchievementGroupLabel(stringResource(label, group.size))
|
||||
for (a in group) AchievementRow(a, compact = narrow)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun LazyListScope.achievementItems(list: List<Achievement>, compact: Boolean, first: FocusRequester) {
|
||||
var index = 0
|
||||
for ((label, group) in groups(list)) {
|
||||
item(key = "group-$label") { AchievementGroupLabel(stringResource(label, group.size)) }
|
||||
val offset = index
|
||||
itemsIndexed(group, key = { _, a -> "a-" + a.id }) { i, a ->
|
||||
AchievementRow(a, compact, if (offset + i == 0) Modifier.focusRequester(first) else Modifier)
|
||||
}
|
||||
index += group.size
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun SessionAchievements(game: StoreAchievements.Game, title: String?, onClose: () -> Unit) {
|
||||
val label = StoreAchievements.forSource(game.source)?.label.orEmpty()
|
||||
SessionAchievementsPanel(label, rememberAchievements(game) ?: AchievementsState.READING, title, onClose)
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun SessionAchievementsPanel(label: String, state: AchievementsState, title: String?, onClose: () -> Unit) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
BackHandler(onBack = onClose)
|
||||
BoxWithConstraints(
|
||||
Modifier.fillMaxSize().background(Color.Black.copy(alpha = 0.45f))
|
||||
.clickable(interactionSource = remember { MutableInteractionSource() }, indication = null, onClick = onClose),
|
||||
contentAlignment = Alignment.CenterEnd,
|
||||
) {
|
||||
val short = maxHeight < 440.dp
|
||||
Column(
|
||||
Modifier.fillMaxHeight().width(minOf(420.dp, maxWidth * 0.92f))
|
||||
.background(pal.background.copy(alpha = 0.97f))
|
||||
.clickable(interactionSource = remember { MutableInteractionSource() }, indication = null) {}
|
||||
.controllerBack(onClose)
|
||||
.padding(if (short) 12.dp else 16.dp),
|
||||
) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth()) {
|
||||
Column(Modifier.weight(1f)) {
|
||||
Text(stringResource(R.string.achievements_title), fontSize = if (short) 18.sp else 20.sp, fontWeight = FontWeight.Bold, color = colors.onBackground)
|
||||
if (title != null) Text(title, fontSize = 13.sp, color = colors.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
}
|
||||
state.list?.takeIf { it.isNotEmpty() }?.let { list ->
|
||||
if (state.all) Trophy(20.dp, Modifier.padding(end = 6.dp))
|
||||
Text(stringResource(R.string.achievements_count_short, state.done, list.size), fontSize = 16.sp, fontWeight = FontWeight.SemiBold, color = pal.signal)
|
||||
}
|
||||
}
|
||||
val list = state.list
|
||||
if (list.isNullOrEmpty()) {
|
||||
Text(achievementsNote(state, label).orEmpty(), fontSize = 13.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(top = 14.dp))
|
||||
} else {
|
||||
LinearProgressIndicator(
|
||||
progress = { state.done / list.size.toFloat() },
|
||||
color = pal.signal, trackColor = pal.line,
|
||||
modifier = Modifier.padding(top = if (short) 6.dp else 10.dp).fillMaxWidth().height(4.dp).clip(RoundedCornerShape(2.dp)),
|
||||
)
|
||||
val first = remember { FocusRequester() }
|
||||
LazyColumn(
|
||||
Modifier.weight(1f).padding(top = 6.dp),
|
||||
contentPadding = PaddingValues(vertical = 6.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(6.dp),
|
||||
) { achievementItems(list, short, first) }
|
||||
LaunchedEffect(list.isNotEmpty()) {
|
||||
withFrameNanos {} // rows lay out a frame after composition
|
||||
runCatching { first.requestFocus() }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** [progress]: (unlocked, total), or null when unknown. */
|
||||
@Composable
|
||||
internal fun DrawerAchievementsRow(progress: Pair<Int, Int>?, modifier: Modifier = Modifier, onClick: () -> Unit) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
val interaction = remember { MutableInteractionSource() }
|
||||
val hot = interaction.collectIsFocusedAsState().value
|
||||
val shape = RoundedCornerShape(12.dp)
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(10.dp),
|
||||
modifier = modifier.fillMaxWidth().height(44.dp).clip(shape)
|
||||
.background(if (hot) pal.signal.copy(alpha = 0.14f) else colors.surface)
|
||||
.glideBorder(hot, shape, pal.signal, pal.line)
|
||||
.clickable(interactionSource = interaction, indication = LocalIndication.current, onClick = onClick)
|
||||
.controllerConfirm(onClick = onClick)
|
||||
.padding(horizontal = 12.dp),
|
||||
) {
|
||||
val all = progress != null && progress.second > 0 && progress.first == progress.second
|
||||
Icon(Icons.Filled.EmojiEvents, null, tint = if (all) TrophyGold else if (hot) pal.signal else colors.onSurfaceVariant, modifier = Modifier.size(20.dp))
|
||||
Text(stringResource(R.string.achievements_title), fontSize = 14.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground, modifier = Modifier.weight(1f))
|
||||
if (progress != null && progress.second > 0) {
|
||||
Text(stringResource(R.string.achievements_count_short, progress.first, progress.second), fontSize = 13.sp, fontWeight = FontWeight.SemiBold, color = pal.signal)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private val previewList = listOf(
|
||||
Achievement("first", "First Steps", "Finish the tutorial.", hidden = false, unlocked = true, unlockedAt = 1_759_000_000, icon = null, iconLocked = null),
|
||||
Achievement("boss", "Giant Slayer", "Defeat the warden of the old keep without taking damage.", hidden = false, unlocked = true, unlockedAt = 1_760_100_000, icon = null, iconLocked = null),
|
||||
Achievement("collector", "Collector", "Find every relic in the valley.", hidden = false, unlocked = false, unlockedAt = 0, icon = null, iconLocked = null),
|
||||
Achievement("secret", "The Last Door", "Open it.", hidden = true, unlocked = false, unlockedAt = 0, icon = null, iconLocked = null),
|
||||
)
|
||||
|
||||
@Composable
|
||||
private fun PreviewSurface(content: @Composable () -> Unit) {
|
||||
DroidDeckTheme(theme = Themes.GRAPHITE) {
|
||||
Box(Modifier.fillMaxSize().background(LocalPalette.current.background).padding(16.dp)) { content() }
|
||||
}
|
||||
}
|
||||
|
||||
@Preview(name = "Store page section", widthDp = 800, heightDp = 600)
|
||||
@Composable
|
||||
private fun StoreAchievementsSectionPreview() = PreviewSurface {
|
||||
Column(Modifier.width(560.dp)) { StoreAchievementsSectionContent("GOG", AchievementsState(previewList, null, false)) }
|
||||
}
|
||||
|
||||
@Preview(name = "Store page section, signed out", widthDp = 800, heightDp = 200)
|
||||
@Composable
|
||||
private fun StoreAchievementsSectionSignedOutPreview() = PreviewSurface {
|
||||
Column(Modifier.width(560.dp)) { StoreAchievementsSectionContent("Epic", AchievementsState(null, Reason.SIGNED_OUT, false)) }
|
||||
}
|
||||
|
||||
@Preview(name = "Session panel", widthDp = 800, heightDp = 500)
|
||||
@Composable
|
||||
private fun SessionAchievementsPanelPreview() = DroidDeckTheme(theme = Themes.GRAPHITE) {
|
||||
SessionAchievementsPanel("Epic", AchievementsState(previewList, null, false), "Hollow Valley", onClose = {})
|
||||
}
|
||||
|
||||
@Preview(name = "Session panel, 4:3", widthDp = 560, heightDp = 420)
|
||||
@Composable
|
||||
private fun SessionAchievementsPanelShortPreview() = DroidDeckTheme(theme = Themes.GRAPHITE) {
|
||||
SessionAchievementsPanel("GOG", AchievementsState(previewList.map {
|
||||
Achievement(it.id, it.name, it.description, it.hidden, true, 1_760_000_000, null, null)
|
||||
}, null, false), "Hollow Valley", onClose = {})
|
||||
}
|
||||
|
||||
@Preview(name = "Session panel, offline", widthDp = 800, heightDp = 500)
|
||||
@Composable
|
||||
private fun SessionAchievementsPanelOfflinePreview() = DroidDeckTheme(theme = Themes.GRAPHITE) {
|
||||
SessionAchievementsPanel("GOG", AchievementsState(null, Reason.UNREACHABLE, false), "Hollow Valley", onClose = {})
|
||||
}
|
||||
|
||||
@Preview(name = "Drawer row", widthDp = 360, heightDp = 160)
|
||||
@Composable
|
||||
private fun DrawerAchievementsRowPreview() = PreviewSurface {
|
||||
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
DrawerAchievementsRow(2 to 4) {}
|
||||
DrawerAchievementsRow(4 to 4) {}
|
||||
DrawerAchievementsRow(null) {}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview(name = "Rows", widthDp = 480, heightDp = 300)
|
||||
@Composable
|
||||
private fun AchievementRowPreview() = PreviewSurface {
|
||||
Column(verticalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
AchievementsProgress(AchievementsState(previewList, null, false))
|
||||
for (a in previewList) AchievementRow(a, compact = false)
|
||||
AchievementRow(previewList[0], compact = true)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
/** Vertical controller moves keep the same column, including across lazy item boundaries. */
|
||||
internal fun storeGridNeighbor(index: Int, count: Int, columns: Int, direction: Int): Int? {
|
||||
if (index !in 0 until count || columns < 1 || direction !in listOf(-1, 1)) return null
|
||||
return (index + columns * direction).takeIf { it in 0 until count }
|
||||
}
|
||||
@@ -70,6 +70,7 @@ import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.draw.clipToBounds
|
||||
import androidx.compose.ui.draw.drawBehind
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.focus.focusProperties
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.geometry.Rect
|
||||
import androidx.compose.ui.graphics.Brush
|
||||
@@ -85,7 +86,10 @@ import androidx.compose.ui.layout.onSizeChanged
|
||||
import androidx.compose.ui.layout.positionInRoot
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.platform.LocalFocusManager
|
||||
import androidx.compose.ui.platform.LocalInputModeManager
|
||||
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
|
||||
import androidx.compose.ui.platform.LocalView
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.semantics.Role
|
||||
import androidx.compose.ui.semantics.contentDescription
|
||||
@@ -267,8 +271,9 @@ private fun SetupButton(s: FrontEndState, busy: Boolean, full: Dp, ring: Int, on
|
||||
|
||||
// ---- storefront ------------------------------------------------------------------------------------
|
||||
|
||||
@OptIn(androidx.compose.ui.ExperimentalComposeUiApi::class)
|
||||
@Composable
|
||||
private fun Storefront(s: FrontEndState, a: FrontEndActions) {
|
||||
internal fun Storefront(s: FrontEndState, a: FrontEndActions) {
|
||||
val ctx = LocalContext.current
|
||||
val narrow = LocalNarrowPane.current
|
||||
val colors = MaterialTheme.colorScheme
|
||||
@@ -290,6 +295,9 @@ private fun Storefront(s: FrontEndState, a: FrontEndActions) {
|
||||
}
|
||||
val ff = LocalFrontFocus.current
|
||||
val inputMode = LocalInputModeManager.current
|
||||
val focusManager = LocalFocusManager.current
|
||||
val keyboard = LocalSoftwareKeyboardController.current
|
||||
val view = LocalView.current
|
||||
// Cards, where they are, for the page that opens from one.
|
||||
val cards = remember { HashMap<String, Rect>() }
|
||||
var viewportAt by remember { mutableStateOf(Offset.Zero) }
|
||||
@@ -300,6 +308,11 @@ private fun Storefront(s: FrontEndState, a: FrontEndActions) {
|
||||
LaunchedEffect(openApp) {
|
||||
val id = openApp
|
||||
if (id != null) {
|
||||
// The grid stays composed for the return animation. Release its native search field
|
||||
// before covering it, so its focus ring and keyboard do not follow onto the app page.
|
||||
focusManager.clearFocus(force = true)
|
||||
view.findFocus()?.clearFocus()
|
||||
keyboard?.hide()
|
||||
detailFrom = cards[id]?.let { Origin(it.translate(-viewportAt), 16f * density.density) }
|
||||
leaving = false
|
||||
detail = id
|
||||
@@ -350,7 +363,10 @@ private fun Storefront(s: FrontEndState, a: FrontEndActions) {
|
||||
Spacer(Modifier.height(8.dp))
|
||||
Box(Modifier.weight(1f).fillMaxWidth().clipToBounds().onGloballyPositioned { viewportAt = it.positionInRoot() }) {
|
||||
Column(
|
||||
Modifier.fillMaxSize().graphicsLayer { scaleX = sink; scaleY = sink; alpha = fade }.verticalScroll(rememberScrollState()).padding(bottom = 16.dp),
|
||||
Modifier.fillMaxSize().focusProperties {
|
||||
enter = { if (detail == null) androidx.compose.ui.focus.FocusRequester.Default else androidx.compose.ui.focus.FocusRequester.Cancel }
|
||||
}.focusGroup()
|
||||
.graphicsLayer { scaleX = sink; scaleY = sink; alpha = fade }.verticalScroll(rememberScrollState()).padding(bottom = 16.dp),
|
||||
) {
|
||||
val open: (String) -> Unit = { openApp = it }
|
||||
when (mode) {
|
||||
@@ -392,7 +408,6 @@ private fun FlathubChips(mode: String, modes: List<String>, installed: Int, upda
|
||||
val bounds = remember { mutableStateMapOf<String, Rect>() }
|
||||
val tint = rememberUpdatedState(pal.signal)
|
||||
Box(Modifier.fillMaxWidth()) {
|
||||
ChipGlide(modes.indexOf(mode), bounds[mode], tint)
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(8.dp), verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth()) {
|
||||
for (m in modes) {
|
||||
key(m) {
|
||||
@@ -400,6 +415,8 @@ private fun FlathubChips(mode: String, modes: List<String>, installed: Int, upda
|
||||
val hot = rememberHot(src)
|
||||
val shape = RoundedCornerShape(99.dp)
|
||||
val on = m == mode
|
||||
// Drawn by the row's glide by touch only; with a pad its own rest look and the bar.
|
||||
val under = on && androidx.compose.ui.platform.LocalInputModeManager.current.inputMode != androidx.compose.ui.input.InputMode.Keyboard
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp, Alignment.CenterHorizontally),
|
||||
modifier = Modifier.weight(1f).paneItem("flathub:$m")
|
||||
@@ -408,8 +425,9 @@ private fun FlathubChips(mode: String, modes: List<String>, installed: Int, upda
|
||||
if (m == MODE_INSTALLED) FlathubMotion.installedChip = it.boundsInRoot()
|
||||
}
|
||||
.heightIn(min = 44.dp).clip(shape)
|
||||
.background(if (on) Color.Transparent else colors.surface)
|
||||
.glideBorder(hot, shape, pal.signal, if (on) Color.Transparent else pal.line)
|
||||
.background(if (under) Color.Transparent else colors.surface)
|
||||
.shownBar(on, pal.signal)
|
||||
.glideBorder(hot, shape, pal.signal, if (under) Color.Transparent else pal.line)
|
||||
.hoverable(src).clickable(interactionSource = src, indication = LocalIndication.current, role = Role.Tab) { onPick(m) }
|
||||
.controllerConfirm { onPick(m) }
|
||||
.padding(horizontal = 12.dp, vertical = 8.dp),
|
||||
@@ -428,6 +446,8 @@ private fun FlathubChips(mode: String, modes: List<String>, installed: Int, upda
|
||||
}
|
||||
}
|
||||
}
|
||||
// Over the chips: under them, their rest fill hid it as it crossed them.
|
||||
ChipGlide(modes.indexOf(mode), bounds[mode], tint)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.layout.boundsInRoot
|
||||
import androidx.compose.ui.layout.onGloballyPositioned
|
||||
import androidx.compose.foundation.background
|
||||
@@ -35,6 +36,7 @@ import coil.compose.AsyncImage
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.stores.CatalogItem
|
||||
import com.droiddeck.launcher.stores.Store
|
||||
import com.droiddeck.launcher.stores.StoreAchievements
|
||||
import com.droiddeck.launcher.stores.StoresState
|
||||
import com.droiddeck.launcher.stores.download.DownloadState
|
||||
import com.droiddeck.launcher.stores.formatBytes
|
||||
@@ -52,8 +54,6 @@ internal fun StoreGameDetail(store: Store, key: String, s: FrontEndState, a: Fro
|
||||
val installed = StoresState.installedGame(store, id)
|
||||
val download = StoresState.download("${store.id}:$id")?.takeIf { it.isActive }
|
||||
// Removal asks twice: one stray press of A should not cost a download.
|
||||
var confirmRemove by remember(key) { mutableStateOf(false) }
|
||||
LaunchedEffect(confirmRemove) { if (confirmRemove) { kotlinx.coroutines.delay(4000); confirmRemove = false } }
|
||||
val title = item?.title ?: installed?.sidecar?.title ?: id
|
||||
Rise(0) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(12.dp), modifier = Modifier.padding(bottom = 12.dp)) {
|
||||
@@ -61,8 +61,16 @@ internal fun StoreGameDetail(store: Store, key: String, s: FrontEndState, a: Fro
|
||||
SourceChip(store.id)
|
||||
}
|
||||
}
|
||||
Rise(1) {
|
||||
Box(Modifier.fillMaxWidth().heightIn(min = if (narrow) 150.dp else 180.dp).clip(Shape16).background(artBrush(hueOf(title)))) {
|
||||
// Out of a card, the hero holds still in its place: the card's flood lands on it, and a hero
|
||||
// still rising in sat below where the flood had measured it (the art showed twice).
|
||||
val hero: @Composable () -> Unit = {
|
||||
androidx.compose.runtime.DisposableEffect(Unit) { onDispose { StoresMotion.heroAt = null } }
|
||||
Box(
|
||||
Modifier.fillMaxWidth().heightIn(min = if (narrow) 150.dp else 180.dp)
|
||||
// The card it opened from floods onto this, and draws back into the card from it.
|
||||
.onGloballyPositioned { StoresMotion.heroAt = it.boundsInRoot() }
|
||||
.clip(Shape16).background(artBrush(hueOf(title))),
|
||||
) {
|
||||
val art = item?.imageUrl ?: installed?.sidecar?.hero ?: installed?.sidecar?.cover
|
||||
if (art != null) AsyncImage(model = art, contentDescription = null, contentScale = ContentScale.Crop, modifier = Modifier.matchParentSize())
|
||||
Spacer(Modifier.matchParentSize().background(Brush.horizontalGradient(0f to colors.background.copy(alpha = 0.94f), 0.5f to colors.background.copy(alpha = 0.55f), 1f to Color.Transparent)))
|
||||
@@ -83,10 +91,13 @@ internal fun StoreGameDetail(store: Store, key: String, s: FrontEndState, a: Fro
|
||||
// Launching, the prefix and the files belong to the Games tab, where every
|
||||
// installed game has them; here an install only says it is in Steam and
|
||||
// offers the one thing Games does not: removing it.
|
||||
// The row keeps its shape: the chip stays, and Uninstall becomes its own
|
||||
// progress in place while the files go; then the page reads Install again.
|
||||
ActionChip(stringResource(R.string.stores_in_steam), ok = true)
|
||||
SecondaryButton(if (confirmRemove) stringResource(R.string.stores_uninstall_confirm) else stringResource(R.string.stores_uninstall), enabled = download == null) {
|
||||
if (!confirmRemove) confirmRemove = true
|
||||
else { confirmRemove = false; StoresState.uninstall(ctx, installed) { StoresState.refresh(ctx); a.onLibraryChanged() }; onBack() }
|
||||
val gone = StoresState.uninstalling["${store.id}:$id"]
|
||||
if (gone != null) SecondaryButton(stringResource(R.string.stores_uninstalling), enabled = false, progress = gone) {}
|
||||
else UninstallButton(title, installed, enabled = download == null) {
|
||||
StoresState.uninstall(ctx, installed) { StoresState.refresh(ctx); a.onLibraryChanged() }
|
||||
}
|
||||
}
|
||||
download != null -> {
|
||||
@@ -110,6 +121,7 @@ internal fun StoreGameDetail(store: Store, key: String, s: FrontEndState, a: Fro
|
||||
}
|
||||
}
|
||||
}
|
||||
if (StoresMotion.heroLands) hero() else Rise(1) { hero() }
|
||||
// Plain text only, and nothing at all when the store sent a template key instead of words.
|
||||
// A description that is only the title again (some stores fill it so) is no description.
|
||||
val description = item?.let { com.droiddeck.launcher.stores.cleanStoreText(it.description) }.orEmpty()
|
||||
@@ -117,6 +129,49 @@ internal fun StoreGameDetail(store: Store, key: String, s: FrontEndState, a: Fro
|
||||
if (description.isNotBlank()) Rise(2) {
|
||||
Text(description, fontSize = 13.sp, lineHeight = 19.sp, color = colors.onSurfaceVariant, maxLines = 6, overflow = TextOverflow.Ellipsis, modifier = Modifier.padding(top = 12.dp))
|
||||
}
|
||||
val achievements = remember(store, id, item?.owned, installed) {
|
||||
when {
|
||||
StoreAchievements.forSource(store.id) == null -> null
|
||||
item?.owned == true -> StoreAchievements.Game.of(item)
|
||||
installed != null -> StoreAchievements.Game.of(installed.sidecar)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
if (achievements != null) Rise(3) { StoreAchievementsSection(achievements) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninstall that asks the way Cancel does: a confirm steps out of it, naming the game and what
|
||||
* goes (its size on disk), with Keep first so a stray A does nothing.
|
||||
*/
|
||||
@Composable
|
||||
private fun UninstallButton(title: String, game: com.droiddeck.launcher.stores.InstalledStoreGame, enabled: Boolean, onUninstall: () -> Unit) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val placed = remember { arrayOfNulls<androidx.compose.ui.layout.LayoutCoordinates>(1) }
|
||||
val heading = stringResource(R.string.stores_uninstall_title, title)
|
||||
val size = com.droiddeck.launcher.stores.StoreSizes.onDisk["${game.sidecar.store.id}:${game.sidecar.id}"]
|
||||
val body = if (size != null && size > 0) stringResource(R.string.stores_uninstall_body_size, formatBytes(size)) else stringResource(R.string.stores_uninstall_body)
|
||||
val keep = stringResource(R.string.stores_notification_keep)
|
||||
val remove = stringResource(R.string.stores_uninstall)
|
||||
Box(Modifier.onGloballyPositioned { placed[0] = it }) {
|
||||
SecondaryButton(remove, enabled = enabled) {
|
||||
val at = placed[0]?.takeIf { it.isAttached }?.boundsInRoot() ?: return@SecondaryButton
|
||||
// It starts once the confirm has folded back into the button: started at once, the button
|
||||
// turned into the progress under the fold and it drew back into a control that had gone.
|
||||
var confirmed = false
|
||||
StoresMotion.ask(StepAsk(anchor = at, side = StepSide.Right, accent = colors.error, items = 3, pillCorner = 12.dp, maxWidth = 340.dp,
|
||||
onDismiss = { if (confirmed) onUninstall() }, handle = {
|
||||
Text(remove, fontSize = 15.sp, fontWeight = FontWeight.SemiBold, color = colors.error, maxLines = 1)
|
||||
}) {
|
||||
StepTitle(heading)
|
||||
Text(body, fontSize = 13.sp, lineHeight = 18.sp, color = colors.onSurfaceVariant, modifier = Modifier.stepItem(1).padding(start = 4.dp, bottom = 12.dp))
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(8.dp, Alignment.End), modifier = Modifier.fillMaxWidth().stepItem(2)) {
|
||||
StepChoice(keep, enabled = open, modifier = Modifier.focusRequester(first)) { StoresMotion.fold() }
|
||||
StepChoice(remove, danger = true, enabled = open) { confirmed = true; StoresMotion.fold() }
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -48,6 +48,7 @@ import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.focusGroup
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.BoxWithConstraints
|
||||
import androidx.compose.foundation.layout.Column
|
||||
@@ -93,17 +94,10 @@ import com.droiddeck.launcher.stores.formatSpeed
|
||||
|
||||
// The Downloads chip: one queue for the three stores, its settings and the engine log.
|
||||
|
||||
/** The queue. Its settings (speed tier, downloads at a time) live in the chip row's cog only. */
|
||||
@Composable
|
||||
internal fun StoresDownloadsPane(s: FrontEndState, a: FrontEndActions) {
|
||||
BoxWithConstraints(Modifier.fillMaxWidth()) {
|
||||
val wide = maxWidth >= 700.dp
|
||||
val list: @Composable () -> Unit = { DownloadList(s, a) }
|
||||
val side: @Composable () -> Unit = { DownloadSettings(s, a) }
|
||||
if (wide) Row(horizontalArrangement = Arrangement.spacedBy(24.dp)) {
|
||||
Box(Modifier.weight(3f)) { list() }
|
||||
Box(Modifier.weight(2f)) { side() }
|
||||
} else Column { list(); side() }
|
||||
}
|
||||
DownloadList(s, a)
|
||||
}
|
||||
|
||||
@Composable
|
||||
@@ -117,10 +111,26 @@ private fun DownloadList(s: FrontEndState, a: FrontEndActions) {
|
||||
var clearing by remember { mutableStateOf(false) }
|
||||
// Under way on top; finished below a line whose X clears them all (rows only - a failed
|
||||
// download's kept files stay until its game page's Clear).
|
||||
val (active, finished) = entries.partition { it.isActive }
|
||||
// Under way first, then paused, then the queue in its order: a queued row sat above the one running.
|
||||
val (active, finished) = entries.partition { it.isActive }.let { (on, off) ->
|
||||
on.sortedWith(compareBy<DownloadEntry>({ when (it.state) { DownloadState.RUNNING -> 0; DownloadState.PAUSED -> 1; else -> 2 } }, { it.queuePosition })) to off
|
||||
}
|
||||
val finishedShown = if (clearing) emptyList() else finished
|
||||
// Installs that stopped without the queue knowing (the app closed or was killed): the queue
|
||||
// lives in memory, so after a restart they were only on their game's page. They resume here too.
|
||||
val queued = entries.mapTo(HashSet()) { it.key }
|
||||
// Matched against each store's library: one not read yet (Downloads opened first) is read from
|
||||
// its cache, quietly, so the rows are there without visiting the store.
|
||||
val ctx = LocalContext.current
|
||||
val missing = StoresState.unfinished.map { it.store }.filter { StoresState.library[it] == null }.toSet()
|
||||
LaunchedEffect(missing) { missing.forEach { StoresState.backend(it)?.syncLibrary(ctx, false) } }
|
||||
val interrupted = StoresState.unfinished.mapNotNull { u ->
|
||||
StoresState.library[u.store]?.firstOrNull {
|
||||
u.id == it.id || (u.id == null && u.folder.name == com.droiddeck.launcher.stores.StoreInstallRoot.folderName(it.title, it.id))
|
||||
}
|
||||
}.filter { "${it.store.id}:${it.id}" !in queued }.distinctBy { "${it.store.id}:${it.id}" }
|
||||
Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
|
||||
AnimatedVisibility(entries.isEmpty(), enter = fadeIn(Motion.tw(300, 300)), exit = fadeOut(Motion.tw(120))) {
|
||||
AnimatedVisibility(entries.isEmpty() && interrupted.isEmpty(), enter = fadeIn(Motion.tw(300, 300)), exit = fadeOut(Motion.tw(120))) {
|
||||
Box(Modifier.fillMaxWidth().padding(vertical = 40.dp), contentAlignment = Alignment.Center) {
|
||||
Text(stringResource(R.string.stores_downloads_empty), fontSize = 13.sp, color = colors.onSurfaceVariant)
|
||||
}
|
||||
@@ -141,6 +151,11 @@ private fun DownloadList(s: FrontEndState, a: FrontEndActions) {
|
||||
else shrinkHorizontally(Motion.tw(260), shrinkTowards = Alignment.End) + shrinkVertically(Motion.tw(300, 120)) + fadeOut(Motion.tw(200, 80))
|
||||
},
|
||||
) { row, _ -> DownloadCard(StoresState.download(row.key) ?: row, s, a) }
|
||||
AnimatedRows(
|
||||
interrupted, key = { "${it.store.id}:${it.id}" },
|
||||
enter = { i, _ -> fadeIn(Motion.tw(300, 60 * i.coerceAtMost(5))) + expandVertically(Motion.tw(260)) },
|
||||
exit = { _, _, _ -> fadeOut(Motion.tw(160)) + shrinkVertically(Motion.tw(220, 60)) },
|
||||
) { item, _ -> InterruptedRow(item) }
|
||||
AnimatedVisibility(
|
||||
finishedShown.isNotEmpty(),
|
||||
enter = expandVertically(Motion.tw(260)) + fadeIn(Motion.tw(220)),
|
||||
@@ -178,21 +193,50 @@ private fun DownloadList(s: FrontEndState, a: FrontEndActions) {
|
||||
}
|
||||
}
|
||||
|
||||
/** An install that stopped before it finished, from an earlier run: Resume picks it up, Clear deletes what it had. */
|
||||
@Composable
|
||||
private fun InterruptedRow(item: com.droiddeck.launcher.stores.CatalogItem) {
|
||||
val ctx = LocalContext.current
|
||||
ArtStrip(item.imageUrl ?: item.tallImageUrl, item.title) {
|
||||
Text(item.title, fontSize = 13.sp, fontWeight = FontWeight.Bold, color = Color.White, maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f, fill = false))
|
||||
SourceChip(item.store.id, small = true)
|
||||
Text(stringResource(R.string.stores_dl_interrupted), fontSize = 12.sp, color = Color(0xFFFFC24D), maxLines = 1)
|
||||
Spacer(Modifier.weight(1f))
|
||||
RoundAction(Icons.Filled.PlayArrow, stringResource(R.string.stores_dl_resume), primary = true) { StoresState.requestInstall(ctx, item) }
|
||||
CancelAction { StoresState.clearUnfinished(ctx, item) }
|
||||
}
|
||||
}
|
||||
|
||||
/** How long a row that installed holds for its bar to gather into Play before it moves under the line. */
|
||||
private const val GATHER_HOLD_MS = 900
|
||||
|
||||
/**
|
||||
* A row in the download card's look, shorter: the game's art behind it under the same dark wash,
|
||||
* the copy in white. Finished and interrupted downloads read as the same thing as one under way.
|
||||
*/
|
||||
@Composable
|
||||
private fun ArtStrip(cover: String?, name: String, content: @Composable androidx.compose.foundation.layout.RowScope.() -> Unit) {
|
||||
val pal = LocalPalette.current
|
||||
Box(Modifier.fillMaxWidth().heightIn(min = 60.dp).clip(Shape12).background(Color(0xFF101318)).border(1.dp, pal.line, Shape12)) {
|
||||
if (!cover.isNullOrEmpty()) AsyncImage(model = cover, contentDescription = null, contentScale = ContentScale.Crop, modifier = Modifier.matchParentSize())
|
||||
else Spacer(Modifier.matchParentSize().background(artBrush(hueOf(name))))
|
||||
Spacer(Modifier.matchParentSize().background(Brush.horizontalGradient(0f to Color.Black.copy(alpha = 0.92f), 0.5f to Color.Black.copy(alpha = 0.72f), 1f to Color.Black.copy(alpha = 0.2f))))
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(10.dp),
|
||||
modifier = Modifier.fillMaxWidth().padding(horizontal = 14.dp, vertical = 8.dp), content = content,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/** A finished download: its name and store, and Play when it installed - blooming out of a dot when it just did. */
|
||||
@Composable
|
||||
private fun FinishedRow(d: DownloadEntry, s: FrontEndState, a: FrontEndActions, bloom: Boolean = false) {
|
||||
val ctx = LocalContext.current
|
||||
val colors = MaterialTheme.colorScheme
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(10.dp),
|
||||
modifier = Modifier.fillMaxWidth().clip(Shape12).background(colors.surface).padding(horizontal = 12.dp, vertical = 6.dp),
|
||||
) {
|
||||
Text(d.name, fontSize = 13.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground, maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f, fill = false))
|
||||
ArtStrip(d.cover, d.name) {
|
||||
Text(d.name, fontSize = 13.sp, fontWeight = FontWeight.Bold, color = Color.White, maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f, fill = false))
|
||||
SourceChip(d.store.id, small = true)
|
||||
Text(stringResource(if (d.state == DownloadState.INSTALLED) R.string.stores_installed_chip else R.string.stores_dl_cancelled), fontSize = 11.sp, color = colors.onSurfaceVariant, maxLines = 1, modifier = Modifier.weight(1f))
|
||||
Text(stringResource(if (d.state == DownloadState.INSTALLED) R.string.stores_installed_chip else R.string.stores_dl_cancelled), fontSize = 12.sp, color = Color.White.copy(alpha = 0.72f), maxLines = 1)
|
||||
Spacer(Modifier.weight(1f))
|
||||
if (d.state == DownloadState.INSTALLED) Box(Modifier.bloomIn(bloom, GATHER_HOLD_MS + 150)) {
|
||||
RoundAction(Icons.Filled.PlayArrow, stringResource(R.string.stores_play), primary = true) { launchStoreGame(ctx, d.store, d.id, s, a) }
|
||||
}
|
||||
@@ -453,21 +497,9 @@ private fun eta(seconds: Long): String = when {
|
||||
else -> "~${seconds / 3600} h ${(seconds % 3600) / 60} m"
|
||||
}
|
||||
|
||||
/** The queue's settings beside it: speed tier, downloads at a time, and the engine log. */
|
||||
@Composable
|
||||
private fun DownloadSettings(s: FrontEndState, a: FrontEndActions) {
|
||||
val ctx = LocalContext.current
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
SectionTitle(stringResource(R.string.stores_download_manager), null)
|
||||
Column(verticalArrangement = Arrangement.spacedBy(8.dp), modifier = Modifier.fillMaxWidth().clip(Shape12).background(colors.surface).border(1.dp, pal.line, Shape12).padding(horizontal = 14.dp, vertical = 10.dp)) {
|
||||
DownloadControls(s, a)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The queue's two knobs on one line - the speed tier on the left, downloads at a time on the
|
||||
* right; the same control sits in the cog's popup. A narrow page puts them on two tight lines.
|
||||
* right; it sits in the cog's popup. A narrow page puts them on two tight lines.
|
||||
*/
|
||||
@Composable
|
||||
internal fun DownloadControls(s: FrontEndState, a: FrontEndActions) {
|
||||
@@ -500,29 +532,35 @@ internal fun DownloadControls(s: FrontEndState, a: FrontEndActions) {
|
||||
*/
|
||||
internal fun storesSettingsStep(at: Rect, s: androidx.compose.runtime.State<FrontEndState>, a: FrontEndActions, accent: androidx.compose.ui.graphics.Color): StepAsk =
|
||||
StepAsk(
|
||||
anchor = at, side = StepSide.Left, accent = accent, items = 3, maxWidth = 440.dp,
|
||||
anchor = at, side = StepSide.Left, accent = accent, items = 2, maxWidth = 440.dp,
|
||||
handle = { androidx.compose.material3.Icon(androidx.compose.material.icons.Icons.Filled.Settings, null, tint = accent, modifier = Modifier.size(20.dp)) },
|
||||
) {
|
||||
StepTitle(stringResource(R.string.stores_settings_eyebrow))
|
||||
Column(
|
||||
Modifier.stepItem(1).fillMaxWidth().heightIn(max = 340.dp).verticalScroll(rememberScrollState()),
|
||||
Modifier.stepItem(1).fillMaxWidth().heightIn(max = minOf(340.dp, (maxHeight - 64.dp).coerceAtLeast(44.dp))).verticalScroll(rememberScrollState()),
|
||||
verticalArrangement = Arrangement.spacedBy(6.dp),
|
||||
) {
|
||||
val st = s.value
|
||||
SettingsRow(stringResource(R.string.setup_stores_open_on), null) {
|
||||
SegmentedTabs(
|
||||
// No OK: B or a tap outside folds it, and a pad starts on the first choice.
|
||||
SettingsRow(stringResource(R.string.setup_stores_open_on), null, stacked = true) {
|
||||
Box(Modifier.focusRequester(first).focusGroup()) { SegmentedTabs(
|
||||
listOf(SessionPrefs.STORES_OPEN_LIBRARY to stringResource(R.string.stores_tab_library), SessionPrefs.STORES_OPEN_STORE to stringResource(R.string.stores_tab_store)),
|
||||
st.storesOpenTab,
|
||||
) { a.onStoresOpenTab(it) }
|
||||
) { a.onStoresOpenTab(it) } }
|
||||
}
|
||||
SettingsRow(stringResource(R.string.stores_show_mature), null) {
|
||||
ToggleSwitch(st.storesShowMature, label = stringResource(R.string.stores_show_mature)) { a.onStoresShowMature(it) }
|
||||
}
|
||||
// The queue's two knobs as one compact row, the same control the Downloads page has.
|
||||
Column(Modifier.fillMaxWidth().padding(horizontal = 14.dp, vertical = 11.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) { DownloadControls(st, a) }
|
||||
val context = androidx.compose.ui.platform.LocalContext.current
|
||||
var gogAchievements by androidx.compose.runtime.remember { androidx.compose.runtime.mutableStateOf(com.droiddeck.launcher.stores.gog.GogComet.enabled(context)) }
|
||||
SettingsRow(stringResource(R.string.gog_achievements), stringResource(R.string.gog_achievements_hint)) {
|
||||
ToggleSwitch(gogAchievements, label = stringResource(R.string.gog_achievements)) {
|
||||
gogAchievements = it
|
||||
com.droiddeck.launcher.stores.gog.GogComet.setEnabled(context, it)
|
||||
}
|
||||
}
|
||||
StoresEngineRow()
|
||||
}
|
||||
Row(horizontalArrangement = Arrangement.End, modifier = Modifier.fillMaxWidth().stepItem(2).padding(top = 8.dp)) {
|
||||
StepChoice(stringResource(R.string.common_ok), enabled = open, modifier = Modifier.focusRequester(first)) { StoresMotion.fold() }
|
||||
}
|
||||
}
|
||||
@@ -125,6 +125,12 @@ internal object StoresMotion {
|
||||
/** Where each store's dot sits on its chip, for a sign-in to come home to. */
|
||||
val dots = HashMap<Store, Rect>()
|
||||
|
||||
/** Where the open game page's hero art sits (root px): what a card's flood lands on, and leaves from. */
|
||||
var heroAt by mutableStateOf<Rect?>(null)
|
||||
|
||||
/** The open game page came out of a card: its hero holds still, for the card's flood to land on. */
|
||||
var heroLands by mutableStateOf(false)
|
||||
|
||||
/** The card a game page is about to open from. */
|
||||
private var card: CardMark? = null
|
||||
private var cardAt = 0L
|
||||
|
||||
@@ -32,6 +32,10 @@ import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import androidx.compose.ui.layout.boundsInWindow
|
||||
import androidx.compose.ui.layout.onGloballyPositioned
|
||||
import android.view.KeyEvent
|
||||
import androidx.compose.ui.input.key.onPreviewKeyEvent
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.ui.layout.onSizeChanged
|
||||
import androidx.compose.ui.draw.drawWithContent
|
||||
import androidx.compose.ui.draw.drawBehind
|
||||
@@ -307,6 +311,7 @@ internal fun StoresPage(s: FrontEndState, a: FrontEndActions, modifier: Modifier
|
||||
val mark = StoresMotion.takeCard(g)
|
||||
detailFrom = mark?.let { Origin(it.bounds.translate(-viewportAt), it.corner) }
|
||||
detailArt = mark?.art
|
||||
StoresMotion.heroLands = mark != null
|
||||
leaving = false
|
||||
detail = g
|
||||
} else if (detail != null) {
|
||||
@@ -446,7 +451,9 @@ internal fun StoresPage(s: FrontEndState, a: FrontEndActions, modifier: Modifier
|
||||
},
|
||||
)
|
||||
}
|
||||
PageFlood(from, leaving, art) { body() }
|
||||
// Onto the page's own hero art, not the whole pane: grown to the pane, the art
|
||||
// then cut down to the hero's banner (and back out to the pane to close).
|
||||
PageFlood(from, leaving, art, onto = { StoresMotion.heroAt }, ontoCorner = 16.dp) { body() }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -581,6 +588,9 @@ private fun StoreChips(
|
||||
val rootBounds = remember { HashMap<String, Rect>() }
|
||||
// The fill travels with focus; only the expensive pane change waits for the debounce.
|
||||
val highlighted = focused ?: selected
|
||||
// With a pad the row has no fill of its own: the focus ring's infill is the only one.
|
||||
val inputMode = androidx.compose.ui.platform.LocalInputModeManager.current.inputMode
|
||||
val fillShown = inputMode != androidx.compose.ui.input.InputMode.Keyboard
|
||||
val tint = androidx.compose.animation.animateColorAsState(
|
||||
Store.byId(highlighted)?.let { sourceColours(it.id).dot } ?: pal.signal, Motion.tw(160), label = "chipTint",
|
||||
)
|
||||
@@ -589,22 +599,15 @@ private fun StoreChips(
|
||||
for (store in Store.entries) {
|
||||
val signedIn = StoresState.isSignedIn(store) && StoresState.expired[store] != true
|
||||
StoreChip(
|
||||
label = store.shortLabel, on = selected == store.id, key = store.id,
|
||||
label = store.shortLabel, on = selected == store.id, under = fillShown && highlighted == store.id, key = store.id, mark = sourceColours(store.id).dot,
|
||||
modifier = Modifier.weight(1f).onGloballyPositioned { bounds[store.id] = it.boundsInParent(); rootBounds[store.id] = it.boundsInRoot() },
|
||||
lead = {
|
||||
val c = sourceColours(store.id)
|
||||
// A store's dot pulses once when it is picked signed in, and when a sign-in lands.
|
||||
var picked by remember { mutableStateOf(0) }
|
||||
val on = selected == store.id
|
||||
val wasOn = remember { booleanArrayOf(on) }
|
||||
LaunchedEffect(on) {
|
||||
if (on && !wasOn[0] && signedIn) picked++
|
||||
wasOn[0] = on
|
||||
}
|
||||
// A store's dot pulses when a sign-in lands (and, with the chip's lead, when picked).
|
||||
Box(
|
||||
Modifier.size(12.dp)
|
||||
.onGloballyPositioned { StoresMotion.dots[store] = it.boundsInRoot() }
|
||||
.pulseRing(picked + (StoresMotion.pulses[store] ?: 0), c.dot),
|
||||
.pulseRing(StoresMotion.pulses[store] ?: 0, c.dot),
|
||||
) { Box(Modifier.matchParentSize().clip(CircleShape).background(c.dot).alpha(if (signedIn) 1f else 0.35f)) }
|
||||
},
|
||||
description = store.label + if (signedIn) "" else " " + stringResource(R.string.stores_chip_signed_out),
|
||||
@@ -612,7 +615,7 @@ private fun StoreChips(
|
||||
) { onStore(store, rootBounds[store.id]) }
|
||||
}
|
||||
StoreChip(
|
||||
label = stringResource(R.string.stores_tab_downloads), on = selected == DOWNLOADS, key = DOWNLOADS,
|
||||
label = stringResource(R.string.stores_tab_downloads), on = selected == DOWNLOADS, under = fillShown && highlighted == DOWNLOADS, key = DOWNLOADS, mark = pal.signal,
|
||||
modifier = Modifier.weight(1f).onGloballyPositioned {
|
||||
bounds[DOWNLOADS] = it.boundsInParent()
|
||||
StoresMotion.downloadsChip = it.boundsInRoot()
|
||||
@@ -627,13 +630,13 @@ private fun StoreChips(
|
||||
}
|
||||
}
|
||||
// Over the chips: the fill is translucent, and the other chips' rest fill would hide it in flight.
|
||||
ChipGlide(keys.indexOf(highlighted), bounds[highlighted], tint)
|
||||
ChipGlide(keys.indexOf(highlighted), bounds[highlighted], tint, visible = fillShown)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun StoreChip(
|
||||
label: String, on: Boolean, key: String, modifier: Modifier, lead: @Composable () -> Unit,
|
||||
label: String, on: Boolean, under: Boolean, key: String, mark: Color, modifier: Modifier, lead: @Composable () -> Unit,
|
||||
trail: (@Composable () -> Unit)? = null, description: String? = null,
|
||||
onFocused: (String?) -> Unit = {}, onClick: () -> Unit,
|
||||
) {
|
||||
@@ -646,7 +649,15 @@ private fun StoreChip(
|
||||
val scale by animateFloatAsState(if (pressed) 0.95f else 1f, Motion.sp(0.5f, Spring.StiffnessMedium), label = "chipScale")
|
||||
val shape = RoundedCornerShape(99.dp)
|
||||
val ink = if (on) colors.onBackground else if (hot) colors.onBackground else colors.onSurfaceVariant
|
||||
// The selected look is the row's glide under the chip, so a chip here draws only its rest state.
|
||||
// The chip whose page shows has a bar of its colour along its foot. Picking it pulses its
|
||||
// lead (a store's dot, Downloads' icon).
|
||||
var picked by remember { mutableStateOf(0) }
|
||||
val wasOn = remember { booleanArrayOf(on) }
|
||||
LaunchedEffect(on) {
|
||||
if (on && !wasOn[0]) picked++
|
||||
wasOn[0] = on
|
||||
}
|
||||
// The row's glide draws the look of the chip [under] it, so that one draws no rest state of its own.
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp, Alignment.CenterHorizontally),
|
||||
modifier = modifier.paneItem("storechip:$key")
|
||||
@@ -655,14 +666,17 @@ private fun StoreChip(
|
||||
else if (!f.isFocused) onFocused(null)
|
||||
}
|
||||
.heightIn(min = 44.dp).graphicsLayer { scaleX = scale; scaleY = scale }.clip(shape)
|
||||
.background(if (on) Color.Transparent else colors.surface)
|
||||
.glideBorder(hot, shape, pal.signal, if (on) Color.Transparent else pal.line)
|
||||
.background(if (under) Color.Transparent else colors.surface)
|
||||
.shownBar(on, mark)
|
||||
.glideBorder(hot, shape, pal.signal, if (under) Color.Transparent else pal.line)
|
||||
.hoverable(src).clickable(interactionSource = src, indication = LocalIndication.current, role = Role.Tab, onClick = onClick)
|
||||
.controllerConfirm(onClick = onClick)
|
||||
.then(if (description != null) Modifier.semantics { contentDescription = description } else Modifier)
|
||||
.padding(horizontal = 12.dp, vertical = 8.dp),
|
||||
) {
|
||||
androidx.compose.runtime.CompositionLocalProvider(androidx.compose.material3.LocalContentColor provides ink) { lead() }
|
||||
androidx.compose.runtime.CompositionLocalProvider(androidx.compose.material3.LocalContentColor provides ink) {
|
||||
Box(Modifier.pulseRing(picked, mark), contentAlignment = Alignment.Center) { lead() }
|
||||
}
|
||||
Text(label, fontSize = 13.sp, fontWeight = FontWeight.Bold, color = ink, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
trail?.invoke()
|
||||
}
|
||||
@@ -718,23 +732,23 @@ private fun SignInCard(store: Store, height: Dp) {
|
||||
val shape = RoundedCornerShape(20.dp)
|
||||
val blank = WallCapsule(Brush.linearGradient(listOf(c.fill, colors.background)), edge = c.dot.copy(alpha = 0.22f))
|
||||
val ground = SolidColor(c.fill)
|
||||
Box(Modifier.fillMaxWidth().height(height.coerceAtLeast(320.dp)).clip(shape).background(colors.background).border(1.dp, pal.line, shape)) {
|
||||
Box(Modifier.fillMaxWidth().heightIn(min = height.coerceAtLeast(0.dp)).clip(shape).background(colors.background).border(1.dp, pal.line, shape)) {
|
||||
// The storefront arrives a moment after the page: its wall fades in over the blank one.
|
||||
androidx.compose.animation.Crossfade(art, animationSpec = Motion.tw(600), label = "signInWall") { tiles ->
|
||||
androidx.compose.animation.Crossfade(art, animationSpec = Motion.tw(600), label = "signInWall", modifier = Modifier.matchParentSize()) { tiles ->
|
||||
TiltedWall(tiles.size, if (tiles.isEmpty()) 75_000 else 50_000) { i -> if (tiles.isEmpty()) blank else WallCapsule(ground, tiles[i]) }
|
||||
}
|
||||
// The wall gives way to the words: dark at the left and the foot, and the store's glow under them.
|
||||
Box(
|
||||
Modifier.fillMaxSize().background(
|
||||
Modifier.matchParentSize().background(
|
||||
Brush.horizontalGradient(
|
||||
0f to colors.background.copy(alpha = 0.97f), 0.45f to colors.background.copy(alpha = 0.9f),
|
||||
0.78f to colors.background.copy(alpha = 0.35f), 1f to colors.background.copy(alpha = 0.15f),
|
||||
),
|
||||
),
|
||||
)
|
||||
Box(Modifier.fillMaxSize().background(Brush.verticalGradient(0.5f to Color.Transparent, 1f to colors.background.copy(alpha = 0.92f))))
|
||||
Box(Modifier.matchParentSize().background(Brush.verticalGradient(0.5f to Color.Transparent, 1f to colors.background.copy(alpha = 0.92f))))
|
||||
Box(
|
||||
Modifier.fillMaxSize().drawBehind {
|
||||
Modifier.matchParentSize().drawBehind {
|
||||
drawRect(Brush.radialGradient(listOf(c.dot.copy(alpha = 0.22f), Color.Transparent), center = Offset(size.width * 0.16f, size.height * 0.9f), radius = size.height * 0.75f))
|
||||
},
|
||||
)
|
||||
@@ -823,13 +837,50 @@ private fun Storefront(
|
||||
// A lazy item can be recomposed or prefetched out of order; the first grid card is identified
|
||||
// by its key, rather than whichever happens to compose first.
|
||||
var firstPlaced = false
|
||||
var columns by remember { mutableIntStateOf(1) }
|
||||
val density = androidx.compose.ui.platform.LocalDensity.current
|
||||
val focus = LocalFrontFocus.current
|
||||
val scope = rememberCoroutineScope()
|
||||
val headerItems = 1 + (if (StoresState.status[store] != null) 1 else 0) + (if (StoresState.problems[store] != null) 1 else 0)
|
||||
val card: @Composable (CatalogItem) -> Unit = { item ->
|
||||
val first = if (showGrid) item.key == visible.firstOrNull()?.key else !firstPlaced
|
||||
firstPlaced = true
|
||||
GameCard(item, store, s, a, installedKeys, onOpen, first)
|
||||
val navigation = if (!showGrid || focus == null) Modifier else Modifier.onPreviewKeyEvent { event ->
|
||||
val key = event.nativeKeyEvent
|
||||
val direction = when (key.keyCode) {
|
||||
KeyEvent.KEYCODE_DPAD_DOWN -> 1
|
||||
KeyEvent.KEYCODE_DPAD_UP -> -1
|
||||
else -> 0
|
||||
}
|
||||
val index = visible.indexOfFirst { it.key == item.key }
|
||||
val next = storeGridNeighbor(index, visible.size, columns, direction)
|
||||
when {
|
||||
direction == 0 || index < 0 -> false
|
||||
next == null -> direction > 0 // The last row stays in its column; Up can reach the header.
|
||||
else -> {
|
||||
if (key.action == KeyEvent.ACTION_DOWN) {
|
||||
val target = "card:${visible[next].key}"
|
||||
val targetIndex = headerItems + next
|
||||
// Prefetched cards can accept focus without being on screen.
|
||||
val visibleTarget = grid.layoutInfo.visibleItemsInfo.any { it.index == targetIndex }
|
||||
if (!visibleTarget || (focus.attached[target] ?: 0) == 0 ||
|
||||
runCatching { focus.items.getValue(target).requestFocus() }.isFailure) scope.launch {
|
||||
grid.scrollToItem(targetIndex)
|
||||
focusWithinFrames({ focus.last == target }) { focus.items[target] ?: androidx.compose.ui.focus.FocusRequester.Default }
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
GameCard(item, store, s, a, installedKeys, onOpen, first, navigation)
|
||||
}
|
||||
LazyVerticalGrid(
|
||||
columns = GridCells.Adaptive(CardWidth), state = grid, modifier = Modifier.fillMaxSize(),
|
||||
columns = GridCells.Adaptive(CardWidth), state = grid, modifier = Modifier.fillMaxSize().focusGroup().onSizeChanged {
|
||||
val gap = with(density) { 10.dp.roundToPx() }
|
||||
val minimum = with(density) { CardWidth.roundToPx() }
|
||||
columns = ((it.width + gap) / (minimum + gap)).toInt().coerceAtLeast(1)
|
||||
},
|
||||
horizontalArrangement = Arrangement.spacedBy(10.dp), verticalArrangement = Arrangement.spacedBy(10.dp),
|
||||
contentPadding = PaddingValues(top = 4.dp, bottom = 16.dp),
|
||||
) {
|
||||
@@ -1066,7 +1117,7 @@ private val CardWidth = 112.dp
|
||||
* on the store. Tapping the card itself opens the game's page.
|
||||
*/
|
||||
@Composable
|
||||
private fun GameCard(item: CatalogItem, store: Store, s: FrontEndState, a: FrontEndActions, installedKeys: Set<String>, onOpen: (String) -> Unit, first: Boolean = false) {
|
||||
private fun GameCard(item: CatalogItem, store: Store, s: FrontEndState, a: FrontEndActions, installedKeys: Set<String>, onOpen: (String) -> Unit, first: Boolean = false, navigation: Modifier = Modifier) {
|
||||
val ctx = LocalContext.current
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
@@ -1095,7 +1146,7 @@ private fun GameCard(item: CatalogItem, store: Store, s: FrontEndState, a: Front
|
||||
if (b.bottom > -ahead && b.top < screen + ahead && b.width > 0f) com.droiddeck.launcher.stores.StoreSizes.request(ctx, item)
|
||||
}
|
||||
}
|
||||
.paneItem("card:${item.key}").then(if (first) Modifier.firstTile() else Modifier).graphicsLayer { scaleX = scale; scaleY = scale }
|
||||
.then(navigation).paneItem("card:${item.key}").then(if (first) Modifier.firstTile() else Modifier).graphicsLayer { scaleX = scale; scaleY = scale }
|
||||
.clip(RoundedCornerShape(10.dp)).glideBorder(hot, RoundedCornerShape(10.dp), pal.signal, pal.line)
|
||||
.hoverable(src).clickable(interactionSource = src, indication = LocalIndication.current, onClick = open).controllerConfirm(onClick = open),
|
||||
) {
|
||||
|
||||
@@ -13,7 +13,7 @@ internal fun StoresEngineRow() {
|
||||
val version = StoresNative.version
|
||||
SettingsRow(
|
||||
stringResource(R.string.setup_stores_engine),
|
||||
version,
|
||||
null,
|
||||
) {
|
||||
Chip(if (version != null) stringResource(R.string.setup_stores_engine_chip_ready) else stringResource(R.string.setup_stores_engine_chip_missing), ok = version != null)
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ object Themes {
|
||||
PAPER, R.string.theme_paper, R.string.theme_paper_detail,
|
||||
background = Color(0xFF000000), surface = Color(0xFF0F0F10), surfaceVariant = Color(0xFF191A1C), line = Color(0xFF262729), line2 = Color(0xFF343638),
|
||||
onBackground = Color(0xFFF9F9F9), onSurfaceVariant = Color(0xFF8E9196),
|
||||
primary = Color(0xFFF9F9F9), primary2 = Color(0xFFD9DADD), onPrimary = Color(0xFF000000), signal = Color(0xFF136CE0),
|
||||
primary = Color(0xFFF9F9F9), primary2 = Color(0xFFD9DADD), onPrimary = Color(0xFF000000), signal = Color(0xFFF9F9F9),
|
||||
good = Color(0xFF4CD37F),
|
||||
),
|
||||
Palette(
|
||||
|
||||
@@ -568,7 +568,7 @@
|
||||
<string name="drawer_game_running">juego en ejecución</string>
|
||||
<string name="drawer_reapplied">reaplicado al iniciar %1$s</string>
|
||||
<string name="drawer_original">Original</string>
|
||||
<string name="drawer_components_note">Descarga, importa y elimina en la página Componentes.</string>
|
||||
<string name="drawer_components_note">Importa y elimina en la página Componentes.</string>
|
||||
<string name="setup_check_done">Hecho</string>
|
||||
<string name="setup_check_warn">Requiere atención</string>
|
||||
<string name="setup_check_busy">Trabajando</string>
|
||||
@@ -2132,4 +2132,19 @@
|
||||
<item quantity="many">%1$d ya en Juegos</item>
|
||||
<item quantity="other">%1$d ya en Juegos</item>
|
||||
</plurals>
|
||||
<string name="achievements_title">Logros</string>
|
||||
<string name="achievements_count">%1$d de %2$d desbloqueados</string>
|
||||
<string name="achievements_count_short">%1$d / %2$d</string>
|
||||
<string name="achievements_group_unlocked">Desbloqueados · %1$d</string>
|
||||
<string name="achievements_group_locked">Bloqueados · %1$d</string>
|
||||
<string name="achievements_group_hidden">Ocultos · %1$d</string>
|
||||
<string name="achievements_hidden">Logro oculto</string>
|
||||
<string name="achievements_hidden_detail">Los detalles se muestran al desbloquearlo.</string>
|
||||
<string name="achievements_all">Todos los logros desbloqueados</string>
|
||||
<string name="achievements_reading">Leyendo…</string>
|
||||
<string name="achievements_signed_out">Inicia sesión en %1$s para ver tus logros.</string>
|
||||
<string name="achievements_unreachable">No se pudo conectar con %1$s. Vuelve a intentarlo cuando tengas conexión.</string>
|
||||
<string name="achievements_none">%1$s no indica logros para este juego.</string>
|
||||
<string name="achievements_show_all">Ver los %1$d</string>
|
||||
<string name="achievements_dialog_title">Logros · %1$s</string>
|
||||
</resources>
|
||||
@@ -451,7 +451,7 @@
|
||||
<string name="drawer_game_running">Jeu en cours d\'exécution</string>
|
||||
<string name="drawer_reapplied">Réappliqué au lancement de %1$s</string>
|
||||
<string name="drawer_original">Original</string>
|
||||
<string name="drawer_components_note">Veuillez télécharger, importer et supprimer depuis la page « Composants ».</string>
|
||||
<string name="drawer_components_note">Importez et supprimez depuis la page « Composants ».</string>
|
||||
<string name="setup_check_done">Terminé</string>
|
||||
<string name="setup_check_warn">À traiter</string>
|
||||
<string name="setup_check_busy">Traitement en cours</string>
|
||||
@@ -962,4 +962,19 @@
|
||||
<item quantity="one">%1$d déjà dans Jeux</item>
|
||||
<item quantity="other">%1$d déjà dans Jeux</item>
|
||||
</plurals>
|
||||
<string name="achievements_title">Succès</string>
|
||||
<string name="achievements_count">%1$d sur %2$d débloqués</string>
|
||||
<string name="achievements_count_short">%1$d / %2$d</string>
|
||||
<string name="achievements_group_unlocked">Débloqués · %1$d</string>
|
||||
<string name="achievements_group_locked">Verrouillés · %1$d</string>
|
||||
<string name="achievements_group_hidden">Cachés · %1$d</string>
|
||||
<string name="achievements_hidden">Succès caché</string>
|
||||
<string name="achievements_hidden_detail">Les détails s\'affichent une fois débloqué.</string>
|
||||
<string name="achievements_all">Tous les succès débloqués</string>
|
||||
<string name="achievements_reading">Lecture…</string>
|
||||
<string name="achievements_signed_out">Connectez-vous à %1$s pour voir vos succès.</string>
|
||||
<string name="achievements_unreachable">Impossible de joindre %1$s. Réessayez une fois en ligne.</string>
|
||||
<string name="achievements_none">%1$s n\'indique aucun succès pour ce jeu.</string>
|
||||
<string name="achievements_show_all">Tout afficher (%1$d)</string>
|
||||
<string name="achievements_dialog_title">Succès · %1$s</string>
|
||||
</resources>
|
||||
@@ -564,7 +564,7 @@
|
||||
<string name="drawer_game_running">ゲーム実行中</string>
|
||||
<string name="drawer_reapplied">%1$sの起動時に再適用しました</string>
|
||||
<string name="drawer_original">元</string>
|
||||
<string name="drawer_components_note">「コンポーネント」ページでダウンロード、インポート、削除してください。</string>
|
||||
<string name="drawer_components_note">「コンポーネント」ページでインポート、削除してください。</string>
|
||||
<string name="setup_check_done">完了</string>
|
||||
<string name="setup_check_warn">要対応</string>
|
||||
<string name="setup_check_busy">処理中</string>
|
||||
@@ -2088,4 +2088,19 @@
|
||||
<plurals name="games_already_n">
|
||||
<item quantity="other">%1$d 本はすでにゲームにあります</item>
|
||||
</plurals>
|
||||
<string name="achievements_title">実績</string>
|
||||
<string name="achievements_count">%2$d 個中 %1$d 個を解除</string>
|
||||
<string name="achievements_count_short">%1$d / %2$d</string>
|
||||
<string name="achievements_group_unlocked">解除済み · %1$d</string>
|
||||
<string name="achievements_group_locked">未解除 · %1$d</string>
|
||||
<string name="achievements_group_hidden">隠し実績 · %1$d</string>
|
||||
<string name="achievements_hidden">隠し実績</string>
|
||||
<string name="achievements_hidden_detail">解除すると詳細が表示されます。</string>
|
||||
<string name="achievements_all">すべての実績を解除</string>
|
||||
<string name="achievements_reading">読み込み中…</string>
|
||||
<string name="achievements_signed_out">実績を表示するには %1$s にサインインしてください。</string>
|
||||
<string name="achievements_unreachable">%1$s に接続できませんでした。オンラインになってから再度確認してください。</string>
|
||||
<string name="achievements_none">%1$s にはこのゲームの実績がありません。</string>
|
||||
<string name="achievements_show_all">すべて表示(%1$d)</string>
|
||||
<string name="achievements_dialog_title">実績 · %1$s</string>
|
||||
</resources>
|
||||
@@ -564,7 +564,7 @@
|
||||
<string name="drawer_game_running">게임 실행 중</string>
|
||||
<string name="drawer_reapplied">%1$s 시작 시 다시 적용됨</string>
|
||||
<string name="drawer_original">원본</string>
|
||||
<string name="drawer_components_note">\"구성 요소\" 페이지에서 다운로드, 가져오기 및 삭제하세요.</string>
|
||||
<string name="drawer_components_note">구성 요소 페이지에서 가져오기 및 삭제하세요.</string>
|
||||
<string name="setup_check_done">완료</string>
|
||||
<string name="setup_check_warn">처리 필요</string>
|
||||
<string name="setup_check_busy">처리 중</string>
|
||||
@@ -2088,4 +2088,19 @@
|
||||
<plurals name="games_already_n">
|
||||
<item quantity="other">%1$d개는 이미 게임에 있음</item>
|
||||
</plurals>
|
||||
<string name="achievements_title">도전 과제</string>
|
||||
<string name="achievements_count">%2$d개 중 %1$d개 달성</string>
|
||||
<string name="achievements_count_short">%1$d / %2$d</string>
|
||||
<string name="achievements_group_unlocked">달성 · %1$d</string>
|
||||
<string name="achievements_group_locked">미달성 · %1$d</string>
|
||||
<string name="achievements_group_hidden">숨겨짐 · %1$d</string>
|
||||
<string name="achievements_hidden">숨겨진 도전 과제</string>
|
||||
<string name="achievements_hidden_detail">달성하면 세부 정보가 표시됩니다.</string>
|
||||
<string name="achievements_all">모든 도전 과제 달성</string>
|
||||
<string name="achievements_reading">불러오는 중…</string>
|
||||
<string name="achievements_signed_out">도전 과제를 보려면 %1$s에 로그인하세요.</string>
|
||||
<string name="achievements_unreachable">%1$s에 연결할 수 없습니다. 온라인 상태에서 다시 확인하세요.</string>
|
||||
<string name="achievements_none">%1$s에 이 게임의 도전 과제가 없습니다.</string>
|
||||
<string name="achievements_show_all">모두 보기(%1$d)</string>
|
||||
<string name="achievements_dialog_title">도전 과제 · %1$s</string>
|
||||
</resources>
|
||||
@@ -526,7 +526,7 @@
|
||||
<string name="drawer_game_running">игра запущена</string>
|
||||
<string name="drawer_reapplied">повторно применено при запуске %1$s</string>
|
||||
<string name="drawer_original">Оригинал</string>
|
||||
<string name="drawer_components_note">Скачивайте, импортируйте и удаляйте на странице «Компоненты».</string>
|
||||
<string name="drawer_components_note">Импортируйте и удаляйте на странице «Компоненты».</string>
|
||||
<string name="setup_check_done">Готово</string>
|
||||
<string name="setup_check_warn">Требует внимания</string>
|
||||
<string name="setup_check_busy">Обработка</string>
|
||||
@@ -1073,4 +1073,19 @@
|
||||
<item quantity="many">%1$d уже в «Играх»</item>
|
||||
<item quantity="other">%1$d уже в «Играх»</item>
|
||||
</plurals>
|
||||
<string name="achievements_title">Достижения</string>
|
||||
<string name="achievements_count">Получено %1$d из %2$d</string>
|
||||
<string name="achievements_count_short">%1$d / %2$d</string>
|
||||
<string name="achievements_group_unlocked">Получены · %1$d</string>
|
||||
<string name="achievements_group_locked">Не получены · %1$d</string>
|
||||
<string name="achievements_group_hidden">Скрытые · %1$d</string>
|
||||
<string name="achievements_hidden">Скрытое достижение</string>
|
||||
<string name="achievements_hidden_detail">Подробности появятся после получения.</string>
|
||||
<string name="achievements_all">Все достижения получены</string>
|
||||
<string name="achievements_reading">Загрузка…</string>
|
||||
<string name="achievements_signed_out">Войдите в %1$s, чтобы увидеть свои достижения.</string>
|
||||
<string name="achievements_unreachable">Не удалось связаться с %1$s. Проверьте снова, когда будете в сети.</string>
|
||||
<string name="achievements_none">В %1$s нет достижений для этой игры.</string>
|
||||
<string name="achievements_show_all">Показать все (%1$d)</string>
|
||||
<string name="achievements_dialog_title">Достижения · %1$s</string>
|
||||
</resources>
|
||||
@@ -564,7 +564,7 @@
|
||||
<string name="drawer_game_running">游戏运行中</string>
|
||||
<string name="drawer_reapplied">于启动 %1$s 时重新应用</string>
|
||||
<string name="drawer_original">原件</string>
|
||||
<string name="drawer_components_note">在“组件”页面下载、导入和删除。</string>
|
||||
<string name="drawer_components_note">在“组件”页面导入和删除。</string>
|
||||
<string name="setup_check_done">完成</string>
|
||||
<string name="setup_check_warn">需要处理</string>
|
||||
<string name="setup_check_busy">处理中</string>
|
||||
@@ -2088,4 +2088,19 @@
|
||||
<plurals name="games_already_n">
|
||||
<item quantity="other">%1$d 个已在游戏中</item>
|
||||
</plurals>
|
||||
<string name="achievements_title">成就</string>
|
||||
<string name="achievements_count">已解锁 %1$d / %2$d</string>
|
||||
<string name="achievements_count_short">%1$d / %2$d</string>
|
||||
<string name="achievements_group_unlocked">已解锁 · %1$d</string>
|
||||
<string name="achievements_group_locked">未解锁 · %1$d</string>
|
||||
<string name="achievements_group_hidden">隐藏 · %1$d</string>
|
||||
<string name="achievements_hidden">隐藏成就</string>
|
||||
<string name="achievements_hidden_detail">解锁后显示详情。</string>
|
||||
<string name="achievements_all">已解锁全部成就</string>
|
||||
<string name="achievements_reading">读取中…</string>
|
||||
<string name="achievements_signed_out">登录 %1$s 以查看你的成就。</string>
|
||||
<string name="achievements_unreachable">无法连接到 %1$s。请在联网后再查看。</string>
|
||||
<string name="achievements_none">%1$s 未列出此游戏的成就。</string>
|
||||
<string name="achievements_show_all">显示全部 %1$d 项</string>
|
||||
<string name="achievements_dialog_title">成就 · %1$s</string>
|
||||
</resources>
|
||||
@@ -564,7 +564,7 @@
|
||||
<string name="drawer_game_running">遊戲執行中</string>
|
||||
<string name="drawer_reapplied">於 %1$s 啟動時重新套用</string>
|
||||
<string name="drawer_original">原始</string>
|
||||
<string name="drawer_components_note">請在「元件」頁面下載、匯入及刪除。</string>
|
||||
<string name="drawer_components_note">請在「元件」頁面匯入及刪除。</string>
|
||||
<string name="setup_check_done">完成</string>
|
||||
<string name="setup_check_warn">需要處理</string>
|
||||
<string name="setup_check_busy">處理中</string>
|
||||
@@ -2088,4 +2088,19 @@
|
||||
<plurals name="games_already_n">
|
||||
<item quantity="other">%1$d 個已在遊戲中</item>
|
||||
</plurals>
|
||||
<string name="achievements_title">成就</string>
|
||||
<string name="achievements_count">已解鎖 %1$d / %2$d</string>
|
||||
<string name="achievements_count_short">%1$d / %2$d</string>
|
||||
<string name="achievements_group_unlocked">已解鎖 · %1$d</string>
|
||||
<string name="achievements_group_locked">未解鎖 · %1$d</string>
|
||||
<string name="achievements_group_hidden">隱藏 · %1$d</string>
|
||||
<string name="achievements_hidden">隱藏成就</string>
|
||||
<string name="achievements_hidden_detail">解鎖後會顯示詳情。</string>
|
||||
<string name="achievements_all">已解鎖全部成就</string>
|
||||
<string name="achievements_reading">正在讀取…</string>
|
||||
<string name="achievements_signed_out">登入 %1$s 以查看你的成就。</string>
|
||||
<string name="achievements_unreachable">無法連接 %1$s。請在連線後再查看。</string>
|
||||
<string name="achievements_none">%1$s 未列出此遊戲的成就。</string>
|
||||
<string name="achievements_show_all">顯示全部 %1$d 項</string>
|
||||
<string name="achievements_dialog_title">成就 · %1$s</string>
|
||||
</resources>
|
||||
@@ -564,7 +564,7 @@
|
||||
<string name="drawer_game_running">遊戲執行中</string>
|
||||
<string name="drawer_reapplied">已在啟動 %1$s 時重新套用</string>
|
||||
<string name="drawer_original">原始</string>
|
||||
<string name="drawer_components_note">請在「元件」頁面下載、匯入和刪除。</string>
|
||||
<string name="drawer_components_note">請在「元件」頁面匯入和刪除。</string>
|
||||
<string name="setup_check_done">完成</string>
|
||||
<string name="setup_check_warn">需要處理</string>
|
||||
<string name="setup_check_busy">處理中</string>
|
||||
@@ -2088,4 +2088,19 @@
|
||||
<plurals name="games_already_n">
|
||||
<item quantity="other">%1$d 個已在遊戲中</item>
|
||||
</plurals>
|
||||
<string name="achievements_title">成就</string>
|
||||
<string name="achievements_count">已解鎖 %1$d / %2$d</string>
|
||||
<string name="achievements_count_short">%1$d / %2$d</string>
|
||||
<string name="achievements_group_unlocked">已解鎖 · %1$d</string>
|
||||
<string name="achievements_group_locked">未解鎖 · %1$d</string>
|
||||
<string name="achievements_group_hidden">隱藏 · %1$d</string>
|
||||
<string name="achievements_hidden">隱藏成就</string>
|
||||
<string name="achievements_hidden_detail">解鎖後會顯示詳細資訊。</string>
|
||||
<string name="achievements_all">已解鎖所有成就</string>
|
||||
<string name="achievements_reading">正在讀取…</string>
|
||||
<string name="achievements_signed_out">登入 %1$s 以查看你的成就。</string>
|
||||
<string name="achievements_unreachable">無法連線到 %1$s。請在連上網路後再查看。</string>
|
||||
<string name="achievements_none">%1$s 沒有列出這款遊戲的成就。</string>
|
||||
<string name="achievements_show_all">顯示全部 %1$d 項</string>
|
||||
<string name="achievements_dialog_title">成就 · %1$s</string>
|
||||
</resources>
|
||||
@@ -438,6 +438,9 @@
|
||||
<string name="comp_game_runtime_options">Runtime options</string>
|
||||
<string name="comp_game_environment_other_hint">Other per-game Proton, DXVK, VKD3D-Proton and synchronization environment options.</string>
|
||||
<string name="comp_game_saved_next">%1$s\'s profile is saved for the next game launch.</string>
|
||||
<string name="game_no_steam_title">Start without Steam</string>
|
||||
<string name="game_no_steam_detail">For a game that closes right away: starts it without Proton\'s Steam setup. Steam features such as the overlay are off for it.</string>
|
||||
<string name="game_no_steam_on">On</string>
|
||||
<string name="comp_game_proton_live">%1$s\'s Proton choice is saved and available in Steam now.</string>
|
||||
<string name="comp_game_proton_next">%1$s\'s Proton choice is saved. Restart Steam before launching the game.</string>
|
||||
<string name="comp_game_proton_not_runnable">%1$s cannot use the selected Proton on this device.</string>
|
||||
@@ -628,7 +631,10 @@
|
||||
<string name="drawer_game_running">game running</string>
|
||||
<string name="drawer_reapplied">re-applied at launch %1$s</string>
|
||||
<string name="drawer_original">Original</string>
|
||||
<string name="drawer_components_note">Download, import and delete on the Components page.</string>
|
||||
<string name="drawer_components_note">Import and delete on the Components page.</string>
|
||||
<string name="drawer_component_downloads">Download components</string>
|
||||
<string name="drawer_component_downloads_hint">Downloads are shared with the Components page. Choose a downloaded version above to use it on the next game launch.</string>
|
||||
<string name="drawer_component_choose_download">Choose a version to download</string>
|
||||
<string name="setup_check_done">Done</string>
|
||||
<string name="setup_check_warn">Needs attention</string>
|
||||
<string name="setup_check_busy">Working</string>
|
||||
@@ -2087,6 +2093,8 @@
|
||||
<string name="stores_play">Play</string>
|
||||
<string name="stores_install">Install</string>
|
||||
<string name="stores_resume_install">Resume install</string>
|
||||
<!-- A Downloads row for an install that stopped when the app closed: it can be resumed -->
|
||||
<string name="stores_dl_interrupted">Interrupted</string>
|
||||
<string name="stores_install_size">Install · %1$s</string>
|
||||
<string name="stores_get_free">Get for free</string>
|
||||
<string name="stores_view_on">View on %1$s</string>
|
||||
@@ -2120,9 +2128,29 @@
|
||||
<string name="stores_eyebrow_installed">installed</string>
|
||||
<string name="stores_eyebrow_library">in your library</string>
|
||||
<string name="stores_eyebrow_store">store</string>
|
||||
<!-- A GOG or Epic game's achievements: the store page's section and the session panel. -->
|
||||
<string name="achievements_title">Achievements</string>
|
||||
<string name="achievements_count">%1$d of %2$d unlocked</string>
|
||||
<string name="achievements_count_short">%1$d / %2$d</string>
|
||||
<string name="achievements_group_unlocked">Unlocked · %1$d</string>
|
||||
<string name="achievements_group_locked">Locked · %1$d</string>
|
||||
<string name="achievements_group_hidden">Hidden · %1$d</string>
|
||||
<string name="achievements_hidden">Hidden achievement</string>
|
||||
<string name="achievements_hidden_detail">Details are shown once it is unlocked.</string>
|
||||
<string name="achievements_all">Every achievement unlocked</string>
|
||||
<string name="achievements_reading">Reading…</string>
|
||||
<string name="achievements_signed_out">Sign in to %1$s to see your achievements.</string>
|
||||
<string name="achievements_unreachable">Could not reach %1$s. Check back once you are online.</string>
|
||||
<string name="achievements_none">%1$s lists no achievements for this game.</string>
|
||||
<string name="achievements_show_all">Show all %1$d</string>
|
||||
<string name="achievements_dialog_title">Achievements · %1$s</string>
|
||||
<string name="stores_in_steam">✓ In Steam</string>
|
||||
<string name="stores_uninstall">Uninstall</string>
|
||||
<string name="stores_uninstall_confirm">Press again to uninstall</string>
|
||||
<string name="stores_uninstalling">Uninstalling…</string>
|
||||
<!-- The heading of the confirm that steps out of a store game's Uninstall; %1$s is the game -->
|
||||
<string name="stores_uninstall_title">Uninstall %1$s?</string>
|
||||
<string name="stores_uninstall_body_size">Frees %1$s and removes it from Steam.</string>
|
||||
<string name="stores_uninstall_body">Removes its files and its Steam shortcut.</string>
|
||||
<string name="stores_launch_not_registered">Steam picks the game up when it next starts; launch it from there, or start Steam now.</string>
|
||||
<string name="stores_card_proton">Proton</string>
|
||||
<string name="stores_card_proton_value">Steam\'s choice per game</string>
|
||||
@@ -2281,4 +2309,14 @@
|
||||
<string name="desktop_size">Size on disk</string>
|
||||
<string name="desktop_uninstall_title">Uninstall the desktop?</string>
|
||||
<string name="desktop_all_systems">All</string>
|
||||
<string name="gog_achievements">GOG achievements</string>
|
||||
<string name="gog_achievements_hint">Sync achievements for supported GOG games. Applies on the next launch.</string>
|
||||
<string name="gog_achievements_off">Achievements off</string>
|
||||
<string name="gog_achievements_on">Achievements enabled</string>
|
||||
<string name="gog_achievements_signin">Sign in to GOG again</string>
|
||||
<string name="gog_achievements_uploaded">Achievements uploaded</string>
|
||||
<string name="gog_achievements_pending">Achievement upload pending</string>
|
||||
<string name="gog_achievements_enable_store">Enable GOG achievements in Stores settings</string>
|
||||
<string name="gog_achievements_unavailable">Achievements unavailable; check session logs</string>
|
||||
<string name="achievement_unlocked">Achievement unlocked</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.droiddeck.launcher.core
|
||||
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
|
||||
class CpuAllocationDefaultsTest {
|
||||
private val thor = (0..7).associateWith { when (it) { in 0..2 -> 2.016; in 3..6 -> 2.8032; else -> 3.1872 } }
|
||||
|
||||
@Test fun gen2UsesTheFourMiddleCoresAndOnePrime() {
|
||||
for (model in listOf("SM8550", "QCS8550", "sm8550-ac")) {
|
||||
assertEquals(CpuAllocationDefaults.Allocation("7", "3,4,5,6"), CpuAllocationDefaults.forDevice(model, "", thor))
|
||||
}
|
||||
assertEquals(CpuAllocationDefaults.Allocation("7", "3,4,5,6"), CpuAllocationDefaults.forDevice("", "kalama", thor))
|
||||
}
|
||||
|
||||
@Test fun coreNumbersAndClockVariantsAreDetectedInsteadOfHardcoded() {
|
||||
val reordered = mapOf(0 to 3.36, 1 to 2.0, 2 to 2.0, 3 to 2.0, 4 to 2.8, 5 to 2.8, 6 to 2.8, 7 to 2.8)
|
||||
assertEquals(CpuAllocationDefaults.Allocation("0", "4,5,6,7"), CpuAllocationDefaults.forDevice("SM8550-AC", "kalama", reordered))
|
||||
}
|
||||
|
||||
@Test fun anotherOrUnknownChipDoesNotAcquireThisDefault() {
|
||||
assertNull(CpuAllocationDefaults.forDevice("SM8650", "pineapple", thor))
|
||||
assertNull(CpuAllocationDefaults.forDevice("SM8650", "kalama", thor))
|
||||
assertNull(CpuAllocationDefaults.forDevice("", "", thor))
|
||||
}
|
||||
|
||||
@Test fun missingOrUnexpectedTopologyKeepsTheSchedulerDefault() {
|
||||
assertNull(CpuAllocationDefaults.forDevice("SM8550", "kalama", thor - 7))
|
||||
assertNull(CpuAllocationDefaults.forDevice("SM8550", "kalama", thor + (7 to null)))
|
||||
assertNull(CpuAllocationDefaults.forDevice("SM8550", "kalama", thor + (7 to 0.0)))
|
||||
assertNull(CpuAllocationDefaults.forDevice("SM8550", "kalama", thor + (7 to Double.NaN)))
|
||||
assertNull(CpuAllocationDefaults.forDevice("SM8550", "kalama", (0..7).associateWith { 2.8 }))
|
||||
}
|
||||
|
||||
@Test fun allCoreGamesUndoTheClientsInheritedRestriction() {
|
||||
val all = CpuCores.listOrAll("")
|
||||
assertEquals(all, CpuCores.gameLaunchList("", clientPinned = true))
|
||||
assertEquals(all, CpuCores.gameLaunchList(all, clientPinned = true))
|
||||
assertEquals("", CpuCores.gameLaunchList("", clientPinned = false))
|
||||
assertEquals("0", CpuCores.gameLaunchList("0", clientPinned = true))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
package com.droiddeck.launcher.input
|
||||
|
||||
import android.graphics.RectF
|
||||
import android.os.Looper
|
||||
import android.view.MotionEvent
|
||||
import java.time.Duration
|
||||
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.Shadows.shadowOf
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [28], manifest = Config.NONE)
|
||||
class TouchpadGesturesTest {
|
||||
private val events = mutableListOf<String>()
|
||||
private lateinit var touchpad: TouchpadGestures
|
||||
private var time = 1000L
|
||||
private var downTime = 0L
|
||||
|
||||
private val listener = object : PointerGestures.Listener {
|
||||
override fun onMove(x: Float, y: Float) { events += "move" }
|
||||
override fun onButton(button: Int, pressed: Boolean, x: Float, y: Float) {
|
||||
val name = if (button == PointerGestures.BTN_RIGHT) "right" else "left"
|
||||
events += "$name ${if (pressed) "down" else "up"}"
|
||||
}
|
||||
override fun onWheel(steps: Int) { events += "wheel $steps" }
|
||||
override fun onLongPress() { events += "long press" }
|
||||
}
|
||||
|
||||
@Before fun setUp() {
|
||||
touchpad = TouchpadGestures(SLOP, listener)
|
||||
touchpad.bounds = RectF(0f, 0f, 1920f, 1080f)
|
||||
touchpad.place(960f, 540f)
|
||||
}
|
||||
|
||||
@Test fun tapHoldsTheLeftButtonBeforeReleasingIt() {
|
||||
tap()
|
||||
assertEquals(listOf("left down"), events)
|
||||
advance(40)
|
||||
assertEquals(listOf("left down"), events)
|
||||
advance(100)
|
||||
assertEquals(listOf("left down", "left up"), events)
|
||||
}
|
||||
|
||||
@Test fun twoFingerTapHoldsTheRightButtonBeforeReleasingIt() {
|
||||
touch(MotionEvent.ACTION_DOWN, 0, 1 to (400f to 300f))
|
||||
advance(10)
|
||||
touch(MotionEvent.ACTION_POINTER_DOWN, 1, 1 to (400f to 300f), 2 to (600f to 310f))
|
||||
advance(60)
|
||||
touch(MotionEvent.ACTION_POINTER_UP, 1, 1 to (400f to 300f), 2 to (600f to 310f))
|
||||
advance(10)
|
||||
touch(MotionEvent.ACTION_UP, 0, 1 to (400f to 300f))
|
||||
assertEquals(listOf("right down"), events)
|
||||
advance(30)
|
||||
assertEquals(listOf("right down"), events)
|
||||
advance(100)
|
||||
assertEquals(listOf("right down", "right up"), events)
|
||||
}
|
||||
|
||||
@Test fun slowTwoFingerTapHoldsTheRightButtonBeforeReleasingIt() {
|
||||
touch(MotionEvent.ACTION_DOWN, 0, 1 to (400f to 300f))
|
||||
advance(10)
|
||||
touch(MotionEvent.ACTION_POINTER_DOWN, 1, 1 to (400f to 300f), 2 to (600f to 310f))
|
||||
advance(350)
|
||||
touch(MotionEvent.ACTION_POINTER_UP, 1, 1 to (400f to 300f), 2 to (600f to 310f))
|
||||
advance(10)
|
||||
touch(MotionEvent.ACTION_UP, 0, 1 to (400f to 300f))
|
||||
assertEquals(listOf("right down"), events)
|
||||
advance(40)
|
||||
assertEquals(listOf("right down"), events)
|
||||
advance(100)
|
||||
assertEquals(listOf("right down", "right up"), events)
|
||||
}
|
||||
|
||||
@Test fun secondTapPressesOnlyAfterTheFirstClickIsReleased() {
|
||||
tap()
|
||||
advance(20)
|
||||
touch(MotionEvent.ACTION_DOWN, 0, 1 to (400f to 300f))
|
||||
assertEquals(listOf("left down", "left up", "left down"), events)
|
||||
advance(80)
|
||||
touch(MotionEvent.ACTION_UP, 0, 1 to (400f to 300f))
|
||||
advance(200)
|
||||
assertEquals(listOf("left down", "left up", "left down", "left up"), events)
|
||||
}
|
||||
|
||||
@Test fun secondFingerTappingAgainReleasesTheFirstRightClickFirst() {
|
||||
touch(MotionEvent.ACTION_DOWN, 0, 1 to (400f to 300f))
|
||||
advance(10)
|
||||
touch(MotionEvent.ACTION_POINTER_DOWN, 1, 1 to (400f to 300f), 2 to (600f to 310f))
|
||||
advance(60)
|
||||
touch(MotionEvent.ACTION_POINTER_UP, 1, 1 to (400f to 300f), 2 to (600f to 310f))
|
||||
advance(10)
|
||||
touch(MotionEvent.ACTION_POINTER_DOWN, 1, 1 to (400f to 300f), 2 to (600f to 310f))
|
||||
advance(20)
|
||||
touch(MotionEvent.ACTION_POINTER_UP, 1, 1 to (400f to 300f), 2 to (600f to 310f))
|
||||
assertEquals(listOf("right down", "right up", "right down"), events)
|
||||
advance(200)
|
||||
assertEquals(listOf("right down", "right up", "right down", "right up"), events)
|
||||
}
|
||||
|
||||
@Test fun cancelReleasesAClickThatIsStillHeld() {
|
||||
tap()
|
||||
touchpad.cancel()
|
||||
assertEquals(listOf("left down", "left up"), events)
|
||||
advance(200)
|
||||
assertEquals(listOf("left down", "left up"), events)
|
||||
}
|
||||
|
||||
private fun tap() {
|
||||
touch(MotionEvent.ACTION_DOWN, 0, 1 to (400f to 300f))
|
||||
advance(80)
|
||||
touch(MotionEvent.ACTION_UP, 0, 1 to (400f to 300f))
|
||||
}
|
||||
|
||||
private fun advance(ms: Long) {
|
||||
time += ms
|
||||
shadowOf(Looper.getMainLooper()).idleFor(Duration.ofMillis(ms))
|
||||
}
|
||||
|
||||
private fun touch(action: Int, index: Int, vararg pointers: Pair<Int, Pair<Float, Float>>) {
|
||||
if (action == MotionEvent.ACTION_DOWN) downTime = time
|
||||
val properties = pointers.map { (id, _) ->
|
||||
MotionEvent.PointerProperties().apply { this.id = id; toolType = MotionEvent.TOOL_TYPE_FINGER }
|
||||
}.toTypedArray()
|
||||
val coords = pointers.map { (_, at) ->
|
||||
MotionEvent.PointerCoords().apply { x = at.first; y = at.second; pressure = 1f; size = 1f }
|
||||
}.toTypedArray()
|
||||
val masked = action or (index shl MotionEvent.ACTION_POINTER_INDEX_SHIFT)
|
||||
val event = MotionEvent.obtain(downTime, time, masked, pointers.size, properties, coords, 0, 0, 1f, 1f, 0, 0, 0, 0)
|
||||
touchpad.onTouch(event)
|
||||
event.recycle()
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val SLOP = 8f
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import android.content.Context
|
||||
import com.droiddeck.launcher.core.CpuAllocationDefaults
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.RuntimeEnvironment
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [33])
|
||||
class CoreAllocationPrefsTest {
|
||||
private val app get() = RuntimeEnvironment.getApplication()
|
||||
private val defaults = CpuAllocationDefaults.Allocation("7", "3,4,5,6")
|
||||
private val saved get() = app.getSharedPreferences("session", Context.MODE_PRIVATE)
|
||||
|
||||
@Before fun clear() { saved.edit().clear().commit() }
|
||||
|
||||
@Test fun absentPreferencesUseTheDeviceDefaultWithoutWritingIt() {
|
||||
assertEquals(SessionPrefs.CoreAllocation(true, "7", "3,4,5,6"), SessionPrefs.coreAllocation(app, defaults))
|
||||
assertTrue(saved.all.isEmpty())
|
||||
assertEquals(SessionPrefs.CoreAllocation(false, "", ""), SessionPrefs.coreAllocation(app, null))
|
||||
}
|
||||
|
||||
@Test fun explicitDisableAndAllCoreChoicesSurviveAnUpdate() {
|
||||
saved.edit().putBoolean("clientCpusOverride", false).putString("clientCpus", "").putString("gameCpus", "").commit()
|
||||
assertEquals(SessionPrefs.CoreAllocation(false, "", ""), SessionPrefs.coreAllocation(app, defaults))
|
||||
}
|
||||
|
||||
@Test fun existingCustomMasksArePreserved() {
|
||||
saved.edit().putBoolean("clientCpusOverride", true).putString("clientCpus", "0,1").putString("gameCpus", "2,7").commit()
|
||||
assertEquals(SessionPrefs.CoreAllocation(true, "0,1", "2,7"), SessionPrefs.coreAllocation(app, defaults))
|
||||
}
|
||||
|
||||
@Test fun anOldClientMaskIsNotEnabledWithoutAnOverrideChoice() {
|
||||
saved.edit().putString("clientCpus", "0,1").commit()
|
||||
assertEquals(SessionPrefs.CoreAllocation(false, "0,1", "3,4,5,6"), SessionPrefs.coreAllocation(app, defaults))
|
||||
}
|
||||
|
||||
@Test fun changingOneChoiceDoesNotReplaceTheOtherDefaults() {
|
||||
SessionPrefs.setGameCpus(app, "0,1,2,3,4,5,6,7")
|
||||
assertEquals(SessionPrefs.CoreAllocation(true, "7", "0,1,2,3,4,5,6,7"), SessionPrefs.coreAllocation(app, defaults))
|
||||
SessionPrefs.setClientCpusOverride(app, false)
|
||||
assertEquals(SessionPrefs.CoreAllocation(false, "7", "0,1,2,3,4,5,6,7"), SessionPrefs.coreAllocation(app, defaults))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import android.content.Context
|
||||
import android.content.ContextWrapper
|
||||
import com.droiddeck.launcher.runtime.BwrapSpawner
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.RuntimeEnvironment
|
||||
import org.robolectric.annotation.Config
|
||||
import org.robolectric.shadows.ShadowBuild
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [28], manifest = Config.NONE)
|
||||
class QuestExperimentalTest {
|
||||
private val context: Context get() = RuntimeEnvironment.getApplication()
|
||||
|
||||
@Before fun reset() {
|
||||
context.getSharedPreferences("session", Context.MODE_PRIVATE).edit().clear().commit()
|
||||
ShadowBuild.setModel("Phone")
|
||||
ShadowBuild.setDevice("phone")
|
||||
}
|
||||
|
||||
@Test fun otherDevicesAndQuest2KeepTheirSettings() {
|
||||
for (model in listOf("Phone", "Quest 2")) {
|
||||
ShadowBuild.setModel(model)
|
||||
QuestExperimental.initialize(context)
|
||||
assertEquals(SessionPrefs.GPU_DRIVERS_AUTO, SessionPrefs.gpuDriverMode(context))
|
||||
assertEquals("", SessionPrefs.androidDriver(context))
|
||||
assertFalse(SessionPrefs.hdr(context, "steam"))
|
||||
}
|
||||
assertFalse(QuestExperimental.supported("Quest 2", "hollywood", "Oculus"))
|
||||
}
|
||||
|
||||
@Test fun questDefaultsSelectBothCompatibilityPathsAndAreAppliedOnlyOnce() {
|
||||
ShadowBuild.setModel("Quest 3")
|
||||
val standard = object : ContextWrapper(context) {
|
||||
override fun getPackageName() = "com.droiddeck.launcher"
|
||||
}
|
||||
QuestExperimental.initialize(standard)
|
||||
assertEquals(SessionPrefs.GPU_DRIVERS_MANUAL, SessionPrefs.gpuDriverMode(context))
|
||||
assertEquals(QuestExperimental.DRIVER, SessionPrefs.androidDriver(context))
|
||||
assertEquals("", SessionPrefs.linuxDriver(context))
|
||||
assertTrue(SessionPrefs.hdr(context, "steam"))
|
||||
assertTrue(context.filesDir.resolve("quest-startup.txt").readText().contains("model=Quest 3"))
|
||||
SessionPrefs.setAndroidDriver(context, "chosen-driver")
|
||||
SessionPrefs.setHdr(context, "steam", false)
|
||||
QuestExperimental.initialize(context)
|
||||
assertEquals("chosen-driver", SessionPrefs.androidDriver(context))
|
||||
assertFalse(SessionPrefs.hdr(context, "steam"))
|
||||
}
|
||||
|
||||
@Test fun quest3sIsRecognizedByModelOrDevice() {
|
||||
assertTrue(QuestExperimental.supported("Quest 3S", "unknown", "Oculus"))
|
||||
assertTrue(QuestExperimental.supported("unknown", "panther", "Oculus"))
|
||||
assertTrue(QuestExperimental.supported("unknown", "eureka", "Meta"))
|
||||
assertFalse(QuestExperimental.supported("Pixel 7", "panther", "Google"))
|
||||
}
|
||||
|
||||
@Test fun installedPackagesUseSeparateSandboxSockets() {
|
||||
val packages = listOf("com.droiddeck.launcher", "com.tencent.ig",
|
||||
"com.antutu.benchmark.full", "com.ludashi.benchmark")
|
||||
val sockets = packages.map { name ->
|
||||
val variant = object : ContextWrapper(context) {
|
||||
override fun getPackageName() = name
|
||||
}
|
||||
BwrapSpawner.socket(variant).also { assertEquals("$name.bwrap", it) }
|
||||
}
|
||||
assertEquals(packages.size, sockets.toSet().size)
|
||||
}
|
||||
}
|
||||
@@ -71,6 +71,19 @@ class SelectedGameProfileTest {
|
||||
assertTrue(profile.hasOverrides)
|
||||
}
|
||||
|
||||
@Test fun startWithoutSteamIsListedByNameAndMakesProfileCustom() {
|
||||
val environment = GameEnvironment.withGameNoSteam(GameEnvironment.Config(), game.profileKey, true)
|
||||
val profile = resolve(environment = environment)
|
||||
|
||||
assertTrue(profile!!.startWithoutSteam)
|
||||
assertEquals(0, profile.environmentOverrides)
|
||||
assertTrue(profile.hasOverrides)
|
||||
|
||||
val off = GameEnvironment.withGameNoSteam(environment, game.profileKey, false)
|
||||
assertFalse(resolve(environment = off)!!.startWithoutSteam)
|
||||
assertEquals(emptyMap<String, Map<String, String?>>(), off.games)
|
||||
}
|
||||
|
||||
@Test fun unknownSelectedAppIsIgnored() {
|
||||
assertNull(resolve(selectedAppId = 42))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Test
|
||||
|
||||
class SessionAchievementGameTest {
|
||||
private val installed = setOf(10L, 20L)
|
||||
|
||||
@Test fun exitingGameCannotRemainSelectedWithoutItsWindow() {
|
||||
assertNull(SessionAchievementGame.activeAppId(10, listOf(769), installed))
|
||||
}
|
||||
|
||||
@Test fun steamOverlayKeepsTheRunningGameSelected() {
|
||||
assertEquals(10L, SessionAchievementGame.activeAppId(769, listOf(769, 10), installed))
|
||||
}
|
||||
|
||||
@Test fun anotherForegroundAppCannotBorrowABackgroundGamesAchievements() {
|
||||
assertNull(SessionAchievementGame.activeAppId(30, listOf(30, 10), installed))
|
||||
}
|
||||
|
||||
@Test fun ambiguousBackgroundGamesDoNotPickAnArbitraryGame() {
|
||||
assertNull(SessionAchievementGame.activeAppId(769, listOf(769, 10, 20), installed))
|
||||
}
|
||||
|
||||
@Test fun theForegroundGameWinsWhenSeveralGamesAreRunning() {
|
||||
assertEquals(20L, SessionAchievementGame.activeAppId(20, listOf(769, 10, 20), installed))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.droiddeck.launcher.stores
|
||||
|
||||
import android.os.Looper
|
||||
import org.json.JSONObject
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.Shadows.shadowOf
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [33])
|
||||
class AchievementNotificationsTest {
|
||||
private val unlock = AchievementNotifications.Unlock("123", "first", "First Steps", "", null, "Hollow Valley")
|
||||
private fun drain() = shadowOf(Looper.getMainLooper()).idle()
|
||||
|
||||
@Before fun reset() { AchievementNotifications.begin("test"); drain() }
|
||||
|
||||
@Test fun duplicatesAndOldSessionEventsDoNotQueue() {
|
||||
AchievementNotifications.unlock("old", unlock)
|
||||
AchievementNotifications.unlock("test", unlock)
|
||||
AchievementNotifications.unlock("test", unlock.copy(name = "Repeated"))
|
||||
drain()
|
||||
assertEquals(listOf(unlock), AchievementNotifications.pending)
|
||||
}
|
||||
|
||||
@Test fun oldTeardownAndDismissCannotRemoveReplacementUnlock() {
|
||||
AchievementNotifications.unlock("test", unlock); drain()
|
||||
AchievementNotifications.begin("replacement")
|
||||
val replacement = unlock.copy(id = "second")
|
||||
AchievementNotifications.unlock("replacement", replacement)
|
||||
AchievementNotifications.end("test"); drain()
|
||||
AchievementNotifications.dismiss(unlock)
|
||||
assertEquals(listOf(replacement), AchievementNotifications.pending)
|
||||
AchievementNotifications.end("replacement"); drain()
|
||||
assertTrue(AchievementNotifications.pending.isEmpty())
|
||||
}
|
||||
|
||||
@Test fun burstIsBoundedAndKeepsOrder() {
|
||||
repeat(30) { AchievementNotifications.unlock("test", unlock.copy(id = "$it")) }; drain()
|
||||
assertEquals((0..15).map { "$it" }, AchievementNotifications.pending.map { it.id })
|
||||
AchievementNotifications.dismiss(AchievementNotifications.pending.first())
|
||||
assertEquals("1", AchievementNotifications.pending.first().id)
|
||||
}
|
||||
|
||||
@Test fun malformedEventsAndNonHttpsIconsAreRejected() {
|
||||
assertNull(AchievementNotifications.parse(JSONObject().put("client_id", "123"), ""))
|
||||
val event = JSONObject().put("client_id", "123").put("id", "first").put("name", "First Steps").put("icon", "file:///private/icon")
|
||||
assertNull(AchievementNotifications.parse(event, "Game")!!.icon)
|
||||
event.put("client_id", "null")
|
||||
assertNull(AchievementNotifications.parse(event, "Game"))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.droiddeck.launcher.stores
|
||||
|
||||
import com.droiddeck.launcher.session.SessionState
|
||||
import com.droiddeck.launcher.stores.gog.GogComet
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertEquals
|
||||
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 = [33])
|
||||
class GogCometGenerationTest {
|
||||
@After fun reset() {
|
||||
GogComet.end(SessionState.sessionId)
|
||||
SessionState.running = false
|
||||
SessionState.sessionId = null
|
||||
}
|
||||
|
||||
@Test fun anOldTeardownCannotDisableTheReplacementSession() {
|
||||
SessionState.running = true
|
||||
SessionState.sessionId = "old"
|
||||
GogComet.begin()
|
||||
SessionState.sessionId = "replacement"
|
||||
GogComet.begin()
|
||||
GogComet.end("old")
|
||||
val app = RuntimeEnvironment.getApplication()
|
||||
assertEquals("no-game", GogComet.prepare(app, "missing").getString("reason"))
|
||||
GogComet.end("replacement")
|
||||
assertEquals("no-session", GogComet.prepare(app, "missing").getString("reason"))
|
||||
}
|
||||
}
|
||||
@@ -74,6 +74,16 @@ class StoreGameSidecarTest {
|
||||
assertEquals(null, StoreGameSidecar.updateEpic(java.io.File(folder, "missing")) { it })
|
||||
}
|
||||
|
||||
@Test fun gogAchievementsAreIndependentOfCloudAndSurviveEdits() {
|
||||
val folder = java.io.File(org.robolectric.RuntimeEnvironment.getApplication().filesDir, "gog-achievements").apply { mkdirs() }
|
||||
StoreGameSidecar(Store.GOG, "1", "Game", "game.exe", cloud = false).write(folder)
|
||||
assertTrue(StoreGameSidecar.read(folder)!!.achievements)
|
||||
StoreGameSidecar.updateAchievements(folder, false)
|
||||
StoreGameSidecar.updateCloud(folder, true)
|
||||
assertFalse(StoreGameSidecar.read(folder)!!.achievements)
|
||||
assertTrue(StoreGameSidecar.read(folder)!!.cloud)
|
||||
}
|
||||
|
||||
@Test fun anInstallUnderWayHasNoExeYetAndIsNotInstalled() {
|
||||
val started = StoreGameSidecar(Store.EPIC, "Metalstorm", "Metalstorm", exe = "", state = StoreGameSidecar.STATE_INSTALLING)
|
||||
val back = StoreGameSidecar.parse(started.toJson().toString())!!
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.testTag
|
||||
import androidx.compose.ui.test.assertIsNotEnabled
|
||||
import androidx.compose.ui.test.onNodeWithTag
|
||||
import androidx.compose.ui.test.onNodeWithText
|
||||
import androidx.compose.ui.test.performClick
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.session.ComponentsManager
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Rule
|
||||
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])
|
||||
class ComponentDownloadsDrawerTest {
|
||||
@get:Rule val compose = createRobolectricComposeRule()
|
||||
|
||||
private val dxvk = item("dxvk-2.4.1-linux.wcp", "dxvk")
|
||||
private val stored = item("dxvk-2.3-linux.wcp", "dxvk")
|
||||
private val inFlight = item("dxvk-2.7.1-linux.wcp", "dxvk")
|
||||
private val fex = item("fex-2609-linux.wcp", "fex")
|
||||
|
||||
@Test fun choosingDxvkDownloadsTheCatalogItemAndPreventsStoredOrInFlightDownloads() {
|
||||
val requested = mutableListOf<ComponentsManager.CatalogItem>()
|
||||
show(downloads = mapOf(inFlight.file to 45), onDownload = requested::add)
|
||||
compose.onNodeWithTag("cmp-download-dxvk").performClick()
|
||||
compose.onNodeWithText(stored.file.removeSuffix(".wcp")).assertIsNotEnabled()
|
||||
compose.onNodeWithText(inFlight.file.removeSuffix(".wcp")).assertIsNotEnabled()
|
||||
compose.onNodeWithText(fex.file.removeSuffix(".wcp")).assertDoesNotExist()
|
||||
compose.onNodeWithText(dxvk.file.removeSuffix(".wcp")).performClick()
|
||||
assertEquals(listOf(dxvk), requested)
|
||||
compose.onNodeWithText(dxvk.file.removeSuffix(".wcp")).assertDoesNotExist()
|
||||
compose.onNodeWithText("45%").assertExists()
|
||||
}
|
||||
|
||||
@Test fun emptyCatalogOffersRefreshAndDisablesVersionChoicesWhileChecking() {
|
||||
var refreshes = 0
|
||||
show(catalog = emptyList(), checking = false, onRefresh = { refreshes++ })
|
||||
compose.onNodeWithTag("cmp-download-refresh").performClick()
|
||||
assertEquals(1, refreshes)
|
||||
compose.onNodeWithTag("cmp-download-dxvk").assertIsNotEnabled()
|
||||
compose.onNodeWithText(RuntimeEnvironment.getApplication().getString(R.string.comp_refresh_to_list)).assertExists()
|
||||
}
|
||||
|
||||
@Test fun catalogRefreshCannotBeStartedTwiceWhileChecking() {
|
||||
show(checking = true)
|
||||
compose.onNodeWithTag("cmp-download-refresh").assertIsNotEnabled()
|
||||
}
|
||||
|
||||
private fun show(
|
||||
catalog: List<ComponentsManager.CatalogItem> = listOf(dxvk, stored, inFlight, fex),
|
||||
downloads: Map<String, Int> = emptyMap(),
|
||||
checking: Boolean = false,
|
||||
onRefresh: () -> Unit = {},
|
||||
onDownload: (ComponentsManager.CatalogItem) -> Unit = {},
|
||||
) {
|
||||
compose.setContent {
|
||||
DroidDeckTheme {
|
||||
Column(Modifier.verticalScroll(rememberScrollState())) {
|
||||
ComponentDownloadsDrawerGroup(
|
||||
host = rememberMenuHost(), catalog = catalog, catalogAt = 0,
|
||||
checking = checking,
|
||||
packages = listOf(ComponentsManager.Package(stored.file, "dxvk", "2.3", "", 100)),
|
||||
downloads = downloads, onRefresh = onRefresh, onDownload = onDownload,
|
||||
track = { Modifier.testTag(it) },
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun item(file: String, comp: String) = ComponentsManager.CatalogItem(
|
||||
file, comp, "Nightlies", "https://github.com/example/$file", 100, "sha256:test",
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.EditText
|
||||
import androidx.compose.runtime.SideEffect
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalView
|
||||
import androidx.compose.ui.semantics.SemanticsActions
|
||||
import androidx.compose.ui.test.onNodeWithContentDescription
|
||||
import androidx.compose.ui.test.onNodeWithText
|
||||
import androidx.compose.ui.test.hasText
|
||||
import androidx.compose.ui.test.hasClickAction
|
||||
import androidx.compose.ui.test.assertIsNotFocused
|
||||
import androidx.compose.ui.test.performClick
|
||||
import androidx.compose.ui.test.performSemanticsAction
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.store.FlathubApi
|
||||
import com.droiddeck.launcher.store.StoreState
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Rule
|
||||
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], qualifiers = "w960dp-h540dp-land", application = android.app.Application::class)
|
||||
class FlathubFocusTest {
|
||||
@get:Rule val compose = createRobolectricComposeRule()
|
||||
|
||||
@After fun clearStore() {
|
||||
StoreState.sections.clear()
|
||||
StoreState.details.clear()
|
||||
StoreState.openRequest = null
|
||||
}
|
||||
|
||||
@Test fun openingAnAppReleasesTheCoveredNativeSearchField() {
|
||||
val id = "io.github.test.Datcord"
|
||||
StoreState.sections["popular"] = listOf(
|
||||
FlathubApi.AppSummary(id, "Datcord", "Discord client", "", null, false, 0),
|
||||
)
|
||||
StoreState.details[id] = FlathubApi.AppDetails(
|
||||
id, "Datcord", "Discord client", "", null, "", null, null, null,
|
||||
emptyList(), emptyList(), null, 0, 0, listOf("aarch64"),
|
||||
)
|
||||
lateinit var root: View
|
||||
val focus = FrontFocus()
|
||||
compose.setContent {
|
||||
DroidDeckTheme {
|
||||
val view = LocalView.current
|
||||
SideEffect { root = view.rootView }
|
||||
CompositionLocalProvider(LocalFrontFocus provides focus) {
|
||||
FocusGlideHost {
|
||||
Storefront(FrontEndState(
|
||||
installed = "r9", ready = true, available = null, busy = false, stage = "", percent = -1,
|
||||
desktopInstalled = true, offlineAccount = null, offline = false, frameGenLabel = "",
|
||||
romsDir = null, logsEnabled = false, steamGames = emptyList(), emulators = emptyList(), running = null,
|
||||
), FrontEndActions(
|
||||
onPlay = {}, onPlayDesktopUi = {}, onSteamGame = {}, onDesktop = {}, onEmulator = {},
|
||||
onRom = {}, onResume = {}, onSteamSettings = {}, onDesktopSettings = {},
|
||||
onInstallPackage = {}, onRemovePackage = {}, onRuntime = {}, onFrameGenPick = {},
|
||||
onImportLossless = {}, onProtons = {}, onComponents = {}, onPerformance = {},
|
||||
onRoms = {}, onFiles = {}, onLogs = {}, onOffline = {},
|
||||
onWirelessAdbPair = { _, _, _, _ -> }, onWirelessAdbApply = { _, _, _, _ -> },
|
||||
onSetPhantomProcessLimit = { _, _ -> },
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
val context = RuntimeEnvironment.getApplication()
|
||||
compose.onNodeWithContentDescription(context.getString(R.string.stores_search_open)).performClick()
|
||||
compose.waitForIdle()
|
||||
val field = editText(root)!!
|
||||
compose.runOnIdle {
|
||||
// Keep a nonempty query, so clearing focus cannot simply dispose the search field.
|
||||
// Whitespace skips the network search while retaining the field just like typed text.
|
||||
field.setText(" ")
|
||||
field.requestFocus()
|
||||
assertTrue(field.isFocused)
|
||||
}
|
||||
compose.waitForIdle()
|
||||
// Touching a card does not implicitly focus a Compose control or release an AndroidView.
|
||||
compose.onNodeWithText("Datcord").performSemanticsAction(SemanticsActions.OnClick) { it() }
|
||||
compose.onNodeWithText(context.getString(R.string.store_install)).assertExists()
|
||||
compose.runOnIdle {
|
||||
assertFalse("Covered search field must release focus", field.isFocused)
|
||||
assertEquals(" ", field.text.toString())
|
||||
focus.items.getValue("tile:store:$id").requestFocus()
|
||||
}
|
||||
compose.onNode(hasText("Datcord") and hasClickAction()).assertIsNotFocused()
|
||||
}
|
||||
|
||||
private fun editText(view: View): EditText? {
|
||||
if (view is EditText) return view
|
||||
if (view is ViewGroup) for (i in 0 until view.childCount) {
|
||||
editText(view.getChildAt(i))?.let { return it }
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,9 @@ import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
|
||||
class LiftSheetTest {
|
||||
@Test fun theSheetTopIs82dpDownA360dpPane() {
|
||||
assertEquals(82f, sheetTop(360f, 56f, 16f, 3f), 0.01f)
|
||||
assertEquals(164f, sheetTop(720f, 56f, 16f, 3f), 0.01f)
|
||||
@Test fun theSheetTopIs60dpDownA360dpPane() {
|
||||
assertEquals(60f, sheetTop(360f, 56f, 16f, 3f), 0.01f)
|
||||
assertEquals(120f, sheetTop(720f, 56f, 16f, 3f), 0.01f)
|
||||
}
|
||||
|
||||
@Test fun theButtonKeeps16dpAboveIt() {
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.runtime.SideEffect
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.snapshots.Snapshot
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.testTag
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.test.onNodeWithTag
|
||||
import androidx.compose.ui.test.onNodeWithText
|
||||
import androidx.compose.ui.test.performClick
|
||||
import androidx.compose.ui.unit.dp
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
// Render the component without starting runtime services or installing the app crash handler.
|
||||
@Config(sdk = [28], application = android.app.Application::class)
|
||||
class PresetScaleTest {
|
||||
@get:Rule val compose = createRobolectricComposeRule()
|
||||
|
||||
@Test fun presetPopupAndPageKeepTheScaleChosenInSetup() {
|
||||
val scale = mutableIntStateOf(100)
|
||||
val preset = mutableStateOf("PERFORMANCE")
|
||||
val open = mutableStateOf(false)
|
||||
compose.setContent {
|
||||
DroidDeckTheme(appScale = scale.intValue) {
|
||||
Box(Modifier.size(100.dp).testTag("page-size"))
|
||||
FexPresetChip(preset.value, false, open.value, true,
|
||||
onToggle = { open.value = true }, onDismiss = { open.value = false },
|
||||
onPick = { preset.value = it!! })
|
||||
}
|
||||
}
|
||||
val originalWidth = compose.onNodeWithTag("page-size").fetchSemanticsNode().boundsInRoot.width
|
||||
// Notify changes driven by the test before asking Compose to become idle again.
|
||||
compose.runOnIdle {
|
||||
scale.intValue = 75
|
||||
Snapshot.sendApplyNotifications()
|
||||
}
|
||||
compose.onNodeWithText("Performance").performClick()
|
||||
compose.onNodeWithText("Intermediate").performClick()
|
||||
compose.waitForIdle()
|
||||
assertEquals(originalWidth * 0.75f,
|
||||
compose.onNodeWithTag("page-size").fetchSemanticsNode().boundsInRoot.width, 1f)
|
||||
compose.runOnIdle {
|
||||
open.value = true
|
||||
Snapshot.sendApplyNotifications()
|
||||
}
|
||||
compose.onNodeWithText("Compatibility").performClick()
|
||||
compose.waitForIdle()
|
||||
assertEquals(originalWidth * 0.75f,
|
||||
compose.onNodeWithTag("page-size").fetchSemanticsNode().boundsInRoot.width, 1f)
|
||||
}
|
||||
|
||||
@Test fun menuUsesItsAnchorsDensity() {
|
||||
var pageDensity = 0f
|
||||
var menuDensity = 0f
|
||||
compose.setContent {
|
||||
DroidDeckTheme(appScale = 75) {
|
||||
val density = LocalDensity.current.density
|
||||
SideEffect { pageDensity = density }
|
||||
AnchoredMenu(true, onDismiss = {}) {
|
||||
val popupDensity = LocalDensity.current.density
|
||||
SideEffect { menuDensity = popupDensity }
|
||||
MenuItem("Preset", false) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
compose.waitForIdle()
|
||||
assertEquals(pageDensity, menuDensity, 0f)
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.droiddeck.launcher.ui
|
||||
import android.content.ComponentName
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.compose.ui.test.junit4.createComposeRule
|
||||
import androidx.compose.runtime.snapshots.Snapshot
|
||||
import org.robolectric.RuntimeEnvironment
|
||||
import org.robolectric.Shadows.shadowOf
|
||||
|
||||
@@ -12,4 +13,7 @@ fun createRobolectricComposeRule() = createComposeRule().also {
|
||||
shadowOf(context.packageManager).addActivityIfNotPresent(
|
||||
ComponentName(context, ComponentActivity::class.java),
|
||||
)
|
||||
// Pure state tests can leave unapplied snapshots before a Compose host starts its snapshot
|
||||
// manager. Apply them before the rule's initial idle check, which runs before the test body.
|
||||
Snapshot.sendApplyNotifications()
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Test
|
||||
|
||||
class StoreGridNavigationTest {
|
||||
@Test fun downAndUpPreserveEveryColumnAcrossSeveralRows() {
|
||||
for (columns in 1..6) for (index in 0 until columns * 3) {
|
||||
val down = storeGridNeighbor(index, columns * 4, columns, 1)!!
|
||||
assertEquals(index % columns, down % columns)
|
||||
assertEquals(index, storeGridNeighbor(down, columns * 4, columns, -1))
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun incompleteLastRowDoesNotWrapBackToTheLeft() {
|
||||
assertEquals(8, storeGridNeighbor(4, 10, 4, 1))
|
||||
assertEquals(9, storeGridNeighbor(5, 10, 4, 1))
|
||||
assertNull(storeGridNeighbor(6, 10, 4, 1))
|
||||
assertNull(storeGridNeighbor(7, 10, 4, 1))
|
||||
assertNull(storeGridNeighbor(9, 10, 4, 1))
|
||||
}
|
||||
|
||||
@Test fun firstRowCanLeaveUpwardsAndChangedColumnCountsAreUsed() {
|
||||
assertNull(storeGridNeighbor(2, 10, 4, -1))
|
||||
assertEquals(5, storeGridNeighbor(2, 10, 3, 1))
|
||||
assertEquals(6, storeGridNeighbor(2, 10, 4, 1))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
# Comet integration research and implementation plan
|
||||
|
||||
Researched 2026-10-12 against DroidDeck `10ef8c4bd62b21872fc13382a808cb0f2f117b26` (0.4.0).
|
||||
The research below informed the implementation on `feat/gog-comet-achievements`, rebased onto refreshed main `a2a9586b`. Controlled SDK unlock/upload has now been verified on Thor; wider gameplay coverage remains an acceptance test for users.
|
||||
|
||||
## Implementation and testing status
|
||||
|
||||
Implemented an opt-in GOG companion built from pinned Comet v0.3.2, credential transfer through stdin, one owned daemon per session/account, private persistent databases, per-game settings, and first-launch Galaxy service provisioning using the selected Proton. Local unlocks, pending uploads and successful uploads produce sanitized session events. The game settings card shows pending/uploaded/unavailable status for the companion in the current session; it is not a per-game achievement history. Local unlocks now show an animated DroidDeck notification with the achievement icon, name and game title. The achievement reader comes from main; upload acknowledgements refresh its progress. No Galaxy overlay is installed. The session-menu reader is available only for a live supported GOG/Epic game window with a nonempty achievement list, including while Steam's overlay is open; GOG browsing does not require Comet syncing to be enabled. Epic syncing remains a separate investigation.
|
||||
|
||||
Comet's patch also uses an unconditional periodic sync tick during SDK traffic, preserves retries after failed achievement POSTs, and limits SDK clients to enabled installed GOG games. Credential errors and raw upstream protocol output are not forwarded to Android/session logs.
|
||||
|
||||
Validation on AYN Thor (`192.168.0.8:38029`, Linux runtime r9):
|
||||
|
||||
- ARM64 companion runs and receives credentials through proot stdin; owned readiness occurs in under a second.
|
||||
- A fresh disposable prefix installs the x64 dummy service through ARM64 Proton/FEX before its first launch.
|
||||
- ELDERBORN (GOG product `1732383191`) launches through the normal managed Steam shortcut. Its Galaxy SDK authentication and 27 achievement definitions can be read through Comet, and independently from GOG's gameplay API.
|
||||
- Normal session stop removes the owned companion and preserves its database.
|
||||
- Release APK builds; 694 JVM tests pass and all 20 store-launch tests pass.
|
||||
- Linux Docker suite: 548 tests, 518 pass, 29 skipped, one failure in the unchanged x86 SIGILL fault-report test (Docker reports `si_code 01`, assertion expects `02`). This is an environment-dependent mismatch, not a green full-suite result.
|
||||
|
||||
The reader updated from 0/27 to 1/27 and back after upload/reset without reopening. A temporary protocol probe unlocked locked ELDERBORN achievements after twenty seconds, repeated the SDK request, confirmed the new unlock independently through the GOG gameplay API, and cleared each tested achievement afterward. The notification appeared once over the focused game and dismissed after five seconds. A temporary per-app HTTPS rejection confirmed a local popup, pending upload, and successful retry after the rule was removed; the account records and network rule were restored. Account changes with pending data, first-ever offline launches, 32-bit titles, and wider game/Proton compatibility still need user testing. A current Steam live-shortcut API mismatch required restarting Steam after installing the test game; the normal startup shortcut worked. That existing issue is outside this change.
|
||||
|
||||
## User test guide
|
||||
|
||||
1. Sign into GOG and enable **GOG achievements** in Stores settings. It is off by default. Keep the game's own achievement switch enabled in its launch settings; cloud saves may be on or off.
|
||||
2. Start a supported GOG game using a DroidDeck managed compatibility tool. Obtain a genuinely unearned achievement through normal gameplay.
|
||||
3. Check the game's GOG profile independently. Allow at least ten seconds online and a normal game exit. A local unlock should show a five-second notification over the game. The popup confirms the local unlock; check the GOG profile or the uploaded event for server delivery.
|
||||
4. Include the game/product ID, device, Proton choice, whether the prefix was new, and online/offline sequence with the session report. The `gog.achievements` events distinguish `unlocked-locally`, `pending-upload` and `uploaded`; `uploaded` is emitted only after a successful GOG POST. Do not include credentials.
|
||||
5. If the game has trouble with the companion, disable its achievement switch and relaunch. Changes to these switches apply on the next game launch.
|
||||
|
||||
## Recommendation and scope
|
||||
|
||||
Integrate Comet as a native ARM64 Linux companion for **GOG Galaxy achievements** inside DroidDeck's existing Linux/Proton session. Start with an opt-in GOG setting and a per-game disable switch. Cover launches from Games, Stores, Android shortcuts, Steam's own Play button, and KDE when those paths use DroidDeck's managed compatibility tool.
|
||||
|
||||
Comet handles the Galaxy SDK requests made by a game and uploads achievements to that game's GOG account. It does not transfer achievements between storefronts, add achievements to games without Galaxy SDK support, or implement Epic achievement sync. [Comet README](https://github.com/imLinguin/comet/blob/19b32597019ea1e64f1916010441960bcaac6e49/README.md)
|
||||
|
||||
Treat the screenshot as two workstreams:
|
||||
|
||||
| Request | Approach | Initial deliverable |
|
||||
| --- | --- | --- |
|
||||
| GOG achievements | Comet + existing GOG sign-in + Proton prefix setup | An unlock reaches the correct GOG profile from a real DroidDeck launch |
|
||||
| Epic achievements | Validate the game's EOS authentication, deployment, consent and achievement calls | Evidence of an EOS unlock and the corresponding Epic profile update; fixes only where a failure is demonstrated |
|
||||
|
||||
Epic Games Store achievements are linked to EOS achievements in a game-specific deployment. A generic launcher service cannot create that integration for a title. DroidDeck already supplies EOS identity/deployment arguments and a fresh exchange code. [Epic achievement setup](https://dev.epicgames.com/docs/epic-games-store/services/epic-achievements/achievements-setup), [Epic authentication guide](https://dev.epicgames.com/docs/epic-online-services/accounts-and-social/eos-epic-account-services/auth-interface/auth-guide/auth-intro)
|
||||
|
||||
## What was verified
|
||||
|
||||
- Local `main` fast-forwarded from `b6c1d3c0` to `10ef8c4b` and matched refreshed `origin/main`.
|
||||
- Removed seven clean, remotely backed checkouts with non-force `git worktree remove`; pruned nine registrations pointing to missing directories. Kept dirty worktrees, open-PR work, credentials, captures, and uncertain checkouts. Remote branches and PRs were not changed.
|
||||
- Inspected Comet release `v0.3.2` (`3d7488ee72f83b7e8462a70fd4c4638d6da71360`) and upstream main (`19b32597019ea1e64f1916010441960bcaac6e49`). Main has substantial unreleased changes, including progress-stat workarounds. Use a pinned release as the initial baseline; evaluate later changes individually.
|
||||
- Downloaded `comet-aarch64-unknown-linux-gnu` and `dummy-service.zip` from v0.3.2. ELF inspection confirmed AArch64, interpreter `/lib/ld-linux-aarch64.so.1`, dependencies on `libgcc_s`, `libm`, `libc` and the loader, and required GLIBC symbols through 2.34. Binary size is 11,365,728 bytes, before APK compression.
|
||||
- The current Linux runtime catalog is `linuxfs-r9`, described as Arch Linux ARM aarch64. This is separate from the Debian image used for x86 preload builds. Actual loader/library compatibility must still be checked in the installed runtime.
|
||||
- Inspected Heroic main `db5272043e74336b72bc60caad14ca74701082d8`: its GOG launcher spawns Comet with `--from-heroic --username ... --quit`, then terminates it after the game. That establishes a reference integration, but its process and credential handling should not be copied wholesale.
|
||||
|
||||
Downloaded artifact hashes, useful for reproducing this inspection:
|
||||
|
||||
```text
|
||||
comet-aarch64-unknown-linux-gnu
|
||||
c8cd850a03ba66c10bf620eee2735946ddf0b5969cd38cae02c6bede6d15c5b8
|
||||
dummy-service.zip
|
||||
7fc5facd1fce4d516cd3ce527e7e4dbe0bfd17649cea805e8ea7c37d4ba58d9a
|
||||
```
|
||||
|
||||
These are locally measured hashes, not independently signed upstream attestations. A patched build will have different hashes.
|
||||
|
||||
## Existing DroidDeck integration points
|
||||
|
||||
| Source | Existing behavior | Proposed change |
|
||||
| --- | --- | --- |
|
||||
| `stores/gog/GogAuth.kt`, `stores/LoginFlows.kt` | Saves access token, optional refresh token/user ID, username; refreshes expired access tokens | Add a validated Comet credential snapshot, recover missing identity where possible, serialize refresh and sign-out |
|
||||
| `stores/StoreAccounts.kt`, `stores/CredentialCipher.kt` | Keeps store credentials encrypted with Android Keystore | Keep these as the durable credential authority; do not export a persistent Heroic auth file |
|
||||
| `stores/StoreLaunchRequests.kt` | App-side request handler under the session's `stores/req` and `stores/resp` | Handle GOG companion preparation; ordinary replies contain status, not tokens |
|
||||
| `tools/linuxfs/overlay/usr/local/bin/droiddeck-store-launch` | Finds sidecars beside a launcher or ancestor of a direct `.exe`; runs before managed Proton launches | Detect GOG settings, request companion readiness and arrange prefix setup, independently of cloud saves |
|
||||
| `tools/linuxfs/overlay/usr/local/bin/steam-compatibility` | Generates compatibility wrappers; waits for Proton and calls `--exited` when cloud saves are enabled | Generalize post-game handling so achievements still get lifecycle handling with cloud saves disabled |
|
||||
| `session/SessionService.kt`, `session/SessionFiles.kt` | Stages session helpers, starts request observation and tears down the guest | Own the companion's session identity and cleanup; request graceful shutdown before guest teardown |
|
||||
| `stores/StoreGameSidecar.kt`, `stores/gog/GogPrefs.kt` | Persist game and store settings | Add backward-compatible GOG achievement settings; keep game tokens out of sidecars |
|
||||
| `app/build.gradle`, `tools/build_local.sh`, `.github/workflows/build.yml`, `tools/release/runtime_inputs.py` | Prepare, cache and attest runtime assets | Include pinned Comet binary, service tools, licenses and build inputs in both local and CI APK paths |
|
||||
|
||||
Paths above are under `app/src/main/java/com/droiddeck/launcher/` unless fully qualified.
|
||||
|
||||
`ComponentsManager.kt` manages FEX/DXVK/VKD3D packages. Comet should initially be an internal runtime asset rather than an additional graphics-component type.
|
||||
|
||||
## Proposed architecture
|
||||
|
||||
### 1. Package a pinned companion
|
||||
|
||||
Build from Comet v0.3.2 with a small, reviewable patch set and its protocol submodule pinned. Put the executable and dummy-service tools under a dedicated guest directory such as `/usr/local/lib/droiddeck-comet/`. Ship the Apache-2.0 license and attribution. Add a `tools/comet/` build recipe and source/patch/hash metadata using the existing prepared-runtime conventions.
|
||||
|
||||
Keep the current upstream ARM64 asset as the initial compatibility probe. The production build needs the credential and logging changes below. Ensure the Rust/toolchain baseline supports the pinned release and that CI cache keys and runtime attestation include the new inputs. Exercise cached and uncached builds, plus runtime installation into an existing app installation.
|
||||
|
||||
### 2. Hand off credentials without putting them in command lines
|
||||
|
||||
Comet's real CLI uses `--access-token`, `--refresh-token`, `--user-id`, and `--username`; the README contains outdated spellings. These flags put tokens in process arguments. `--from-heroic` reads a plaintext Heroic auth file, and its Linux parser uses `XDG_CONFIG_PATH`, not the usual `XDG_CONFIG_HOME`. Neither is the preferred production handoff. [CLI source](https://github.com/imLinguin/comet/blob/3d7488ee72f83b7e8462a70fd4c4638d6da71360/src/main.rs), [Heroic import source](https://github.com/imLinguin/comet/blob/3d7488ee72f83b7e8462a70fd4c4638d6da71360/src/import_parsers/heroic.rs)
|
||||
|
||||
Add a small Comet credential-input option that accepts JSON over stdin or an inherited file descriptor. The Android-owned supervisor launches Comet through the existing proot command builder, writes one validated snapshot into its stdin, closes it, and tracks the process. Prove this pipe survives the proot setup before committing to the plumbing; if it does not, use a short-lived private mode-600 file with immediate unlink and startup cleanup.
|
||||
|
||||
The snapshot needs a usable access token, refresh token, numeric GOG user ID and username. Existing logins may lack refresh token or user ID: current `saveLogin` accepts both as optional and only saves the username from its user-data lookup. Recover identity through GOG's authenticated user endpoint where possible. If no refresh token exists, show a specific GOG re-sign-in requirement and let the game launch without achievement support.
|
||||
|
||||
Comet exchanges the Galaxy refresh token for each game's SDK client credentials; the game's SDK handshake supplies its client ID/secret. Do not confuse the store product ID with the SDK client ID, and do not require those per-game secrets in a store sidecar. Explicit offline preloading is a separate case and can wait.
|
||||
|
||||
Patch or sanitize Comet's HTTP error logging as well: token requests encode credentials in URLs, and raw `reqwest` errors can include those URLs. Filter before stderr reaches session logs, crash reports, or exported artifacts. Passing secrets through stdin alone is insufficient. [Token exchange source](https://github.com/imLinguin/comet/blob/3d7488ee72f83b7e8462a70fd4c4638d6da71360/src/api/gog/users.rs)
|
||||
|
||||
### 3. One owned daemon for the session/account
|
||||
|
||||
Comet binds `127.0.0.1:9977`. Proot does not provide a private network namespace. Use a serialized ensure-running operation for one owned daemon per active session/account, shared by GOG games in that session. Verify process identity, session generation and GOG account before reuse; an occupied port is not proof that our daemon is ready. If another service owns the port, report unavailable and continue launching the game.
|
||||
|
||||
Prefer session ownership over `--quit`: upstream's idle quit requires a client to have connected, so games without Galaxy can leave it running indefinitely. Explicit lifecycle ownership also avoids stopping it while another GOG client is active. Readiness should come from the owned process's listening event plus liveness, with a bounded wait; a probe connection has side effects on Comet's client/idle accounting.
|
||||
|
||||
Give Comet a persistent, private data location outside the session request tree and game directory through process-local XDG settings. Upstream stores gameplay databases by `<SDK client ID>/<user ID>/gameplay.db`. Preserve these databases across session resets and APK updates. Stop the old daemon on sign-out/account change, retain pending data under the old account, and never upload it using the replacement account. Provide explicit data deletion separately from sign-out.
|
||||
|
||||
### 4. Provision the game's actual Wine prefix on its first launch
|
||||
|
||||
Some Galaxy SDK versions need the Windows `GalaxyCommunication` service even though Comet itself runs on Linux. The release ZIP contains `GalaxyCommunication.exe`, `install-dummy-service.bat`, and `update-permissions.exe`; packaging only the standalone service executable misses part of upstream's setup. [Dummy-service instructions](https://github.com/imLinguin/comet/blob/3d7488ee72f83b7e8462a70fd4c4638d6da71360/dummy-service/README.md)
|
||||
|
||||
Use the title's selected Proton build and `STEAM_COMPAT_DATA_PATH`, not a global prefix. After Proton has created/updated that prefix, copy the tools into the prefix and idempotently register the service with `sc`, including the upstream permission adjustment where necessary. Preserve an existing genuine Galaxy installation or service. Record completion only after service verification, with a versioned marker so tool updates can be applied safely.
|
||||
|
||||
This is an explicit first-launch problem: the existing `droiddeck-store-launch` runs before Proton creates a new prefix, and several existing registry helpers defer until a later launch. Add a guarded bootstrap/prelaunch stage using the selected Proton, prevent recursive store preparation, wait for its wineserver as needed, then register the service before starting the game. Do not accept "works on the second launch" as completion.
|
||||
|
||||
Test PE x64 service tools through DroidDeck's ARM64 Proton/FEX path and at least one 32-bit Galaxy game. Architecture fit of the Linux daemon does not prove the Windows helpers work.
|
||||
|
||||
### 5. Keep sync and teardown honest
|
||||
|
||||
Upstream persists changed achievements in SQLite, has a sync branch after ten seconds without another selected event, and performs a final sync when a client handler ends. This is not an unconditional ten-second timer or a guarantee of server delivery. Failed achievement PUTs retain database `changed` markers, but the examined sync routine clears its in-memory update flag after processing even when an individual upload fails. Require a targeted retry test and a narrow fix if it confirms that no retry occurs while the client remains connected. [Handler source](https://github.com/imLinguin/comet/blob/3d7488ee72f83b7e8462a70fd4c4638d6da71360/src/api/handlers.rs)
|
||||
|
||||
Allow disconnect/final sync before daemon shutdown, then use SIGINT (upstream explicitly handles Ctrl-C) with a bounded grace period. Add shutdown handling before `SessionService` tears down proot; adding it only to `finishSessionStop` is too late. Forced termination must leave durable pending data for the next valid game connection. Avoid promising a headless "sync everything" action: upstream's pending data is game-scoped and its CLI does not expose that operation.
|
||||
|
||||
Offline support depends on prior metadata/cache availability. First-ever offline starts are not guaranteed. Test cached offline unlocks, reconnection in the same launch, next online launch, forced stop, and app updates. Preserve both local dirty unlocks and unlocks made on another machine during reconciliation. [Offline issue](https://github.com/imLinguin/comet/issues/16)
|
||||
|
||||
### 6. Keep the first UI small
|
||||
|
||||
Add an opt-in **GOG achievements** setting and a per-game override. Keep this independent of the cloud-save toggle. Show actionable states such as sign-in needed, service unavailable, and connection established; distinguish local unlocks from uploads actually accepted by GOG. Include redacted diagnostics in the existing session report.
|
||||
|
||||
Defer a unified achievement browser, Android unlock toasts, GOG overlay downloads/injection, leaderboards UI, multiplayer and playtime claims. Upstream can implement more than achievements, but those features require their own validation. Comet itself downloads Galaxy peer redists in the background, so measure that network/cache behavior before deciding whether to defer or package it.
|
||||
|
||||
Keep a per-game escape hatch: upstream has reports of incompatible games and crashes when Comet is enabled, including [Rise of the Tomb Raider](https://github.com/imLinguin/comet/issues/80) and [unhandled message type 43](https://github.com/imLinguin/comet/issues/90). These are reports, not reproduced DroidDeck failures.
|
||||
|
||||
## Implementation order and acceptance gates
|
||||
|
||||
1. **Compatibility spike:** run the pinned ARM64 daemon's `--help` in the installed Thor runtime; prove localhost connectivity from Wine, proot stdin handoff and first-prefix dummy-service setup. Use a known Galaxy-achievement game owned by the test account. Do not change graphics or download behavior to mask a Comet failure.
|
||||
2. **Build and credential foundation:** add reproducible assets, license notices, stdin/FD input, credential validation, refresh serialization and log redaction. Verify cached and uncached APK asset preparation.
|
||||
3. **Launch and lifecycle integration:** add the serialized session supervisor, GOG prepare operation, first-launch prefix provisioning, persistent databases, sign-out handling and shutdown before guest teardown. Verify cloud-off still retains achievement lifecycle handling.
|
||||
4. **Settings and targeted coverage:** add opt-in and per-game override, useful status, request timeout/error cases, process reuse/conflict cases, database preservation, and fake-secret leak checks. Extend `tools/tests/test_store_launch.py`, `test_store_shortcuts.py`, `test_game_environment.py`, `test_runtime_inputs.py` and relevant JVM tests rather than duplicating unrelated suites.
|
||||
5. **Device acceptance:** verify an actual unlock appears on the correct GOG profile, then launch the same game twice and another game in a different prefix. Cover Steam Play, app launch, KDE, internal/SD installs, service-required and service-free titles, cloud-off, offline/reconnect, transient upload failure, suspend/resume, normal exit, drawer Stop, force stop, account change and app update. Record exact APK/runtime/Proton versions.
|
||||
|
||||
For the initial spike, use an upstream-listed service-free title such as Hollow Knight and a service-required title such as Cuphead, subject to ownership and the current installed build. The [compatibility table](https://github.com/imLinguin/comet/blob/19b32597019ea1e64f1916010441960bcaac6e49/docs/wiki/Game-Compatibility.md) is a starting point, not a DroidDeck compatibility guarantee.
|
||||
|
||||
A first GOG PR should include the complete minimal path through packaging, authentication, first launch, sync and teardown. Split Epic into a separate investigation/PR so a GOG success is not presented as fulfilling the Epic half of the request.
|
||||
|
||||
## Epic investigation
|
||||
|
||||
Choose a game with published Epic Games Store achievements and an easy unearned achievement. Establish current behavior before adding code: verify the exchange code, expected production sandbox/deployment, browser consent completion and successful EOS Auth/Connect identity. Observe the game's EOS achievement callback and verify the Epic profile independently.
|
||||
|
||||
Current `droiddeck-store-launch` deliberately removes an old `HKCU\Software\Epic Games\EOS\OverlayPath` because that overlay setup caused a launch exit. Do not blindly restore it or globally replace game EOS DLLs. Determine whether the selected title needs additional EOS redistributable/overlay support, and reproduce any missing authentication or unlock behavior before patching. Sync, profile visibility and notification overlays are separate acceptance criteria.
|
||||
|
||||
## Remaining uncertainties
|
||||
|
||||
The original research was static. The implementation validation and remaining device acceptance tests are recorded above; controlled GOG SDK unlock/upload and failed-upload retry are verified; Epic EOS behavior remains unverified. Forced Android process teardown, account replacement with pending data, and wider real-game coverage remain acceptance tests.
|
||||
|
||||
Additional source: [Heroic GOG launch integration](https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher/blob/db5272043e74336b72bc60caad14ca74701082d8/src/backend/storeManagers/gog/games.ts), [Comet v0.3.2 release](https://github.com/imLinguin/comet/releases/tag/v0.3.2).
|
||||
@@ -0,0 +1,202 @@
|
||||
# HelixSR integration plan
|
||||
|
||||
Status: research only, nothing tested on the Thor yet. Reviewed 2026-10-13 against HelixSR 1.9.0
|
||||
(pre-release, 2026-10-13) and 1.8.1 (latest stable).
|
||||
|
||||
## What HelixSR is
|
||||
|
||||
[HelixSR](https://github.com/lonewolf0622/HelixSR) runs NVIDIA's DLSS "Model E" super-resolution
|
||||
network as plain D3D12 compute shaders (cs_6_6, 16-bit types, wave intrinsics), so it needs no
|
||||
Tensor Cores and no NVIDIA driver. It is built for AMD RDNA on Proton and Windows. It works like
|
||||
DLSS: it uses DLSS jitter and render sizes and offers every mode from DLAA to Ultra Performance.
|
||||
It does super resolution only, with no frame generation of its own.
|
||||
|
||||
- **Closed source.** It ships under the HelixSR Freeware License: you may run it and redistribute
|
||||
it unmodified and complete, but you may not modify, decompile or disassemble it. The setup
|
||||
scripts are readable but fall under the same license (scripts up to 1.8.1 are Apache 2.0).
|
||||
- **No NVIDIA material in the download.** The setup downloads NVIDIA's `nvngx_dlss.dll` 310.7.0
|
||||
from `github.com/NVIDIA/DLSS`, after asking and with a pinned SHA-256. It then pulls the PTX
|
||||
kernels and weights out of it, translates PTX to HLSL (`ptx2hlsl.py`) and compiles them with
|
||||
DXC. The result is embedded in HelixSR's DLL. **The built DLL contains NVIDIA's network and
|
||||
must never be redistributed**, so DroidDeck cannot ship a ready-made one. It has to be built on
|
||||
the device.
|
||||
- **Three ways into a game** (`setup/helixsr_install.py`):
|
||||
- **f**: replaces the game's FSR 3.1 DLL (`amd_fidelityfx_upscaler_dx12.dll` /
|
||||
`amd_fidelityfx_dx12.dll`) and keeps the original as `*.original.dll`. Select **AMD FSR** in
|
||||
the game.
|
||||
- **o**: installs the official OptiScaler 0.9.4 (as `dxgi.dll` and similar) with its FSR 3.1
|
||||
backend pointed at HelixSR. Select **DLSS**, XeSS or FSR 2 in the game.
|
||||
- **d** (experimental): installs a `dxgi.dll` loader plus HelixSR as `nvngx.dll`. The loader
|
||||
spoofs an NVIDIA GPU and answers the DLSS signature check.
|
||||
|
||||
Everything replaced goes to `HelixSR/backup`, and uninstall puts it back.
|
||||
- **Runtime knobs:** `helixsr.ini` next to the DLL (`[Upscaling] Int8`, `NetworkResolution`,
|
||||
`UpscaleFilter`; `[Sharpening]`; `[Compatibility] WaveSize`), and the environment variable
|
||||
`HELIXSR_INT8`. It writes `helixsr.log` next to the DLL.
|
||||
- **Cost on the developer's BC-250** (RDNA1 at 2 GHz): 1.13 ms for 720p→1080p Quality and
|
||||
0.75 ms for 360p→1080p Ultra Performance.
|
||||
|
||||
## The Adreno state of the art (the video)
|
||||
|
||||
The video, ["DLSS on Adreno | HelixSR Tested on Odin 3"](https://youtu.be/ZW670_3U7bE) (blackheart909,
|
||||
2026-10-12), shows an **unofficial HelixSR 1.8.0 adaptation** running on an Odin 3 (Adreno 830)
|
||||
under Armada Linux, through the FSR 3 slot. PRAGMATA works, with a "performance hit" its author
|
||||
says still needs optimising, and slow startup and loading. Witcher 3 shows black flickering on
|
||||
fast camera moves that is still unsolved. The description says the Thor/Android port "has not been
|
||||
verified running".
|
||||
|
||||
How their port works ([HelixSR-Snapdragon-V762](https://github.com/dawoodtogoo2020-code/HelixSR-Snapdragon-V762),
|
||||
[HelixSR-Decky-Armada](https://github.com/dawoodtogoo2020-code/HelixSR-Decky-Armada)):
|
||||
|
||||
1. They run HelixSR 1.8.0 in a probe under Proton ARM64 with vkd3d-proton (`44cf7c2`), and dump the
|
||||
SPIR-V for four kernels with `VKD3D_SHADER_DUMP_PATH`.
|
||||
2. They rewrite that SPIR-V so that wave32 logic runs on a physical 64-lane subgroup. Bindless CBV
|
||||
accesses are split into subgroup-uniform loads, because two logical waves now share one
|
||||
subgroup and the CBV index is no longer uniform across it.
|
||||
3. They install the rewritten shaders as runtime overrides. The pipeline is pinned by hash to
|
||||
1.8.0. Users must provide the "private" dumps themselves, and the README says the extraction
|
||||
is not clean yet.
|
||||
|
||||
The HelixSR author allowed this in [issue #3](https://github.com/lonewolf0622/HelixSR/issues/3).
|
||||
|
||||
**Why we probably do not need any of that:** Adreno has no wave32. Turnip's subgroup sizes are 64
|
||||
and 128, so 1.8.x's `[WaveSize(32)]` kernels cannot run as written. **1.9.0 fixes this upstream
|
||||
for Vega:**
|
||||
|
||||
- The setup now builds every kernel twice, once as `[WaveSize(32)]` and once as `[WaveSize(64)]`
|
||||
(the `_w64` variants, with cross-lane reads through LDS on `k5*`, `k7`, `k9`–`k11`).
|
||||
- At run time the DLL probes the device's lane range. Its log strings include "device lanes
|
||||
%u..%u" and "the GPU has no wave32 ... every kernel at 64 lanes".
|
||||
- `[Compatibility] WaveSize = 64` forces the 64-lane path.
|
||||
|
||||
On vkd3d-proton over Turnip, `WaveLaneCountMin` should come back as 64, so **unmodified 1.9.0
|
||||
should choose wave64 for every kernel by itself**. That would make the SPIR-V patching and its
|
||||
CBV-split workaround unnecessary. It should also remove the most likely cause of the Witcher 3
|
||||
flicker, which is 32-on-64 emulation. This is the first thing to verify on the device (Phase 0).
|
||||
|
||||
## Fit with DroidDeck
|
||||
|
||||
| HelixSR needs | DroidDeck today |
|
||||
| --- | --- |
|
||||
| D3D12 + SM 6.6, 16-bit types, `WaveSize(64)` → `VK_EXT_subgroup_size_control` | vkd3d-proton per Proton build, `VKD3D_SHADER_MODEL=6_9` / FL `12_2` by default; Turnip a7xx (subgroup 64..128, fp16) |
|
||||
| Python 3 + numpy to build the network | Debian arm64 rootfs already has `python3` (`droiddeck-game-env` is Python); numpy is one apt package |
|
||||
| `launch_synth` (prebuilt only for x86-64 Linux and Windows) | Build it from the shipped `model.cpp` with arm64 `g++` (the setup does this itself when no prebuilt runs), or run the x86 one under FEX |
|
||||
| DXC (the setup runs the Windows `dxc.exe` through Proton's Wine) | Either Windows DXC through our ARM64 Proton plus FEX (slow but no new code), or an aarch64 Linux `dxc` built in our CI from Microsoft's MIT/NCSA source (fast, preferred) |
|
||||
| `nvngx_dlss.dll` 310.7.0 (or 310.2) | Download from NVIDIA after user consent, or reuse a copy already in an installed game (`--dlss <path>`), like `Lossless.kt` reuses Steam's `Lossless.dll` |
|
||||
| Per-game DLL placement + `WINEDLLOVERRIDES` for `dxgi`-named OptiScaler / loader | Per-game profiles, launch wrapper `droiddeck-game-env` that already stages component files before Proton starts |
|
||||
| Somewhere to turn it on | Components page (packages) + per-game Game environment profile |
|
||||
|
||||
`setup/helixsr-setup.sh` refuses to run on anything but x86-64 (`uname -m`), and we may not modify
|
||||
it. So **DroidDeck drives `setup/helixsr_setup.py` directly**, the same way the `.sh` does. That
|
||||
counts as running the scripts, not modifying them:
|
||||
|
||||
```
|
||||
python3 setup/helixsr_setup.py <OUT_DIR> --yes --dxc <dxc> [--dlss <nvngx_dlss.dll>]
|
||||
```
|
||||
|
||||
## Plan
|
||||
|
||||
### Phase 0: feasibility on the Thor (manual, needs the device)
|
||||
|
||||
Goal: find out whether stock 1.9.0 runs on Adreno 740, what it costs, and whether it looks right,
|
||||
before any app code is written.
|
||||
|
||||
1. In the rootfs:
|
||||
- `apt install python3-numpy g++`.
|
||||
- Get DXC: start with Windows `dxc.exe` through ARM64 Proton, and time it against an aarch64
|
||||
`dxc` built on the Mac with Docker.
|
||||
- Run `helixsr_setup.py` with `--dlss` pointing at a 310.7.0 DLL. Record wall time, peak RAM
|
||||
and thermals.
|
||||
2. Install by hand into one FSR 3.1 game using the **f** way. PRAGMATA is a good first pick
|
||||
because the video has a reference.
|
||||
3. Read `helixsr.log`:
|
||||
- The `wave size:` line should say `device lanes 64..128 ... network kernels wave64`.
|
||||
- Note the `int8 network:` line. Qualcomm is probably "no fast int8". Try `HELIXSR_INT8=1`,
|
||||
since a7xx Turnip exposes `VK_KHR_shader_integer_dot_product`.
|
||||
4. Measure the upscale pass with the Perf HUD at 1080p output in Quality, Performance and Ultra
|
||||
Performance, and compare against the game's own FSR 3.1. Back-of-envelope: Adreno 740 has about
|
||||
a third of the BC-250's fp16 throughput and about a seventh of its memory bandwidth, so expect
|
||||
**roughly 4–10 ms** at 720p→1080p. Ultra Performance or Performance mode may be the only
|
||||
practical ones on the Thor.
|
||||
5. Repeat with Witcher 3 (the DLSS game in the video) using the **o** way, to test OptiScaler under
|
||||
our Proton/FEX and to check the flicker.
|
||||
6. If the kernels fail, gather `VKD3D_SHADER_DUMP_PATH` dumps and the vkd3d log. Failures are
|
||||
driver bugs we can fix in our own Turnip or vkd3d builds, not HelixSR bugs we may patch.
|
||||
|
||||
Go/no-go: wave64 runs, the image is correct, and the cost at some mode is below what a native
|
||||
resolution step would save.
|
||||
|
||||
### Phase 1: HelixSR as a component (build the network on device)
|
||||
|
||||
- **Package entry.** Add `HelixSR` to the Components catalog. Download the official release zip
|
||||
from GitHub releases, pinned to version and SHA-256, and never mirror it (the license allows
|
||||
only unmodified, complete redistribution; fetching from upstream avoids any question). Show the
|
||||
HelixSR license, plus NVIDIA's DLSS license notice before the DLSS download.
|
||||
- **DXC.** Ship it as a DroidDeck-built package (aarch64 Linux `dxc`, pinned to the same DXC
|
||||
release HelixSR pins: v1.9.2607), with our own license notice.
|
||||
- **Build job.**
|
||||
- Runs on the existing background queue (`AutoComponents`-style: low priority, `nice`/`ionice`,
|
||||
waits while a session runs, and waits on battery saver or thermal limits).
|
||||
- Steps: unpack the zip, `apt`-free check for numpy (or bundle numpy in the rootfs image), find
|
||||
the DLSS DLL, run `helixsr_setup.py`, and parse its `[helixsr-setup]` progress lines into the
|
||||
UI progress bar.
|
||||
- Output goes to a DroidDeck-owned folder in the rootfs, for example
|
||||
`/root/.local/share/droiddeck/helixsr/<version>/`.
|
||||
- **DLSS source.** First look for `nvngx_dlss.dll` 310.7.0 or 310.2 in installed Steam, GOG or
|
||||
Epic games, the same way `Lossless.kt` finds Lossless.dll. Otherwise offer the NVIDIA download
|
||||
after explicit consent. Delete the DLL afterwards, as the setup does.
|
||||
- **Rebuilds.** Rebuild when the HelixSR version changes, and keep the previous build until the new
|
||||
one succeeds.
|
||||
|
||||
### Phase 2: per-game upscaler injection
|
||||
|
||||
- Add **Upscaler** to the per-game profile: *Off* / *HelixSR (FSR 3.1 slot)* / *HelixSR via
|
||||
OptiScaler (DLSS/XeSS/FSR2)*. Show only the ways that work for that game's files (scan the game
|
||||
folder for the FSR 3.1 / `nvngx_dlss.dll` / XeSS DLLs, as `droiddeck-game-env`'s `game_files`
|
||||
does).
|
||||
- **Applying it.** Start with option (a) and keep (b) as a fallback.
|
||||
- **(a)** Call HelixSR's own installer with `HOME` pointed at an empty directory, so its Steam
|
||||
scan finds nothing, plus `--folder <game>`. It keeps HelixSR's backups, markers and uninstall
|
||||
behaviour exactly.
|
||||
- **(b)** Use DroidDeck's own file sync. It does the documented manual-install steps with our
|
||||
own managed-file manifest, the same pattern as the per-game DXVK/VKD3D overrides.
|
||||
- **When:** at profile change, never mid-session. Re-check at launch in `droiddeck-game-env`,
|
||||
because a Steam update or "verify files" puts the game's DLLs back. When that happens,
|
||||
re-apply quietly or show a notice.
|
||||
- **Environment.**
|
||||
- The **o** way: add `WINEDLLOVERRIDES=dxgi=n,b` (or whatever DLL name OptiScaler took) to the
|
||||
game's environment.
|
||||
- Expose `HELIXSR_INT8` and generate a `helixsr.ini` (Int8, WaveSize, sharpening,
|
||||
NetworkResolution) from profile settings rather than asking users to edit an ini.
|
||||
- **Turning it off** runs the uninstall and restores the originals. Reset game profile must do the
|
||||
same.
|
||||
- **Leave out the experimental d way** (DLSS loader and NVIDIA spoof): it is unsafe with
|
||||
anti-cheat, tested only on desktop Linux, and depends on nvapi on ARM Proton. Revisit later.
|
||||
|
||||
### Phase 3: in-session UX and diagnostics
|
||||
|
||||
- Show the active upscaler and the `helixsr.log` wave/int8 lines in the Perf HUD or session
|
||||
overlay, and attach `helixsr.log` and `OptiScaler.log` to session log shares (`SessionLogShare`).
|
||||
- Explain the Insert-key OptiScaler menu for pad users. Map it to a pad combo, or document the
|
||||
QAM shortcut.
|
||||
- Add `docs/development/helixsr.md` and an entry in Components' license notices (OptiScaler
|
||||
GPL-3.0, fakenvapi MIT, AMD FidelityFX license; all of these come from the official zip).
|
||||
|
||||
## Risks and open questions
|
||||
|
||||
- **Performance on Adreno 740** is the deciding factor, and the Odin 3 (830) already reports a
|
||||
visible hit. Without fp16 dot or int8 acceleration, HelixSR may only be worthwhile in Ultra
|
||||
Performance or with `NetworkResolution` reduced.
|
||||
- **Licensing.** HelixSR's license forbids modification but allows running and unmodified
|
||||
redistribution. We only download, run and copy its files as its own installer does, which is
|
||||
fine. The built DLL contains NVIDIA's network, so it must never leave the device: no cloud
|
||||
backup of game folders with it, and keep it out of log shares and save-sync. Ask the author
|
||||
(issue or Discord) whether a DroidDeck integration that drives `helixsr_setup.py` directly is
|
||||
welcome. It costs nothing and they have been receptive (issue #3).
|
||||
- **Project velocity.** Seven releases in a week, and 1.9.0 is a pre-release with an open int8
|
||||
flicker bug (#44). Pin versions and let users choose stable or latest.
|
||||
- **Build cost on device.** The PC build takes about a minute. On the Thor, with DXC under
|
||||
Proton/FEX, it could take tens of minutes, which is why the native aarch64 `dxc` matters.
|
||||
- **OptiScaler under ARM64 Proton + FEX** has not been tested in DroidDeck. That needs testing
|
||||
for the **o** way to be useful.
|
||||
- **D3D12 only.** DX11 games need OptiScaler's DX11-on-12 path, which is out of scope.
|
||||
@@ -0,0 +1,53 @@
|
||||
# Discord UI and session reports, 2026-10-11
|
||||
|
||||
Sources: [bug thread](https://discord.com/channels/1552707793247539220/1558928314956120174), [general](https://discord.com/channels/1552707793247539220/1552707794430459916), and [development](https://discord.com/channels/1552707793247539220/1552751182165049435). Reviewed the post-overhaul discussion on October 11, including screenshot-only messages and linked reports.
|
||||
|
||||
Branch: `fix/discord-ui-session-reports`, based on `origin/main` at `0cafa83e`.
|
||||
Device: AYN Thor, selected by the full advertised ADB serial.
|
||||
|
||||
## Changes
|
||||
|
||||
| Report | Change |
|
||||
| --- | --- |
|
||||
| Settings needs an X and a larger handle | Add a 44dp close target in the sheet's controller focus group; enlarge the visible handle to 32dp and its label to 14sp. |
|
||||
| Settings has too little height | Raise the sheet from 82/360 to 60/360 of the pane while preserving clearance above the primary action. |
|
||||
| Reopening during the closing animation breaks settings | Cancel the outstanding drag settlement when a new gesture or open/close transition takes ownership. |
|
||||
| Store navigation returns to the left column | Route Up/Down by the actual adaptive column count and focus the corresponding card after lazy composition. Incomplete final rows do not wrap. Prefetched offscreen cards are scrolled into view before focus moves. |
|
||||
| A selection stays as a dot | Unpinch an interrupted long chip jump during the next adjacent move. Cancel an obsolete focus-ring flight and its fill animation on focus loss. |
|
||||
| Performance opens with focus on Steam | Wait for Back to attach and take focus after the outgoing page leaves. |
|
||||
| Desktop settings navigation jumps | Do not apply the main page's Down-to-first-app shortcut to settings-sheet buttons. |
|
||||
| Display-driver navigation loses focus | Wait for the chooser to disappear before focusing the selected driver; initialize controller focus when switching back from touch. |
|
||||
| Stores can no longer be hidden | Restore a persisted Stores switch under Setup > Launcher; keep it enabled by default. |
|
||||
| Stores engine is clipped in the settings panel | Bound popup height to the available screen space, expose that limit to its scrollable body, and allow tall popup content to scroll. |
|
||||
| Wine Sync renders vertically | Stack its label above the full-width sync choices. |
|
||||
| Profile picker leaves too little room for Proton lists | Replace the large profile group with a compact 44dp picker row. |
|
||||
| Theme accent is inconsistent | Paper's signal color now follows its white primary color rather than retaining blue. Store brand colors and controller-button tint remain separate settings. |
|
||||
|
||||
| Phone sign-in buttons clipped ([development report](https://discord.com/channels/1552707793247539220/1552751182165049435/1558947589997469820)) | Size the sign-in card to the pane and its content instead of enforcing a 320dp minimum. Decorative layers follow the measured card. |
|
||||
| Force SSBS hard to find behind empty scrolling ([general report](https://discord.com/channels/1552707793247539220/1552707794430459916/1558976573758251029)) | Place shared Proton options before installed/downloadable lists; start each component layer's detail at the top when switching layers. |
|
||||
|
||||
## Validation
|
||||
|
||||
The release APK was prepared with `tools/build_local.sh`, built with `assembleRelease`, signed with the normal release lineage, and installed with `adb install -r` over Thor's existing app.
|
||||
|
||||
16 focused unit tests passed: LiftSheetTest, StoreGridNavigationTest, GlideShapeTest, StoreTabsTest, AppScaleTest, and the Compose ComponentsPageProfileTest. The first unrestricted unit-test run ended because the Gradle test executor exited with code 2 without an individual test failure report; it is not counted as a passing full suite.
|
||||
|
||||
Thor checks include the close control, eight close/reopen swipe cycles, 21 rapid long/adjacent Setup tab switches, hiding and restoring Stores, Paper theme colors, controller entry into Performance (Back focused, then Down to the first setting), driver chooser handoff and Up/Down scrolling, and Desktop Files navigation (Open > Choose > Uninstall > Choose > Open). The new close control is reachable and operable with a controller. The newer Stores engine clipping, compact profile picker, and horizontal Wine Sync label were also checked on Thor. The original Graphite theme and existing session preferences were restored after checks.
|
||||
|
||||
Device screenshots and UI dumps are saved locally under `captures/discord-reports/` (ignored build evidence). The final signed APK is `app/build/outputs/apk/release/app-release-signed.apk`.
|
||||
|
||||
The first pass saw no populated authenticated store grid. During the follow-up, Epic and Amazon loaded their retained accounts and libraries (402 and 150 titles). On Epic, six controller Down moves and six Up moves stayed in the third column, including transitions to offscreen rows, and returned to the original card. This caught and fixed the case where a prefetched offscreen card accepted focus without scrolling. The completed trace is `captures/discord-reports/epic-grid-navigation.json`.
|
||||
|
||||
Follow-up validation used both Thor's normal display and a temporary 2400x1080 / 540dpi phone-like layout. GOG's sign-in card and button were fully visible without scrolling. Epic and Amazon remained signed in, so their library layouts were inspected rather than signing the accounts out. Proton options appeared before the catalogs, Force SSBS was reachable by scrolling, and changing layers reset the detail scroll. The physical size/density were restored (1080x1920 / 369dpi). The final build and four focused tests passed; the final signed APK hash is `7dca710d081042ec68aeaf6e8b68371d5fdfa73eca5860ba4ca5f0134c21b9fc`. Wireless ADB file-sync stalled, so the APK was transferred over a temporary direct LAN socket, hash-verified on Thor, and installed with `pm install -r`. The transfer listener closed after delivery.
|
||||
|
||||
## Runtime reports still unresolved
|
||||
|
||||
**Second Steam launch fails or has sound with a black picture.** The two submitted log bundles reach a first frame and Steam focus, then record a guest exit with status 0. Their crash buffers contain no Android crash. Two consecutive launches of Thor's existing main build reached READY and displayed Steam correctly, using the same retained compositor and app process. Two consecutive Steam launches of the new branch also reached READY with visible Steam UI, and its desktop launch reached READY and stopped cleanly. These observations do not establish the cause of the reporters' failures, and no speculative compositor or Steam-startup change was made.
|
||||
|
||||
**Persona 3 Reload drops from 60 to 35 FPS and crashes.** The linked compatibility thread identifies an Odin 3 Max and a UE4 GameThread timeout waiting 120 seconds for RenderThread. Earlier working settings were Performance + TSO and VKD3D shader/feature levels 6_6 / 12_1. The new report has no session log, before/after build identifiers, or controlled comparison. Persona 3 Reload was not found in the inspected Thor library locations. Neither an Odin reproduction nor a Persona performance improvement is claimed. The RDR2 launcher governor matches Rockstar helper executable paths and is not a blanket game-core restriction.
|
||||
|
||||
## Related follow-ups outside launcher design
|
||||
|
||||
General's fullscreen desktop-app report matches the existing runtime contract: the software desktop hands Steam to a Steam session and wraps games/emulators in gamescope for GPU access. `droiddeck-desktop-gpu` preserves a “Run in a desktop window” action. Changing that GPU/window architecture is separate runtime work; no claim of fixing it here.
|
||||
|
||||
Development's request to update driver and Proton defaults without visiting Components is also runtime policy. Driver Auto already calls `ensureAuto` during activity startup. This branch does not replace manual driver selections or install/switch Proton builds as part of a layout fix.
|
||||
@@ -0,0 +1,26 @@
|
||||
# Steam black screen with FSR 1
|
||||
|
||||
Branch `fix/fsr-steam-black-screen` starts at `origin/main` `e4c375ad` after PR #596 merged.
|
||||
|
||||
## Diagnosis
|
||||
|
||||
On AYN Thor (Adreno 740, WN-Turnip-1.19-p_Axxx), Steam reached READY and retained focus while the entire screen was black with FSR 1 at 720p / 85% sharpness. Switching the same running session to Linear immediately restored the picture. Production SGSR also went black. At native 1080p, FSR stayed selected but its upscale pass was unnecessary and Steam remained visible.
|
||||
|
||||
A temporary SGSR shader drew a constant red strip beside a normal texture sample. The strip and sampled picture were corrupted in a tiled pattern. Allowing unrestricted mutable formats on the post-processing targets made both render correctly. Restoring the original shaders then restored the first production FSR launch. A second launch exposed a separate source-view lifetime bug: the scene owner destroyed its image while the effect chain retained a view and descriptor; a recycled image handle at the same dimensions could hit that stale cache.
|
||||
|
||||
## Change
|
||||
|
||||
Create the effect chain's intermediate images with `VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT`, without a restricted view-format list. Turnip consequently avoids UBWC compression on these render-then-sample/blit targets. The input scene and guest images retain their existing allocation policy. Release the cached source view and descriptor before an SDR, HDR or frame-generation scene image is destroyed. This makes recycled Vulkan handles create fresh sampling resources. Scaling remains enabled and the FSR EASU/RCAS shaders and sharpness settings are unchanged.
|
||||
|
||||
Driver behavior is documented in Mesa's [image allocation implementation](https://chromium.googlesource.com/external/gitlab.freedesktop.org/mesa/mesa/+/3fcec4762f3fec551c00da52f349c83443152159/src/freedreno/vulkan/tu_image.cc), including the mutable-format check and `format_list_ubwc_possible`.
|
||||
|
||||
## Validation
|
||||
|
||||
- Four native cache regressions passed: recycled handles, unrelated/null images, repeated invalidation, and dimension changes. The fixture executes the actual cache implementation with Vulkan lifetime callbacks.
|
||||
- Release build and 14 focused Android tests passed: SessionScalingPrefsTest and SessionDisplayTest.
|
||||
- A separate Vulkan/MoltenVK smoke test ran the actual effect chain: a 16x16 source scaled by FSR to 32x32 retained RGBA 64/128/191/255.
|
||||
- Signed APK installed over Thor's existing app, with its device-side transfer hash verified.
|
||||
- Production FSR at 720p / 85% rendered visible Steam, including two consecutive stop/start cycles with the app/compositor retained (sessions 42 and 43). Live SGSR, Linear and return-to-FSR switching also rendered correctly.
|
||||
- Session preferences match the pre-test snapshot; FSR 1 / 85%, 720p and the existing driver selections are retained.
|
||||
|
||||
Local screenshots, state snapshots and renderer logs are under `captures/fsr-black-screen/` (ignored). Temporary probe shaders are excluded from the final source change. The signed APK hash is `2b8b7ea18c49bf53f1f3cb00eea8f73d122258a900c18ffe660c85c5654bedae`. The old cache behavior fails the recycled-handle regression; the corrected implementation passes all four cases.
|
||||
@@ -0,0 +1,40 @@
|
||||
# Experimental Quest 3/3S support
|
||||
|
||||
Quest 3/3S runs DroidDeck as a 2D panel. This does not add immersive VR or
|
||||
OpenXR support. Quest 2 is outside the bundled Adreno 7xx driver path.
|
||||
|
||||
Install the standard DroidDeck APK on Quest 3/3S. Device detection on the
|
||||
first launch selects manual drivers, the bundled
|
||||
`turnip25.1.0-quest1` Android driver and the default Linux driver. It enables
|
||||
`hdr.steam` to use the existing SurfaceControl presentation workaround from
|
||||
[the Quest report](https://github.com/Droid-Deck/DroidDeck/issues/245).
|
||||
These defaults apply once; subsequent user changes are retained. Colour
|
||||
accuracy and headset performance still need testing.
|
||||
|
||||
Both the Android driver wrapper and the Linux session preload use
|
||||
`tools/quest/kgsl_compat.c`. Successful legacy allocation/free calls are
|
||||
unchanged. Only `EACCES`/`EPERM` failures retry through `GPUOBJ_ALLOC`,
|
||||
`GPUOBJ_INFO` and `GPUOBJ_FREE`. The Android wrapper depends on the original
|
||||
bundled Turnip binary. Unhandled controller ioctls forward to the next
|
||||
preload hook rather than skipping it with a raw syscall.
|
||||
|
||||
`tools/build_local.sh` and CI build the wrapper from source using the pinned
|
||||
Android NDK; the normal preload builds include the shared Linux adapter.
|
||||
Runtime input verification checks the resulting driver archive and invalidates
|
||||
stale prepared assets after compatibility sources change. To rebuild only the
|
||||
Android driver archive:
|
||||
|
||||
```sh
|
||||
python3 tools/quest/build-driver.py "$ANDROID_HOME/ndk/27.3.13750724"
|
||||
```
|
||||
|
||||
Quest compatibility is included in the standard APK; no separate Quest
|
||||
package is needed. Other devices retain their existing defaults. The remaining
|
||||
performance-name APK variants continue to use separate app data and bwrap sockets.
|
||||
|
||||
Quest 3 testers have successfully launched games.
|
||||
|
||||
On a headset, check the Steam login panel, sign-in, game installation and
|
||||
then an owned game's rendering/input. Capture the device/OS, session logs,
|
||||
`files/quest-startup.txt` and any `files/quest-last-crash.txt` failure.
|
||||
Host allocation and preload-chain tests do not establish headset operation.
|
||||
@@ -0,0 +1,123 @@
|
||||
# DroidDeck 0.4.0
|
||||
|
||||
<p align="center"><a href="https://discord.gg/JRGAvawjsm"><img src="https://img.shields.io/badge/Discord-Join%20the%20community-5865F2?logo=discord&logoColor=white" alt="Join the DroidDeck Discord"></a></p>
|
||||
|
||||
> **TL;DR for Mr. Sujano specifically**
|
||||
>
|
||||
> And speaking about the coolest thing since sliced bread, next up here we're talking about DroidDeck.
|
||||
>
|
||||
> For those who are unaware, DroidDeck brings the SteamOS experience to Android on your Snapdragon powered handheld, and DroidDeck just got a brand new update. Now, they just released version 0.4.0, and taking a look at this update, it seems to be a pretty big one.
|
||||
>
|
||||
> It says here they've added GOG, Epic Games and Amazon Games integration, with cloud saves for GOG and Epic. On top of that here, they've implemented a fully featured SteamOS-style KDE Plasma desktop with a working "Return to Gaming Mode."
|
||||
>
|
||||
> Steam's own Steam Link touch controller, with community layouts that back up to Steam Cloud. Support for connecting up to four controllers for local co-op. Native support for the new Steam Controller. And the built-in controls can now pretend to be a Steam Deck, Steam Controller, Xbox 360, DualShock 4 or DualSense.
|
||||
>
|
||||
> If you're on a foldable, Steam and your games now resize when you fold, unfold or rotate, and there's an optional touch gamepad below the game when it's unfolded.
|
||||
>
|
||||
> They've also got per-game compatibility profiles, automatic redistributable and Windows component installs, their own custom DroidDeck-Proton, and streamlined non-Steam game imports with automatic artwork. And on the performance side, PRoot is up to 57% faster in some workloads, with lower idle CPU usage, and even more.
|
||||
>
|
||||
> You let me know your thoughts.
|
||||
|
||||
### Features
|
||||
|
||||
- Replaced LXQt with **SteamOS-style KDE Plasma 6.7**, including the familiar desktop layout, Dolphin, Firefox, Konsole, the Steam desktop client and Return to Gaming Mode. (@xXJSONDeruloXx, [#473](https://github.com/Droid-Deck/DroidDeck/pull/473), [#610](https://github.com/Droid-Deck/DroidDeck/pull/610))
|
||||
|
||||
<img src="media/0.4.0/desktop-round-trip.gif" width="50%" alt="Switching from Steam to the KDE Plasma desktop, browsing the application launcher, then returning to Gaming Mode; loading shortened and boot animation removed">
|
||||
- Added **GOG, Epic Games and Amazon Games** integration with account sign-in, game libraries, downloads and launching through Steam. GOG and Epic games also support cloud saves. (@The412Banner, @xXJSONDeruloXx, @Gustash, @maxjivi05, [#476](https://github.com/Droid-Deck/DroidDeck/pull/476), [#500](https://github.com/Droid-Deck/DroidDeck/pull/500), [#578](https://github.com/Droid-Deck/DroidDeck/pull/578), [#400](https://github.com/Droid-Deck/DroidDeck/pull/400))
|
||||
|
||||
<img src="media/0.4.0/store-downloads.gif" width="50%" alt="Browsing the Epic Games library, installing 20 Minutes Till Dawn and viewing its download progress">
|
||||
<img src="media/0.4.0/gog-sign-in.jpg" width="50%" alt="GOG store tab with its Sign in button">
|
||||
- Added **Steam's native touch controller (beta)**, with per-game Steam Input layouts, community configurations, an on-screen layout editor and Steam Cloud syncing. (@xXJSONDeruloXx, [#431](https://github.com/Droid-Deck/DroidDeck/pull/431))
|
||||
|
||||
<img src="media/0.4.0/castle-crashers-touch.gif" width="50%" alt="Launching Castle Crashers with Steam touch controls that switch to its game-specific icons, then browsing and applying a community touch layout; loading and menus sped up">
|
||||
<img src="media/0.4.0/steam-touch-editor.jpg" width="50%" alt="Castle Crashers touch layout editor">
|
||||
|
||||
<details>
|
||||
<summary>Steam Input layouts and touch settings</summary>
|
||||
|
||||
<img src="media/0.4.0/steam-input-touch.jpg" width="50%" alt="Steam Input settings for the Remote Play Touch Controller">
|
||||
<img src="media/0.4.0/steam-input-cloud-layouts.jpg" width="50%" alt="The saved Castle Crashers touch layout in Steam Input">
|
||||
<img src="media/0.4.0/steam-input-community.jpg" width="50%" alt="Community touch-controller layouts for Castle Crashers">
|
||||
<img src="media/0.4.0/steam-touch-menu.jpg" width="50%" alt="Castle Crashers touch controller and mouse settings">
|
||||
|
||||
</details>
|
||||
- Added **multi-controller support for up to 4 players**, allowing connected Android gamepads to work independently for local co-op and split-screen multiplayer through Steam Input. (@xXJSONDeruloXx, @maxjivi05, @Neolyum, [#431](https://github.com/Droid-Deck/DroidDeck/pull/431), [#614](https://github.com/Droid-Deck/DroidDeck/pull/614))
|
||||
|
||||
<img src="media/0.4.0/multi-controller.gif" width="50%" alt="Two Bluetooth controllers playing split-screen on the Thor, with both listed under connected devices on the bottom screen">
|
||||
- Added **Bluetooth LE Steam Controller (2025)** support, including trackpads, back grips and motion controls. (@SG3xHERO, [#404](https://github.com/Droid-Deck/DroidDeck/pull/404))
|
||||
|
||||
<img src="media/0.4.0/steam-controller-ble.jpg" width="35%" alt="A 2025 Steam Controller connected to the Thor over Bluetooth, with its Steam Input layout on the top screen">
|
||||
- The built-in controller can now emulate a **Steam Deck, Steam Controller, Xbox 360, DualShock 4 or DualSense**, with live switching from the session menu without restarting Steam. (@xXJSONDeruloXx, [#545](https://github.com/Droid-Deck/DroidDeck/pull/545), [#558](https://github.com/Droid-Deck/DroidDeck/pull/558), [#559](https://github.com/Droid-Deck/DroidDeck/pull/559))
|
||||
|
||||
<img src="media/0.4.0/controller-emulation.jpg" width="50%" alt="Choosing the emulated built-in controller during a Castle Crashers session: Steam Deck, Steam Controller, DualShock 4, DualSense or Xbox 360">
|
||||
- Added persistent **per-game compatibility profiles** for Proton, FEX, DXVK, VKD3D-Proton, Windows components, environment variables and texture filtering, with inheritance from your default settings. (@jmarti326, [#449](https://github.com/Droid-Deck/DroidDeck/pull/449))
|
||||
|
||||
<img src="media/0.4.0/game-profiles.jpg" width="50%" alt="Configure profile menu listing the default profile and per-game profiles">
|
||||
- Completely revamped **adding and managing non-Steam games**, with automatic game detection, artwork, bulk imports and editing directly from the Games tab. (@The412Banner, [#492](https://github.com/Droid-Deck/DroidDeck/pull/492))
|
||||
|
||||
<img src="media/0.4.0/add-game.jpg" width="50%" alt="The Games tab Add a game dialog, choosing internal storage or an SD card to scan">
|
||||
- Added **Follow screen** resolution for foldables, automatically resizing Steam and games when folding, unfolding or rotating the device. (@SG3xHERO, [#403](https://github.com/Droid-Deck/DroidDeck/pull/403))
|
||||
|
||||
<img src="media/0.4.0/follow-screen-landscape.jpg" width="35%" alt="Steam filling the inner screen of an unfolded foldable in landscape">
|
||||
<img src="media/0.4.0/follow-screen-portrait.jpg" width="20%" alt="Steam resized to the inner screen in portrait">
|
||||
<img src="media/0.4.0/follow-screen-cover.jpg" width="42%" alt="Steam resized to the folded cover screen">
|
||||
- Added an optional **touch gamepad below the game on unfolded foldables**, with Steam Deck-style controls, configurable sticks and trackpads. (@SG3xHERO, [#407](https://github.com/Droid-Deck/DroidDeck/pull/407))
|
||||
|
||||
<img src="media/0.4.0/foldable-gamepad.jpg" width="25%" alt="Steam on the top half of an unfolded foldable with the touch gamepad below it">
|
||||
<img src="media/0.4.0/foldable-trackpads.jpg" width="25%" alt="The foldable touch gamepad switched to its two-trackpad layout with back buttons">
|
||||
<img src="media/0.4.0/foldable-landscape.jpg" width="50%" alt="The foldable touch gamepad in landscape, laid out along the bottom edge under Steam">
|
||||
- Added **DroidDeck-Proton** as an installable Proton source alongside GE-Proton and CachyOS Proton, with update notifications for all three. (@The412Banner, [#588](https://github.com/Droid-Deck/DroidDeck/pull/588))
|
||||
- Added support for installing **Flatpak apps directly from .flatpak bundles**, including apps no longer available through Flathub. (@xXJSONDeruloXx, [#446](https://github.com/Droid-Deck/DroidDeck/pull/446))
|
||||
- Added a manual **landscape orientation** setting, including reverse landscape. (@Kobtul, [#441](https://github.com/Droid-Deck/DroidDeck/pull/441))
|
||||
- Added an optional controller setting to open the Steam menu with the physical **Select** button. (@0x1428571429, [#384](https://github.com/Droid-Deck/DroidDeck/pull/384))
|
||||
|
||||
### Improvements
|
||||
|
||||
- Major **launcher UI redesign** across Steam settings, Components, Setup, Stores, Flathub and Desktop, with smoother transitions, animated navigation, redesigned settings panels and improved controller focus. (@xXJSONDeruloXx, [#482](https://github.com/Droid-Deck/DroidDeck/pull/482), [#548](https://github.com/Droid-Deck/DroidDeck/pull/548), [#605](https://github.com/Droid-Deck/DroidDeck/pull/605))
|
||||
|
||||
<img src="media/0.4.0/steam-settings.gif" width="50%" alt="Opening the slide-up Steam settings panel and switching to Display settings">
|
||||
- **Store downloads now survive app restarts**, preserving queued and paused downloads and allowing interrupted installs to resume from the Downloads page. (@xXJSONDeruloXx, [#608](https://github.com/Droid-Deck/DroidDeck/pull/608))
|
||||
- Store game removal now shows **confirmation and uninstall progress** before returning the game to its installable state. (@xXJSONDeruloXx, [#609](https://github.com/Droid-Deck/DroidDeck/pull/609))
|
||||
- Expanded **PRoot fast paths**, with performance improvements of up to 57% in measured workloads, alongside further reductions in filesystem and process overhead. (@maxjivi05, @xXJSONDeruloXx, [#466](https://github.com/Droid-Deck/DroidDeck/pull/466), [#494](https://github.com/Droid-Deck/DroidDeck/pull/494))
|
||||
- Significantly reduced launcher idle CPU usage, controller input overhead and session log processing time, with additional game startup and performance optimizations. (@maxjivi05, [#529](https://github.com/Droid-Deck/DroidDeck/pull/529))
|
||||
- **Windows components are now selected automatically** using each game's Steam, GOG, Epic or Amazon dependency information, while preserving manual overrides. (@The412Banner, [#554](https://github.com/Droid-Deck/DroidDeck/pull/554))
|
||||
- Expanded Windows component installation to support **VC++ redistributables, .NET Framework and more installer formats**, without needing to run the original Windows setup programs. (@The412Banner, [#480](https://github.com/Droid-Deck/DroidDeck/pull/480), [#495](https://github.com/Droid-Deck/DroidDeck/pull/495))
|
||||
- KDE Desktop can now launch **Windows executables, Linux programs, AppImages and scripts** directly from the file manager or terminal. (@maxjivi05, [#549](https://github.com/Droid-Deck/DroidDeck/pull/549))
|
||||
- Added safer **Desktop uninstall and legacy LXQt cleanup**, preserving user data while reclaiming storage from older desktop installations. (@xXJSONDeruloXx, [#493](https://github.com/Droid-Deck/DroidDeck/pull/493))
|
||||
- Improved **Proton and component management**, with newest versions shown first, update detection, clearer installed-version information and streamlined settings. (@The412Banner, @xXJSONDeruloXx, [#588](https://github.com/Droid-Deck/DroidDeck/pull/588), [#606](https://github.com/Droid-Deck/DroidDeck/pull/606))
|
||||
- Improved **DirectAudio compatibility**, including CachyOS Proton support and direct audio output from the Steam client. (@The412Banner, [#439](https://github.com/Droid-Deck/DroidDeck/pull/439))
|
||||
- Reduced unnecessary motion sensor polling, reading the device's gyro and accelerometer only when Steam requests them. (@muazkadan, [#534](https://github.com/Droid-Deck/DroidDeck/pull/534))
|
||||
- Added alignment guides and snapping when dragging buttons in the **on-screen controller editor**. (@willie-yao, [#490](https://github.com/Droid-Deck/DroidDeck/pull/490))
|
||||
- Improved security by **encrypting store credentials with Android Keystore** and keeping logs in private app storage until explicitly shared as a sanitized ZIP. (@The412Banner, [#484](https://github.com/Droid-Deck/DroidDeck/pull/484), [#486](https://github.com/Droid-Deck/DroidDeck/pull/486))
|
||||
- Steam now consistently uses **Steam Deck mode and the Steam Deck beta branch**, removing the legacy client and mode switches. (@xXJSONDeruloXx, [#546](https://github.com/Droid-Deck/DroidDeck/pull/546))
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed **Red Dead Redemption 2** failing to launch, and reduced resource usage from the Rockstar launcher while playing. (@maxjivi05, [#585](https://github.com/Droid-Deck/DroidDeck/pull/585))
|
||||
- Fixed Steam's screensaver appearing over running games after prolonged controller inactivity. (@maxjivi05, [#585](https://github.com/Droid-Deck/DroidDeck/pull/585))
|
||||
- Fixed **black Steam output with FSR 1** image scaling enabled. (@xXJSONDeruloXx, [#597](https://github.com/Droid-Deck/DroidDeck/pull/597))
|
||||
- Fixed **touch and mouse input landing away from the displayed position** when the session resolution and device screen have different aspect ratios. (@maxjivi05, [#389](https://github.com/Droid-Deck/DroidDeck/pull/389))
|
||||
- Fixed the **Odin 3 unexpectedly rebooting** when its Wi-Fi firmware enters low-latency mode. (@kmnkv1, [#512](https://github.com/Droid-Deck/DroidDeck/pull/512))
|
||||
- Fixed **Linux runtime removal getting stuck** on files that Android's SELinux policy would not allow the app to delete. (@xXJSONDeruloXx, [#463](https://github.com/Droid-Deck/DroidDeck/pull/463))
|
||||
- Fixed **Android 12 and older devices crashing during audio initialization**, and restored Firefox compatibility on affected Android 16 devices. (@kolmant, @The412Banner, [#531](https://github.com/Droid-Deck/DroidDeck/pull/531), [#460](https://github.com/Droid-Deck/DroidDeck/pull/460))
|
||||
- Fixed **Bluetooth keyboards with combined keyboard, mouse and controller interfaces** losing ordinary keyboard input. (@kaosjammo, [#435](https://github.com/Droid-Deck/DroidDeck/pull/435))
|
||||
- Fixed repeated force-feedback packets unnecessarily restarting the device vibrator. (@kmnkv1, [#514](https://github.com/Droid-Deck/DroidDeck/pull/514))
|
||||
- Fixed **CPU temperature showing 0°C** in the Steam performance overlay on affected devices. (@muazkadan, [#516](https://github.com/Droid-Deck/DroidDeck/pull/516))
|
||||
- Fixed older **NativeAOT games failing to start** because of an incompatible .NET garbage collector setting. (@Arthur031221, [#385](https://github.com/Droid-Deck/DroidDeck/pull/385))
|
||||
- Fixed fullscreen layout issues around display cutouts, clipped settings, and several controller navigation and focus problems. (@kaosjammo, @xXJSONDeruloXx, [#432](https://github.com/Droid-Deck/DroidDeck/pull/432), [#596](https://github.com/Droid-Deck/DroidDeck/pull/596), [#600](https://github.com/Droid-Deck/DroidDeck/pull/600))
|
||||
- Fixed the touchpad cursor remaining visible after switching from Touchpad to Direct touch mode. (@KingHacker9000, [#424](https://github.com/Droid-Deck/DroidDeck/pull/424))
|
||||
|
||||
### New contributors
|
||||
|
||||
- @SG3xHERO made their first contribution in [#403](https://github.com/Droid-Deck/DroidDeck/pull/403).
|
||||
- @Arthur031221 made their first contribution in [#385](https://github.com/Droid-Deck/DroidDeck/pull/385).
|
||||
- @KingHacker9000 made their first contribution in [#424](https://github.com/Droid-Deck/DroidDeck/pull/424).
|
||||
- @kaosjammo made their first contribution in [#432](https://github.com/Droid-Deck/DroidDeck/pull/432).
|
||||
- @Kobtul made their first contribution in [#441](https://github.com/Droid-Deck/DroidDeck/pull/441).
|
||||
- @willie-yao made their first contribution in [#490](https://github.com/Droid-Deck/DroidDeck/pull/490).
|
||||
- @muazkadan made their first contribution in [#516](https://github.com/Droid-Deck/DroidDeck/pull/516).
|
||||
- @kolmant made their first contribution in [#531](https://github.com/Droid-Deck/DroidDeck/pull/531).
|
||||
- @Gustash made their first contribution in [#578](https://github.com/Droid-Deck/DroidDeck/pull/578).
|
||||
- @Neolyum made their first contribution in [#614](https://github.com/Droid-Deck/DroidDeck/pull/614).
|
||||
|
||||
[Full changelog](https://github.com/Droid-Deck/DroidDeck/compare/0.3.2...0.4.0)
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 177 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 9.5 MiB |
Loaded 100 of 152 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user