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: plan usage has its own colours and a near-limit look

Claude152e8d7a61ab
diff --git a/android/app/src/main/kotlin/com/coucou/android/app/BarBitmap.kt b/android/app/src/main/kotlin/com/coucou/android/app/BarBitmap.kt
index 8fa5a0a0..e31fb372 100644
--- a/android/app/src/main/kotlin/com/coucou/android/app/BarBitmap.kt
+++ b/android/app/src/main/kotlin/com/coucou/android/app/BarBitmap.kt
@@ -16,7 +16,7 @@ import kotlin.math.max
/**
* The thin bar of a plan-usage row on Mochi Big, drawn once into a bitmap like [RingBitmap] draws the Usage Ring's ring: a faint
- * track and a rounded fill in the colour of the usage (green, orange above 75%, red above 90%). A few are kept so a push that changes
+ * track and a rounded fill in the colour of the usage (teal, yellow from 75%, red from 90%: [com.coucou.android.core.PlanUsageLook]). A few are kept so a push that changes
* nothing about a bar draws nothing. No timer, no frame loop.
*/
object BarBitmap {
@@ -32,7 +32,7 @@ object BarBitmap {
/** The bar for [row], [widthPx] by [heightPx]. */
@Synchronized
fun of(row: UsageRing, widthPx: Int, heightPx: Int): Bitmap {
- val key = Key(row.pct.coerceIn(0, 100), row.barTone.argb, widthPx, heightPx)
+ val key = Key(row.shown, row.tone.argb, widthPx, heightPx)
return cache.getOrPut(key) { draw(row, widthPx, heightPx) }
}
@@ -44,7 +44,7 @@ object BarBitmap {
if (row.fraction > 0f) {
// Never narrower than its own height, so a small value still shows a round dot.
val fill = max(heightPx.toFloat(), widthPx * row.fraction)
- drawRoundRect(Color(row.barTone.argb), Offset.Zero, Size(fill, heightPx.toFloat()), round)
+ drawRoundRect(Color(row.tone.argb), Offset.Zero, Size(fill, heightPx.toFloat()), round)
}
}
return image.asAndroidBitmap()
diff --git a/android/app/src/main/kotlin/com/coucou/android/app/MochiBigWidget.kt b/android/app/src/main/kotlin/com/coucou/android/app/MochiBigWidget.kt
index c226763e..68e0f8bb 100644
--- a/android/app/src/main/kotlin/com/coucou/android/app/MochiBigWidget.kt
+++ b/android/app/src/main/kotlin/com/coucou/android/app/MochiBigWidget.kt
@@ -16,11 +16,13 @@ import com.coucou.android.core.WidgetTone
/**
* The Mochi Big widget (4x4). The top is in two sides. On the left, Mochi with his glow and his badge, then the agent's name and
- * state word, so the state reads without a sentence. On the right, the plan usage (up to two rows: Claude and Codex, each with a big percentage and a thin bar that is green, orange above
- * 75% and red above 90%), or one calm message when it is off or the computer is not there. Under them, rounded buttons that only open a screen of the app (Home, Chat, Settings, Recent, the top agent, Pair
- * again): none when the card is small, one row of four from the medium size, two rows of three when large. They are tinted orange
- * while something waits. Drawn by [WidgetHub] when something changes (updatePeriodMillis = 0). A tap on the card opens the top agent,
- * or the app. Nothing here changes anything.
+ * state word, so the state reads without a sentence. On the right, the plan usage: up to two rows (Claude and Codex), each with a thin
+ * bar that is teal, yellow from 75% and red from 90%. Under the red line the percentage is small and normal; from 90% it is big and
+ * bold with "Near limit" and, when known, when it resets. When plan usage is off or the computer is not there, one calm message.
+ * Under them, rounded buttons that only open a screen of the app (Home, Chat, Settings, Recent, the top agent, Pair again): none
+ * when the card is small, one row of four from the medium size, two rows of three when large; tinted orange while something waits.
+ * Drawn by [WidgetHub] when something changes (updatePeriodMillis = 0). A tap on the card opens the top agent, or the app.
+ * Nothing here changes anything.
*/
class MochiBigWidget : AppWidgetProvider() {
override fun onUpdate(context: Context, manager: AppWidgetManager, ids: IntArray) =
@@ -117,9 +119,9 @@ class MochiBigWidget : AppWidgetProvider() {
when (c.usageSide) {
UsageSide.ROWS -> {
v.setViewVisibility(R.id.big_off, View.GONE)
- bindRow(v, context, rows[0], R.id.big_usage_a, R.id.big_usage_a_label, R.id.big_usage_a_pct, R.id.big_usage_a_bar)
+ bindRow(v, context, rows[0], BigRow(R.id.big_usage_a, R.id.big_usage_a_label, R.id.big_usage_a_pct, R.id.big_usage_a_pct_big, R.id.big_usage_a_note, R.id.big_usage_a_bar))
val second = rows.getOrNull(1)?.takeIf { !small }
- if (second != null) bindRow(v, context, second, R.id.big_usage_b, R.id.big_usage_b_label, R.id.big_usage_b_pct, R.id.big_usage_b_bar)
+ if (second != null) bindRow(v, context, second, BigRow(R.id.big_usage_b, R.id.big_usage_b_label, R.id.big_usage_b_pct, R.id.big_usage_b_pct_big, R.id.big_usage_b_note, R.id.big_usage_b_bar))
else v.setViewVisibility(R.id.big_usage_b, View.GONE)
v.setOnClickPendingIntent(R.id.big_right, WidgetHub.openApp(context, WidgetHub.CODE_BIG_USAGE_APP))
}
@@ -140,12 +142,23 @@ class MochiBigWidget : AppWidgetProvider() {
}
}
- private fun bindRow(v: RemoteViews, context: Context, row: UsageRing, group: Int, label: Int, pct: Int, bar: Int) {
- v.setViewVisibility(group, View.VISIBLE)
- v.setTextViewText(label, row.label)
- v.setTextViewText(pct, "${row.pct}%")
- v.setImageViewBitmap(bar, BarBitmap.of(row, WidgetHub.px(context, 180), WidgetHub.px(context, 6)))
- v.setContentDescription(group, context.getString(R.string.widget_ring_cd, row.plan, row.pct))
+ private class BigRow(val group: Int, val label: Int, val pct: Int, val pctBig: Int, val note: Int, val bar: Int)
+
+ /**
+ * One plan-usage row. Under the red line the percentage is small and normal, with no warning. From the red line it is big and
+ * bold, with "Near limit" (and when it resets) under it. The bar is teal, yellow from 75% and red from 90%.
+ */
+ private fun bindRow(v: RemoteViews, context: Context, row: UsageRing, r: BigRow) {
+ v.setViewVisibility(r.group, View.VISIBLE)
+ v.setTextViewText(r.label, row.label)
+ val near = row.nearLimit
+ v.setViewVisibility(r.pct, if (near) View.GONE else View.VISIBLE)
+ v.setViewVisibility(r.pctBig, if (near) View.VISIBLE else View.GONE)
+ v.setTextViewText(if (near) r.pctBig else r.pct, "${row.shown}%")
+ v.setViewVisibility(r.note, if (row.note != null) View.VISIBLE else View.GONE)
+ v.setTextViewText(r.note, row.note.orEmpty())
+ v.setImageViewBitmap(r.bar, BarBitmap.of(row, WidgetHub.px(context, 180), WidgetHub.px(context, 6)))
+ v.setContentDescription(r.group, context.getString(R.string.widget_ring_cd, row.plan, row.shown))
}
}
}
diff --git a/android/app/src/main/kotlin/com/coucou/android/app/RingBitmap.kt b/android/app/src/main/kotlin/com/coucou/android/app/RingBitmap.kt
index 90a81b47..70a1da1d 100644
--- a/android/app/src/main/kotlin/com/coucou/android/app/RingBitmap.kt
+++ b/android/app/src/main/kotlin/com/coucou/android/app/RingBitmap.kt
@@ -32,7 +32,7 @@ object RingBitmap {
/** The ring for [ring], [sizePx] pixels square. */
@Synchronized
fun of(ring: UsageRing, sizePx: Int): Bitmap {
- val key = Key(ring.pct.coerceIn(0, 100), ring.tone.argb, sizePx)
+ val key = Key(ring.shown, ring.tone.argb, sizePx)
return cache.getOrPut(key) { draw(ring, sizePx) }
}
diff --git a/android/app/src/main/kotlin/com/coucou/android/app/UsageRingWidget.kt b/android/app/src/main/kotlin/com/coucou/android/app/UsageRingWidget.kt
index 0947e692..d757d889 100644
--- a/android/app/src/main/kotlin/com/coucou/android/app/UsageRingWidget.kt
+++ b/android/app/src/main/kotlin/com/coucou/android/app/UsageRingWidget.kt
@@ -7,6 +7,7 @@ import android.view.View
import android.widget.RemoteViews
import com.coucou.android.R
import com.coucou.android.core.WidgetContent
+import com.coucou.android.core.WidgetTone
/**
* The Usage Ring widget: a ring drawn to a bitmap for the plan usage the computer sent (its switch is on), with the
@@ -21,18 +22,27 @@ class UsageRingWidget : AppWidgetProvider() {
fun views(context: Context, c: WidgetContent): RemoteViews {
val v = RemoteViews(context.packageName, R.layout.widget_ring)
val ring = c.ring
- WidgetHub.paint(v, R.id.ring_root, R.id.ring_tint, ring?.tone ?: com.coucou.android.core.WidgetTone.MUTED)
if (ring != null) {
+ // The card, the ring and the percentage follow the usage palette (teal, yellow, red), never a state colour.
+ WidgetHub.paintUsage(v, R.id.ring_root, R.id.ring_tint, ring.tone)
v.setViewVisibility(R.id.ring_area, View.VISIBLE)
v.setViewVisibility(R.id.ring_label, View.VISIBLE)
v.setViewVisibility(R.id.ring_off, View.GONE)
v.setImageViewBitmap(R.id.ring_image, RingBitmap.of(ring, WidgetHub.px(context, 96)))
- v.setTextViewText(R.id.ring_pct, "${ring.pct}%")
+ // Under the red line a small normal percentage; from the red line a big bold one with "Near limit" and when it resets.
+ val near = ring.nearLimit
+ v.setViewVisibility(R.id.ring_pct, if (near) View.GONE else View.VISIBLE)
+ v.setViewVisibility(R.id.ring_pct_big, if (near) View.VISIBLE else View.GONE)
+ v.setTextViewText(if (near) R.id.ring_pct_big else R.id.ring_pct, "${ring.shown}%")
v.setTextViewText(R.id.ring_label, ring.label)
- v.setContentDescription(R.id.ring_root, context.getString(R.string.widget_ring_cd, ring.plan, ring.pct))
+ v.setViewVisibility(R.id.ring_note, if (ring.note != null) View.VISIBLE else View.GONE)
+ v.setTextViewText(R.id.ring_note, ring.note.orEmpty())
+ v.setContentDescription(R.id.ring_root, context.getString(R.string.widget_ring_cd, ring.plan, ring.shown))
} else {
+ WidgetHub.paint(v, R.id.ring_root, R.id.ring_tint, if (c.connected) WidgetTone.IDLE else WidgetTone.MUTED)
v.setViewVisibility(R.id.ring_area, View.GONE)
v.setViewVisibility(R.id.ring_label, View.GONE)
+ v.setViewVisibility(R.id.ring_note, View.GONE)
v.setViewVisibility(R.id.ring_off, View.VISIBLE)
v.setTextViewText(R.id.ring_off_text, if (c.connected) context.getString(R.string.widget_usage_off) else c.emptyLine.orEmpty())
v.setContentDescription(R.id.ring_root, context.getString(R.string.widget_ring_label))
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 ead2e98b..7b01c521 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
@@ -12,6 +12,7 @@ import android.widget.RemoteViews
import com.coucou.android.MainActivity
import com.coucou.android.R
import com.coucou.android.core.LaunchScreen
+import com.coucou.android.core.UsageTone
import com.coucou.android.core.WidgetContent
import com.coucou.android.core.WidgetTone
import kotlin.math.roundToInt
@@ -90,6 +91,20 @@ object WidgetHub {
v.setInt(tint, "setBackgroundResource", tintOf(tone))
}
+ /** The same for a plan-usage Widget: the usage palette (teal, yellow, red), never a state colour. */
+ fun paintUsage(v: RemoteViews, root: Int, tint: Int, tone: UsageTone) {
+ v.setInt(root, "setBackgroundResource", when (tone) {
+ UsageTone.CALM -> R.drawable.widget_card_usage_calm
+ UsageTone.CLOSE -> R.drawable.widget_card_usage_close
+ UsageTone.LIMIT -> R.drawable.widget_card_usage_limit
+ })
+ v.setInt(tint, "setBackgroundResource", when (tone) {
+ UsageTone.CALM -> R.drawable.widget_tint_usage_calm
+ UsageTone.CLOSE -> R.drawable.widget_tint_usage_close
+ UsageTone.LIMIT -> R.drawable.widget_tint_usage_limit
+ })
+ }
+
private fun cardOf(tone: WidgetTone): Int = when (tone) {
WidgetTone.MUTED -> R.drawable.widget_card_muted
WidgetTone.IDLE -> R.drawable.widget_card_idle
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 eb207c17..58775c94 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
@@ -56,23 +56,80 @@ data class WidgetTile(val pillId: String, val name: String, val state: BotState,
val tone: WidgetTone get() = WidgetTone.of(state)
}
-/** The plan usage a ring shows: which plan and window, and how much of it is used. */
-data class UsageRing(val plan: String, val window: String, val pct: Int) {
- /** 0 to 1, for the arc. */
- val fraction: Float get() = pct.coerceIn(0, 100) / 100f
+/**
+ * The colours of plan usage: their own palette, so that a plan close to its limit never looks like "waiting for you" (orange) or like a
+ * working agent (blue). Teal while there is room, yellow when getting close, red at the limit. In res/values/colors.xml as
+ * `widget_usage_<name>`; a test keeps the two in step.
+ */
+enum class UsageTone(val rgb: Rgb) {
+ CALM(Rgb(0.055, 0.561, 0.604)),
+ CLOSE(Rgb(0.949, 0.816, 0.141)),
+ LIMIT(Rgb(0.851, 0.176, 0.125)),
+ ;
+
+ /** Opaque ARGB. */
+ val argb: Int get() = 0xFF000000.toInt() or (c(rgb.r) shl 16) or (c(rgb.g) shl 8) or c(rgb.b)
+
+ private fun c(v: Double) = (v.coerceIn(0.0, 1.0) * 255).roundToInt()
+}
+
+/**
+ * How a plan-usage percentage looks, in one place: the colour of the ring and of the bar, and the "Near limit" line. Below the red line
+ * the percentage is shown small and normal with no warning; from [LIMIT_FROM] it is shown big and bold with "Near limit" and, when the
+ * usage snapshot has one, when the window resets ("resets in 2 h"). Pure, so every boundary is a unit test.
+ */
+object PlanUsageLook {
+ /** From this percentage (included) the usage is "getting close": yellow. */
+ const val CLOSE_FROM = 75
+
+ /** From this percentage (included) the usage is at the limit: red, with the warning. */
+ const val LIMIT_FROM = 90
+
+ /** What is shown and drawn: a percentage under 0 or over 100 is clamped. */
+ fun clamp(pct: Int): Int = pct.coerceIn(0, 100)
+
+ fun tone(pct: Int): UsageTone = when {
+ clamp(pct) >= LIMIT_FROM -> UsageTone.LIMIT
+ clamp(pct) >= CLOSE_FROM -> UsageTone.CLOSE
+ else -> UsageTone.CALM
+ }
+
+ /** True from the red line: the Widget then shows the rate prominently. */
+ fun nearLimit(pct: Int): Boolean = clamp(pct) >= LIMIT_FROM
+
+ /** "resets in 2 h", "resets in 40 min", "resets in 3 d"; null when there is no reset time (0) or it has passed. */
+ fun resetLine(resetsAtMs: Long, nowMs: Long): String? {
+ if (resetsAtMs <= 0 || resetsAtMs <= nowMs) return null
+ val minutes = (resetsAtMs - nowMs) / 60_000
+ val hours = minutes / 60
+ return when {
+ minutes < 60 -> "resets in ${maxOf(minutes, 1)} min"
+ hours < 48 -> "resets in $hours h"
+ else -> "resets in ${hours / 24} d"
+ }
+ }
+
+ /** "Near limit" (with the reset time when known) from the red line; null below it, where there is no warning. */
+ fun note(pct: Int, resetsAtMs: Long, nowMs: Long): String? =
+ if (!nearLimit(pct)) null else listOfNotNull("Near limit", resetLine(resetsAtMs, nowMs)).joinToString(" · ")
+}
+
+/** The plan usage a ring or a bar shows: which plan and window, how much of it is used, and the warning line when it is near the limit. */
+data class UsageRing(val plan: String, val window: String, val pct: Int, val note: String? = null) {
+ /** The percentage to show, 0 to 100. */
+ val shown: Int get() = PlanUsageLook.clamp(pct)
+
+ /** 0 to 1, for the arc and the bar. */
+ val fraction: Float get() = shown / 100f
/** "Claude · 5 h". */
val label: String get() = "$plan · $window"
- /** The colour of Mochi Big's bar: green, orange above 75%, red above 90% ([WidgetData.barTone]). */
- val barTone: WidgetTone get() = WidgetData.barTone(pct)
+ /** The colour of the ring and of the bar ([PlanUsageLook]). */
+ val tone: UsageTone get() = PlanUsageLook.tone(pct)
- /** Green while there is room, orange from half, red from four fifths: the same rule as Home ([PlanText]). */
- val tone: WidgetTone get() = when (PlanText.level(pct)) {
- PlanText.Level.LOW -> WidgetTone.DONE
- PlanText.Level.MEDIUM -> WidgetTone.ATTENTION
- PlanText.Level.HIGH -> WidgetTone.TROUBLE
- }
+ /** True from the red line: big and bold, with [note] under it. */
+ val nearLimit: Boolean get() = PlanUsageLook.nearLimit(pct)
}
/** What the right side of Mochi Big shows: the plan usage rows, a calm "Plan usage is off", or "Not connected". Never nothing. */
@@ -200,19 +257,6 @@ object WidgetData {
return WidgetContent(glance.headline, glance.tone, glance.connected, glance.waiting, tiles, ring, today.coerceAtLeast(0), rows)
}
- /** Mochi Big's bar turns orange above this percentage... */
- const val BAR_ORANGE_ABOVE = 75
-
- /** ...and red above this one. */
- const val BAR_RED_ABOVE = 90
-
- /** Green up to 75%, orange above 75%, red above 90%. */
- fun barTone(pct: Int): WidgetTone = when {
- pct > BAR_RED_ABOVE -> WidgetTone.TROUBLE
- pct > BAR_ORANGE_ABOVE -> WidgetTone.ATTENTION
- else -> WidgetTone.DONE
- }
-
/**
* Up to two rows for Mochi Big: Claude, then Codex, each with its main window (five hours, else the week). A plan the computer
* does not know has no row. The same data as the Usage Ring, with a window that has reset counted as zero ([PlanText]).
@@ -220,8 +264,7 @@ object WidgetData {
fun usageRows(usage: UsageSnapshot?, nowMs: Long): List<UsageRing> {
usage ?: return emptyList()
return listOf("Claude" to usage.claude, "Codex" to usage.codex).mapNotNull { (name, plan) ->
- plan?.fiveHour?.let { UsageRing(name, "5 h", PlanText.effectivePct(it, nowMs)) }
- ?: plan?.sevenDay?.let { UsageRing(name, "week", PlanText.effectivePct(it, nowMs)) }
+ plan?.fiveHour?.let { row(name, "5 h", it, nowMs) } ?: plan?.sevenDay?.let { row(name, "week", it, nowMs) }
}
}
@@ -268,13 +311,19 @@ object WidgetData {
private const val HOUR_MS = 3_600_000L
+ /** One row: the percentage counted as zero once the window has reset, and the "Near limit" line with its reset time. */
+ private fun row(plan: String, window: String, w: PlanWindow, nowMs: Long): UsageRing {
+ val pct = PlanText.effectivePct(w, nowMs)
+ return UsageRing(plan, window, pct, PlanUsageLook.note(pct, w.resetsAtMs, nowMs))
+ }
+
/** Claude's five-hour window first, then its week, then Codex; null when the computer sent none of them. */
fun ring(usage: UsageSnapshot?, nowMs: Long): UsageRing? {
usage ?: return null
for ((name, plan) in listOf("Claude" to usage.claude, "Codex" to usage.codex)) {
plan ?: continue
- plan.fiveHour?.let { return UsageRing(name, "5 h", PlanText.effectivePct(it, nowMs)) }
- plan.sevenDay?.let { return UsageRing(name, "week", PlanText.effectivePct(it, nowMs)) }
+ plan.fiveHour?.let { return row(name, "5 h", it, nowMs) }
+ plan.sevenDay?.let { return row(name, "week", it, nowMs) }
}
return null
}
diff --git a/android/app/src/main/res/drawable/preview_bar_done.xml b/android/app/src/main/res/drawable/preview_bar_calm.xml
similarity index 50%
rename from android/app/src/main/res/drawable/preview_bar_done.xml
rename to android/app/src/main/res/drawable/preview_bar_calm.xml
index f1a9ded8..ec9bcc12 100644
--- a/android/app/src/main/res/drawable/preview_bar_done.xml
+++ b/android/app/src/main/res/drawable/preview_bar_calm.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- The green fill of a plan-usage bar in the Widget picker (green up to 75%). -->
+<!-- The teal fill of a plan-usage bar in the Widget picker (teal while there is room; yellow from 75%, red from 90%). -->
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
- <solid android:color="@color/widget_tone_done" />
+ <solid android:color="@color/widget_usage_calm" />
<corners android:radius="3dp" />
</shape>
diff --git a/android/app/src/main/res/drawable/preview_ring_70.xml b/android/app/src/main/res/drawable/preview_ring_68.xml
similarity index 56%
rename from android/app/src/main/res/drawable/preview_ring_70.xml
rename to android/app/src/main/res/drawable/preview_ring_68.xml
index 3539192d..adb930cd 100644
--- a/android/app/src/main/res/drawable/preview_ring_70.xml
+++ b/android/app/src/main/res/drawable/preview_ring_68.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- A plan-usage ring at 70 %, drawn with a vector arc for the Widget picker: a faint track and an orange arc from the top
- (from 50 % the usage is orange, from 80 % red, like Home). The real ring is drawn to a bitmap by RingBitmap. -->
+<!-- A plan-usage ring at 68 %, drawn with a vector arc for the Widget picker: a faint track and a teal arc from the top (teal under 75 %,
+ yellow from 75 %, red from 90 %: the usage palette, not the state colours). The real ring is drawn to a bitmap by RingBitmap. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="100dp"
android:height="100dp"
@@ -11,8 +11,8 @@
android:strokeColor="#40808080"
android:strokeWidth="12" />
<path
- android:pathData="M50,6 A44,44 0 1 1 8.2,63.6"
- android:strokeColor="#F5A524"
+ android:pathData="M50,6 A44,44 0 1 1 10.2,68.7"
+ android:strokeColor="#0E8F9A"
android:strokeWidth="12"
android:strokeLineCap="round" />
</vector>
diff --git a/android/app/src/main/res/drawable/widget_card_usage_calm.xml b/android/app/src/main/res/drawable/widget_card_usage_calm.xml
new file mode 100644
index 00000000..bce2e363
--- /dev/null
+++ b/android/app/src/main/res/drawable/widget_card_usage_calm.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- The card of a plan-usage Widget in the "calm" tone: the shared card with a 1dp border in the usage colour. -->
+<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
+ <solid android:color="@color/widget_card" />
+ <stroke android:width="@dimen/widget_border_width" android:color="@color/widget_border_usage_calm" />
+ <corners android:radius="@dimen/widget_radius" />
+</shape>
diff --git a/android/app/src/main/res/drawable/widget_card_usage_close.xml b/android/app/src/main/res/drawable/widget_card_usage_close.xml
new file mode 100644
index 00000000..b7f3d825
--- /dev/null
+++ b/android/app/src/main/res/drawable/widget_card_usage_close.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- The card of a plan-usage Widget in the "close" tone: the shared card with a 1dp border in the usage colour. -->
+<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
+ <solid android:color="@color/widget_card" />
+ <stroke android:width="@dimen/widget_border_width" android:color="@color/widget_border_usage_close" />
+ <corners android:radius="@dimen/widget_radius" />
+</shape>
diff --git a/android/app/src/main/res/drawable/widget_card_usage_limit.xml b/android/app/src/main/res/drawable/widget_card_usage_limit.xml
new file mode 100644
index 00000000..cbcf612b
--- /dev/null
+++ b/android/app/src/main/res/drawable/widget_card_usage_limit.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- The card of a plan-usage Widget in the "limit" tone: the shared card with a 1dp border in the usage colour. -->
+<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
+ <solid android:color="@color/widget_card" />
+ <stroke android:width="@dimen/widget_border_width" android:color="@color/widget_border_usage_limit" />
+ <corners android:radius="@dimen/widget_radius" />
+</shape>
diff --git a/android/app/src/main/res/drawable/widget_preview_image_ring.xml b/android/app/src/main/res/drawable/widget_preview_image_ring.xml
index 4d5b0dd4..f58c4eb0 100644
--- a/android/app/src/main/res/drawable/widget_preview_image_ring.xml
+++ b/android/app/src/main/res/drawable/widget_preview_image_ring.xml
@@ -1,18 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- The picture the Widget picker shows on Android 11 (no previewLayout there): the card, its gradient and Mochi in the state of the sample. -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:drawable="@drawable/widget_card" />
+ <item android:drawable="@drawable/widget_card_usage_calm" />
<item
android:left="1dp"
android:top="1dp"
android:right="1dp"
android:bottom="1dp"
- android:drawable="@drawable/widget_tint_attention" />
+ android:drawable="@drawable/widget_tint_usage_calm" />
<item
android:width="76dp"
android:height="76dp"
android:left="0dp"
android:top="0dp"
android:gravity="center"
- android:drawable="@drawable/preview_ring_70" />
+ android:drawable="@drawable/preview_ring_68" />
</layer-list>
diff --git a/android/app/src/main/res/drawable/widget_tint_usage_calm.xml b/android/app/src/main/res/drawable/widget_tint_usage_calm.xml
new file mode 100644
index 00000000..45de3e35
--- /dev/null
+++ b/android/app/src/main/res/drawable/widget_tint_usage_calm.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- The gradient over a plan-usage card in the "calm" tone (plan usage has its own palette, not the state colours). -->
+<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
+ <gradient
+ android:angle="315"
+ android:startColor="@color/widget_tint_usage_calm"
+ android:endColor="#00000000" />
+ <corners android:radius="@dimen/widget_radius" />
+</shape>
diff --git a/android/app/src/main/res/drawable/widget_tint_usage_close.xml b/android/app/src/main/res/drawable/widget_tint_usage_close.xml
new file mode 100644
index 00000000..bef3b35b
--- /dev/null
+++ b/android/app/src/main/res/drawable/widget_tint_usage_close.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- The gradient over a plan-usage card in the "close" tone (plan usage has its own palette, not the state colours). -->
+<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
+ <gradient
+ android:angle="315"
+ android:startColor="@color/widget_tint_usage_close"
+ android:endColor="#00000000" />
+ <corners android:radius="@dimen/widget_radius" />
+</shape>
diff --git a/android/app/src/main/res/drawable/widget_tint_usage_limit.xml b/android/app/src/main/res/drawable/widget_tint_usage_limit.xml
new file mode 100644
index 00000000..f573f276
--- /dev/null
+++ b/android/app/src/main/res/drawable/widget_tint_usage_limit.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- The gradient over a plan-usage card in the "limit" tone (plan usage has its own palette, not the state colours). -->
+<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
+ <gradient
+ android:angle="315"
+ android:startColor="@color/widget_tint_usage_limit"
+ android:endColor="#00000000" />
+ <corners android:radius="@dimen/widget_radius" />
+</shape>
diff --git a/android/app/src/main/res/layout/widget_big.xml b/android/app/src/main/res/layout/widget_big.xml
index 8c1d0db3..47b52a5d 100644
--- a/android/app/src/main/res/layout/widget_big.xml
+++ b/android/app/src/main/res/layout/widget_big.xml
@@ -127,8 +127,27 @@
android:layout_height="wrap_content"
android:maxLines="1"
android:textColor="@color/widget_text"
- android:textSize="@dimen/widget_text_big"
- android:textStyle="bold" />
+ android:textSize="@dimen/widget_text_pct" />
+
+ <TextView
+ android:id="@+id/big_usage_a_pct_big"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:maxLines="1"
+ android:textColor="@color/widget_text"
+ android:textSize="@dimen/widget_text_pct_big"
+ android:textStyle="bold"
+ android:visibility="gone" />
+
+ <TextView
+ android:id="@+id/big_usage_a_note"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ellipsize="end"
+ android:maxLines="1"
+ android:textColor="@color/widget_text_soft"
+ android:textSize="@dimen/widget_text_secondary"
+ android:visibility="gone" />
<ImageView
android:id="@+id/big_usage_a_bar"
@@ -162,8 +181,27 @@
android:layout_height="wrap_content"
android:maxLines="1"
android:textColor="@color/widget_text"
- android:textSize="@dimen/widget_text_big"
- android:textStyle="bold" />
+ android:textSize="@dimen/widget_text_pct" />
+
+ <TextView
+ android:id="@+id/big_usage_b_pct_big"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:maxLines="1"
+ android:textColor="@color/widget_text"
+ android:textSize="@dimen/widget_text_pct_big"
+ android:textStyle="bold"
+ android:visibility="gone" />
+
+ <TextView
+ android:id="@+id/big_usage_b_note"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ellipsize="end"
+ android:maxLines="1"
+ android:textColor="@color/widget_text_soft"
+ android:textSize="@dimen/widget_text_secondary"
+ android:visibility="gone" />
<ImageView
android:id="@+id/big_usage_b_bar"
diff --git a/android/app/src/main/res/layout/widget_preview_big.xml b/android/app/src/main/res/layout/widget_preview_big.xml
index 7a26981d..29b37368 100644
--- a/android/app/src/main/res/layout/widget_preview_big.xml
+++ b/android/app/src/main/res/layout/widget_preview_big.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Preview of Mochi Big: on the left a working Mochi with his glow, Claude Code and Working; on the right plan usage (Claude 68% and Codex
- 41%, each with a thin bar); under them the six button tiles.
+ 41%, each small with a thin teal bar: under the red line there is no warning); under them the six button tiles.
A still picture for the Widget picker (android:previewLayout): sample text, no ids, nothing from the app, no runtime bitmap.
It uses the same card, border, gradient, type scale, buttons and state colours as the real Widget, so the picker shows what you will get. -->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
@@ -106,8 +106,7 @@
android:maxLines="1"
android:text="@string/widget_sample_pct_a"
android:textColor="@color/widget_text"
- android:textSize="@dimen/widget_text_big"
- android:textStyle="bold" />
+ android:textSize="@dimen/widget_text_pct" />
<LinearLayout
android:layout_width="match_parent"
@@ -122,7 +121,7 @@
android:layout_height="match_parent"
android:layout_weight="68"
android:importantForAccessibility="no"
- android:src="@drawable/preview_bar_done" />
+ android:src="@drawable/preview_bar_calm" />
</LinearLayout>
</LinearLayout>
@@ -147,8 +146,7 @@
android:maxLines="1"
android:text="@string/widget_sample_pct_b"
android:textColor="@color/widget_text"
- android:textSize="@dimen/widget_text_big"
- android:textStyle="bold" />
+ android:textSize="@dimen/widget_text_pct" />
<LinearLayout
android:layout_width="match_parent"
@@ -163,7 +161,7 @@
android:layout_height="match_parent"
android:layout_weight="41"
android:importantForAccessibility="no"
- android:src="@drawable/preview_bar_done" />
+ android:src="@drawable/preview_bar_calm" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
diff --git a/android/app/src/main/res/layout/widget_preview_ring.xml b/android/app/src/main/res/layout/widget_preview_ring.xml
index 8339d2d3..d331b73f 100644
--- a/android/app/src/main/res/layout/widget_preview_ring.xml
+++ b/android/app/src/main/res/layout/widget_preview_ring.xml
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Preview of Usage Ring: a ring at about 70 percent with its label.
+<!-- Preview of Usage Ring: a normal teal ring at about 68 percent, with a small percentage and its label.
A still picture for the Widget picker (android:previewLayout): sample text and numbers, no ids, nothing from the app, no runtime bitmap.
It uses the same card, border, gradient, type scale and state colours as the real Widget, so the picker shows what you will get. -->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:background="@drawable/widget_card">
+ android:background="@drawable/widget_card_usage_calm">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="1dp"
- android:background="@drawable/widget_tint_attention" />
+ android:background="@drawable/widget_tint_usage_calm" />
<LinearLayout
android:layout_width="match_parent"
@@ -30,7 +30,7 @@
android:layout_height="match_parent"
android:importantForAccessibility="no"
android:scaleType="fitCenter"
- android:src="@drawable/preview_ring_70" />
+ android:src="@drawable/preview_ring_68" />
<TextView
android:layout_width="match_parent"
@@ -39,8 +39,7 @@
android:maxLines="1"
android:text="@string/widget_sample_ring_pct"
android:textColor="@color/widget_text"
- android:textSize="24sp"
- android:textStyle="bold" />
+ android:textSize="@dimen/widget_text_pct" />
</FrameLayout>
<TextView
diff --git a/android/app/src/main/res/layout/widget_ring.xml b/android/app/src/main/res/layout/widget_ring.xml
index 4dbae5f0..7d33b7f8 100644
--- a/android/app/src/main/res/layout/widget_ring.xml
+++ b/android/app/src/main/res/layout/widget_ring.xml
@@ -41,8 +41,18 @@
android:gravity="center"
android:maxLines="1"
android:textColor="@color/widget_text"
- android:textSize="24sp"
- android:textStyle="bold" />
+ android:textSize="@dimen/widget_text_pct" />
+
+ <TextView
+ android:id="@+id/ring_pct_big"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="center"
+ android:maxLines="1"
+ android:textColor="@color/widget_text"
+ android:textSize="@dimen/widget_text_ring_big"
+ android:textStyle="bold"
+ android:visibility="gone" />
</FrameLayout>
<TextView
@@ -56,6 +66,17 @@
android:textColor="@color/widget_text_secondary"
android:textSize="@dimen/widget_text_state" />
+ <TextView
+ android:id="@+id/ring_note"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ellipsize="end"
+ android:gravity="center"
+ android:maxLines="1"
+ android:textColor="@color/widget_text_soft"
+ android:textSize="@dimen/widget_text_secondary"
+ android:visibility="gone" />
+
<LinearLayout
android:id="@+id/ring_off"
android:layout_width="match_parent"
diff --git a/android/app/src/main/res/values/colors.xml b/android/app/src/main/res/values/colors.xml
index 29c05ee0..d16e0d30 100644
--- a/android/app/src/main/res/values/colors.xml
+++ b/android/app/src/main/res/values/colors.xml
@@ -37,4 +37,16 @@
<color name="widget_on_tone">#FF1C1C1E</color>
<!-- The tone as text colour: the tone itself on the dark card; in day mode a deeper one (see values-notnight). -->
<color name="widget_tone_attention_text">#FFF5A524</color>
+
+ <!-- Plan usage has its own colours, so it never looks like a state: teal while there is room, yellow from 75 %, red from 90 %.
+ The same colours as UsageTone in core/WidgetData.kt. -->
+ <color name="widget_usage_calm">#FF0E8F9A</color>
+ <color name="widget_usage_close">#FFF2D024</color>
+ <color name="widget_usage_limit">#FFD92D20</color>
+ <color name="widget_tint_usage_calm">#330E8F9A</color>
+ <color name="widget_tint_usage_close">#40F2D024</color>
+ <color name="widget_tint_usage_limit">#33D92D20</color>
+ <color name="widget_border_usage_calm">#990E8F9A</color>
+ <color name="widget_border_usage_close">#99F2D024</color>
+ <color name="widget_border_usage_limit">#99D92D20</color>
</resources>
diff --git a/android/app/src/main/res/values/dimens.xml b/android/app/src/main/res/values/dimens.xml
index 3e0c4325..546b4a77 100644
--- a/android/app/src/main/res/values/dimens.xml
+++ b/android/app/src/main/res/values/dimens.xml
@@ -11,7 +11,9 @@
<dimen name="widget_tile_height">52dp</dimen>
<dimen name="widget_dot">10dp</dimen>
<dimen name="widget_icon">18dp</dimen>
- <dimen name="widget_text_big">28sp</dimen>
+ <dimen name="widget_text_pct">18sp</dimen>
+ <dimen name="widget_text_pct_big">32sp</dimen>
+ <dimen name="widget_text_ring_big">26sp</dimen>
<dimen name="widget_text_name">16sp</dimen>
<dimen name="widget_text_state">13sp</dimen>
<dimen name="widget_text_secondary">12sp</dimen>
diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml
index e809c6b2..04ce9e4f 100644
--- a/android/app/src/main/res/values/strings.xml
+++ b/android/app/src/main/res/values/strings.xml
@@ -63,7 +63,7 @@
<string name="widget_sample_header">Waiting for you</string>
<string name="widget_sample_one">1</string>
<string name="widget_sample_two_waiting">2 waiting</string>
- <string name="widget_sample_ring_pct">70%</string>
+ <string name="widget_sample_ring_pct">68%</string>
<string name="widget_sample_ring_label">Claude · 5 h</string>
<string name="widget_sample_pct_a">68%</string>
<string name="widget_sample_pct_b">41%</string>
diff --git a/android/i18n/app-strings.json b/android/i18n/app-strings.json
index d2713db6..b986e4d1 100644
--- a/android/i18n/app-strings.json
+++ b/android/i18n/app-strings.json
@@ -63,7 +63,7 @@
"widget_sample_header": "Waiting for you",
"widget_sample_one": "1",
"widget_sample_two_waiting": "2 waiting",
- "widget_sample_ring_pct": "70%",
+ "widget_sample_ring_pct": "68%",
"widget_sample_ring_label": "Claude · 5 h",
"widget_sample_pct_a": "68%",
"widget_sample_pct_b": "41%",