feat(widgets): next alarm, timer and clock home-screen widgets
Three Glance widgets, mirroring state the app already computes rather than owning any of their own: the next alarm (AlarmEngine.upcoming()), the live pill's subject timer (same selection logic, no ticker of its own — a running countdown is the platform chronometer, exactly like the ring notification), and the local time growing to world clocks at larger sizes. WidgetSync collects the same read-only flows the shell already reads and redraws on change, event-driven (updatePeriodMillis = 0) — it touches no engine, only re-renders, and covers every write path including SystemEventReceiver's since the process is already alive whenever those run. Tapping a widget reuses the same internal navigation actions the AlarmClock contract's door already produces; the timer buttons send the same unexported broadcasts its notification does. A widget is just another caller of machinery that already exists. ManifestRulesTest is updated deliberately: three GlanceAppWidgetReceivers join the exported set, each pinned to exactly the platform-required APPWIDGET_UPDATE filter and no permission — no new permission is requested anywhere in this change.
This commit is contained in:
1 parent
a11396b058
commit
fb81bfbf2e
25 files changed
+1039
-4
No files matched your search
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Embedded inside a Glance layout via AndroidRemoteViews (widget/TimerWidget.kt):
|
||||
Glance has no chronometer composable, and RemoteViews.setChronometer +
|
||||
setChronometerCountDown is exactly the mechanism TimerNotifications.kt
|
||||
already uses for the same reason — the platform ticks it, not the app.
|
||||
-->
|
||||
<Chronometer xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/widget_chronometer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="28sp" />
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Embedded inside a Glance layout via AndroidRemoteViews (widget/ClockWidget.kt):
|
||||
a self-updating platform clock that honours the device's 12/24-hour
|
||||
setting on its own, with no per-second app code. The timezone is set at
|
||||
render time via RemoteViews.setString(id, "setTimeZone", zoneId).
|
||||
-->
|
||||
<TextClock xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/widget_text_clock"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="28sp" />
|
||||
@@ -341,4 +341,13 @@
|
||||
<string name="selfcheck_next_alarm_title">Next alarm, as the system sees it</string>
|
||||
<string name="selfcheck_next_alarm_ok">Matches what Clockula scheduled</string>
|
||||
<string name="selfcheck_next_alarm_problem">Doesn\'t match what Clockula scheduled — open the app to re-check</string>
|
||||
|
||||
<!-- M10: widgets -->
|
||||
<string name="widget_next_alarm_description">Next alarm</string>
|
||||
<string name="widget_next_alarm_empty">No alarms set</string>
|
||||
<string name="widget_next_alarm_today">Today</string>
|
||||
<string name="widget_timer_description">Timer</string>
|
||||
<string name="widget_timer_new">New timer</string>
|
||||
<string name="widget_timer_expired">Time\'s up</string>
|
||||
<string name="widget_clock_description">Clock</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:minWidth="90dp"
|
||||
android:minHeight="40dp"
|
||||
android:minResizeWidth="90dp"
|
||||
android:minResizeHeight="40dp"
|
||||
android:targetCellWidth="2"
|
||||
android:targetCellHeight="2"
|
||||
android:updatePeriodMillis="0"
|
||||
android:resizeMode="horizontal|vertical"
|
||||
android:widgetCategory="home_screen"
|
||||
android:previewImage="@mipmap/ic_launcher"
|
||||
android:description="@string/widget_clock_description" />
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:minWidth="110dp"
|
||||
android:minHeight="40dp"
|
||||
android:minResizeWidth="110dp"
|
||||
android:minResizeHeight="40dp"
|
||||
android:targetCellWidth="2"
|
||||
android:targetCellHeight="1"
|
||||
android:updatePeriodMillis="0"
|
||||
android:resizeMode="horizontal|vertical"
|
||||
android:widgetCategory="home_screen"
|
||||
android:previewImage="@mipmap/ic_launcher"
|
||||
android:description="@string/widget_next_alarm_description" />
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:minWidth="110dp"
|
||||
android:minHeight="60dp"
|
||||
android:minResizeWidth="110dp"
|
||||
android:minResizeHeight="40dp"
|
||||
android:targetCellWidth="2"
|
||||
android:targetCellHeight="2"
|
||||
android:updatePeriodMillis="0"
|
||||
android:resizeMode="horizontal|vertical"
|
||||
android:widgetCategory="home_screen"
|
||||
android:previewImage="@mipmap/ic_launcher"
|
||||
android:description="@string/widget_timer_description" />
|
||||
Reference in new issue
Block a user