Skip to content

Your phone, on your command. Gotcha is world's first fully on-device AI copilot for Android that turns natural language into real device actions — safely.

refactor: replace AlertDialog with SkinAlertDialog for consistent theming across dialogs

Durganshu Mishra5828c8de3633
diff --git a/app/src/main/java/com/gotcha/LegalConsentDialog.kt b/app/src/main/java/com/gotcha/LegalConsentDialog.kt
index 12f8e01..6939f68 100644
--- a/app/src/main/java/com/gotcha/LegalConsentDialog.kt
+++ b/app/src/main/java/com/gotcha/LegalConsentDialog.kt
@@ -10,7 +10,6 @@ import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.selection.toggleable
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
-import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Checkbox
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.MaterialTheme
@@ -33,7 +32,7 @@ import androidx.compose.ui.semantics.Role
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import com.gotcha.ui.renderLegalMarkdown
-import com.gotcha.ui.theme.LocalSkin
+import com.gotcha.ui.theme.SkinAlertDialog
/**
* First-launch / re-acceptance gate. Non-dismissable: the only way out is the
@@ -72,13 +71,8 @@ fun LegalConsentDialog(
val bullets = stringArrayResource(R.array.legal_consent_bullets)
val loadingLabel = stringResource(R.string.legal_consent_loading)
- AlertDialog(
+ SkinAlertDialog(
onDismissRequest = { /* non-dismissable until accepted */ },
- // Material 3 paints a dialog from `surface`, which every glass skin
- // leaves see-through for in-page chrome — so the chat screen reads
- // straight through the legal copy. Same colour with the ground already
- // behind it, exactly as the long-press menus do. See Skin.menuContainer.
- containerColor = LocalSkin.current.menuContainer,
title = {
Column(verticalArrangement = Arrangement.spacedBy(12.dp)) {
Text(
diff --git a/app/src/main/java/com/gotcha/ui/AppDrawer.kt b/app/src/main/java/com/gotcha/ui/AppDrawer.kt
index f2ed59b..7848c51 100644
--- a/app/src/main/java/com/gotcha/ui/AppDrawer.kt
+++ b/app/src/main/java/com/gotcha/ui/AppDrawer.kt
@@ -14,7 +14,6 @@ import androidx.compose.material.icons.filled.AutoAwesome
import androidx.compose.material.icons.filled.Link
import androidx.compose.material.icons.filled.Settings
import androidx.compose.material.icons.outlined.Delete
-import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.DrawerDefaults
@@ -40,6 +39,7 @@ import androidx.compose.ui.unit.dp
import com.gotcha.data.ChatSession
import com.gotcha.ui.theme.GotchaMono
import com.gotcha.ui.theme.LocalSkin
+import com.gotcha.ui.theme.SkinAlertDialog
import com.gotcha.ui.tour.TourAnchor
import com.gotcha.ui.tour.tourAnchor
@@ -190,7 +190,7 @@ fun AppDrawerContent(
sessionToDelete?.let { id ->
val title = sessions.find { it.id == id }?.title ?: "this chat"
- AlertDialog(
+ SkinAlertDialog(
onDismissRequest = { sessionToDelete = null },
title = { Text("Delete Chat?") },
text = { Text("Are you sure you want to permanently delete \"$title\"? This action cannot be undone.") },
diff --git a/app/src/main/java/com/gotcha/ui/ChatScreen.kt b/app/src/main/java/com/gotcha/ui/ChatScreen.kt
index d7ac921..e227a0a 100644
--- a/app/src/main/java/com/gotcha/ui/ChatScreen.kt
+++ b/app/src/main/java/com/gotcha/ui/ChatScreen.kt
@@ -35,7 +35,6 @@ import androidx.compose.material.icons.filled.Share
import androidx.compose.material.icons.filled.Stop
import androidx.compose.material.icons.filled.TouchApp
import androidx.compose.material.icons.outlined.Visibility
-import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.CircularProgressIndicator
@@ -78,6 +77,7 @@ import com.gotcha.agent.ChatUiState
import com.gotcha.tools.AgentMode
import com.gotcha.ui.theme.GotchaMono
import com.gotcha.ui.theme.LocalSkin
+import com.gotcha.ui.theme.SkinAlertDialog
import com.gotcha.ui.theme.motionSpec
import kotlinx.coroutines.delay
import androidx.compose.foundation.Image as ComposeImage
@@ -592,7 +592,7 @@ fun ChatScreen(
}
state.pendingConfirmation?.let { pending ->
- AlertDialog(
+ SkinAlertDialog(
onDismissRequest = { onConfirm(false) },
title = { Text("Allow these actions?") },
text = {
@@ -613,7 +613,7 @@ fun ChatScreen(
if (state.pendingQuestion != null) {
val pending = state.pendingQuestion!!
var customAnswer by remember { mutableStateOf("") }
- AlertDialog(
+ SkinAlertDialog(
onDismissRequest = { onAnswer(null) },
title = { Text(pending.question) },
text = {
diff --git a/app/src/main/java/com/gotcha/ui/NotificationDetailDialog.kt b/app/src/main/java/com/gotcha/ui/NotificationDetailDialog.kt
index 7d6039c..8e2664a 100644
--- a/app/src/main/java/com/gotcha/ui/NotificationDetailDialog.kt
+++ b/app/src/main/java/com/gotcha/ui/NotificationDetailDialog.kt
@@ -7,7 +7,6 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
-import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Button
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
@@ -17,6 +16,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.dp
import com.gotcha.notifications.NotificationPayload
+import com.gotcha.ui.theme.SkinAlertDialog
@Composable
fun NotificationDetailDialog(
@@ -26,7 +26,7 @@ fun NotificationDetailDialog(
val context = LocalContext.current
val scrollState = rememberScrollState()
- AlertDialog(
+ SkinAlertDialog(
onDismissRequest = onDismiss,
title = {
Text(
diff --git a/app/src/main/java/com/gotcha/ui/PersonalInfoScreen.kt b/app/src/main/java/com/gotcha/ui/PersonalInfoScreen.kt
index 64a901a..04f5e81 100644
--- a/app/src/main/java/com/gotcha/ui/PersonalInfoScreen.kt
+++ b/app/src/main/java/com/gotcha/ui/PersonalInfoScreen.kt
@@ -1,7 +1,6 @@
package com.gotcha.ui
import androidx.compose.foundation.layout.fillMaxWidth
-import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Button
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.ExperimentalMaterial3Api
@@ -26,6 +25,7 @@ import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import com.gotcha.data.Settings
import com.gotcha.i18n.Language
+import com.gotcha.ui.theme.SkinAlertDialog
import com.gotcha.ui.theme.SkinExposedDropdownMenu
import kotlinx.coroutines.launch
@@ -213,7 +213,7 @@ fun PersonalInfoScreen(
Text(if (testingVoice) "Playing…" else "Test voice")
}
voiceDataMissing?.let { missingLang ->
- AlertDialog(
+ SkinAlertDialog(
onDismissRequest = { voiceDataMissing = null },
title = { Text("Voice data not installed") },
text = {
diff --git a/app/src/main/java/com/gotcha/ui/SkillsScreen.kt b/app/src/main/java/com/gotcha/ui/SkillsScreen.kt
index 44a6dfa..9f047ae 100644
--- a/app/src/main/java/com/gotcha/ui/SkillsScreen.kt
+++ b/app/src/main/java/com/gotcha/ui/SkillsScreen.kt
@@ -9,7 +9,6 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Delete
-import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.HorizontalDivider
@@ -38,6 +37,7 @@ import androidx.compose.ui.unit.dp
import com.gotcha.agent.skills.Skill
import com.gotcha.agent.skills.SkillRegistry
import com.gotcha.data.Settings
+import com.gotcha.ui.theme.SkinAlertDialog
import kotlinx.coroutines.launch
/**
@@ -289,7 +289,7 @@ fun SkillsScreen(
// ---- Delete confirmation dialog ----
communitySkillToDelete?.let { pending ->
- AlertDialog(
+ SkinAlertDialog(
onDismissRequest = { communitySkillToDelete = null },
title = { Text("Delete community skill?") },
text = {
diff --git a/app/src/main/java/com/gotcha/ui/theme/Dialog.kt b/app/src/main/java/com/gotcha/ui/theme/Dialog.kt
new file mode 100644
index 0000000..846cafc
--- /dev/null
+++ b/app/src/main/java/com/gotcha/ui/theme/Dialog.kt
@@ -0,0 +1,46 @@
+package com.gotcha.ui.theme
+
+import androidx.compose.material3.AlertDialog
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.Color
+
+/**
+ * Dialogs, in the skin.
+ *
+ * The same problem [SkinDropdownMenu] exists to solve, one layer up. Material 3
+ * paints an alert dialog from the `surface` role, which every glass skin leaves
+ * translucent on purpose — that alpha is what makes the in-page panels read as
+ * glass over the wallpaper. A dialog is not a panel: it floats over live
+ * content, so the same alpha lets the screen underneath read straight through
+ * the text, which is unreadable rather than atmospheric. It is worst over a busy
+ * screen — the legal gate on top of a chat — but it is wrong everywhere, and a
+ * confirmation the user cannot read is a confirmation they cannot give.
+ *
+ * Hands the dialog the same colour with the ground already behind it. See
+ * [Skin.menuContainer], which names menus only because they were the first
+ * floating surface to need it.
+ *
+ * Use this everywhere instead of `AlertDialog`. Parameter order follows the
+ * Material 3 original so call sites read the same.
+ */
+@Composable
+fun SkinAlertDialog(
+ onDismissRequest: () -> Unit,
+ confirmButton: @Composable () -> Unit,
+ modifier: Modifier = Modifier,
+ dismissButton: (@Composable () -> Unit)? = null,
+ title: (@Composable () -> Unit)? = null,
+ text: (@Composable () -> Unit)? = null,
+ containerColor: Color = LocalSkin.current.menuContainer
+) {
+ AlertDialog(
+ onDismissRequest = onDismissRequest,
+ confirmButton = confirmButton,
+ modifier = modifier,
+ dismissButton = dismissButton,
+ title = title,
+ text = text,
+ containerColor = containerColor
+ )
+}
diff --git a/app/src/main/java/com/gotcha/ui/theme/Skin.kt b/app/src/main/java/com/gotcha/ui/theme/Skin.kt
index df86cfe..6af751d 100644
--- a/app/src/main/java/com/gotcha/ui/theme/Skin.kt
+++ b/app/src/main/java/com/gotcha/ui/theme/Skin.kt
@@ -88,11 +88,15 @@ data class Skin(
get() = if (isGlass) ground else scheme.background
/**
- * What a menu popup paints itself. Material 3 takes that colour from
- * `surface`, which every glass skin leaves see-through for the in-page
- * chrome — and a see-through popup lets the page read straight through the
- * items under it. Same colour, composited onto the ground first: the menu
- * looks like the rest of the skin and stops being a window.
+ * What anything floating over the app paints itself — menus and dialogs
+ * both. Material 3 takes that colour from `surface`, which every glass skin
+ * leaves see-through for the in-page chrome — and a see-through popup lets
+ * the page read straight through the items under it. Same colour,
+ * composited onto the ground first: the popup looks like the rest of the
+ * skin and stops being a window.
+ *
+ * Named for menus because they were the first to need it; see
+ * [com.gotcha.ui.theme.SkinAlertDialog] for the other caller.
*/
val menuContainer: Color
get() = scheme.surface.over(ground)