calendar: remove manual watch sync from wear and settings
- Commit
c56d3963256d2d8c6e30114335710911d062fb33- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-05 16:53 UTC (23 hours ago)
- Parents
b83b545
Phone-to-watch sync is now fully automatic over the Watch conduit, so both manual sync actions are dead weight: the 'Sync now' chip on the wear agenda and the tappable Watch row in phone Settings (which called syncWearNow). Remove both, the SettingsUiState wear fields, CalendarViewModel.syncWearNow/wearSyncState, the now-unused sync/WearSyncRequest.kt helper, the wear sync strings, and update previews, the wear screenshot and AGENTS.md. Automatic WearCalendarSync publishing and the conduit sync-trigger receiver are unchanged. Verified: :calendar:lint :calendar:lintVitalRelease pass; :calendar:testDevUnitTest has two pre-existing failures (ImportGlanceHolidayTest, also failing on clean origin/main); :calendar:metadata regenerated.
Diff
calendar/AGENTS.md
diff --git a/calendar/AGENTS.md b/calendar/AGENTS.mdindex dd1abcedf0..b3bb6e418e 100644--- a/calendar/AGENTS.md+++ b/calendar/AGENTS.md@@ -43,7 +43,7 @@ any phone state loads; phones get the month/agenda UI. The phone - **Transport: Watch conduit client** — phone side `sync/WearCalendarSync.kt` and watch side `sync/WearLinkBridge.kt` both use `WearLinkClientNode` (Messenger to the Watch app's `watch_conduit` service, appId `calendar`); this app owns no RFCOMM link and holds no Bluetooth permission for this channel, so neither entry activity prompts for Bluetooth. With the Watch app absent the node reports `NotInstalled`/`Unavailable` and the sync stays idle; snapshots republish on conduit `Connected` and on calendar changes. `FormFactor` picks the side at runtime, so only one of the two nodes runs on a given device. - **Push triggers:** the publish also runs on the phone Watch app's scheduled sync-trigger intent (`sync/ConduitSyncTriggerReceiver`, exported only under the `CONDUIT` signature permission, invoking `WearCalendarSync.syncNow()` — no UI, no prompt). Data arriving while the receiving process is dead lands in the conduit host's persistent store and replays on registration. **Watch experience:**-- `ui/WearMainActivity` routes `ui/WearRoute` over the agenda (`ui/WearAgendaScreen`) and read-only event detail (`ui/WearEventScreen`), rendered from `data/WearCalendarStore` (`wear-calendar-snapshot.json`); sectioning is `domain/wearAgenda`. The watch has no event editing or RSVP; its one write is `sync/requestWearSync` asking the phone for a fresh snapshot.+- `ui/WearMainActivity` routes `ui/WearRoute` over the agenda (`ui/WearAgendaScreen`) and read-only event detail (`ui/WearEventScreen`), rendered from `data/WearCalendarStore` (`wear-calendar-snapshot.json`); sectioning is `domain/wearAgenda`. The watch has no event editing or RSVP and no manual sync action; snapshots arrive automatically over the conduit. - Watch listing screenshots are the `group = "wear"` previews in `src/screenshotTest/.../ui/WearMetadataPreviews.kt`, collected by `:calendar:metadata` into `metadata_data/photos/calendar/wear/`; phone shots use the `phone` bucket. **Gotchas:** - `util/` is NOT a closed package root — don't add more files there@@ -107,7 +107,6 @@ any phone state loads; phones get the month/agenda UI. The phone ### sync/ — wear companion sync (both sides, one APK) - com/vayunmathur/calendar/sync/WearCalendarSync.kt — phone conduit client node; snapshot publish, watch-state receive, request-sync handling - com/vayunmathur/calendar/sync/WearLinkBridge.kt — watch conduit client node; snapshot receive into the store, watch-state publish-- com/vayunmathur/calendar/sync/WearSyncRequest.kt — `requestWearSync` helper (watch asks phone for a fresh snapshot) ### Watch experience (ui/ + data/ + domain/ + platform/) - com/vayunmathur/calendar/ui/WearMainActivity.kt — watch entry (agenda + event detail from the synced store) - com/vayunmathur/calendar/ui/WearRoute.kt, WearAgendaScreen.kt, WearEventScreen.kt
calendar/src/main/java/com/vayunmathur/calendar/platform/CalendarUiContract.kt
diff --git a/calendar/src/main/java/com/vayunmathur/calendar/platform/CalendarUiContract.kt b/calendar/src/main/java/com/vayunmathur/calendar/platform/CalendarUiContract.ktindex 8dcd3090b5..6f546d9327 100644--- a/calendar/src/main/java/com/vayunmathur/calendar/platform/CalendarUiContract.kt+++ b/calendar/src/main/java/com/vayunmathur/calendar/platform/CalendarUiContract.kt@@ -52,12 +52,6 @@ data class SettingsUiState( val calendarVisibility: Map<Long, Boolean> = emptyMap(), val layout: CalendarViewModel.CalendarLayout = CalendarViewModel.CalendarLayout.FullWeek, val themeMode: CalendarViewModel.ThemeMode = CalendarViewModel.ThemeMode.System,- /** True when a watch advertising the calendar companion capability is reachable. */- val wearCompanionPresent: Boolean = false,- /** When the phone last published a wear snapshot, epoch millis; null when never. */- val wearLastSyncMillis: Long? = null,- /** Events in the last published wear snapshot. */- val wearLastSyncEventCount: Int = 0, ) /**@@ -123,9 +117,6 @@ interface SettingsActions { /** Same, restricted to one calendar. Read-only calendars are exportable too. */ fun exportCalendarIcs(calendarId: Long) {} - /** Publish a fresh calendar snapshot to the wear companion now. */- fun syncWearNow() {}- /** No-op settings actions used by previews, which render the screen without behaviour. */ companion object { val Noop: SettingsActions = object : SettingsActions {}
calendar/src/main/java/com/vayunmathur/calendar/platform/CalendarViewModel.kt
diff --git a/calendar/src/main/java/com/vayunmathur/calendar/platform/CalendarViewModel.kt b/calendar/src/main/java/com/vayunmathur/calendar/platform/CalendarViewModel.ktindex 36681a678e..31feca0728 100644--- a/calendar/src/main/java/com/vayunmathur/calendar/platform/CalendarViewModel.kt+++ b/calendar/src/main/java/com/vayunmathur/calendar/platform/CalendarViewModel.kt@@ -45,14 +45,6 @@ class CalendarViewModel(application: Application) : private val _events = MutableStateFlow<List<Event>>(emptyList()) val events: StateFlow<List<Event>> = _events.asStateFlow() - /** Wear companion presence + last-sync truth, owned by the sync singleton. */- val wearSyncState = com.vayunmathur.calendar.sync.WearCalendarSync.get(application).state-- /** Manual wear sync from Settings. */- override fun syncWearNow() {- com.vayunmathur.calendar.sync.WearCalendarSync.get(getApplication()).syncNow()- }- private val _calendars = MutableStateFlow<List<Calendar>>(emptyList()) val calendars: StateFlow<List<Calendar>> = _calendars.asStateFlow()
calendar/src/main/java/com/vayunmathur/calendar/sync/WearSyncRequest.kt
diff --git a/calendar/src/main/java/com/vayunmathur/calendar/sync/WearSyncRequest.kt b/calendar/src/main/java/com/vayunmathur/calendar/sync/WearSyncRequest.ktdeleted file mode 100644index cc9ec62215..0000000000--- a/calendar/src/main/java/com/vayunmathur/calendar/sync/WearSyncRequest.kt+++ /dev/null@@ -1,10 +0,0 @@-package com.vayunmathur.calendar.sync--import android.content.Context--/**- * Asks the phone for a fresh snapshot over the conduit. Returns false when- * the conduit link is not connected — the watch keeps rendering its last synced copy,- * and the UI says exactly that instead of pretending a sync happened.- */-suspend fun requestWearSync(context: Context): Boolean = WearLinkBridge.requestSync(context)
calendar/src/main/java/com/vayunmathur/calendar/ui/SettingsScreen.kt
diff --git a/calendar/src/main/java/com/vayunmathur/calendar/ui/SettingsScreen.kt b/calendar/src/main/java/com/vayunmathur/calendar/ui/SettingsScreen.ktindex e56092e29e..c41e0fef68 100644--- a/calendar/src/main/java/com/vayunmathur/calendar/ui/SettingsScreen.kt+++ b/calendar/src/main/java/com/vayunmathur/calendar/ui/SettingsScreen.kt@@ -67,7 +67,6 @@ fun SettingsScreen(viewModel: CalendarViewModel, backStack: NavBackStack<Route>) val visibility by viewModel.calendarVisibility.collectAsStateWithLifecycle() val currentLayout by viewModel.currentLayout.collectAsStateWithLifecycle() val currentTheme by viewModel.themeMode.collectAsStateWithLifecycle()- val wearState by viewModel.wearSyncState.collectAsStateWithLifecycle() // Kept in the binder rather than the screen: rememberLauncherForActivityResult needs an // ActivityResultRegistryOwner, which a @Preview has no way to supply.@@ -93,9 +92,6 @@ fun SettingsScreen(viewModel: CalendarViewModel, backStack: NavBackStack<Route>) calendarVisibility = visibility, layout = currentLayout, themeMode = currentTheme,- wearCompanionPresent = wearState.companionPresent,- wearLastSyncMillis = wearState.lastPublishedAtMillis,- wearLastSyncEventCount = wearState.lastPublishedEventCount, ), actions = object : SettingsActions by viewModel { override fun closeSettings() {@@ -310,26 +306,6 @@ fun SettingsScreen(state: SettingsUiState, actions: SettingsActions) { HorizontalDivider() } }- item {- val wearSupporting = when {- !state.wearCompanionPresent ->- stringResource(R.string.wear_watch_not_found)- state.wearLastSyncMillis != null ->- stringResource(- R.string.wear_watch_synced,- state.wearLastSyncEventCount,- )- else -> stringResource(R.string.wear_watch_connected)- }- SettingsRow(- title = stringResource(R.string.wear_watch),- supportingText = wearSupporting,- onClick = { actions.syncWearNow() },- trailingContent = { IconArrowDropDown() },- )- HorizontalDivider()- }- item { Spacer(modifier = Modifier.height(64.dp)) }
calendar/src/main/java/com/vayunmathur/calendar/ui/WearAgendaScreen.kt
diff --git a/calendar/src/main/java/com/vayunmathur/calendar/ui/WearAgendaScreen.kt b/calendar/src/main/java/com/vayunmathur/calendar/ui/WearAgendaScreen.ktindex a600d2c618..fedbb8dba0 100644--- a/calendar/src/main/java/com/vayunmathur/calendar/ui/WearAgendaScreen.kt+++ b/calendar/src/main/java/com/vayunmathur/calendar/ui/WearAgendaScreen.kt@@ -15,14 +15,10 @@ import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue-import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember-import androidx.compose.runtime.rememberCoroutineScope-import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color-import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign@@ -41,8 +37,6 @@ import com.vayunmathur.library.wearlink.calendar.WearCalendarEvent import com.vayunmathur.library.wearlink.calendar.WearCalendarSnapshot import com.vayunmathur.calendar.domain.wearAgenda import com.vayunmathur.calendar.domain.wearEventDay-import com.vayunmathur.calendar.sync.requestWearSync-import kotlinx.coroutines.launch import kotlinx.datetime.DatePeriod import kotlinx.datetime.TimeZone import kotlinx.datetime.format@@ -57,12 +51,10 @@ import kotlinx.datetime.toLocalDateTime @Composable fun WearAgendaScreen(store: WearCalendarStore, onOpenEvent: (WearCalendarEvent) -> Unit) { val snapshot by store.snapshot.collectAsState()- val context = LocalContext.current WearAgendaContent( snapshot = snapshot, nowMillis = System.currentTimeMillis(), onOpenEvent = onOpenEvent,- onRequestSync = { requestWearSync(context) }, ) } @@ -83,12 +75,7 @@ internal fun WearAgendaContent( snapshot: WearCalendarSnapshot, nowMillis: Long, onOpenEvent: (WearCalendarEvent) -> Unit,- onRequestSync: suspend () -> Boolean, ) {- val scope = rememberCoroutineScope()- var syncNote by remember { mutableStateOf<String?>(null) }- val requestedText = stringResource(R.string.wear_sync_requested)- val noPhoneText = stringResource(R.string.wear_no_phone) val zone = remember { TimeZone.currentSystemDefault() } val agenda = remember(snapshot, nowMillis) { wearAgenda(snapshot, nowMillis, zone)@@ -107,16 +94,6 @@ internal fun WearAgendaContent( modifier = Modifier.fillMaxWidth().padding(horizontal = 12.dp), ) }- syncNote?.let { note ->- item {- Text(- note,- style = MaterialTheme.typography.body2,- textAlign = TextAlign.Center,- modifier = Modifier.fillMaxWidth().padding(horizontal = 12.dp, vertical = 4.dp),- )- }- } if (snapshot.events.isEmpty()) { item { Text(@@ -150,18 +127,6 @@ internal fun WearAgendaContent( } } }- item {- Chip(- onClick = {- scope.launch {- syncNote = if (onRequestSync()) requestedText else noPhoneText- }- },- label = { Text(stringResource(R.string.wear_request_sync), maxLines = 1) },- colors = ChipDefaults.secondaryChipColors(),- modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp),- )- } } }
calendar/src/main/res/values/strings.xml
diff --git a/calendar/src/main/res/values/strings.xml b/calendar/src/main/res/values/strings.xmlindex 3ca9607113..bfc651e860 100644--- a/calendar/src/main/res/values/strings.xml+++ b/calendar/src/main/res/values/strings.xml@@ -226,12 +226,6 @@ <!-- Import ICS dialog: import events from .ics file --> <!-- Dropdown option to create new calendar for import. + indicates add new --> <string name="create_new_calendar">+ Create new calendar</string>- <!-- Settings: wear companion row; tap publishes a fresh snapshot -->- <string name="wear_watch">Watch</string>- <string name="wear_watch_not_found">No watch with the Calendar companion found</string>- <string name="wear_watch_connected">Watch found — tap to sync now</string>- <!-- %1$d = events in the last published snapshot -->- <string name="wear_watch_synced">Watch synced · %1$d events — tap to sync again</string> <!-- Settings: row to open file picker for .ics import --> <string name="import_ics_file">Import .ics file</string> <!-- Settings: row to choose a destination file for .ics export -->
calendar/src/main/res/values/wear_strings.xml
diff --git a/calendar/src/main/res/values/wear_strings.xml b/calendar/src/main/res/values/wear_strings.xmlindex 55bde6ccd8..d03d7e07fb 100644--- a/calendar/src/main/res/values/wear_strings.xml+++ b/calendar/src/main/res/values/wear_strings.xml@@ -4,9 +4,6 @@ <string name="wear_today">Today</string> <string name="wear_upcoming">Upcoming</string> <string name="wear_all_day">All day</string>- <string name="wear_request_sync">Sync now</string>- <string name="wear_sync_requested">Asked your phone for a fresh copy</string>- <string name="wear_no_phone">Phone not reachable — showing the last synced copy</string> <string name="wear_truncated">Showing the first part of your calendar; the rest stays on your phone</string> <string name="wear_back">Back</string> </resources>
calendar/src/screenshotTest/kotlin/com/vayunmathur/calendar/ui/WearMetadataPreviews.kt
diff --git a/calendar/src/screenshotTest/kotlin/com/vayunmathur/calendar/ui/WearMetadataPreviews.kt b/calendar/src/screenshotTest/kotlin/com/vayunmathur/calendar/ui/WearMetadataPreviews.ktindex ddc8dca8cc..8556701f5b 100644--- a/calendar/src/screenshotTest/kotlin/com/vayunmathur/calendar/ui/WearMetadataPreviews.kt+++ b/calendar/src/screenshotTest/kotlin/com/vayunmathur/calendar/ui/WearMetadataPreviews.kt@@ -41,7 +41,6 @@ class WearMetadataPreviews { snapshot = WearCalendarSnapshot(generatedAtMillis = FIXED_NOW_MILLIS, events = fixtureEvents), nowMillis = FIXED_NOW_MILLIS, onOpenEvent = {},- onRequestSync = { true }, ) } }@@ -62,7 +61,6 @@ class WearMetadataPreviews { snapshot = WearCalendarSnapshot(generatedAtMillis = FIXED_NOW_MILLIS, events = emptyList()), nowMillis = FIXED_NOW_MILLIS, onOpenEvent = {},- onRequestSync = { true }, ) } }
metadata_data/photos/calendar/wear/3.png
diff --git a/metadata_data/photos/calendar/wear/3.png b/metadata_data/photos/calendar/wear/3.pngindex f1305700db..cd5a20aa98 100644Binary files a/metadata_data/photos/calendar/wear/3.png and b/metadata_data/photos/calendar/wear/3.png differ