Skip to content

A tiny friend in your Mac's notch and on your iPhone that keeps an eye on your AI coding agents: Claude Code, Codex, Cursor, Gemini CLI, Antigravity and more. Approve from the notch or your Lock Screen.

Android Widgets: restyle Solo and List with the shared look

Claudea8881f5ac431
diff --git a/android/app/src/main/kotlin/com/coucou/android/app/ListWidget.kt b/android/app/src/main/kotlin/com/coucou/android/app/ListWidget.kt
index 1631a981..3938ddf6 100644
--- a/android/app/src/main/kotlin/com/coucou/android/app/ListWidget.kt
+++ b/android/app/src/main/kotlin/com/coucou/android/app/ListWidget.kt
@@ -3,36 +3,64 @@ package com.coucou.android.app
import android.appwidget.AppWidgetManager
import android.appwidget.AppWidgetProvider
import android.content.Context
+import android.util.SizeF
import android.view.View
import android.widget.RemoteViews
import com.coucou.android.R
import com.coucou.android.core.WidgetContent
/**
- * The List widget: the headline, then one row per agent (a dot in its colour, its name, a state word). Drawn by
- * [WidgetHub] when something changes (updatePeriodMillis = 0). A tap on a row opens that agent; a tap on the headline
- * opens the app. It only opens things: a request waits for you in the app, behind the fingerprint.
+ * The List widget: the headline with a badge, then one row per agent of at least 48dp (a bar in its own colour, Mochi's
+ * face, its name, a state word and a dot in the state's tone). With no agent it is a centred empty state: Mochi asleep and
+ * one clear line. Drawn by [WidgetHub] when something changes (updatePeriodMillis = 0). A tap on a row opens that agent; a
+ * tap anywhere else opens the app. It only opens things: a request waits for you in the app, behind the fingerprint.
*/
class ListWidget : AppWidgetProvider() {
override fun onUpdate(context: Context, manager: AppWidgetManager, ids: IntArray) =
WidgetHub.refresh(context, manager, ids) { c, w -> views(c, w) }
companion object {
+ // Header 28dp + padding 20dp + 48dp per row: two rows fit 150dp, three 190dp, five 290dp.
+ private val MEDIUM_AT = SizeF(0f, 190f)
+ private val LARGE_AT = SizeF(0f, 290f)
+
private val ROWS = listOf(
- Row(R.id.list_row0, R.id.list_dot0, R.id.list_name0, R.id.list_state0),
- Row(R.id.list_row1, R.id.list_dot1, R.id.list_name1, R.id.list_state1),
- Row(R.id.list_row2, R.id.list_dot2, R.id.list_name2, R.id.list_state2),
- Row(R.id.list_row3, R.id.list_dot3, R.id.list_name3, R.id.list_state3),
- Row(R.id.list_row4, R.id.list_dot4, R.id.list_name4, R.id.list_state4),
+ Row(R.id.list_row0, R.id.list_stripe0, R.id.list_face0, R.id.list_name0, R.id.list_state0, R.id.list_dot0),
+ Row(R.id.list_row1, R.id.list_stripe1, R.id.list_face1, R.id.list_name1, R.id.list_state1, R.id.list_dot1),
+ Row(R.id.list_row2, R.id.list_stripe2, R.id.list_face2, R.id.list_name2, R.id.list_state2, R.id.list_dot2),
+ Row(R.id.list_row3, R.id.list_stripe3, R.id.list_face3, R.id.list_name3, R.id.list_state3, R.id.list_dot3),
+ Row(R.id.list_row4, R.id.list_stripe4, R.id.list_face4, R.id.list_name4, R.id.list_state4, R.id.list_dot4),
)
- private class Row(val row: Int, val dot: Int, val name: Int, val state: Int)
+ private class Row(val row: Int, val stripe: Int, val face: Int, val name: Int, val state: Int, val dot: Int)
+
+ fun views(context: Context, c: WidgetContent): RemoteViews =
+ WidgetHub.responsive(MEDIUM_AT, LARGE_AT) { size -> render(context, c, size) }
- fun views(context: Context, c: WidgetContent): RemoteViews {
+ private fun render(context: Context, c: WidgetContent, size: WidgetHub.Size): RemoteViews {
val v = RemoteViews(context.packageName, R.layout.widget_list)
+ WidgetHub.paint(v, R.id.list_root, R.id.list_tint, c.look)
+ v.setOnClickPendingIntent(R.id.list_root, WidgetHub.openApp(context, WidgetHub.CODE_LIST_HEADER))
+
+ if (c.tiles.isEmpty()) {
+ // The empty state fills the card: Mochi asleep (or calm) with his glow, the headline and one clear line.
+ v.setViewVisibility(R.id.list_header, View.GONE)
+ v.setViewVisibility(R.id.list_rows, View.GONE)
+ v.setViewVisibility(R.id.list_empty, View.VISIBLE)
+ v.setImageViewBitmap(R.id.list_empty_face, MochiBitmap.of(c.mood, WidgetHub.px(context, 96), glow = true))
+ v.setContentDescription(R.id.list_empty_face, context.getString(R.string.widget_mochi_description, c.mood.key))
+ v.setImageViewResource(R.id.list_empty_icon, if (c.connected) R.drawable.widget_dot else R.drawable.ic_widget_offline)
+ v.setInt(R.id.list_empty_icon, "setColorFilter", c.look.argb)
+ v.setTextViewText(R.id.list_empty_title, c.headline)
+ v.setTextViewText(R.id.list_empty_line, c.emptyLine.orEmpty())
+ return v
+ }
+
+ v.setViewVisibility(R.id.list_empty, View.GONE)
+ v.setViewVisibility(R.id.list_header, View.VISIBLE)
+ v.setViewVisibility(R.id.list_rows, View.VISIBLE)
+ v.setInt(R.id.list_status, "setColorFilter", c.look.argb)
v.setTextViewText(R.id.list_headline, c.headline)
- v.setTextColor(R.id.list_headline, c.tone.argb)
- v.setOnClickPendingIntent(R.id.list_header, WidgetHub.openApp(context, WidgetHub.CODE_LIST_HEADER))
if (c.waiting > 0) {
v.setTextViewText(R.id.list_badge, c.waiting.toString())
v.setContentDescription(R.id.list_badge, context.getString(R.string.widget_badge_description, c.waiting))
@@ -40,16 +68,25 @@ class ListWidget : AppWidgetProvider() {
} else {
v.setViewVisibility(R.id.list_badge, View.GONE)
}
+ val shown = when (size) {
+ WidgetHub.Size.SMALL -> 2
+ WidgetHub.Size.MEDIUM -> 3
+ WidgetHub.Size.LARGE -> ROWS.size
+ }
+ val face = WidgetHub.px(context, 36)
ROWS.forEachIndexed { i, r ->
val tile = c.tiles.getOrNull(i)
- if (tile == null) {
+ if (tile == null || i >= shown) {
v.setViewVisibility(r.row, View.GONE)
return@forEachIndexed
}
v.setViewVisibility(r.row, View.VISIBLE)
- v.setTextColor(r.dot, tile.argb)
+ v.setInt(r.stripe, "setColorFilter", tile.argb)
+ v.setImageViewBitmap(r.face, MochiBitmap.of(tile.state, face))
+ v.setContentDescription(r.face, context.getString(R.string.widget_mochi_description, tile.stateWord.lowercase()))
v.setTextViewText(r.name, tile.name)
v.setTextViewText(r.state, tile.stateWord)
+ v.setInt(r.dot, "setColorFilter", tile.tone.argb)
v.setOnClickPendingIntent(r.row, WidgetHub.openSession(context, WidgetHub.CODE_LIST_ROW + i, tile.pillId))
}
return v
diff --git a/android/app/src/main/kotlin/com/coucou/android/app/SoloWidget.kt b/android/app/src/main/kotlin/com/coucou/android/app/SoloWidget.kt
index c2e01379..4f625ac5 100644
--- a/android/app/src/main/kotlin/com/coucou/android/app/SoloWidget.kt
+++ b/android/app/src/main/kotlin/com/coucou/android/app/SoloWidget.kt
@@ -3,34 +3,59 @@ package com.coucou.android.app
import android.appwidget.AppWidgetManager
import android.appwidget.AppWidgetProvider
import android.content.Context
+import android.util.SizeF
+import android.util.TypedValue
import android.view.View
import android.widget.RemoteViews
import com.coucou.android.R
import com.coucou.android.core.WidgetContent
/**
- * The Solo widget: Mochi in the state of the most urgent agent, its name and one state word. Drawn by [WidgetHub] when
- * something changes (updatePeriodMillis = 0). A tap opens that agent, or the app when none is running. It only opens things: nothing is changed from here.
+ * The Solo widget: Mochi with a glow in the state's colour, the name of the most urgent agent with a dot and one state
+ * word. Drawn by [WidgetHub] when something changes (updatePeriodMillis = 0). A tap opens that agent, or the app when none
+ * is running. It only opens things: nothing is changed from here.
*/
class SoloWidget : AppWidgetProvider() {
override fun onUpdate(context: Context, manager: AppWidgetManager, ids: IntArray) =
WidgetHub.refresh(context, manager, ids) { c, w -> views(c, w) }
companion object {
- /** Mochi's picture is drawn this many dp wide; the system scales it to the widget. */
- private const val MOCHI_DP = 96
+ private val MEDIUM_AT = SizeF(100f, 100f)
+ private val LARGE_AT = SizeF(200f, 200f)
- fun views(context: Context, c: WidgetContent): RemoteViews {
+ fun views(context: Context, c: WidgetContent): RemoteViews =
+ WidgetHub.responsive(MEDIUM_AT, LARGE_AT) { size -> render(context, c, size) }
+
+ private fun render(context: Context, c: WidgetContent, size: WidgetHub.Size): RemoteViews {
val v = RemoteViews(context.packageName, R.layout.widget_solo)
+ WidgetHub.paint(v, R.id.solo_root, R.id.solo_tint, c.look)
val top = c.top
- val px = (MOCHI_DP * context.resources.displayMetrics.density).toInt().coerceAtLeast(1)
- v.setImageViewBitmap(R.id.solo_mochi, MochiBitmap.of(c.mood, px))
+ val large = size == WidgetHub.Size.LARGE
+ val small = size == WidgetHub.Size.SMALL
+
+ v.setImageViewBitmap(R.id.solo_mochi, MochiBitmap.of(c.mood, WidgetHub.px(context, if (large) 150 else if (small) 72 else 104), glow = true))
val word = top?.stateWord ?: c.headline
v.setContentDescription(R.id.solo_mochi, context.getString(R.string.widget_mochi_description, word.lowercase()))
- v.setTextViewText(R.id.solo_name, top?.name ?: c.headline)
- v.setTextColor(R.id.solo_name, top?.argb ?: c.tone.argb)
- v.setTextViewText(R.id.solo_state, top?.stateWord.orEmpty())
- v.setViewVisibility(R.id.solo_state, if (top == null) View.GONE else View.VISIBLE)
+
+ if (top != null) {
+ v.setViewVisibility(R.id.solo_name_row, View.VISIBLE)
+ v.setViewVisibility(R.id.solo_note_row, View.GONE)
+ v.setTextViewText(R.id.solo_name, top.name)
+ v.setInt(R.id.solo_dot, "setColorFilter", top.tone.argb)
+ v.setTextViewText(R.id.solo_state, top.stateWord)
+ } else {
+ // Nothing to list: the headline with an icon, and the one clear line under it.
+ v.setViewVisibility(R.id.solo_name_row, View.GONE)
+ v.setViewVisibility(R.id.solo_note_row, View.VISIBLE)
+ v.setTextViewText(R.id.solo_note, c.headline)
+ v.setImageViewResource(R.id.solo_note_icon, if (c.connected) R.drawable.widget_dot else R.drawable.ic_widget_offline)
+ v.setInt(R.id.solo_note_icon, "setColorFilter", c.look.argb)
+ v.setTextViewText(R.id.solo_state, c.emptyLine.orEmpty())
+ }
+ v.setViewVisibility(R.id.solo_state, if (small && top != null) View.GONE else View.VISIBLE)
+ v.setTextViewTextSize(R.id.solo_name, TypedValue.COMPLEX_UNIT_SP, if (large) 20f else 16f)
+ v.setTextViewTextSize(R.id.solo_state, TypedValue.COMPLEX_UNIT_SP, if (large) 15f else 13f)
+
if (c.waiting > 0) {
v.setTextViewText(R.id.solo_badge, c.waiting.toString())
v.setContentDescription(R.id.solo_badge, context.getString(R.string.widget_badge_description, c.waiting))
diff --git a/android/app/src/main/kotlin/com/coucou/android/app/WidgetHub.kt b/android/app/src/main/kotlin/com/coucou/android/app/WidgetHub.kt
index fd85245d..9c2a0a3f 100644
--- a/android/app/src/main/kotlin/com/coucou/android/app/WidgetHub.kt
+++ b/android/app/src/main/kotlin/com/coucou/android/app/WidgetHub.kt
@@ -10,8 +10,11 @@ import android.os.Build
import android.util.SizeF
import android.widget.RemoteViews
import com.coucou.android.MainActivity
+import com.coucou.android.R
import com.coucou.android.core.WidgetContent
import com.coucou.android.core.WidgetData
+import com.coucou.android.core.WidgetTone
+import kotlin.math.roundToInt
/**
* The one place that pushes the Solo and List widgets. The app calls [update] on every change of sessions, requests and
@@ -58,22 +61,35 @@ object WidgetHub {
/** The three sizes a responsive Widget is drawn for (Android 12 and later picks one by the room it has). */
enum class Size { SMALL, MEDIUM, LARGE }
- // Where each size starts, in dp. The system picks the largest entry that fits, so SMALL starts at zero.
- private val SMALL_AT = SizeF(0f, 0f)
- private val MEDIUM_AT = SizeF(180f, 110f)
- private val LARGE_AT = SizeF(250f, 180f)
-
/**
- * One picture per size on Android 12 and later; on Android 11 (API 30) there is no size map, so the plain MEDIUM
- * picture is the only one. [draw] builds the picture for a size from the same layout.
+ * One picture per size on Android 12 (API 31) and later; on Android 11 there is no size map, so the plain MEDIUM
+ * picture is the only one. [mediumAt] and [largeAt] are where those sizes start, in dp (the system picks the largest
+ * entry that fits, so SMALL starts at zero); [draw] builds the picture for a size from the same layout.
*/
- fun responsive(draw: (Size) -> RemoteViews): RemoteViews =
+ fun responsive(mediumAt: SizeF, largeAt: SizeF, draw: (Size) -> RemoteViews): RemoteViews =
if (Build.VERSION.SDK_INT >= 31) {
- RemoteViews(mapOf(SMALL_AT to draw(Size.SMALL), MEDIUM_AT to draw(Size.MEDIUM), LARGE_AT to draw(Size.LARGE)))
+ RemoteViews(mapOf(SizeF(0f, 0f) to draw(Size.SMALL), mediumAt to draw(Size.MEDIUM), largeAt to draw(Size.LARGE)))
} else {
draw(Size.MEDIUM)
}
+ /** dp to pixels on this screen, at least 1. */
+ fun px(context: Context, dp: Int): Int = (dp * context.resources.displayMetrics.density).roundToInt().coerceAtLeast(1)
+
+ /** The card and its gradient for a tone: an orange border while something waits, else the plain border; the tone's tint over it. */
+ fun paint(v: RemoteViews, root: Int, tint: Int, tone: WidgetTone) {
+ v.setInt(root, "setBackgroundResource", if (tone == WidgetTone.ATTENTION) R.drawable.widget_card_attention else R.drawable.widget_card)
+ v.setInt(tint, "setBackgroundResource", tintOf(tone))
+ }
+
+ private fun tintOf(tone: WidgetTone): Int = when (tone) {
+ WidgetTone.MUTED -> R.drawable.widget_tint_muted
+ WidgetTone.WORKING -> R.drawable.widget_tint_working
+ WidgetTone.ATTENTION -> R.drawable.widget_tint_attention
+ WidgetTone.DONE -> R.drawable.widget_tint_done
+ WidgetTone.TROUBLE -> R.drawable.widget_tint_trouble
+ }
+
/** Opens the app on Home. */
fun openApp(context: Context, code: Int): PendingIntent {
val open = Intent(context, MainActivity::class.java)
diff --git a/android/app/src/main/kotlin/com/coucou/android/core/WidgetData.kt b/android/app/src/main/kotlin/com/coucou/android/core/WidgetData.kt
index eedf9a35..b2d68986 100644
--- a/android/app/src/main/kotlin/com/coucou/android/core/WidgetData.kt
+++ b/android/app/src/main/kotlin/com/coucou/android/core/WidgetData.kt
@@ -36,7 +36,10 @@ enum class WidgetTone(val rgb: Rgb) {
}
/** One agent on a widget: who it is, a plain state word and its colour. Only names, state words and colours. */
-data class WidgetTile(val pillId: String, val name: String, val state: BotState, val stateWord: String, val argb: Int)
+data class WidgetTile(val pillId: String, val name: String, val state: BotState, val stateWord: String, val argb: Int) {
+ /** The colour of its dot: the state's tone (the agent's own colour is [argb]). */
+ val tone: WidgetTone get() = WidgetTone.of(state)
+}
/**
* Everything the Solo and List widgets draw, as plain data so two pushes can be compared and the identical one skipped.
@@ -55,6 +58,13 @@ data class WidgetContent(
/** The agent Solo shows. */
val top: WidgetTile? get() = tiles.firstOrNull()
+ /** The one clear line when there is no agent to list: the computer is not there, or nothing runs. Null when there are agents. */
+ val emptyLine: String? get() = when {
+ tiles.isNotEmpty() -> null
+ !connected -> "Waiting for your computer"
+ else -> "No agents running"
+ }
+
/** The look of the whole widget: orange while something waits for you, else the top agent's tone, muted when nothing runs. */
val look: WidgetTone get() = when {
!connected -> WidgetTone.MUTED
diff --git a/android/app/src/main/res/layout/widget_list.xml b/android/app/src/main/res/layout/widget_list.xml
index 71ecb340..46c5d5f3 100644
--- a/android/app/src/main/res/layout/widget_list.xml
+++ b/android/app/src/main/res/layout/widget_list.xml
@@ -1,245 +1,411 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- The List widget: the headline with a badge for what waits for you, then one row per agent (dot, name, state word). Plain RemoteViews, no library. -->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<!-- The List widget: a card with the headline and a badge, then rows of at least 48dp (stripe, Mochi's face, name, state word, dot).
+ With no agent the header and the rows give way to a centred empty state, so the card is never half blank. Plain RemoteViews. -->
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/list_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:background="@drawable/widget_bg"
- android:orientation="vertical"
- android:padding="14dp">
+ android:background="@drawable/widget_card">
- <LinearLayout
- android:id="@+id/list_header"
+ <FrameLayout
+ android:id="@+id/list_tint"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:orientation="horizontal"
- android:paddingBottom="4dp">
-
- <TextView
- android:id="@+id/list_headline"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:ellipsize="end"
- android:maxLines="1"
- android:textColor="#FFFFFFFF"
- android:textSize="15sp"
- android:textStyle="bold" />
-
- <TextView
- android:id="@+id/list_badge"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginStart="8dp"
- android:background="@drawable/widget_badge_bg"
- android:gravity="center"
- android:minWidth="20dp"
- android:paddingStart="6dp"
- android:paddingEnd="6dp"
- android:textColor="#FF1C1C1E"
- android:textSize="12sp"
- android:textStyle="bold"
- android:visibility="gone" />
- </LinearLayout>
+ android:layout_height="match_parent"
+ android:layout_margin="1dp"
+ android:background="@drawable/widget_tint_muted" />
<LinearLayout
- android:id="@+id/list_row0"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:orientation="horizontal"
- android:paddingTop="3dp"
- android:paddingBottom="3dp">
-
- <TextView
- android:id="@+id/list_dot0"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:importantForAccessibility="no"
- android:text="●"
- android:textSize="12sp" />
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:paddingStart="14dp"
+ android:paddingTop="10dp"
+ android:paddingEnd="14dp"
+ android:paddingBottom="10dp">
- <TextView
- android:id="@+id/list_name0"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_marginStart="8dp"
- android:layout_weight="1"
- android:ellipsize="end"
- android:maxLines="1"
- android:textColor="#FFFFFFFF"
- android:textSize="13sp"
- android:textStyle="bold" />
-
- <TextView
- android:id="@+id/list_state0"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginStart="8dp"
- android:ellipsize="end"
- android:maxLines="1"
- android:textColor="#FFAEAEB2"
- android:textSize="12sp" />
- </LinearLayout>
+ <LinearLayout
+ android:id="@+id/list_header"
+ android:layout_width="match_parent"
+ android:layout_height="28dp"
+ android:gravity="center_vertical"
+ android:orientation="horizontal">
- <LinearLayout
- android:id="@+id/list_row1"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:orientation="horizontal"
- android:paddingTop="3dp"
- android:paddingBottom="3dp">
-
- <TextView
- android:id="@+id/list_dot1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:importantForAccessibility="no"
- android:text="●"
- android:textSize="12sp" />
+ <ImageView
+ android:id="@+id/list_status"
+ android:layout_width="@dimen/widget_dot"
+ android:layout_height="@dimen/widget_dot"
+ android:importantForAccessibility="no"
+ android:src="@drawable/widget_dot" />
- <TextView
- android:id="@+id/list_name1"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_marginStart="8dp"
- android:layout_weight="1"
- android:ellipsize="end"
- android:maxLines="1"
- android:textColor="#FFFFFFFF"
- android:textSize="13sp"
- android:textStyle="bold" />
-
- <TextView
- android:id="@+id/list_state1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginStart="8dp"
- android:ellipsize="end"
- android:maxLines="1"
- android:textColor="#FFAEAEB2"
- android:textSize="12sp" />
- </LinearLayout>
+ <TextView
+ android:id="@+id/list_headline"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="8dp"
+ android:layout_weight="1"
+ android:ellipsize="end"
+ android:maxLines="1"
+ android:textColor="@color/widget_text"
+ android:textSize="@dimen/widget_text_name"
+ android:textStyle="bold" />
- <LinearLayout
- android:id="@+id/list_row2"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:orientation="horizontal"
- android:paddingTop="3dp"
- android:paddingBottom="3dp">
-
- <TextView
- android:id="@+id/list_dot2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:importantForAccessibility="no"
- android:text="●"
- android:textSize="12sp" />
+ <TextView
+ android:id="@+id/list_badge"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="8dp"
+ android:background="@drawable/widget_badge_bg"
+ android:gravity="center"
+ android:minWidth="22dp"
+ android:paddingStart="6dp"
+ android:paddingEnd="6dp"
+ android:textColor="#FF1C1C1E"
+ android:textSize="@dimen/widget_text_secondary"
+ android:textStyle="bold"
+ android:visibility="gone" />
+ </LinearLayout>
- <TextView
- android:id="@+id/list_name2"
- android:layout_width="0dp"
+ <LinearLayout
+ android:id="@+id/list_rows"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginStart="8dp"
- android:layout_weight="1"
- android:ellipsize="end"
- android:maxLines="1"
- android:textColor="#FFFFFFFF"
- android:textSize="13sp"
- android:textStyle="bold" />
-
- <TextView
- android:id="@+id/list_state2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginStart="8dp"
- android:ellipsize="end"
- android:maxLines="1"
- android:textColor="#FFAEAEB2"
- android:textSize="12sp" />
- </LinearLayout>
+ android:orientation="vertical">
- <LinearLayout
- android:id="@+id/list_row3"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:orientation="horizontal"
- android:paddingTop="3dp"
- android:paddingBottom="3dp">
-
- <TextView
- android:id="@+id/list_dot3"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:importantForAccessibility="no"
- android:text="●"
- android:textSize="12sp" />
+ <LinearLayout
+ android:id="@+id/list_row0"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/widget_row_min"
+ android:gravity="center_vertical"
+ android:orientation="horizontal">
- <TextView
- android:id="@+id/list_name3"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_marginStart="8dp"
- android:layout_weight="1"
- android:ellipsize="end"
- android:maxLines="1"
- android:textColor="#FFFFFFFF"
- android:textSize="13sp"
- android:textStyle="bold" />
-
- <TextView
- android:id="@+id/list_state3"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginStart="8dp"
- android:ellipsize="end"
- android:maxLines="1"
- android:textColor="#FFAEAEB2"
- android:textSize="12sp" />
- </LinearLayout>
+ <ImageView
+ android:id="@+id/list_stripe0"
+ android:layout_width="3dp"
+ android:layout_height="28dp"
+ android:importantForAccessibility="no"
+ android:src="@drawable/widget_stripe" />
- <LinearLayout
- android:id="@+id/list_row4"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:orientation="horizontal"
- android:paddingTop="3dp"
- android:paddingBottom="3dp">
-
- <TextView
- android:id="@+id/list_dot4"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:importantForAccessibility="no"
- android:text="●"
- android:textSize="12sp" />
+ <ImageView
+ android:id="@+id/list_face0"
+ android:layout_width="36dp"
+ android:layout_height="36dp"
+ android:layout_marginStart="8dp"
+ android:scaleType="fitCenter" />
- <TextView
- android:id="@+id/list_name4"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_marginStart="8dp"
- android:layout_weight="1"
- android:ellipsize="end"
- android:maxLines="1"
- android:textColor="#FFFFFFFF"
- android:textSize="13sp"
- android:textStyle="bold" />
-
- <TextView
- android:id="@+id/list_state4"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginStart="8dp"
- android:ellipsize="end"
- android:maxLines="1"
- android:textColor="#FFAEAEB2"
- android:textSize="12sp" />
+ <LinearLayout
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="10dp"
+ android:layout_weight="1"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/list_name0"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ellipsize="end"
+ android:maxLines="1"
+ android:textColor="@color/widget_text"
+ android:textSize="@dimen/widget_text_name"
+ android:textStyle="bold" />
+
+ <TextView
+ android:id="@+id/list_state0"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ellipsize="end"
+ android:maxLines="1"
+ android:textColor="@color/widget_text_secondary"
+ android:textSize="@dimen/widget_text_state" />
+ </LinearLayout>
+
+ <ImageView
+ android:id="@+id/list_dot0"
+ android:layout_width="@dimen/widget_dot"
+ android:layout_height="@dimen/widget_dot"
+ android:layout_marginStart="8dp"
+ android:importantForAccessibility="no"
+ android:src="@drawable/widget_dot" />
+ </LinearLayout>
+
+ <LinearLayout
+ android:id="@+id/list_row1"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/widget_row_min"
+ android:gravity="center_vertical"
+ android:orientation="horizontal">
+
+ <ImageView
+ android:id="@+id/list_stripe1"
+ android:layout_width="3dp"
+ android:layout_height="28dp"
+ android:importantForAccessibility="no"
+ android:src="@drawable/widget_stripe" />
+
+ <ImageView
+ android:id="@+id/list_face1"
+ android:layout_width="36dp"
+ android:layout_height="36dp"
+ android:layout_marginStart="8dp"
+ android:scaleType="fitCenter" />
+
+ <LinearLayout
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="10dp"
+ android:layout_weight="1"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/list_name1"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ellipsize="end"
+ android:maxLines="1"
+ android:textColor="@color/widget_text"
+ android:textSize="@dimen/widget_text_name"
+ android:textStyle="bold" />
+
+ <TextView
+ android:id="@+id/list_state1"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ellipsize="end"
+ android:maxLines="1"
+ android:textColor="@color/widget_text_secondary"
+ android:textSize="@dimen/widget_text_state" />
+ </LinearLayout>
+
+ <ImageView
+ android:id="@+id/list_dot1"
+ android:layout_width="@dimen/widget_dot"
+ android:layout_height="@dimen/widget_dot"
+ android:layout_marginStart="8dp"
+ android:importantForAccessibility="no"
+ android:src="@drawable/widget_dot" />
+ </LinearLayout>
+
+ <LinearLayout
+ android:id="@+id/list_row2"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/widget_row_min"
+ android:gravity="center_vertical"
+ android:orientation="horizontal">
+
+ <ImageView
+ android:id="@+id/list_stripe2"
+ android:layout_width="3dp"
+ android:layout_height="28dp"
+ android:importantForAccessibility="no"
+ android:src="@drawable/widget_stripe" />
+
+ <ImageView
+ android:id="@+id/list_face2"
+ android:layout_width="36dp"
+ android:layout_height="36dp"
+ android:layout_marginStart="8dp"
+ android:scaleType="fitCenter" />
+
+ <LinearLayout
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="10dp"
+ android:layout_weight="1"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/list_name2"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ellipsize="end"
+ android:maxLines="1"
+ android:textColor="@color/widget_text"
+ android:textSize="@dimen/widget_text_name"
+ android:textStyle="bold" />
+
+ <TextView
+ android:id="@+id/list_state2"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ellipsize="end"
+ android:maxLines="1"
+ android:textColor="@color/widget_text_secondary"
+ android:textSize="@dimen/widget_text_state" />
+ </LinearLayout>
+
+ <ImageView
+ android:id="@+id/list_dot2"
+ android:layout_width="@dimen/widget_dot"
+ android:layout_height="@dimen/widget_dot"
+ android:layout_marginStart="8dp"
+ android:importantForAccessibility="no"
+ android:src="@drawable/widget_dot" />
+ </LinearLayout>
+
+ <LinearLayout
+ android:id="@+id/list_row3"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/widget_row_min"
+ android:gravity="center_vertical"
+ android:orientation="horizontal">
+
+ <ImageView
+ android:id="@+id/list_stripe3"
+ android:layout_width="3dp"
+ android:layout_height="28dp"
+ android:importantForAccessibility="no"
+ android:src="@drawable/widget_stripe" />
+
+ <ImageView
+ android:id="@+id/list_face3"
+ android:layout_width="36dp"
+ android:layout_height="36dp"
+ android:layout_marginStart="8dp"
+ android:scaleType="fitCenter" />
+
+ <LinearLayout
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="10dp"
+ android:layout_weight="1"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/list_name3"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ellipsize="end"
+ android:maxLines="1"
+ android:textColor="@color/widget_text"
+ android:textSize="@dimen/widget_text_name"
+ android:textStyle="bold" />
+
+ <TextView
+ android:id="@+id/list_state3"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ellipsize="end"
+ android:maxLines="1"
+ android:textColor="@color/widget_text_secondary"
+ android:textSize="@dimen/widget_text_state" />
+ </LinearLayout>
+
+ <ImageView
+ android:id="@+id/list_dot3"
+ android:layout_width="@dimen/widget_dot"
+ android:layout_height="@dimen/widget_dot"
+ android:layout_marginStart="8dp"
+ android:importantForAccessibility="no"
+ android:src="@drawable/widget_dot" />
+ </LinearLayout>
+
+ <LinearLayout
+ android:id="@+id/list_row4"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/widget_row_min"
+ android:gravity="center_vertical"
+ android:orientation="horizontal">
+
+ <ImageView
+ android:id="@+id/list_stripe4"
+ android:layout_width="3dp"
+ android:layout_height="28dp"
+ android:importantForAccessibility="no"
+ android:src="@drawable/widget_stripe" />
+
+ <ImageView
+ android:id="@+id/list_face4"
+ android:layout_width="36dp"
+ android:layout_height="36dp"
+ android:layout_marginStart="8dp"
+ android:scaleType="fitCenter" />
+
+ <LinearLayout
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="10dp"
+ android:layout_weight="1"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/list_name4"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ellipsize="end"
+ android:maxLines="1"
+ android:textColor="@color/widget_text"
+ android:textSize="@dimen/widget_text_name"
+ android:textStyle="bold" />
+
+ <TextView
+ android:id="@+id/list_state4"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ellipsize="end"
+ android:maxLines="1"
+ android:textColor="@color/widget_text_secondary"
+ android:textSize="@dimen/widget_text_state" />
+ </LinearLayout>
+
+ <ImageView
+ android:id="@+id/list_dot4"
+ android:layout_width="@dimen/widget_dot"
+ android:layout_height="@dimen/widget_dot"
+ android:layout_marginStart="8dp"
+ android:importantForAccessibility="no"
+ android:src="@drawable/widget_dot" />
+ </LinearLayout>
+ </LinearLayout>
+
+ <LinearLayout
+ android:id="@+id/list_empty"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="center"
+ android:orientation="vertical"
+ android:visibility="gone">
+
+ <ImageView
+ android:id="@+id/list_empty_face"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:scaleType="fitCenter" />
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical"
+ android:orientation="horizontal">
+
+ <ImageView
+ android:id="@+id/list_empty_icon"
+ android:layout_width="@dimen/widget_icon"
+ android:layout_height="@dimen/widget_icon"
+ android:importantForAccessibility="no"
+ android:src="@drawable/ic_widget_offline" />
+
+ <TextView
+ android:id="@+id/list_empty_title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="6dp"
+ android:maxLines="1"
+ android:ellipsize="end"
+ android:textColor="@color/widget_text_soft"
+ android:textSize="@dimen/widget_text_note"
+ android:textStyle="bold" />
+ </LinearLayout>
+
+ <TextView
+ android:id="@+id/list_empty_line"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ellipsize="end"
+ android:gravity="center"
+ android:maxLines="1"
+ android:textColor="@color/widget_text_secondary"
+ android:textSize="@dimen/widget_text_state" />
+ </LinearLayout>
</LinearLayout>
-</LinearLayout>
+</FrameLayout>
diff --git a/android/app/src/main/res/layout/widget_solo.xml b/android/app/src/main/res/layout/widget_solo.xml
index 04031ce6..4c9a8b65 100644
--- a/android/app/src/main/res/layout/widget_solo.xml
+++ b/android/app/src/main/res/layout/widget_solo.xml
@@ -1,10 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- The Solo widget: Mochi in the state of the most urgent agent, its name and a state word. Plain RemoteViews, no library. -->
+<!-- The Solo widget: Mochi with a glow in the state's colour (over half the card), the top agent's name with its dot and a state word.
+ With no agent the name gives way to a note with an icon ("Not connected"). Plain RemoteViews, no library. -->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/solo_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:background="@drawable/widget_bg">
+ android:background="@drawable/widget_card">
+
+ <FrameLayout
+ android:id="@+id/solo_tint"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_margin="1dp"
+ android:background="@drawable/widget_tint_muted" />
<LinearLayout
android:layout_width="match_parent"
@@ -15,22 +23,64 @@
<ImageView
android:id="@+id/solo_mochi"
- android:contentDescription="@string/widget_solo_label"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
+ android:contentDescription="@string/widget_solo_label"
android:scaleType="fitCenter" />
- <TextView
- android:id="@+id/solo_name"
- android:layout_width="match_parent"
+ <LinearLayout
+ android:id="@+id/solo_name_row"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:ellipsize="end"
- android:gravity="center"
- android:maxLines="1"
- android:textColor="#FFFFFFFF"
- android:textSize="14sp"
- android:textStyle="bold" />
+ android:gravity="center_vertical"
+ android:orientation="horizontal">
+
+ <ImageView
+ android:id="@+id/solo_dot"
+ android:layout_width="@dimen/widget_dot"
+ android:layout_height="@dimen/widget_dot"
+ android:importantForAccessibility="no"
+ android:src="@drawable/widget_dot" />
+
+ <TextView
+ android:id="@+id/solo_name"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="6dp"
+ android:ellipsize="end"
+ android:maxLines="1"
+ android:textColor="@color/widget_text"
+ android:textSize="@dimen/widget_text_name"
+ android:textStyle="bold" />
+ </LinearLayout>
+
+ <LinearLayout
+ android:id="@+id/solo_note_row"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical"
+ android:orientation="horizontal"
+ android:visibility="gone">
+
+ <ImageView
+ android:id="@+id/solo_note_icon"
+ android:layout_width="@dimen/widget_icon"
+ android:layout_height="@dimen/widget_icon"
+ android:importantForAccessibility="no"
+ android:src="@drawable/ic_widget_offline" />
+
+ <TextView
+ android:id="@+id/solo_note"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="6dp"
+ android:ellipsize="end"
+ android:maxLines="1"
+ android:textColor="@color/widget_text_soft"
+ android:textSize="@dimen/widget_text_note"
+ android:textStyle="bold" />
+ </LinearLayout>
<TextView
android:id="@+id/solo_state"
@@ -39,8 +89,8 @@
android:ellipsize="end"
android:gravity="center"
android:maxLines="1"
- android:textColor="#FFAEAEB2"
- android:textSize="12sp" />
+ android:textColor="@color/widget_text_secondary"
+ android:textSize="@dimen/widget_text_state" />
</LinearLayout>
<TextView
@@ -48,14 +98,14 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|end"
- android:layout_margin="8dp"
+ android:layout_margin="10dp"
android:background="@drawable/widget_badge_bg"
android:gravity="center"
- android:minWidth="20dp"
+ android:minWidth="22dp"
android:paddingStart="6dp"
android:paddingEnd="6dp"
android:textColor="#FF1C1C1E"
- android:textSize="12sp"
+ android:textSize="@dimen/widget_text_secondary"
android:textStyle="bold"
android:visibility="gone" />
</FrameLayout>
diff --git a/android/app/src/main/res/xml/coucou_list_widget_info.xml b/android/app/src/main/res/xml/coucou_list_widget_info.xml
index 66ef6863..8e9fa658 100644
--- a/android/app/src/main/res/xml/coucou_list_widget_info.xml
+++ b/android/app/src/main/res/xml/coucou_list_widget_info.xml
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="250dp"
- android:minHeight="180dp"
+ android:minHeight="190dp"
android:targetCellWidth="4"
android:targetCellHeight="3"
android:minResizeWidth="180dp"
- android:minResizeHeight="110dp"
+ android:minResizeHeight="150dp"
android:resizeMode="horizontal|vertical"
android:updatePeriodMillis="0"
android:widgetCategory="home_screen"
diff --git a/android/app/src/test/kotlin/com/coucou/android/WidgetDataTest.kt b/android/app/src/test/kotlin/com/coucou/android/WidgetDataTest.kt
index 3a890ca5..6747d0c5 100644
--- a/android/app/src/test/kotlin/com/coucou/android/WidgetDataTest.kt
+++ b/android/app/src/test/kotlin/com/coucou/android/WidgetDataTest.kt
@@ -96,4 +96,17 @@ class WidgetDataTest {
assertFalse(text.contains("secret"))
assertFalse(text.contains("rm -rf"))
}
+
+ @Test fun anEmptyCardSaysOneClearLine() {
+ assertEquals("Waiting for your computer", build(emptyList(), link = LinkState.DISCONNECTED).emptyLine)
+ assertEquals("Waiting for your computer", build(listOf(s("agent_codex", BotState.WORKING)), link = LinkState.CONNECTING).emptyLine)
+ assertEquals("No agents running", build(emptyList()).emptyLine)
+ assertNull(build(listOf(s("agent_codex", BotState.WORKING))).emptyLine)
+ }
+
+ @Test fun aTilesDotIsTheToneOfItsState() {
+ val t = build(listOf(s("agent_codex", BotState.APPROVAL), s("agent_amp", BotState.FINISHED))).tiles
+ assertEquals(com.coucou.android.core.WidgetTone.ATTENTION, t[0].tone)
+ assertEquals(com.coucou.android.core.WidgetTone.DONE, t[1].tone)
+ }
}
diff --git a/android/app/src/test/kotlin/com/coucou/android/WidgetSurfacesTest.kt b/android/app/src/test/kotlin/com/coucou/android/WidgetSurfacesTest.kt
index 617bc921..4a76919d 100644
--- a/android/app/src/test/kotlin/com/coucou/android/WidgetSurfacesTest.kt
+++ b/android/app/src/test/kotlin/com/coucou/android/WidgetSurfacesTest.kt
@@ -89,4 +89,33 @@ class WidgetSurfacesTest {
assertTrue(File("src/main/res/layout/widget_glance.xml").exists())
assertTrue(read("src/main/res/xml/coucou_widget_info.xml").contains("""android:targetCellWidth="3""""))
}
+
+ @Test fun theListRowsAreAtLeastFortyEightDpAndTheEmptyStateFillsTheCard() {
+ val list = read("src/main/res/layout/widget_list.xml")
+ assertEquals(5, Regex("""android:layout_height="@dimen/widget_row_min"""").findAll(list).count())
+ for (id in listOf("list_empty", "list_empty_face", "list_empty_title", "list_empty_line", "list_tint", "list_root")) assertTrue(id, list.contains("@+id/$id"))
+ val code = read(main + "app/ListWidget.kt")
+ assertTrue(code.contains("c.tiles.isEmpty()"))
+ assertTrue(code.contains("R.id.list_empty"))
+ }
+
+ @Test fun theCardsUseTheSharedLook() {
+ for (layout in listOf("widget_solo", "widget_list")) {
+ val xml = read("src/main/res/layout/$layout.xml")
+ assertTrue(layout, xml.contains("@drawable/widget_card"))
+ assertTrue(layout, xml.contains("@drawable/widget_tint_muted"))
+ // Colours and sizes come from the shared resources, never from a literal grey at 12sp.
+ assertFalse(layout, xml.contains("#FFAEAEB2"))
+ }
+ val solo = read(main + "app/SoloWidget.kt")
+ assertTrue(solo.contains("WidgetHub.paint("))
+ assertTrue(read(main + "app/ListWidget.kt").contains("WidgetHub.paint("))
+ }
+
+ @Test fun mochiHasAtLeastHalfOfTheSoloCard() {
+ val solo = read("src/main/res/layout/widget_solo.xml")
+ // Mochi takes the leftover height (weight 1) while the text rows wrap their content.
+ assertTrue(solo.contains("""android:layout_weight="1""""))
+ assertTrue(read(main + "app/SoloWidget.kt").contains("glow = true"))
+ }
}