weather: remove manual watch sync chip from wear location
- Commit
af81ace580a79145160a4bd1814600d2570cd06b- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-05 16:53 UTC (16 hours ago)
- Parents
b878361
Phone-to-watch sync is now fully automatic over the Watch conduit, so the 'Sync now' chip on the wear location detail is dead weight. Remove the chip, its result note, the requestWearSync wrapper in WearLinkBridge, the dead WeatherViewModel.syncWearNow manual entry, and the wear sync strings; update AGENTS.md. The informational watch-status text on the phone locations page is purely textual (not a button or settings row) and is kept. Automatic WearWeatherSync publishing is unchanged. Verified: :weather:lint :weather:lintVitalRelease :weather:testDevUnitTest pass; :weather:metadata regenerated.
Diff
weather/AGENTS.md
diff --git a/weather/AGENTS.md b/weather/AGENTS.mdindex deb2809fd3..0826599449 100644--- a/weather/AGENTS.md+++ b/weather/AGENTS.md@@ -42,7 +42,7 @@ receivers are a phone-only surface and early-return on a watch. - **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 `WearWeatherSync.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 (in this module)-- `ui/WearMainActivity` (a `WearShellActivity`) routes `ui/WearRoute` over locations (`ui/WearLocationsScreen`) and one location's current/hourly/daily detail (`ui/WearLocationScreen`), with a sync-now action that messages the phone side.+- `ui/WearMainActivity` (a `WearShellActivity`) routes `ui/WearRoute` over locations (`ui/WearLocationsScreen`) and one location's current/hourly/daily detail (`ui/WearLocationScreen`); snapshots arrive automatically over the conduit, with no manual sync action. - Watch state persists in `data/WearWeatherStore` (`wear-weather-snapshot.json`). - Watch listing screenshots are the `group = "wear"` previews in `src/screenshotTest/.../ui/WearMetadataPreviews.kt`, collected by `:weather:metadata` into `metadata_data/photos/weather/wear/`; phone shots use the `phone` bucket. **Gotchas:**
weather/src/main/java/com/vayunmathur/weather/platform/WeatherViewModel.kt
diff --git a/weather/src/main/java/com/vayunmathur/weather/platform/WeatherViewModel.kt b/weather/src/main/java/com/vayunmathur/weather/platform/WeatherViewModel.ktindex ccbcaab453..ccc67cc3e6 100644--- a/weather/src/main/java/com/vayunmathur/weather/platform/WeatherViewModel.kt+++ b/weather/src/main/java/com/vayunmathur/weather/platform/WeatherViewModel.kt@@ -68,7 +68,6 @@ class WeatherViewModel( } val wearSyncState = com.vayunmathur.weather.sync.WearWeatherSync.get(application).state- fun syncWearNow() = com.vayunmathur.weather.sync.WearWeatherSync.get(getApplication()).syncNow() val savedLocations: StateFlow<List<SavedLocation>?> = repository.locations .stateIn(viewModelScope, SharingStarted.WhileSubscribed(5_000), null)
weather/src/main/java/com/vayunmathur/weather/sync/WearLinkBridge.kt
diff --git a/weather/src/main/java/com/vayunmathur/weather/sync/WearLinkBridge.kt b/weather/src/main/java/com/vayunmathur/weather/sync/WearLinkBridge.ktindex 9cff4496bd..ba0bf7ad95 100644--- a/weather/src/main/java/com/vayunmathur/weather/sync/WearLinkBridge.kt+++ b/weather/src/main/java/com/vayunmathur/weather/sync/WearLinkBridge.kt@@ -42,10 +42,3 @@ object WearLinkBridge { fun publishWatchState(c:Context,s:WearWeatherSnapshot){ scope.launch{ get(c).putData(WearWeatherProtocol.WATCH_STATE_PATH, WearWeatherProtocol.json.encodeToString(WearWatchState(s.generatedAtMillis,s.locations.size)).encodeToByteArray()) } } suspend fun requestSync(c:Context):Boolean=get(c).sendMessage(WearWeatherProtocol.REQUEST_SYNC_PATH,ByteArray(0)) }-/**- * 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(c:Context):Boolean=WearLinkBridge.requestSync(c)
weather/src/main/java/com/vayunmathur/weather/ui/WearLocationScreen.kt
diff --git a/weather/src/main/java/com/vayunmathur/weather/ui/WearLocationScreen.kt b/weather/src/main/java/com/vayunmathur/weather/ui/WearLocationScreen.ktindex 77515ad8f0..375a294069 100644--- a/weather/src/main/java/com/vayunmathur/weather/ui/WearLocationScreen.kt+++ b/weather/src/main/java/com/vayunmathur/weather/ui/WearLocationScreen.kt@@ -4,12 +4,8 @@ import androidx.compose.foundation.layout.padding 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.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp@@ -29,13 +25,10 @@ import com.vayunmathur.weather.domain.wearTemp import com.vayunmathur.weather.domain.wearWind import com.vayunmathur.weather.platform.systemWearTemperatureUnit import com.vayunmathur.weather.platform.systemWearWindUnit-import com.vayunmathur.weather.sync.requestWearSync-import kotlinx.coroutines.launch @Composable fun WearLocationScreen(store:WearWeatherStore, locationId:Long, onBack:()->Unit){ val s by store.snapshot.collectAsState(); val loc=s.locations.firstOrNull{it.locationId==locationId}?:s.locations.firstOrNull()- val ctx=LocalContext.current; val scope=rememberCoroutineScope(); var note by remember{mutableStateOf<String?>(null)} val tempUnit=remember{systemWearTemperatureUnit()}; val windUnit=remember{systemWearWindUnit()}- val req=stringResource(R.string.wear_sync_requested); val no=stringResource(R.string.wear_no_phone); val st=rememberScalingLazyListState()+ val st=rememberScalingLazyListState() ScalingLazyColumn(state=st){ if(loc==null){ item{ Text(stringResource(R.string.wear_empty),textAlign=TextAlign.Center,modifier=Modifier.fillMaxWidth().padding(horizontal=12.dp)) } } else{@@ -47,8 +40,6 @@ import kotlinx.coroutines.launch if(loc.daily.isNotEmpty()){ item{ Text(stringResource(R.string.wear_daily),style=MaterialTheme.typography.caption1,textAlign=TextAlign.Center,modifier=Modifier.fillMaxWidth().padding(horizontal=12.dp)) } items(loc.daily){d-> Chip(onClick={}, enabled=false,label={Text("${wearDayLabel(d.dateIso)} ${wearTemp(d.temperatureMinC,tempUnit)}–${wearTemp(d.temperatureMaxC,tempUnit)}",maxLines=1)},secondaryLabel={Text("${wearConditionLabel(d.weatherCode)} ${d.precipitationProbabilityMaxPercent}%",maxLines=1)},colors=ChipDefaults.secondaryChipColors(),modifier=Modifier.fillMaxWidth().padding(horizontal=8.dp))} } }- note?.let{n-> item{ Text(n,style=MaterialTheme.typography.body2,textAlign=TextAlign.Center,modifier=Modifier.fillMaxWidth().padding(horizontal=12.dp)) } }- item{ Chip(onClick={scope.launch{note=if(requestWearSync(ctx))req else no}},label={Text(stringResource(R.string.wear_request_sync),maxLines=1)},colors=ChipDefaults.secondaryChipColors(),modifier=Modifier.fillMaxWidth().padding(horizontal=8.dp)) } item{ Chip(onClick=onBack,label={Text(stringResource(R.string.wear_back),maxLines=1)},colors=ChipDefaults.secondaryChipColors(),modifier=Modifier.fillMaxWidth().padding(horizontal=8.dp)) } } }
weather/src/main/res/values/wear_strings.xml
diff --git a/weather/src/main/res/values/wear_strings.xml b/weather/src/main/res/values/wear_strings.xmlindex c300670b0c..002283444e 100644--- a/weather/src/main/res/values/wear_strings.xml+++ b/weather/src/main/res/values/wear_strings.xml@@ -6,9 +6,6 @@ <string name="wear_locations">Locations</string> <string name="wear_hourly">Next hours</string> <string name="wear_daily">Outlook</string>-<string name="wear_request_sync">Sync now</string>-<string name="wear_sync_requested">Asked your phone for fresh weather</string>-<string name="wear_no_phone">Phone not reachable — showing last synced weather</string> <string name="wear_truncated">Showing primary locations only</string> <string name="wear_back">Back</string> </resources>