weather: fix watch design (no Back buttons, centered filled actions)
- Commit
c46085dbd8faf03c26285fa7015b1fe37154869f- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-05 14:37 UTC (19 hours ago)
- Parents
bf57559
Remove bottom text Back chips from watch screens (system back now pops the shared WearBackStack), add a centered filled Open on phone button with the mobile-arrow-right icon on detail/summary screens, and convert existing watch deletes to a red filled Delete button below it where a real watch delete path already exists (notes: Delete note via store op, todo: Delete task via its confirm route). Open on phone sends the /<app>/open-on-phone conduit message; the phone sync opens the app main activity with the entity id extra. List/nav chips and toggles keep their component types; no Outlined/TextButton remains on watch screens. Verified: :weather:compileDevKotlin (lint/test in the sweep run).
Diff
weather/src/main/java/com/vayunmathur/weather/sync/WearWeatherSync.kt
diff --git a/weather/src/main/java/com/vayunmathur/weather/sync/WearWeatherSync.kt b/weather/src/main/java/com/vayunmathur/weather/sync/WearWeatherSync.ktindex 7bb3f9c7e8..53c358cc42 100644--- a/weather/src/main/java/com/vayunmathur/weather/sync/WearWeatherSync.kt+++ b/weather/src/main/java/com/vayunmathur/weather/sync/WearWeatherSync.kt@@ -1,5 +1,6 @@ package com.vayunmathur.weather.sync import android.content.Context+import android.content.Intent import com.vayunmathur.library.log.Log import com.vayunmathur.library.wearlink.WearLinkListener import com.vayunmathur.library.wearlink.WearLinkState@@ -53,7 +54,7 @@ class WearWeatherSync private constructor(context:Context){ override fun onData(path:String,body:ByteArray){ if(path!=WearWeatherProtocol.WATCH_STATE_PATH)return val ws=runCatching{WearWeatherProtocol.json.decodeFromString<WearWatchState>(body.decodeToString())}.getOrNull()?:return _state.update{it.copy(lastWatchAppliedAtMillis=ws.appliedGeneratedAtMillis.takeIf{a->a>0L})} }- override fun onMessage(path:String,body:ByteArray){ if(path==WearWeatherProtocol.REQUEST_SYNC_PATH) scope.launch{publishSnapshot()} }+ override fun onMessage(path:String,body:ByteArray){ if(path.endsWith("/open-on-phone")){ runCatching{ appContext.startActivity(Intent(appContext, com.vayunmathur.weather.MainActivity::class.java).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK).putExtra("wear_open_id", body.decodeToString())) }; return }; if(path==WearWeatherProtocol.REQUEST_SYNC_PATH) scope.launch{publishSnapshot()} } } // Conduit appId = first path segment of the weather paths (the // ConduitProtocol route key), not the RFCOMM handshake capability.
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 375a294069..36f96341d2 100644--- a/weather/src/main/java/com/vayunmathur/weather/ui/WearLocationScreen.kt+++ b/weather/src/main/java/com/vayunmathur/weather/ui/WearLocationScreen.kt@@ -25,8 +25,15 @@ 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 androidx.compose.runtime.rememberCoroutineScope+import androidx.compose.ui.platform.LocalContext+import com.vayunmathur.weather.sync.WearLinkBridge+import com.vayunmathur.library.ui.IconMobileArrowRight+import com.vayunmathur.library.wearlink.wearOpenOnPhoneItem+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() val tempUnit=remember{systemWearTemperatureUnit()}; val windUnit=remember{systemWearWindUnit()} val st=rememberScalingLazyListState() ScalingLazyColumn(state=st){@@ -40,6 +47,6 @@ import com.vayunmathur.weather.platform.systemWearWindUnit 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))} } }- item{ Chip(onClick=onBack,label={Text(stringResource(R.string.wear_back),maxLines=1)},colors=ChipDefaults.secondaryChipColors(),modifier=Modifier.fillMaxWidth().padding(horizontal=8.dp)) }+ wearOpenOnPhoneItem(onClick={scope.launch{WearLinkBridge.get(ctx).sendMessage("/weather/open-on-phone",ByteArray(0))}},icon={IconMobileArrowRight(tint=androidx.compose.ui.graphics.Color.White)}) } }