diff options
| author | Claudomator Agent <agent@claudomator> | 2026-03-13 19:59:01 +0000 |
|---|---|---|
| committer | Claudomator Agent <agent@claudomator> | 2026-03-13 19:59:01 +0000 |
| commit | 51f86cff118f9532783c4e61724e07173ec029d7 (patch) | |
| tree | 1c5601142391003830527f0c97d8ef7fa4145052 /android-app/app/src/main/res/layout | |
| parent | 7e40bd03ab0246552d26d92fda8623b8da4653f3 (diff) | |
feat: add wind/current map overlay and weather forecast on startup
Implements the wind/current map overlay and 7-day weather forecast
display that loads on application launch:
Data layer:
- Open-Meteo API (free, no key): WeatherApiService + MarineApiService
- Moshi-annotated response models (WeatherResponse, MarineResponse)
- WeatherRepository: parallel async fetch, Result<T> error propagation
- Domain models: WindArrow (with beaufortScale/isCalm) + ForecastItem
(with weatherDescription/isRainy via WMO weather codes)
Presentation layer:
- MainViewModel: StateFlow<UiState> (Loading/Success/Error),
windArrow and forecast streams
- MainActivity: runtime location permission, FusedLocationProvider
GPS fetch on startup, falls back to SF Bay default
- MapFragment: MapLibre GL map with wind-arrow SymbolLayer;
icon rotated by wind direction, size scaled by speed in knots
- ForecastFragment + ForecastAdapter: RecyclerView ListAdapter
showing 7-day hourly forecast (time, description, wind, temp, precip)
Resources:
- ic_wind_arrow.xml vector drawable (north-pointing, rotated by MapLibre)
- BottomNavigationView: Map / Forecast tabs
- ViewBinding enabled throughout
Tests (TDD — written before implementation):
- WindArrowTest: calm detection, direction normalisation, Beaufort scale
- ForecastItemTest: weatherDescription, isRainy for WMO codes
- WeatherApiServiceTest: MockWebServer request params + response parsing
- WeatherRepositoryTest: MockK service mocks, data mapping, error paths
- MainViewModelTest: Turbine StateFlow assertions for all state transitions
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'android-app/app/src/main/res/layout')
4 files changed, 153 insertions, 0 deletions
diff --git a/android-app/app/src/main/res/layout/activity_main.xml b/android-app/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..757dbdb --- /dev/null +++ b/android-app/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<androidx.coordinatorlayout.widget.CoordinatorLayout + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <androidx.fragment.app.FragmentContainerView + android:id="@+id/fragment_container" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_marginBottom="56dp" /> + + <com.google.android.material.bottomnavigation.BottomNavigationView + android:id="@+id/bottom_nav" + android:layout_width="match_parent" + android:layout_height="56dp" + android:layout_gravity="bottom" + android:background="?attr/colorSurface" + app:menu="@menu/bottom_nav_menu" /> + +</androidx.coordinatorlayout.widget.CoordinatorLayout> diff --git a/android-app/app/src/main/res/layout/fragment_forecast.xml b/android-app/app/src/main/res/layout/fragment_forecast.xml new file mode 100644 index 0000000..aca38ba --- /dev/null +++ b/android-app/app/src/main/res/layout/fragment_forecast.xml @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" + android:background="?attr/colorSurface"> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingHorizontal="16dp" + android:paddingTop="16dp" + android:paddingBottom="8dp" + android:text="7-Day Forecast" + android:textAppearance="?attr/textAppearanceHeadline6" + android:textColor="?attr/colorOnSurface" /> + + <ProgressBar + android:id="@+id/progress" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:visibility="gone" /> + + <TextView + android:id="@+id/error_text" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="16dp" + android:textColor="@color/wind_strong" + android:visibility="gone" /> + + <androidx.recyclerview.widget.RecyclerView + android:id="@+id/forecast_list" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="1" + android:clipToPadding="false" + android:paddingBottom="8dp" /> + +</LinearLayout> diff --git a/android-app/app/src/main/res/layout/fragment_map.xml b/android-app/app/src/main/res/layout/fragment_map.xml new file mode 100644 index 0000000..e5b86b7 --- /dev/null +++ b/android-app/app/src/main/res/layout/fragment_map.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="utf-8"?> +<FrameLayout + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <org.maplibre.android.maps.MapView + android:id="@+id/map_view" + android:layout_width="match_parent" + android:layout_height="match_parent" + app:maplibre_cameraTargetLat="37.0" + app:maplibre_cameraTargetLng="-122.0" + app:maplibre_cameraZoom="5.0" /> + + <!-- Loading / error overlay --> + <TextView + android:id="@+id/status_text" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="top|center_horizontal" + android:layout_marginTop="16dp" + android:background="#AA000000" + android:paddingHorizontal="12dp" + android:paddingVertical="4dp" + android:textColor="#FFFFFF" + android:textSize="14sp" + android:visibility="gone" /> + +</FrameLayout> diff --git a/android-app/app/src/main/res/layout/item_forecast.xml b/android-app/app/src/main/res/layout/item_forecast.xml new file mode 100644 index 0000000..473661a --- /dev/null +++ b/android-app/app/src/main/res/layout/item_forecast.xml @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:paddingHorizontal="16dp" + android:paddingVertical="12dp" + android:gravity="center_vertical"> + + <!-- Time --> + <TextView + android:id="@+id/tv_time" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="2" + android:textAppearance="?attr/textAppearanceBody2" + android:textColor="?attr/colorOnSurface" /> + + <!-- Weather description --> + <TextView + android:id="@+id/tv_description" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="3" + android:textAppearance="?attr/textAppearanceBody2" + android:textColor="?attr/colorOnSurface" /> + + <!-- Wind --> + <TextView + android:id="@+id/tv_wind" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="2" + android:gravity="end" + android:textAppearance="?attr/textAppearanceBody2" + android:textColor="?attr/colorOnSurface" /> + + <!-- Temperature --> + <TextView + android:id="@+id/tv_temp" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1.5" + android:gravity="end" + android:textAppearance="?attr/textAppearanceBody2" + android:textColor="?attr/colorOnSurface" /> + + <!-- Precip probability --> + <TextView + android:id="@+id/tv_precip" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1.5" + android:gravity="end" + android:textAppearance="?attr/textAppearanceBody2" + android:textColor="@color/primary" /> + +</LinearLayout> |
