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.

feat: the overlays follow the skin (stage 1 of the overlay work)

Durganshu Mishra4a326847b5a6
diff --git a/app/src/main/java/com/gotcha/ui/AssistiveBallOverlay.kt b/app/src/main/java/com/gotcha/ui/AssistiveBallOverlay.kt
index ac5268f..2f5d8fa 100644
--- a/app/src/main/java/com/gotcha/ui/AssistiveBallOverlay.kt
+++ b/app/src/main/java/com/gotcha/ui/AssistiveBallOverlay.kt
@@ -4,7 +4,6 @@ import android.animation.ValueAnimator
import android.content.Context
import android.graphics.Color
import android.graphics.PixelFormat
-import android.graphics.Typeface
import android.graphics.drawable.GradientDrawable
import android.os.Handler
import android.os.Looper
@@ -20,15 +19,15 @@ import android.widget.FrameLayout
import android.widget.LinearLayout
import android.widget.ScrollView
import android.widget.TextView
-import androidx.compose.ui.graphics.toArgb
-import androidx.core.content.res.ResourcesCompat
import androidx.core.graphics.ColorUtils
import com.gotcha.R
import com.gotcha.data.SettingsRepository
import com.gotcha.service.EntityType
import com.gotcha.service.ProactiveSessionItem
import com.gotcha.service.SmartActionDetector
+import com.gotcha.ui.theme.OverlaySkin
import com.gotcha.ui.theme.Skins
+import com.gotcha.ui.theme.overlaySkin
import kotlin.math.abs
import kotlin.math.hypot
@@ -75,43 +74,18 @@ class AssistiveBallOverlay(context: Context) {
private var dockSide: Int = DOCK_SIDE_END
private val ballParams: WindowManager.LayoutParams by lazy { ballLayoutParams() }
private val settingsRepository by lazy { SettingsRepository(appContext) }
- private val figtree: Typeface? by lazy {
- runCatching { ResourcesCompat.getFont(appContext, R.font.figtree) }.getOrNull()
- }
-
- private class OverlayPalette(
- val surface: Int,
- val onSurface: Int,
- val outline: Int,
- val buttonBg: Int,
- val buttonText: Int
- )
/**
- * The ball is a window over other apps, so it takes its colours from the
- * chosen skin rather than from a pair of hardcoded Deep Space palettes.
- *
- * Always the [Skin.opaque] variant: there is no wallpaper of ours behind
- * this window, only whatever app the user is looking at, and translucent
- * chrome over someone else's screen is unreadable.
+ * The active skin, translated for View code. Re-read on each build rather
+ * than cached, so changing theme in Settings reaches the ball the next time
+ * it draws anything without needing to tear the window down.
*/
- private fun skinScheme() = Skins.byId(
+ private fun palette(): OverlaySkin = overlaySkin(
+ appContext,
runCatching { settingsRepository.load().skinId }.getOrDefault(Skins.DEFAULT_ID)
- ).opaque().scheme
-
- private fun palette(): OverlayPalette {
- val scheme = skinScheme()
- return OverlayPalette(
- surface = scheme.surface.toArgb(),
- onSurface = scheme.onSurface.toArgb(),
- outline = scheme.outline.toArgb(),
- buttonBg = scheme.secondaryContainer.toArgb(),
- buttonText = scheme.onSecondaryContainer.toArgb()
- )
- }
+ )
- /** The skin's own accent, for the ring and any other tinted overlay part. */
- private fun accentColor(): Int = skinScheme().primary.toArgb()
+ private fun accentColor(): Int = palette().accent
fun canShow(): Boolean = Settings.canDrawOverlays(appContext)
@@ -216,7 +190,7 @@ class AssistiveBallOverlay(context: Context) {
orientation = LinearLayout.VERTICAL
setPadding(dp(20), dp(16), dp(20), dp(16))
background = GradientDrawable().apply {
- cornerRadius = dp(20).toFloat()
+ cornerRadius = dp(colors.cardRadiusDp.toInt()).toFloat()
setColor(colors.surface)
setStroke(dp(1), colors.outline)
}
@@ -225,9 +199,9 @@ class AssistiveBallOverlay(context: Context) {
addView(
TextView(appContext).apply {
text = message
- typeface = figtree ?: Typeface.DEFAULT
+ typeface = colors.sans
setTextColor(colors.onSurface)
- textSize = 14f
+ textSize = colors.bodySp
}
)
layoutParams = LinearLayout.LayoutParams(
@@ -293,7 +267,7 @@ class AssistiveBallOverlay(context: Context) {
orientation = LinearLayout.VERTICAL
setPadding(dp(10), dp(10), dp(10), dp(10))
background = GradientDrawable().apply {
- cornerRadius = dp(18).toFloat()
+ cornerRadius = dp(colors.cardRadiusDp.toInt()).toFloat()
setColor(colors.surface)
setStroke(dp(1), colors.outline)
}
@@ -364,7 +338,7 @@ class AssistiveBallOverlay(context: Context) {
}
}
- private fun buildProactiveMenuContent(menuCard: LinearLayout, colors: OverlayPalette) {
+ private fun buildProactiveMenuContent(menuCard: LinearLayout, colors: OverlaySkin) {
// Always show clipboard/smart action at the top
pendingSmartAction?.let { (label, prompt) ->
menuCard.addView(
@@ -399,8 +373,8 @@ class AssistiveBallOverlay(context: Context) {
val entity = item.entity
val headerText = TextView(appContext).apply {
text = "${getCategoryIcon(entity.type)} ${SmartActionDetector.snippet(entity.normalizedValue, 24)}"
- typeface = figtree ?: Typeface.DEFAULT
- textSize = 12f
+ typeface = colors.sans
+ textSize = colors.labelSp
setTextColor(colors.onSurface)
setPadding(dp(6), dp(6), dp(6), dp(4))
}
@@ -413,13 +387,13 @@ class AssistiveBallOverlay(context: Context) {
for (action in entity.actions) {
val chipBtn = TextView(appContext).apply {
text = action.label
- typeface = figtree ?: Typeface.DEFAULT
- textSize = 12f
+ typeface = colors.sans
+ textSize = colors.labelSp
setTextColor(colors.buttonText)
gravity = Gravity.CENTER
setPadding(dp(10), dp(6), dp(10), dp(6))
background = GradientDrawable().apply {
- cornerRadius = dp(10).toFloat()
+ cornerRadius = dp(colors.buttonRadiusDp.toInt()).toFloat()
setColor(colors.buttonBg)
}
layoutParams = LinearLayout.LayoutParams(
@@ -457,16 +431,16 @@ class AssistiveBallOverlay(context: Context) {
EntityType.GENERIC_TEXT -> "📋"
}
- private fun tapButton(label: String, colors: OverlayPalette, onClick: () -> Unit): TextView {
+ private fun tapButton(label: String, colors: OverlaySkin, onClick: () -> Unit): TextView {
return TextView(appContext).apply {
text = label
- typeface = figtree ?: Typeface.DEFAULT
- textSize = 13f
+ typeface = colors.sans
+ textSize = colors.bodySp
setTextColor(colors.buttonText)
gravity = Gravity.CENTER
setPadding(dp(14), dp(8), dp(14), dp(8))
background = GradientDrawable().apply {
- cornerRadius = dp(12).toFloat()
+ cornerRadius = dp(colors.buttonRadiusDp.toInt()).toFloat()
setColor(colors.buttonBg)
}
layoutParams = LinearLayout.LayoutParams(
diff --git a/app/src/main/java/com/gotcha/ui/CallChatWindow.kt b/app/src/main/java/com/gotcha/ui/CallChatWindow.kt
index 1fc69d8..b69294d 100644
--- a/app/src/main/java/com/gotcha/ui/CallChatWindow.kt
+++ b/app/src/main/java/com/gotcha/ui/CallChatWindow.kt
@@ -20,7 +20,10 @@ import android.widget.FrameLayout
import android.widget.LinearLayout
import android.widget.TextView
import androidx.core.graphics.ColorUtils
+import com.gotcha.data.SettingsRepository
import com.gotcha.service.CallState
+import com.gotcha.ui.theme.Skins
+import com.gotcha.ui.theme.overlaySkin
import kotlin.math.abs
/**
@@ -67,7 +70,7 @@ class CallChatWindow(context: Context) {
private var breatheAnimator: ValueAnimator? = null
private var swapAnimator: ValueAnimator? = null
private var currentActionEmoji: String = ""
- private var currentActionTint: Int = TINT_MIC
+ private var currentActionTint: Int = Color.TRANSPARENT
private var currentBreatheTag: String = ""
private var entranceAnimating: Boolean = false
@@ -145,7 +148,7 @@ class CallChatWindow(context: Context) {
/** (emoji, glass tint) for the action button in a given call state. */
private fun actionAppearance(s: CallState): Pair<String, Int>? = when (s) {
- CallState.READY, CallState.WAITING_USER -> "\uD83C\uDFA4" to TINT_MIC
+ CallState.READY, CallState.WAITING_USER -> "\uD83C\uDFA4" to readyTint()
CallState.LISTENING -> "\u23F9" to TINT_STOP
CallState.THINKING, CallState.SPEAKING -> "\uD83D\uDED1" to TINT_INTERRUPT
else -> null
@@ -331,7 +334,7 @@ class CallChatWindow(context: Context) {
private fun glassButton(emoji: String, size: Int, isEnd: Boolean): View {
val density = appContext.resources.displayMetrics.density
- val glass = GlassButtonDrawable(if (isEnd) TINT_END else TINT_MIC).apply {
+ val glass = GlassButtonDrawable(if (isEnd) TINT_END else readyTint()).apply {
fillAlpha = if (isEnd) 120 else 105
}
if (isEnd) glassEnd = glass else glassAction = glass
@@ -763,12 +766,21 @@ class CallChatWindow(context: Context) {
private fun dp(value: Float): Int =
(value * appContext.resources.displayMetrics.density).toInt()
+ /** The resting mic tint, taken from whichever skin is on. */
+ private fun readyTint(): Int = overlaySkin(
+ appContext,
+ runCatching { SettingsRepository(appContext).load().skinId }
+ .getOrDefault(Skins.DEFAULT_ID)
+ ).accent
+
private companion object {
const val BTN_SIZE_DP = 44
const val END_LONG_PRESS_MS = 2000L
- // Glass tints per action state and the end button.
- val TINT_MIC = Color.parseColor("#2FB6C4") // calm teal — ready / mic
+ // Glass tints per action state. Three of these are semantic and stay
+ // fixed: amber, coral and red have to keep meaning the same thing in
+ // every theme, the way the context meter's warning colour does. Only
+ // the resting state follows the skin — see [readyTint].
val TINT_STOP = Color.parseColor("#E8A13A") // amber — listening / stop
val TINT_INTERRUPT = Color.parseColor("#E5544B") // coral — interrupt
val TINT_END = Color.parseColor("#E23B3B") // red — end call
diff --git a/app/src/main/java/com/gotcha/ui/ConfirmationOverlay.kt b/app/src/main/java/com/gotcha/ui/ConfirmationOverlay.kt
index 8b585e4..2f557f6 100644
--- a/app/src/main/java/com/gotcha/ui/ConfirmationOverlay.kt
+++ b/app/src/main/java/com/gotcha/ui/ConfirmationOverlay.kt
@@ -1,7 +1,6 @@
package com.gotcha.ui
import android.content.Context
-import android.graphics.Color
import android.graphics.PixelFormat
import android.graphics.drawable.GradientDrawable
import android.os.Handler
@@ -13,6 +12,9 @@ import android.view.WindowManager
import android.widget.Button
import android.widget.LinearLayout
import android.widget.TextView
+import com.gotcha.data.SettingsRepository
+import com.gotcha.ui.theme.Skins
+import com.gotcha.ui.theme.overlaySkin
/**
* A confirmation prompt drawn as a floating window on top of whatever app is in the
@@ -65,27 +67,34 @@ class ConfirmationOverlay(context: Context) {
}
private fun buildCard(summary: String, onAllow: () -> Unit, onDeny: () -> Unit): View {
+ val colors = overlaySkin(
+ appContext,
+ runCatching { SettingsRepository(appContext).load().skinId }
+ .getOrDefault(Skins.DEFAULT_ID)
+ )
val container = LinearLayout(appContext).apply {
orientation = LinearLayout.VERTICAL
setPadding(dp(20), dp(20), dp(20), dp(20))
background = GradientDrawable().apply {
- cornerRadius = dp(16).toFloat()
- setColor(Color.parseColor("#1E1E1E"))
- setStroke(dp(1), Color.parseColor("#3A3A3A"))
+ cornerRadius = dp(colors.cardRadiusDp.toInt()).toFloat()
+ setColor(colors.surface)
+ setStroke(dp(1), colors.outline)
}
}
val title = TextView(appContext).apply {
text = "Gotcha — confirm action"
- setTextColor(Color.WHITE)
- textSize = 16f
+ setTextColor(colors.onSurface)
+ textSize = colors.titleSp
+ typeface = colors.sans
setPadding(0, 0, 0, dp(8))
}
val body = TextView(appContext).apply {
text = summary
- setTextColor(Color.parseColor("#CCCCCC"))
- textSize = 13f
+ setTextColor(colors.onSurfaceVariant)
+ textSize = colors.bodySp
+ typeface = colors.sans
}
val buttonRow = LinearLayout(appContext).apply {
diff --git a/app/src/main/java/com/gotcha/ui/ScreenCompanionPanelOverlay.kt b/app/src/main/java/com/gotcha/ui/ScreenCompanionPanelOverlay.kt
index 5c2dbc4..dd1a094 100644
--- a/app/src/main/java/com/gotcha/ui/ScreenCompanionPanelOverlay.kt
+++ b/app/src/main/java/com/gotcha/ui/ScreenCompanionPanelOverlay.kt
@@ -18,7 +18,10 @@ import android.widget.EditText
import android.widget.LinearLayout
import android.widget.ScrollView
import android.widget.TextView
-import androidx.core.graphics.ColorUtils
+import com.gotcha.data.SettingsRepository
+import com.gotcha.ui.theme.OverlaySkin
+import com.gotcha.ui.theme.Skins
+import com.gotcha.ui.theme.overlaySkin
import io.noties.markwon.Markwon
class ScreenCompanionPanelOverlay(private val context: Context) {
@@ -49,6 +52,17 @@ class ScreenCompanionPanelOverlay(private val context: Context) {
private fun dp(value: Int): Int = (value * appContext.resources.displayMetrics.density).toInt()
+ /**
+ * The active skin, in View form. This panel used to paint itself `#CC1E1E1E`
+ * with a `Color.CYAN` stroke — Deep Space, hardcoded, from before there was
+ * more than one theme.
+ */
+ private fun skin(): OverlaySkin = overlaySkin(
+ appContext,
+ runCatching { SettingsRepository(appContext).load().skinId }
+ .getOrDefault(Skins.DEFAULT_ID)
+ )
+
fun setVisibleForCapture(visible: Boolean) {
mainHandler.post {
panelView?.visibility = if (visible) View.VISIBLE else View.GONE
@@ -65,13 +79,14 @@ class ScreenCompanionPanelOverlay(private val context: Context) {
panelView = null
}
+ val colors = skin()
val container = LinearLayout(appContext).apply {
orientation = LinearLayout.VERTICAL
setPadding(dp(16), dp(16), dp(16), dp(16))
background = GradientDrawable().apply {
- cornerRadius = dp(24).toFloat()
- setColor(Color.parseColor("#CC1E1E1E"))
- setStroke(dp(1), ColorUtils.setAlphaComponent(Color.CYAN, 80))
+ cornerRadius = dp(colors.cardRadiusDp.toInt()).toFloat()
+ setColor(colors.surface)
+ setStroke(dp(1), colors.outline)
}
}
@@ -82,14 +97,14 @@ class ScreenCompanionPanelOverlay(private val context: Context) {
}
val titleText = TextView(appContext).apply {
text = "Screen Companion"
- setTextColor(Color.WHITE)
- textSize = 16f
- typeface = Typeface.DEFAULT_BOLD
+ setTextColor(colors.onSurface)
+ textSize = colors.titleSp
+ typeface = Typeface.create(colors.sans, Typeface.BOLD)
layoutParams = LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1f)
}
val speakerBtn = TextView(appContext).apply {
text = "🔊"
- textSize = 18f
+ textSize = colors.titleSp
setPadding(dp(8), dp(8), dp(8), dp(8))
setOnClickListener {
if (isSpeaking) {
@@ -107,8 +122,8 @@ class ScreenCompanionPanelOverlay(private val context: Context) {
speakerButton = speakerBtn
val closeButton = TextView(appContext).apply {
text = "✕"
- setTextColor(Color.LTGRAY)
- textSize = 18f
+ setTextColor(colors.onSurfaceVariant)
+ textSize = colors.titleSp
setPadding(dp(8), dp(8), dp(8), dp(8))
setOnClickListener { dismiss() }
}
@@ -130,16 +145,16 @@ class ScreenCompanionPanelOverlay(private val context: Context) {
val promptView = TextView(appContext).apply {
text = initialPrompt
- setTextColor(Color.LTGRAY)
- textSize = 14f
+ setTextColor(colors.onSurfaceVariant)
+ textSize = colors.labelSp
setPadding(0, 0, 0, dp(8))
}
chatContainer.addView(promptView)
responseTextView = TextView(appContext).apply {
text = resultText ?: "Thinking..."
- setTextColor(Color.WHITE)
- textSize = 15f
+ setTextColor(colors.onSurface)
+ textSize = colors.bodySp
setPadding(0, dp(8), 0, dp(16))
// Ensure links are clickable
movementMethod = android.text.method.LinkMovementMethod.getInstance()
@@ -185,8 +200,8 @@ class ScreenCompanionPanelOverlay(private val context: Context) {
orientation = LinearLayout.HORIZONTAL
gravity = Gravity.CENTER_VERTICAL
background = GradientDrawable().apply {
- cornerRadius = dp(20).toFloat()
- setColor(Color.parseColor("#33FFFFFF"))
+ cornerRadius = dp(colors.buttonRadiusDp.toInt()).toFloat()
+ setColor(colors.buttonBg)
}
setPadding(dp(12), dp(4), dp(4), dp(4))
}
@@ -194,17 +209,17 @@ class ScreenCompanionPanelOverlay(private val context: Context) {
val editText = EditText(appContext).apply {
hint = "Ask a follow-up..."
setHintTextColor(Color.GRAY)
- setTextColor(Color.WHITE)
+ setTextColor(colors.onSurface)
background = null
layoutParams = LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1f)
- textSize = 14f
+ textSize = colors.labelSp
maxLines = 3
}
inputEditText = editText
val micBtn = TextView(appContext).apply {
text = "🎤"
- textSize = 18f
+ textSize = colors.titleSp
setPadding(dp(8), dp(8), dp(8), dp(8))
setOnClickListener {
if (isListening) {
@@ -285,15 +300,17 @@ class ScreenCompanionPanelOverlay(private val context: Context) {
}
private fun createChip(label: String): TextView {
+ val colors = skin()
return TextView(appContext).apply {
text = label
- setTextColor(Color.WHITE)
- textSize = 13f
+ setTextColor(colors.buttonText)
+ textSize = colors.bodySp
+ typeface = colors.sans
setPadding(dp(12), dp(6), dp(12), dp(6))
background = GradientDrawable().apply {
- cornerRadius = dp(16).toFloat()
- setColor(Color.parseColor("#444444"))
- setStroke(dp(1), Color.GRAY)
+ cornerRadius = dp(colors.buttonRadiusDp.toInt()).toFloat()
+ setColor(colors.buttonBg)
+ setStroke(dp(1), colors.outline)
}
layoutParams = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
diff --git a/app/src/main/java/com/gotcha/ui/theme/OverlaySkin.kt b/app/src/main/java/com/gotcha/ui/theme/OverlaySkin.kt
new file mode 100644
index 0000000..4eee390
--- /dev/null
+++ b/app/src/main/java/com/gotcha/ui/theme/OverlaySkin.kt
@@ -0,0 +1,90 @@
+package com.gotcha.ui.theme
+
+import android.content.Context
+import android.graphics.Typeface
+import androidx.compose.ui.graphics.toArgb
+import androidx.core.content.res.ResourcesCompat
+import com.gotcha.R
+
+/**
+ * The active skin, in the form View code can use.
+ *
+ * The overlays are `LinearLayout`/`TextView`/`GradientDrawable` rather than
+ * Compose, so none of them can read [LocalSkin]. They were therefore carrying
+ * their own hardcoded look — two dozen loose radii and text sizes, a `#1E1E1E`
+ * panel, a `Color.CYAN` stroke left over from when Deep Space was the only
+ * theme. This is the one place that translates a [Skin] for them.
+ *
+ * Always built from [Skin.opaque]. An overlay floats over somebody else's app,
+ * not over our wallpaper: there is nothing of ours behind it to show through,
+ * and translucent chrome over an unknown screen is unreadable. Depth here comes
+ * from an edge highlight and a shadow, never from transparency.
+ */
+data class OverlaySkin(
+ val surface: Int,
+ val onSurface: Int,
+ val onSurfaceVariant: Int,
+ val outline: Int,
+ val buttonBg: Int,
+ val buttonText: Int,
+ val accent: Int,
+ val onAccent: Int,
+ val error: Int,
+ /** Radius for cards and menus, in dp, from [Skin.corner]. */
+ val cardRadiusDp: Float,
+ /** Radius for buttons and rows, in dp, from [Skin.cornerSmall]. */
+ val buttonRadiusDp: Float,
+ val sans: Typeface,
+ val mono: Typeface,
+ val titleSp: Float,
+ val bodySp: Float,
+ val labelSp: Float
+)
+
+/**
+ * Figtree, cached. Loaded once because an overlay can be rebuilt many times in a
+ * session and font lookup is not free.
+ *
+ * The fallback is deliberate: an overlay that fails to draw is worse than one
+ * drawn in the platform face, and this code runs over other people's apps where
+ * there is no screen of ours left to report an error on.
+ */
+private var figtreeCache: Typeface? = null
+
+private fun figtree(context: Context): Typeface {
+ figtreeCache?.let { return it }
+ val loaded = runCatching {
+ ResourcesCompat.getFont(context.applicationContext, R.font.figtree)
+ }.getOrNull() ?: Typeface.DEFAULT
+ figtreeCache = loaded
+ return loaded
+}
+
+/**
+ * Builds the overlay tokens for [skinId].
+ *
+ * Type sizes come off the app's own [Typography] rather than being chosen here,
+ * so the overlays cannot drift onto a scale of their own.
+ */
+fun overlaySkin(context: Context, skinId: String): OverlaySkin {
+ val skin = Skins.byId(skinId).opaque()
+ val scheme = skin.scheme
+ return OverlaySkin(
+ surface = scheme.surface.toArgb(),
+ onSurface = scheme.onSurface.toArgb(),
+ onSurfaceVariant = scheme.onSurfaceVariant.toArgb(),
+ outline = scheme.outline.toArgb(),
+ buttonBg = scheme.secondaryContainer.toArgb(),
+ buttonText = scheme.onSecondaryContainer.toArgb(),
+ accent = scheme.primary.toArgb(),
+ onAccent = scheme.onPrimary.toArgb(),
+ error = scheme.error.toArgb(),
+ cardRadiusDp = skin.corner.value,
+ buttonRadiusDp = skin.cornerSmall.value,
+ sans = figtree(context),
+ mono = Typeface.MONOSPACE,
+ titleSp = Typography.titleMedium.fontSize.value,
+ bodySp = Typography.bodyMedium.fontSize.value,
+ labelSp = Typography.labelMedium.fontSize.value
+ )
+}
diff --git a/app/src/test/java/com/gotcha/ui/theme/OverlaySkinTest.kt b/app/src/test/java/com/gotcha/ui/theme/OverlaySkinTest.kt
new file mode 100644
index 0000000..f2854ec
--- /dev/null
+++ b/app/src/test/java/com/gotcha/ui/theme/OverlaySkinTest.kt
@@ -0,0 +1,82 @@
+package com.gotcha.ui.theme
+
+import android.graphics.Color
+import androidx.compose.ui.graphics.toArgb
+import androidx.test.core.app.ApplicationProvider
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertTrue
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.robolectric.RobolectricTestRunner
+
+/**
+ * The overlays are View code and cannot read [LocalSkin], so [overlaySkin] is
+ * the only thing keeping them on the same design as the app. Before it existed
+ * they had drifted to a hardcoded `#1E1E1E` panel with a `Color.CYAN` stroke —
+ * which nobody noticed, because nothing asserted otherwise.
+ */
+@RunWith(RobolectricTestRunner::class)
+class OverlaySkinTest {
+
+ private val context = ApplicationProvider.getApplicationContext<android.content.Context>()
+
+ @Test
+ fun `radii come from the chosen skin`() {
+ val orchid = overlaySkin(context, Skins.Orchid.id)
+ assertEquals(Skins.Orchid.corner.value, orchid.cardRadiusDp, 0.001f)
+ assertEquals(Skins.Orchid.cornerSmall.value, orchid.buttonRadiusDp, 0.001f)
+
+ val nocturne = overlaySkin(context, Skins.Nocturne.id)
+ assertTrue(
+ "the skins have different shapes, so their overlays must too",
+ orchid.cardRadiusDp != nocturne.cardRadiusDp
+ )
+ }
+
+ @Test
+ fun `the accent is the skin's own`() {
+ Skins.all.forEach { skin ->
+ assertEquals(
+ skin.id,
+ skin.opaque().scheme.primary.toArgb(),
+ overlaySkin(context, skin.id).accent
+ )
+ }
+ }
+
+ /**
+ * An overlay draws over another app. Anything see-through there is unreadable,
+ * and there is no wallpaper of ours behind it to justify the attempt.
+ */
+ @Test
+ fun `every overlay colour is fully opaque`() {
+ Skins.all.forEach { skin ->
+ val tokens = overlaySkin(context, skin.id)
+ listOf(
+ "surface" to tokens.surface,
+ "onSurface" to tokens.onSurface,
+ "outline" to tokens.outline,
+ "buttonBg" to tokens.buttonBg,
+ "buttonText" to tokens.buttonText,
+ "accent" to tokens.accent
+ ).forEach { (role, argb) ->
+ assertEquals("${skin.id} $role", 255, Color.alpha(argb))
+ }
+ }
+ }
+
+ @Test
+ fun `an unknown skin falls back rather than throwing`() {
+ val fallback = overlaySkin(context, "a-skin-from-a-future-build")
+ assertEquals(overlaySkin(context, Skins.DEFAULT_ID).accent, fallback.accent)
+ }
+
+ /** Type sizes track the app's scale rather than being chosen per overlay. */
+ @Test
+ fun `type sizes come from the app typography`() {
+ val tokens = overlaySkin(context, Skins.Aura.id)
+ assertEquals(Typography.titleMedium.fontSize.value, tokens.titleSp, 0.001f)
+ assertEquals(Typography.bodyMedium.fontSize.value, tokens.bodySp, 0.001f)
+ assertEquals(Typography.labelMedium.fontSize.value, tokens.labelSp, 0.001f)
+ }
+}