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.
Swift ai-agentsanthropicantigravityclaudeclaude-codecodexcursordynamic-islandgemini-cliiosiphonlinuxmacosmacos-appmenubar-appnotchopen-sourceswiftswiftuiwindows
Android Widgets: restyle the 3x2 summary widget
Claude925c379e4ec4
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xmlindex 1f7ff0f7..43c9d157 100644--- a/android/app/src/main/AndroidManifest.xml+++ b/android/app/src/main/AndroidManifest.xml@@ -67,7 +67,7 @@<receiver android:name=".app.ActionReceiver" android:exported="false" /><!-- The home-screen widget: a short summary, updated by the app when something changes (no timer). -->- <receiver android:name=".app.GlanceWidget" android:exported="true" android:label="@string/app_name">+ <receiver android:name=".app.GlanceWidget" android:exported="true" android:label="@string/widget_glance_label"><intent-filter><action android:name="android.appwidget.action.APPWIDGET_UPDATE" /></intent-filter>diff --git a/android/app/src/main/kotlin/com/coucou/android/app/GlanceWidget.kt b/android/app/src/main/kotlin/com/coucou/android/app/GlanceWidget.ktindex dce827c9..20d32502 100644--- a/android/app/src/main/kotlin/com/coucou/android/app/GlanceWidget.kt+++ b/android/app/src/main/kotlin/com/coucou/android/app/GlanceWidget.kt@@ -1,20 +1,23 @@package com.coucou.android.app-import android.app.PendingIntentimport android.appwidget.AppWidgetManagerimport android.appwidget.AppWidgetProviderimport android.content.ComponentNameimport android.content.Context-import android.content.Intent+import android.util.SizeF+import android.view.Viewimport android.widget.RemoteViews-import com.coucou.android.MainActivityimport com.coucou.android.Rimport com.coucou.android.core.Glance+import com.coucou.android.core.WidgetTone+import com.coucou.android.core.mood/**- * The home-screen widget: the same short summary as the notification and the tile ([Glance]), drawn with plain- * RemoteViews. It never updates on a timer (updatePeriodMillis = 0): the app pushes a new picture when something- * changes, so it costs nothing while nothing happens. A tap opens Coucou.+ * The home-screen summary widget (3x2): the same short summary as the notification and the tile ([Glance]: its text and counts+ * are unchanged), on the shared card with a gradient in the colour of the state. A small Mochi in the state of the most urgent+ * agent sits on the left; on the right are the headline, a badge for what waits for you and up to three short lines, each with a+ * dot in the state's tone. It never updates on a timer (updatePeriodMillis = 0): the app pushes a new picture when something+ * changes, so it costs nothing while nothing happens. A tap anywhere opens Coucou; there is no button here.*/class GlanceWidget : AppWidgetProvider() {override fun onUpdate(context: Context, manager: AppWidgetManager, ids: IntArray) {@@ -35,18 +38,60 @@ class GlanceWidget : AppWidgetProvider() {}}- private fun views(context: Context, g: Glance): RemoteViews {+ // Height in dp: from 100 two lines under the headline, from 150 the detail line and three lines; below, one line.+ private val MEDIUM_AT = SizeF(0f, 100f)+ private val LARGE_AT = SizeF(0f, 150f)++ private class Row(val row: Int, val dot: Int, val name: Int, val text: Int)++ private val ROWS = listOf(+ Row(R.id.glance_row0, R.id.glance_dot0, R.id.glance_name0, R.id.glance_text0),+ Row(R.id.glance_row1, R.id.glance_dot1, R.id.glance_name1, R.id.glance_text1),+ Row(R.id.glance_row2, R.id.glance_dot2, R.id.glance_name2, R.id.glance_text2),+ )++ private fun views(context: Context, g: Glance): RemoteViews =+ WidgetHub.responsive(MEDIUM_AT, LARGE_AT) { size -> render(context, g, size) }++ private fun render(context: Context, g: Glance, size: WidgetHub.Size): RemoteViews {val v = RemoteViews(context.packageName, R.layout.widget_glance)- v.setTextViewText(R.id.widget_headline, g.headline)- v.setTextViewText(R.id.widget_detail, g.detail)- v.setTextColor(R.id.widget_dot, g.tone.argb)- v.setTextViewText(R.id.widget_lines, g.lines.joinToString("\n") { "${it.agent}: ${it.text}" })- val open = Intent(context, MainActivity::class.java)- .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP)- v.setOnClickPendingIntent(- R.id.widget_root,- PendingIntent.getActivity(context, 0, open, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE),- )+ val tone = WidgetTone.of(g.tone)+ WidgetHub.paint(v, R.id.widget_root, R.id.glance_tint, tone)++ val mood = g.mood()+ v.setImageViewBitmap(R.id.glance_mochi, MochiBitmap.of(mood, WidgetHub.px(context, 64), glow = true))+ v.setContentDescription(R.id.glance_mochi, context.getString(R.string.widget_mochi_description, mood.key))++ v.setTextViewText(R.id.glance_headline, g.headline)+ if (g.waiting > 0) {+ v.setTextViewText(R.id.glance_badge, g.waiting.toString())+ v.setContentDescription(R.id.glance_badge, context.getString(R.string.widget_badge_description, g.waiting))+ v.setViewVisibility(R.id.glance_badge, View.VISIBLE)+ } else {+ v.setViewVisibility(R.id.glance_badge, View.GONE)+ }++ val rows = when (size) {+ WidgetHub.Size.SMALL -> 1+ WidgetHub.Size.MEDIUM -> 2+ WidgetHub.Size.LARGE -> ROWS.size+ }+ // The detail line says why there is nothing to list, or, with room to spare, adds to the headline.+ v.setTextViewText(R.id.glance_detail, g.detail)+ v.setViewVisibility(R.id.glance_detail, if (g.lines.isEmpty() || size == WidgetHub.Size.LARGE) View.VISIBLE else View.GONE)+ ROWS.forEachIndexed { i, r ->+ val line = g.lines.getOrNull(i)+ if (line == null || i >= rows) {+ v.setViewVisibility(r.row, View.GONE)+ return@forEachIndexed+ }+ v.setViewVisibility(r.row, View.VISIBLE)+ v.setInt(r.dot, "setColorFilter", WidgetTone.of(line.state).argb)+ v.setTextViewText(r.name, line.agent)+ v.setTextViewText(r.text, line.text)+ }++ v.setOnClickPendingIntent(R.id.widget_root, WidgetHub.openApp(context, WidgetHub.CODE_GLANCE))return v}}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.ktindex aed7b499..13fcab46 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@@ -28,6 +28,15 @@ enum class WidgetTone(val rgb: Rgb) {companion object {private fun c(v: Double) = (v.coerceIn(0.0, 1.0) * 255).roundToInt()+ /** The tone of a [Glance] (the summary widget, the tile and the notification share these five). */+ fun of(tone: GlanceTone): WidgetTone = when (tone) {+ GlanceTone.CALM -> MUTED+ GlanceTone.OK -> DONE+ GlanceTone.BUSY -> WORKING+ GlanceTone.ATTENTION -> ATTENTION+ GlanceTone.TROUBLE -> TROUBLE+ }+/** The tone of one agent's state; a computer that is not connected is always muted. */fun of(state: BotState, connected: Boolean = true): WidgetTone = if (!connected) MUTED else when (state) {BotState.APPROVAL, BotState.QUESTION -> ATTENTION@@ -156,6 +165,9 @@ enum class WidgetSample(val key: String) {}}+/** The state of Mochi's face on the summary widget: the most urgent agent's, else calm when connected and asleep when not. */+fun Glance.mood(): BotState = lines.firstOrNull()?.state ?: if (connected) BotState.IDLE else BotState.SLEEPING+object WidgetData {/** Rows on the List widget. */const val MAX_ROWS = 5diff --git a/android/app/src/main/res/layout/widget_glance.xml b/android/app/src/main/res/layout/widget_glance.xmlindex 10504118..571d617c 100644--- a/android/app/src/main/res/layout/widget_glance.xml+++ b/android/app/src/main/res/layout/widget_glance.xml@@ -1,57 +1,202 @@<?xml version="1.0" encoding="utf-8"?>-<!-- The home-screen widget: a dot for the tone, the headline, one detail line and up to four agents. Plain RemoteViews, no library. -->-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"+<!-- The summary widget (3x2) on the shared card: a small Mochi in the state of the most urgent agent on the left; on the right a clear+ headline (with a badge for what waits for you), one detail line when there is room, and up to three short lines with a dot in the+ state's tone. Until the first update it shows a calm Mochi and a short line. A tap anywhere opens the app. Plain RemoteViews. -->+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"android:id="@+id/widget_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">++ <FrameLayout+ android:id="@+id/glance_tint"+ android:layout_width="match_parent"+ android:layout_height="match_parent"+ android:layout_margin="1dp"+ android:background="@drawable/widget_tint_muted" /><LinearLayoutandroid:layout_width="match_parent"- android:layout_height="wrap_content"+ android:layout_height="match_parent"android:gravity="center_vertical"- android:orientation="horizontal">+ android:orientation="horizontal"+ android:padding="12dp">- <TextView- android:id="@+id/widget_dot"- android:layout_width="wrap_content"- android:layout_height="wrap_content"- android:text="●"- android:textSize="14sp" />+ <ImageView+ android:id="@+id/glance_mochi"+ android:layout_width="64dp"+ android:layout_height="64dp"+ android:contentDescription="@string/widget_glance_label"+ android:scaleType="fitCenter"+ android:src="@drawable/preview_mochi_idle" />- <TextView- android:id="@+id/widget_headline"+ <LinearLayoutandroid:layout_width="0dp"android:layout_height="wrap_content"android:layout_marginStart="8dp"android:layout_weight="1"- android:maxLines="1"- android:ellipsize="end"- android:textColor="#FFFFFFFF"- android:textSize="15sp"- android:textStyle="bold" />- </LinearLayout>+ android:orientation="vertical">- <TextView- android:id="@+id/widget_detail"- android:layout_width="match_parent"- android:layout_height="wrap_content"- android:layout_marginTop="2dp"- android:maxLines="1"- android:ellipsize="end"- android:textColor="#FFAEAEB2"- android:textSize="12sp" />-- <TextView- android:id="@+id/widget_lines"- android:layout_width="match_parent"- android:layout_height="wrap_content"- android:layout_marginTop="8dp"- android:maxLines="4"- android:ellipsize="end"- android:lineSpacingExtra="2dp"- android:textColor="#FFE5E5EA"- android:textSize="12sp" />-</LinearLayout>+ <LinearLayout+ android:layout_width="match_parent"+ android:layout_height="wrap_content"+ android:gravity="center_vertical"+ android:orientation="horizontal">++ <TextView+ android:id="@+id/glance_headline"+ android:layout_width="0dp"+ android:layout_height="wrap_content"+ android:layout_weight="1"+ android:ellipsize="end"+ android:maxLines="1"+ android:text="@string/widget_initial_title"+ android:textColor="@color/widget_text"+ android:textSize="@dimen/widget_text_name"+ android:textStyle="bold" />++ <TextView+ android:id="@+id/glance_badge"+ android:layout_width="wrap_content"+ android:layout_height="wrap_content"+ android:layout_marginStart="6dp"+ 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/glance_detail"+ android:layout_width="match_parent"+ android:layout_height="wrap_content"+ android:ellipsize="end"+ android:maxLines="1"+ android:text="@string/widget_initial_line"+ android:textColor="@color/widget_text_secondary"+ android:textSize="@dimen/widget_text_secondary" />++ <LinearLayout+ android:id="@+id/glance_row0"+ android:layout_width="match_parent"+ android:layout_height="wrap_content"+ android:layout_marginTop="3dp"+ android:gravity="center_vertical"+ android:orientation="horizontal"+ android:visibility="gone">++ <ImageView+ android:id="@+id/glance_dot0"+ android:layout_width="8dp"+ android:layout_height="8dp"+ android:importantForAccessibility="no"+ android:src="@drawable/widget_dot" />++ <TextView+ android:id="@+id/glance_name0"+ 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_state"+ android:textStyle="bold" />++ <TextView+ android:id="@+id/glance_text0"+ android:layout_width="0dp"+ android:layout_height="wrap_content"+ android:layout_marginStart="6dp"+ android:layout_weight="1"+ android:ellipsize="end"+ android:maxLines="1"+ android:textColor="@color/widget_text_secondary"+ android:textSize="@dimen/widget_text_secondary" />+ </LinearLayout>++ <LinearLayout+ android:id="@+id/glance_row1"+ android:layout_width="match_parent"+ android:layout_height="wrap_content"+ android:layout_marginTop="3dp"+ android:gravity="center_vertical"+ android:orientation="horizontal"+ android:visibility="gone">++ <ImageView+ android:id="@+id/glance_dot1"+ android:layout_width="8dp"+ android:layout_height="8dp"+ android:importantForAccessibility="no"+ android:src="@drawable/widget_dot" />++ <TextView+ android:id="@+id/glance_name1"+ 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_state"+ android:textStyle="bold" />++ <TextView+ android:id="@+id/glance_text1"+ android:layout_width="0dp"+ android:layout_height="wrap_content"+ android:layout_marginStart="6dp"+ android:layout_weight="1"+ android:ellipsize="end"+ android:maxLines="1"+ android:textColor="@color/widget_text_secondary"+ android:textSize="@dimen/widget_text_secondary" />+ </LinearLayout>++ <LinearLayout+ android:id="@+id/glance_row2"+ android:layout_width="match_parent"+ android:layout_height="wrap_content"+ android:layout_marginTop="3dp"+ android:gravity="center_vertical"+ android:orientation="horizontal"+ android:visibility="gone">++ <ImageView+ android:id="@+id/glance_dot2"+ android:layout_width="8dp"+ android:layout_height="8dp"+ android:importantForAccessibility="no"+ android:src="@drawable/widget_dot" />++ <TextView+ android:id="@+id/glance_name2"+ 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_state"+ android:textStyle="bold" />++ <TextView+ android:id="@+id/glance_text2"+ android:layout_width="0dp"+ android:layout_height="wrap_content"+ android:layout_marginStart="6dp"+ android:layout_weight="1"+ android:ellipsize="end"+ android:maxLines="1"+ android:textColor="@color/widget_text_secondary"+ android:textSize="@dimen/widget_text_secondary" />+ </LinearLayout>+ </LinearLayout>+ </LinearLayout>+</FrameLayout>diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xmlindex c26e7b11..780ee242 100644--- a/android/app/src/main/res/values/strings.xml+++ b/android/app/src/main/res/values/strings.xml@@ -10,7 +10,8 @@<string name="action_allow">Allow</string><string name="action_deny">Deny</string><string name="action_close">Close</string>- <string name="widget_description">Shows whether your agents are working, without opening Coucou.</string>+ <string name="widget_description">Who is working and what waits for you.</string>+ <string name="widget_glance_label">Agents summary</string><string name="widget_solo_label">Mochi at a glance</string><string name="widget_list_label">All your agents</string><string name="widget_solo_description">Mochi and your most urgent agent.</string>@@ -62,6 +63,9 @@<string name="widget_sample_ring_pct">70%</string><string name="widget_sample_ring_label">Claude · 5 h</string><string name="widget_sample_today">5</string>+ <string name="widget_sample_two_agents">2 agents are working</string>+ <string name="widget_sample_thinking">Thinking</string>+ <string name="widget_sample_idle">Idle</string><string name="status_connected">Connected</string><string name="status_connecting">Connecting…</string><string name="status_not_connected">Not connected</string>diff --git a/android/i18n/app-strings.json b/android/i18n/app-strings.jsonindex 97f1f3b2..e99ee9f7 100644--- a/android/i18n/app-strings.json+++ b/android/i18n/app-strings.json@@ -10,7 +10,8 @@"action_allow": "Allow","action_deny": "Deny","action_close": "Close",- "widget_description": "Shows whether your agents are working, without opening Coucou.",+ "widget_description": "Who is working and what waits for you.",+ "widget_glance_label": "Agents summary","widget_solo_label": "Mochi at a glance","widget_list_label": "All your agents","widget_solo_description": "Mochi and your most urgent agent.",@@ -62,6 +63,9 @@"widget_sample_ring_pct": "70%","widget_sample_ring_label": "Claude · 5 h","widget_sample_today": "5",+ "widget_sample_two_agents": "2 agents are working",+ "widget_sample_thinking": "Thinking",+ "widget_sample_idle": "Idle","status_connected": "Connected","status_connecting": "Connecting…","status_not_connected": "Not connected",