From 65c04f94ecd862ec2ba195e0128da84f79647ef1 Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Mon, 23 Mar 2026 07:07:17 +0000 Subject: fix: resolve Kotlin compilation errors from UI refactor - Make InstrumentHandler.labelTrend and barometerTrendView nullable - Remove anchorWatchHandler init block referencing non-existent view IDs - Fix state.radiusM -> state.watchCircleRadiusMeters - Add bottom_nav_weather_menu.xml with nav_forecast; point WeatherActivity at it Co-Authored-By: Claude Sonnet 4.6 --- .../app/src/main/kotlin/org/terst/nav/MainActivity.kt | 13 ++----------- .../src/main/kotlin/org/terst/nav/ui/InstrumentHandler.kt | 8 ++++---- android-app/app/src/main/res/layout/activity_weather.xml | 2 +- .../app/src/main/res/menu/bottom_nav_weather_menu.xml | 11 +++++++++++ 4 files changed, 18 insertions(+), 16 deletions(-) create mode 100644 android-app/app/src/main/res/menu/bottom_nav_weather_menu.xml diff --git a/android-app/app/src/main/kotlin/org/terst/nav/MainActivity.kt b/android-app/app/src/main/kotlin/org/terst/nav/MainActivity.kt index bbc9853..d0b0e58 100644 --- a/android-app/app/src/main/kotlin/org/terst/nav/MainActivity.kt +++ b/android-app/app/src/main/kotlin/org/terst/nav/MainActivity.kt @@ -159,16 +159,7 @@ class MainActivity : AppCompatActivity(), SafetyFragment.SafetyListener { polarDiagramView = findViewById(R.id.polar_diagram_view) ) - anchorWatchHandler = AnchorWatchHandler( - context = this, - container = findViewById(R.id.anchor_config_container) ?: FrameLayout(this), // stub for now - statusText = findViewById(R.id.anchor_status_text) ?: android.widget.TextView(this), - radiusText = findViewById(R.id.anchor_radius_text) ?: android.widget.TextView(this), - buttonDecrease = findViewById(R.id.button_decrease_radius) ?: android.widget.Button(this), - buttonIncrease = findViewById(R.id.button_increase_radius) ?: android.widget.Button(this), - buttonSet = findViewById(R.id.button_set_anchor) ?: android.widget.Button(this), - buttonStop = findViewById(R.id.button_stop_anchor) ?: android.widget.Button(this) - ) + // anchorWatchHandler is initialized when the anchor config UI is available val mockPolarTable = createMockPolarTable() findViewById(R.id.polar_diagram_view).setPolarTable(mockPolarTable) @@ -242,7 +233,7 @@ class MainActivity : AppCompatActivity(), SafetyFragment.SafetyListener { } lifecycleScope.launch { LocationService.anchorWatchState.collect { state -> - safetyFragment.updateAnchorStatus(if (state.isActive) "Active: ${state.radiusM}m" else "Inactive") + safetyFragment.updateAnchorStatus(if (state.isActive) "Active: ${state.watchCircleRadiusMeters}m" else "Inactive") } } } diff --git a/android-app/app/src/main/kotlin/org/terst/nav/ui/InstrumentHandler.kt b/android-app/app/src/main/kotlin/org/terst/nav/ui/InstrumentHandler.kt index 63c6165..2f72153 100644 --- a/android-app/app/src/main/kotlin/org/terst/nav/ui/InstrumentHandler.kt +++ b/android-app/app/src/main/kotlin/org/terst/nav/ui/InstrumentHandler.kt @@ -21,8 +21,8 @@ class InstrumentHandler( private val valueDepth: TextView, private val valuePolarPct: TextView, private val valueBaro: TextView, - private val labelTrend: TextView, - private val barometerTrendView: BarometerTrendView, + private val labelTrend: TextView?, + private val barometerTrendView: BarometerTrendView?, private val polarDiagramView: PolarDiagramView ) { /** @@ -51,7 +51,7 @@ class InstrumentHandler( depth?.let { valueDepth.text = it } polarPct?.let { valuePolarPct.text = it } baro?.let { valueBaro.text = it } - trend?.let { labelTrend.text = it } + trend?.let { labelTrend?.text = it } } /** @@ -65,6 +65,6 @@ class InstrumentHandler( * Updates the barometer trend chart. */ fun updateBarometerTrend(history: List) { - barometerTrendView.setHistory(history) + barometerTrendView?.setHistory(history) } } diff --git a/android-app/app/src/main/res/layout/activity_weather.xml b/android-app/app/src/main/res/layout/activity_weather.xml index 36ea871..68374ca 100644 --- a/android-app/app/src/main/res/layout/activity_weather.xml +++ b/android-app/app/src/main/res/layout/activity_weather.xml @@ -14,7 +14,7 @@ android:id="@+id/bottom_nav" android:layout_width="match_parent" android:layout_height="wrap_content" - app:menu="@menu/bottom_nav_menu" + app:menu="@menu/bottom_nav_weather_menu" xmlns:app="http://schemas.android.com/apk/res-auto" /> diff --git a/android-app/app/src/main/res/menu/bottom_nav_weather_menu.xml b/android-app/app/src/main/res/menu/bottom_nav_weather_menu.xml new file mode 100644 index 0000000..d3c1427 --- /dev/null +++ b/android-app/app/src/main/res/menu/bottom_nav_weather_menu.xml @@ -0,0 +1,11 @@ + + + + + -- cgit v1.2.3