From 5d8fd3f5f069862d2b27ed67320cde521d8fa968 Mon Sep 17 00:00:00 2001 From: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com> Date: Wed, 21 Oct 2026 12:47:10 -0400 Subject: [PATCH] feat: warn before installing a Decky plugin ZIP (#1263) --- .../java/com/droiddeck/launcher/DeckyMenu.kt | 12 ++++++++ .../com/droiddeck/launcher/MainActivity.kt | 3 ++ .../launcher/session/SessionPrefs.kt | 7 +++++ .../launcher/ui/ModeSettingsDialog.kt | 30 +++++++++++++++++++ app/src/main/res/values/strings.xml | 7 +++++ 5 files changed, 59 insertions(+) diff --git a/app/src/main/java/com/droiddeck/launcher/DeckyMenu.kt b/app/src/main/java/com/droiddeck/launcher/DeckyMenu.kt index 9f8a27f9f7..03e7812479 100644 --- a/app/src/main/java/com/droiddeck/launcher/DeckyMenu.kt +++ b/app/src/main/java/com/droiddeck/launcher/DeckyMenu.kt @@ -17,6 +17,7 @@ internal class DeckyMenu(private val activity: android.app.Activity, private val var deckyPercent by mutableIntStateOf(-1) var deckyDownloadingBinary by mutableStateOf(false) var deckySupervisor by mutableStateOf(false) + var deckyPendingZip by mutableStateOf(null) var deckyReleaseRequest = 0 fun refreshDecky() { @@ -49,6 +50,17 @@ internal class DeckyMenu(private val activity: android.app.Activity, private val } fun importPluginZip(archive: File) { + if (deckyStage != null || SessionState.running || deckyInstalled == null) return + deckyPendingZip = archive + } + + fun cancelPluginZip() { + deckyPendingZip = null + } + + fun confirmPluginZip() { + val archive = deckyPendingZip ?: return + deckyPendingZip = null if (deckyStage != null || SessionState.running || deckyInstalled == null) return deckyStage = activity.getString(R.string.decky_plugin_starting); deckyPercent = -1 Thread({ diff --git a/app/src/main/java/com/droiddeck/launcher/MainActivity.kt b/app/src/main/java/com/droiddeck/launcher/MainActivity.kt index 66b43bc347..4735d19dc5 100644 --- a/app/src/main/java/com/droiddeck/launcher/MainActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/MainActivity.kt @@ -768,6 +768,9 @@ class MainActivity : ComponentActivity() { setContent { DroidDeckTheme(theme, appScale = appScale) { com.droiddeck.launcher.ui.FocusGlideHost(androidx.compose.ui.Modifier.fillMaxSize().exposeTestTags()) { + if (decky.deckyPendingZip != null) com.droiddeck.launcher.ui.DeckyZipWarningDialog( + onConfirm = { decky.confirmPluginZip() }, onCancel = { decky.cancelPluginZip() }, + ) val page: (@Composable () -> Unit)? = when { showPerformance -> { { PerformanceHost() } } showComponents -> { { ComponentsHost() } } diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt index e7556e97a5..e7b810c238 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt @@ -21,6 +21,7 @@ object SessionPrefs { const val SUSPEND_NEVER = "never" private const val LEGACY_SUSPEND_DOWNLOADS = "downloads" private const val STEAM_DOWNLOADS_IN_BACKGROUND = "steamDownloadsInBackground" + private const val DECKY_ZIP_WARNING_SEEN = "deckyZipWarningSeen" const val CONTROLLER_DECK = "deck" const val CONTROLLER_XBOX360 = "xbox360" @@ -953,6 +954,12 @@ object SessionPrefs { }.apply() } + fun deckyZipWarningSeen(context: Context): Boolean = prefs(context).getBoolean(DECKY_ZIP_WARNING_SEEN, false) + + fun setDeckyZipWarningSeen(context: Context) { + prefs(context).edit().putBoolean(DECKY_ZIP_WARNING_SEEN, true).apply() + } + fun steamDownloadsInBackground(context: Context): Boolean { val prefs = prefs(context) return prefs.getBoolean(STEAM_DOWNLOADS_IN_BACKGROUND, false) || diff --git a/app/src/main/java/com/droiddeck/launcher/ui/ModeSettingsDialog.kt b/app/src/main/java/com/droiddeck/launcher/ui/ModeSettingsDialog.kt index d90747aca4..e096058199 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/ModeSettingsDialog.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/ModeSettingsDialog.kt @@ -14,6 +14,7 @@ import androidx.compose.material3.LinearProgressIndicator import androidx.compose.material3.TextButton import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue @@ -529,6 +530,35 @@ internal fun ProtonOptions( GameEnvironmentRow() } +@Composable +internal fun DeckyZipWarningDialog(onConfirm: () -> Unit, onCancel: () -> Unit) { + val context = androidx.compose.ui.platform.LocalContext.current + var left by remember { mutableIntStateOf(if (SessionPrefs.deckyZipWarningSeen(context)) 0 else DECKY_ZIP_WARNING_SECONDS) } + androidx.compose.runtime.LaunchedEffect(Unit) { + while (left > 0) { + kotlinx.coroutines.delay(1000L) + left-- + } + SessionPrefs.setDeckyZipWarningSeen(context) + } + AlertDialog( + onDismissRequest = onCancel, + title = { Text(stringResource(R.string.decky_zip_warning_title)) }, + text = { Text(stringResource(R.string.decky_zip_warning_text)) }, + confirmButton = { + androidx.compose.material3.TextButton(onClick = onConfirm, enabled = left == 0) { + Text( + if (left > 0) androidx.compose.ui.res.pluralStringResource(R.plurals.decky_zip_warning_wait, left, left) + else stringResource(R.string.decky_zip_warning_continue), + ) + } + }, + dismissButton = { androidx.compose.material3.TextButton(onClick = onCancel) { Text(stringResource(R.string.common_cancel)) } }, + ) +} + +private const val DECKY_ZIP_WARNING_SECONDS = 5 + @Composable private fun DeckyUninstall(enabled: Boolean, onUninstall: () -> Unit) { val colors = MaterialTheme.colorScheme diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ebef852975..026229b8d8 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1404,6 +1404,13 @@ Install a plugin ZIP for the next Steam session. Downloading… Install from ZIP + Third-Party Plugin Installation + The Decky Loader team has not reviewed this plugin. It may contain malware, such as software to steal your Steam account or harm your device. By installing this plugin, you agree you have assumed all risks to your device. + Continue + + Please wait %1$d second + Please wait %1$d seconds + Games Audio & Video Graphics