18 Commits
Author SHA1 Message Date
MrBlakeandClaude Opus 5.5 4b5c9bdf85 widgets: reload data on update, clock widget, picker previews; README screenshots; 0.2.0
- Glance update() only recomposed the running session, so saved styles (opacity, colours)
  and new forecasts never reached placed widgets; a state version now triggers a reload
- new minimal clock widget (live TextClock, date, current weather), transparent by default
- static preview images for the widget picker, generated previews on Android 15+
- debug builds install next to the release app (app.wetter.debug)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-17 14:51:16 +02:00
MrBlakeandClaude Opus 5.5 d1d8d01dd0 build: release script for Obtainium-compatible Gitea releases
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-17 14:41:38 +02:00
MrBlakeandClaude Opus 5.5 963a5e0e86 build: sign releases with a dedicated key kept outside the repo
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-17 14:40:54 +02:00
MrBlakeandClaude Opus 5.5 a1a56d9b50 docs: Obtainium link with Gitea source override and per-app filters, verified against Obtainium's parser
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-17 14:38:08 +02:00
MrBlakeandClaude Opus 5.5 a134b8f46f design: adaptive app icon (sky, hills, cookie sun, cloud) with themed monochrome layer
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-17 14:30:21 +02:00
MrBlakeandClaude Opus 5.5 79e6031823 ui: Pixel-style settings (grouped tiles, tonal icons, dialogs, check switches) for app and widget config
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-17 14:28:19 +02:00
MrBlakeandClaude Opus 5.5 0c42d8570b build: S12 five widgets after reference, per-widget style config
- weather card (3x2 to 4x5), pill, tilted pill, bar with cookie badge, classic
- configuration screen on add and via reconfigure: location, theme, palette, opacity, live preview
- wallpaper (Material You), weather and five fixed palettes, all pairs WCAG AA
- Glance 1.2: picker previews on Android 15+, debug widget gallery
- DB v2 migration for widget theme and opacity

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-17 14:24:52 +02:00
MrBlakeandClaude Opus 5.5 8eb9544189 docs: project README
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-17 14:14:11 +02:00
MrBlakeandClaude Opus 5.5 27bf4e88f4 fix: retry Open-Meteo on 429/5xx and show why loading failed
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-17 14:09:21 +02:00
MrBlakeandClaude Opus 5.5 c61b03b48f test: re-record screenshots after scene path change
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-17 14:02:14 +02:00
MrBlakeandClaude Opus 5.5 054c76d093 perf: draw-phase scene animation, parallel and de-duplicated loading, release build
- scene time and scroll offset are read only while drawing, so frames no longer recompose the page
- forecast and air quality load in parallel; concurrent refreshes of one location share a request
- saving a previewed place stores the already loaded forecast instead of fetching again
- platform fused location provider first; recent last-known position used at once
- release build signed with the debug key for local installs

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-17 14:01:38 +02:00
MrBlakeandClaude Opus 5.5 c446798403 test: screenshot tests from a real Open-Meteo response
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-17 13:52:42 +02:00
MrBlakeandClaude Opus 5.5 c1c76252f1 build: S12 widgets (now, forecast)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-17 13:52:42 +02:00
MrBlakeandClaude Opus 5.5 c0bf0f6042 build: S08 settings and S09 units
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-17 13:52:42 +02:00
MrBlakeandClaude Opus 5.5 1d8c3f8f5f build: S04 day detail
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-17 13:52:42 +02:00
MrBlakeandClaude Opus 5.5 c5c1483544 build: S15 location preview
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-17 13:52:42 +02:00
MrBlakeandClaude Opus 5.5 a9f2f69398 build: S02 locations and S03 search
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-17 13:52:42 +02:00
MrBlakeandClaude Opus 5.5 b359249c59 build: S01 home and S14 permission prompt
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-17 13:52:42 +02:00
80 changed files with 3189 additions and 121 deletions

No files matched your search

+3
View File
@@ -0,0 +1,3 @@
.giteatoken
*.jks
keystore.properties
+131
View File
@@ -0,0 +1,131 @@
# NoGooleApps
**Everyday Android apps without Google.** Privacy-friendly rebuilds of the standard Google apps, for people who want the polish of the originals without Play Services, tracking or an account. Made with GrapheneOS, CalyxOS, /e/OS and LineageOS in mind, and works the same on any stock Android phone.
> Not affiliated with, endorsed by or connected to Google. These are independent, clean-room rebuilds: no Google code, assets, icons, fonts or text are used.
## Apps
| App | Replaces | Status | Install |
| --- | --- | --- | --- |
| **Wetter** (`wetter/`) | Google Weather / Pixel Weather | alpha, in daily testing | [Obtainium](https://apps.obtainium.imranr.dev/redirect?r=obtainium://app/%7B%22id%22%3A%22app.wetter%22%2C%22url%22%3A%22https%3A%2F%2Fgit.mrblake.cc%2FMrBlake%2FNoGooleApps%22%2C%22author%22%3A%22MrBlake%22%2C%22name%22%3A%22Wetter%22%2C%22overrideSource%22%3A%22Codeberg%22%2C%22preferredApkIndex%22%3A0%2C%22additionalSettings%22%3A%22%7B%5C%22appId%5C%22%3A%5C%22app.wetter%5C%22%2C%5C%22includePrereleases%5C%22%3Atrue%2C%5C%22fallbackToOlderReleases%5C%22%3Atrue%2C%5C%22filterReleaseTitlesByRegEx%5C%22%3A%5C%22%5EWetter%20%5C%22%2C%5C%22apkFilterRegEx%5C%22%3A%5C%22%5Ewetter-.%2A%5C%5C%5C%5C.apk%24%5C%22%2C%5C%22autoApkFilterByArch%5C%22%3Afalse%2C%5C%22verifyLatestTag%5C%22%3Afalse%2C%5C%22releaseTitleAsVersion%5C%22%3Afalse%7D%22%7D) · F-Droid: not yet |
More apps will follow, one folder each. Each one goes through the same pipeline (see [How these apps are made](#how-these-apps-are-made)).
### Wetter
A weather app with the look and feel of Pixel Weather: an animated sky that changes with the conditions, a large hero temperature, hourly and 10-day forecasts, and shaped Material 3 Expressive detail tiles (wind, sun, UV, air quality, visibility, humidity, pressure, pollen).
- **No Google Play Services.** Location uses the platform's own providers (including the AOSP fused provider), so it works on GrapheneOS without sandboxed Play.
- **No account, no tracking, no analytics.** Everything stays on the device. Coordinates are rounded to two decimals (about 1 km) before they reach the weather service.
- **Open data sources only:** [Open-Meteo](https://open-meteo.com) for forecasts, 15-minute precipitation, air quality, pollen and place search (CC BY 4.0), and [Nominatim / OpenStreetMap](https://nominatim.org) for naming your current location.
- **Features today:** current location and saved cities (swipe between them), search with a full preview before saving, precipitation-in-the-next-hours card, a rule-based daily summary, day detail view, units and theme settings, light and dark mode.
- **Six home-screen widgets:** a minimal clock with date and current weather (transparent by default), a weather card that grows from 3×2 to 4×5 (hourly panel, then a daily list), a pill, a tilted pill, a one-line bar with a cookie badge, and a classic card. The widget picker shows real previews. Each one can be customised when added or later: location, system/light/dark, colours (wallpaper Material You, current weather, or five fixed palettes, all WCAG AA checked) and background opacity from 100 % down to fully transparent.
- **Coming next:** severe weather alerts (DWD / MeteoAlarm), precipitation radar map, card reordering, notifications.
<p align="center">
<img src="docs/screenshots/S01-clear-day.png" width="200" alt="Home, sunny">
<img src="docs/screenshots/S01-clear-night-dark.png" width="200" alt="Home, clear night, dark mode">
<img src="docs/screenshots/S01-rain-nowcast.png" width="200" alt="Rain with the next-hours precipitation card">
</p>
<p align="center">
<img src="docs/screenshots/S01-full-light.png" width="200" alt="Full forecast with detail tiles">
<img src="docs/screenshots/S04-day-dark.png" width="200" alt="Day detail">
<img src="docs/screenshots/S08-settings.png" width="200" alt="Settings">
</p>
<p align="center">
<img src="docs/screenshots/widgets.png" width="380" alt="Home-screen widgets: clock, weather card, pill, bar, classic, tilted pill">
</p>
<sub>Screenshots are rendered from a real Open-Meteo response (Berlin) by the app's screenshot tests; widgets are rendered on a Pixel with the wallpaper colours of that phone.</sub>
Requires Android 10 (API 29) or newer.
## Install with Obtainium
[Obtainium](https://github.com/ImranR98/Obtainium) installs and updates apps straight from this repository's releases, with no store in between.
### Wetter
[<img src="https://raw.githubusercontent.com/ImranR98/Obtainium/main/assets/graphics/badge_obtainium.png" alt="Get it on Obtainium" height="54">](https://apps.obtainium.imranr.dev/redirect?r=obtainium://app/%7B%22id%22%3A%22app.wetter%22%2C%22url%22%3A%22https%3A%2F%2Fgit.mrblake.cc%2FMrBlake%2FNoGooleApps%22%2C%22author%22%3A%22MrBlake%22%2C%22name%22%3A%22Wetter%22%2C%22overrideSource%22%3A%22Codeberg%22%2C%22preferredApkIndex%22%3A0%2C%22additionalSettings%22%3A%22%7B%5C%22appId%5C%22%3A%5C%22app.wetter%5C%22%2C%5C%22includePrereleases%5C%22%3Atrue%2C%5C%22fallbackToOlderReleases%5C%22%3Atrue%2C%5C%22filterReleaseTitlesByRegEx%5C%22%3A%5C%22%5EWetter%20%5C%22%2C%5C%22apkFilterRegEx%5C%22%3A%5C%22%5Ewetter-.%2A%5C%5C%5C%5C.apk%24%5C%22%2C%5C%22autoApkFilterByArch%5C%22%3Afalse%2C%5C%22verifyLatestTag%5C%22%3Afalse%2C%5C%22releaseTitleAsVersion%5C%22%3Afalse%7D%22%7D)
Open the button on your phone with Obtainium installed and confirm the import. The link carries the complete configuration, so nothing has to be set by hand:
| setting | value | why |
| --- | --- | --- |
| Source | `https://git.mrblake.cc/MrBlake/NoGooleApps` | this repository (note the spelling: **NoGooleApps**) |
| Override source | Forgejo (Codeberg) | the repository runs on a self-hosted Gitea, which Obtainium does not detect on its own; Gitea speaks the same release API |
| Filter release titles | `^Wetter ` | several apps share this repository; only weather releases count |
| Filter APKs | `^wetter-.*\.apk$` | picks the weather APK from the release assets |
If the button does not open Obtainium (some browsers block links to apps; the page then shows a button to tap, or enable "open links in apps" in the browser), paste this link into the phone's browser address bar, or add the app by hand with the settings above:
```
obtainium://app/%7B%22id%22%3A%22app.wetter%22%2C%22url%22%3A%22https%3A%2F%2Fgit.mrblake.cc%2FMrBlake%2FNoGooleApps%22%2C%22author%22%3A%22MrBlake%22%2C%22name%22%3A%22Wetter%22%2C%22overrideSource%22%3A%22Codeberg%22%2C%22preferredApkIndex%22%3A0%2C%22additionalSettings%22%3A%22%7B%5C%22appId%5C%22%3A%5C%22app.wetter%5C%22%2C%5C%22includePrereleases%5C%22%3Atrue%2C%5C%22fallbackToOlderReleases%5C%22%3Atrue%2C%5C%22filterReleaseTitlesByRegEx%5C%22%3A%5C%22%5EWetter%20%5C%22%2C%5C%22apkFilterRegEx%5C%22%3A%5C%22%5Ewetter-.%2A%5C%5C%5C%5C.apk%24%5C%22%2C%5C%22autoApkFilterByArch%5C%22%3Afalse%2C%5C%22verifyLatestTag%5C%22%3Afalse%2C%5C%22releaseTitleAsVersion%5C%22%3Afalse%7D%22%7D
```
**Releases.** Every app is published as a release titled `<App> <version>` (for example `Wetter 0.1.0`, tag `wetter-v0.1.0`) with one asset named `<app>-<version>.apk`. Obtainium shows *"no matching version"* until the first release of an app exists.
**F-Droid:** not available yet. The apps contain no proprietary libraries, so an F-Droid build is planned (either the main repository or a self-hosted F-Droid repo).
## How these apps are made
### The Replica pipeline
Every app is rebuilt with **[Replica](https://github.com/Jakeschincariol/replica-skill)**, an open set of eleven Claude Code skills by Jake Schincariol for cloning an app's *functionality and UX patterns* clean-room style. Each skill writes files the next one reads, and everything is kept in [`replica/`](replica/):
| Step | Skill | What it produced for Wetter |
| --- | --- | --- |
| 1 | `replica-recon` | [Recon map](replica/recon.md) built from public sources (help center, reviews, store listing): 15 screens, 9 user flows, components, inferred data model, [feature matrix](replica/features.csv) |
| 2 | `replica-architect` | [Architecture](replica/architecture.md) and [schema](replica/schema.sql): native Kotlin, offline-first, no server, public APIs only |
| 3 | `replica-design` | [Design tokens](replica/design/tokens.json) and [component specs](replica/design/components.md), WCAG AA contrast checked (70 colour pairs), generated into Compose code |
| 4 | `replica-build` | The app itself, screen by screen, with a [build log](replica/build-log.md) and [screenshots](replica/clone-screens/) rendered from a real API response |
| next | `replica-test`, `replica-diff`, `replica-entrepreneur`, `replica-brand`, `replica-launch`, `replica-deploy`, `replica-backend` | QA, parity scoring against the original, reading real user reviews for improvements, naming and branding, store listing, release |
The rules Replica enforces, and that this project follows:
- **Public sources and our own devices only.** No decompiling, no private APIs, no reading the original's code or network traffic.
- **Everything written fresh.** Code, icons, weather glyphs, the animated sky and every label are made from scratch. Reference screenshots of the originals live in `replica/screens/` for layout comparison only and never ship.
- **What cannot be cloned is left out on purpose:** Google's own forecast models, Gemini summaries, Calendar/Gmail-based insights and account sync. Open alternatives replace them where it makes sense.
### Built with AI, steered by a human
The code, the design system and this README were written by **Claude Opus 5.5** (Anthropic's model, ID `claude-opus-5-5`) running in **Claude Code**, working through the Replica skills step by step. The human side of the project (that's [@MrBlake](https://git.mrblake.cc/MrBlake)) sets direction, supplies reference screenshots, tests every build on a real Pixel phone and reports what feels wrong. Issues found that way, like stutter during scrolling or slow location, are measured on the device and fixed. A typical loop:
1. A skill produces its document or code; the human reviews it.
2. The app is built and rendered to screenshots on the JVM (Roborazzi), and the screenshots are checked against the reference.
3. The release build is installed on the phone over adb and used for real; frame timings (`dumpsys gfxinfo`) and logs guide the fixes.
Each commit says what changed and carries a `Co-Authored-By` line for the AI.
## Building from source
Requirements: JDK 17 or newer and the Android SDK (platform 36).
```bash
cd wetter
./gradlew :app:assembleRelease # APK in app/build/outputs/apk/release/
./gradlew :app:testDebugUnitTest # unit + screenshot tests
./gradlew :app:recordRoborazziDebug # re-render replica/clone-screens/
```
Release builds are signed with the project key from `~/.android/nogoogleapps-release.properties` (kept outside the repository); without it they fall back to the debug key for local testing. `scripts/release.sh <app>` builds, signs and publishes a release in the format Obtainium expects.
## Repository layout
```
replica/ recon, architecture, design system, build log, screenshots
wetter/ the weather app (Kotlin, Jetpack Compose, Glance widgets, Room, WorkManager)
```
## Credits
- Weather data: [Open-Meteo.com](https://open-meteo.com), CC BY 4.0
- Place names: © [OpenStreetMap](https://www.openstreetmap.org/copyright) contributors, via Nominatim
- UI icons: [Material Symbols](https://fonts.google.com/icons), Apache 2.0
- Method: [Replica](https://github.com/Jakeschincariol/replica-skill) by Jake Schincariol
## License
Not chosen yet. Until a license file is added, all rights are reserved by the author.
Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 261 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

+2 -1
View File
@@ -12,7 +12,8 @@ Stack as in architecture.md. App in `wetter/`. Screenshots are rendered on the J
| S15 Preview | 2026-10-17 | done | – | – |
| S04 Day detail | 2026-10-17 | done | – | tiles need day-specific values (noon), not today's |
| S08/S09 Settings | 2026-10-17 | done | notification settings (no notifications yet) | – |
| S12 Widgets | 2026-10-17 | partial | config activity (pick a location), 4×4 and 4×1 types, dynamic-colour style; **no screenshot** (Glance does not render in Robolectric), only verified to compile | widgets cannot draw shaders → the scene is pre-rendered to a bitmap |
| S12 Widgets | 2026-10-17 | done | – | Glance 1.1 could not render outside the launcher; upgraded to 1.2 for compose() and picker previews, checked on the phone via a debug gallery |
| S12 Widgets (first pass) | 2026-10-17 | superseded | config activity (pick a location), 4×4 and 4×1 types, dynamic-colour style; **no screenshot** (Glance does not render in Robolectric), only verified to compile | widgets cannot draw shaders → the scene is pre-rendered to a bitmap |
| S05, S06, S10, S11, S13 | – | not started | card detail, radar map, reordering, alert detail, notifications | – |
Not yet verified on a real device: location without Play Services, network on device, widgets on the launcher, WorkManager timing.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 904 KiB

After

Width:  |  Height:  |  Size: 907 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 893 KiB

After

Width:  |  Height:  |  Size: 895 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 794 KiB

After

Width:  |  Height:  |  Size: 800 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 843 KiB

After

Width:  |  Height:  |  Size: 846 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 976 KiB

After

Width:  |  Height:  |  Size: 978 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 MiB

After

Width:  |  Height:  |  Size: 1.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 158 KiB

After

Width:  |  Height:  |  Size: 148 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 887 KiB

After

Width:  |  Height:  |  Size: 890 KiB

+72
View File
@@ -114,6 +114,78 @@ object WColor {
val aqiBar6 = Color(0xFF8E24AA)
val uvDotLow = Color(0xFF5CCF8A)
val uvDotOff = Color(0xFF6B5A52)
val widgetOceanLightBg = Color(0xFFCCE4F0)
val widgetOceanLightOn = Color(0xFF0F2733)
val widgetOceanLightAccent = Color(0xFF20546F)
val widgetOceanLightPanel = Color(0xFFF9FAFB)
val widgetOceanLightOnpanel = Color(0xFF192124)
val widgetOceanLightBadge = Color(0xFFA8D1E6)
val widgetOceanLightOnbadge = Color(0xFF0F2733)
val widgetOceanDarkBg = Color(0xFF194257)
val widgetOceanDarkOn = Color(0xFFDBECF5)
val widgetOceanDarkAccent = Color(0xFFB0D5E8)
val widgetOceanDarkPanel = Color(0xFF0E1315)
val widgetOceanDarkOnpanel = Color(0xFFE7ECEF)
val widgetOceanDarkBadge = Color(0xFF1F516B)
val widgetOceanDarkOnbadge = Color(0xFFDFEEF6)
val widgetForestLightBg = Color(0xFFD2E9DA)
val widgetForestLightOn = Color(0xFF162D1D)
val widgetForestLightAccent = Color(0xFF2E603F)
val widgetForestLightPanel = Color(0xFFF9FBFA)
val widgetForestLightOnpanel = Color(0xFF1B221D)
val widgetForestLightBadge = Color(0xFFB3DBC0)
val widgetForestLightOnbadge = Color(0xFF162D1D)
val widgetForestDarkBg = Color(0xFF244C32)
val widgetForestDarkOn = Color(0xFFE0F0E5)
val widgetForestDarkAccent = Color(0xFFBADEC6)
val widgetForestDarkPanel = Color(0xFF101411)
val widgetForestDarkOnpanel = Color(0xFFE8EDEA)
val widgetForestDarkBadge = Color(0xFF2D5D3D)
val widgetForestDarkOnbadge = Color(0xFFE3F2E8)
val widgetSunLightBg = Color(0xFFF7E4C5)
val widgetSunLightOn = Color(0xFF3A2808)
val widgetSunLightAccent = Color(0xFF7D5612)
val widgetSunLightPanel = Color(0xFFFBFAF9)
val widgetSunLightOnpanel = Color(0xFF272117)
val widgetSunLightBadge = Color(0xFFF1D29D)
val widgetSunLightOnbadge = Color(0xFF3A2808)
val widgetSunDarkBg = Color(0xFF62430E)
val widgetSunDarkOn = Color(0xFFF9EDD7)
val widgetSunDarkAccent = Color(0xFFF2D6A6)
val widgetSunDarkPanel = Color(0xFF17130D)
val widgetSunDarkOnpanel = Color(0xFFF0ECE5)
val widgetSunDarkBadge = Color(0xFF785311)
val widgetSunDarkOnbadge = Color(0xFFFAEFDB)
val widgetLavenderLightBg = Color(0xFFDBCFED)
val widgetLavenderLightOn = Color(0xFF1F1230)
val widgetLavenderLightAccent = Color(0xFF422768)
val widgetLavenderLightPanel = Color(0xFFFAF9FB)
val widgetLavenderLightOnpanel = Color(0xFF1E1A23)
val widgetLavenderLightBadge = Color(0xFFC3AEE0)
val widgetLavenderLightOnbadge = Color(0xFF1F1230)
val widgetLavenderDarkBg = Color(0xFF341F51)
val widgetLavenderDarkOn = Color(0xFFE6DEF2)
val widgetLavenderDarkAccent = Color(0xFFC8B5E3)
val widgetLavenderDarkPanel = Color(0xFF110F15)
val widgetLavenderDarkOnpanel = Color(0xFFEAE7EE)
val widgetLavenderDarkBadge = Color(0xFF402664)
val widgetLavenderDarkOnbadge = Color(0xFFE9E1F4)
val widgetGraphiteLightBg = Color(0xFFDBDDE1)
val widgetGraphiteLightOn = Color(0xFF1E2124)
val widgetGraphiteLightAccent = Color(0xFF42464D)
val widgetGraphiteLightPanel = Color(0xFFFAFAFA)
val widgetGraphiteLightOnpanel = Color(0xFF1E1E1F)
val widgetGraphiteLightBadge = Color(0xFFC2C6CB)
val widgetGraphiteLightOnbadge = Color(0xFF1E2124)
val widgetGraphiteDarkBg = Color(0xFF34373D)
val widgetGraphiteDarkOn = Color(0xFFE6E8EA)
val widgetGraphiteDarkAccent = Color(0xFFC8CBD0)
val widgetGraphiteDarkPanel = Color(0xFF111212)
val widgetGraphiteDarkOnpanel = Color(0xFFEAEBEB)
val widgetGraphiteDarkBadge = Color(0xFF3F444A)
val widgetGraphiteDarkOnbadge = Color(0xFFE9EAEC)
val darkAccentContainer = Color(0xFF244A80)
val darkOnAccentContainer = Color(0xFFD6E3FF)
}
object WType {
Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

+7
View File
@@ -0,0 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 108 108" width="432" height="432">
<defs><linearGradient id="g" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#4E9BE6"/><stop offset="1" stop-color="#BFE3F7"/></linearGradient>
<clipPath id="c"><circle cx="54" cy="54" r="54"/></clipPath></defs>
<g clip-path="url(#c)"><rect width="108" height="108" fill="url(#g)"/>
<path d="M0.00,108.00 L0.00,77.13 L2.00,76.77 L4.00,76.47 L6.00,76.25 L8.00,76.09 L10.00,76.01 L12.00,76.01 L14.00,76.09 L16.00,76.24 L18.00,76.46 L20.00,76.76 L22.00,77.11 L24.00,77.53 L26.00,77.99 L28.00,78.49 L30.00,79.02 L32.00,79.57 L34.00,80.13 L36.00,80.68 L38.00,81.23 L40.00,81.74 L42.00,82.23 L44.00,82.67 L46.00,83.06 L48.00,83.39 L50.00,83.65 L52.00,83.84 L54.00,83.96 L56.00,84.00 L58.00,83.96 L60.00,83.85 L62.00,83.66 L64.00,83.40 L66.00,83.07 L68.00,82.68 L70.00,82.25 L72.00,81.76 L74.00,81.25 L76.00,80.71 L78.00,80.15 L80.00,79.59 L82.00,79.04 L84.00,78.51 L86.00,78.01 L88.00,77.55 L90.00,77.13 L92.00,76.77 L94.00,76.47 L96.00,76.25 L98.00,76.09 L100.00,76.01 L102.00,76.01 L104.00,76.09 L106.00,76.24 L108.00,76.46 L108.00,108.00 Z" fill="#8EC2EC"/><path d="M0.00,108.00 L0.00,85.97 L2.00,86.20 L4.00,86.44 L6.00,86.69 L8.00,86.96 L10.00,87.23 L12.00,87.52 L14.00,87.81 L16.00,88.10 L18.00,88.38 L20.00,88.67 L22.00,88.95 L24.00,89.22 L26.00,89.48 L28.00,89.72 L30.00,89.95 L32.00,90.16 L34.00,90.35 L36.00,90.52 L38.00,90.67 L40.00,90.79 L42.00,90.88 L44.00,90.95 L46.00,90.99 L48.00,91.00 L50.00,90.98 L52.00,90.94 L54.00,90.87 L56.00,90.77 L58.00,90.65 L60.00,90.50 L62.00,90.32 L64.00,90.13 L66.00,89.92 L68.00,89.69 L70.00,89.44 L72.00,89.18 L74.00,88.91 L76.00,88.63 L78.00,88.34 L80.00,88.05 L82.00,87.76 L84.00,87.47 L86.00,87.19 L88.00,86.92 L90.00,86.65 L92.00,86.40 L94.00,86.16 L96.00,85.94 L98.00,85.74 L100.00,85.56 L102.00,85.40 L104.00,85.27 L106.00,85.16 L108.00,85.08 L108.00,108.00 Z" fill="#A9D3F2"/>
<path d="M78.41,44.00 L78.32,44.76 L78.08,45.49 L77.70,46.20 L77.25,46.87 L76.77,47.50 L76.32,48.10 L75.94,48.71 L75.65,49.33 L75.47,49.99 L75.37,50.70 L75.33,51.46 L75.29,52.25 L75.21,53.05 L75.04,53.83 L74.76,54.55 L74.33,55.19 L73.78,55.71 L73.12,56.12 L72.38,56.42 L71.61,56.64 L70.83,56.81 L70.10,56.99 L69.41,57.21 L68.80,57.50 L68.23,57.89 L67.70,58.37 L67.18,58.92 L66.64,59.50 L66.07,60.07 L65.44,60.56 L64.75,60.93 L64.02,61.14 L63.26,61.19 L62.49,61.08 L61.73,60.83 L61.00,60.50 L60.30,60.14 L59.62,59.80 L58.96,59.53 L58.29,59.36 L57.61,59.29 L56.90,59.32 L56.14,59.41 L55.36,59.50 L54.55,59.56 L53.76,59.54 L52.99,59.38 L52.30,59.08 L51.68,58.62 L51.17,58.04 L50.74,57.37 L50.39,56.64 L50.09,55.91 L49.79,55.21 L49.45,54.58 L49.06,54.02 L48.57,53.53 L48.01,53.10 L47.38,52.68 L46.71,52.25 L46.06,51.78 L45.46,51.24 L44.98,50.64 L44.64,49.95 L44.46,49.21 L44.44,48.44 L44.55,47.65 L44.75,46.87 L44.99,46.11 L45.20,45.38 L45.35,44.68 L45.41,44.00 L45.35,43.32 L45.20,42.62 L44.99,41.89 L44.75,41.13 L44.55,40.35 L44.44,39.56 L44.46,38.79 L44.64,38.05 L44.98,37.36 L45.46,36.76 L46.06,36.22 L46.71,35.75 L47.38,35.32 L48.01,34.90 L48.57,34.47 L49.06,33.98 L49.45,33.42 L49.79,32.79 L50.09,32.09 L50.39,31.36 L50.74,30.63 L51.17,29.96 L51.68,29.38 L52.30,28.92 L52.99,28.62 L53.76,28.46 L54.55,28.44 L55.36,28.50 L56.14,28.59 L56.90,28.68 L57.61,28.71 L58.29,28.64 L58.96,28.47 L59.62,28.20 L60.30,27.86 L61.00,27.50 L61.73,27.17 L62.49,26.92 L63.26,26.81 L64.02,26.86 L64.75,27.07 L65.44,27.44 L66.07,27.93 L66.64,28.50 L67.18,29.08 L67.70,29.63 L68.23,30.11 L68.80,30.50 L69.41,30.79 L70.10,31.01 L70.83,31.19 L71.61,31.36 L72.38,31.58 L73.12,31.88 L73.78,32.29 L74.33,32.81 L74.76,33.45 L75.04,34.17 L75.21,34.95 L75.29,35.75 L75.33,36.54 L75.37,37.30 L75.47,38.01 L75.65,38.67 L75.94,39.29 L76.32,39.90 L76.77,40.50 L77.25,41.13 L77.70,41.80 L78.08,42.51 L78.32,43.24 Z" fill="#FFB02E"/><circle cx="61" cy="44" r="10" fill="#FF9A1F" opacity=".35"/>
<path d="M38,74 h30 a9,9 0 0 0 0,-18 a12,12 0 0 0 -22.5,-3.5 a10,10 0 0 0 -7.5,21.5 z" fill="#D5DEE8" transform="translate(0,2.5)"/><path d="M38,74 h30 a9,9 0 0 0 0,-18 a12,12 0 0 0 -22.5,-3.5 a10,10 0 0 0 -7.5,21.5 z" fill="#FFFFFF"/></g></svg>

After

Width:  |  Height:  |  Size: 4.0 KiB

+237 -1
View File
@@ -106,7 +106,79 @@
"aqi-bar-5": "#e53935",
"aqi-bar-6": "#8e24aa",
"uv-dot-low": "#5ccf8a",
"uv-dot-off": "#6b5a52"
"uv-dot-off": "#6b5a52",
"widget-ocean-light-bg": "#cce4f0",
"widget-ocean-light-on": "#0f2733",
"widget-ocean-light-accent": "#20546f",
"widget-ocean-light-panel": "#f9fafb",
"widget-ocean-light-onpanel": "#192124",
"widget-ocean-light-badge": "#a8d1e6",
"widget-ocean-light-onbadge": "#0f2733",
"widget-ocean-dark-bg": "#194257",
"widget-ocean-dark-on": "#dbecf5",
"widget-ocean-dark-accent": "#b0d5e8",
"widget-ocean-dark-panel": "#0e1315",
"widget-ocean-dark-onpanel": "#e7ecef",
"widget-ocean-dark-badge": "#1f516b",
"widget-ocean-dark-onbadge": "#dfeef6",
"widget-forest-light-bg": "#d2e9da",
"widget-forest-light-on": "#162d1d",
"widget-forest-light-accent": "#2e603f",
"widget-forest-light-panel": "#f9fbfa",
"widget-forest-light-onpanel": "#1b221d",
"widget-forest-light-badge": "#b3dbc0",
"widget-forest-light-onbadge": "#162d1d",
"widget-forest-dark-bg": "#244c32",
"widget-forest-dark-on": "#e0f0e5",
"widget-forest-dark-accent": "#badec6",
"widget-forest-dark-panel": "#101411",
"widget-forest-dark-onpanel": "#e8edea",
"widget-forest-dark-badge": "#2d5d3d",
"widget-forest-dark-onbadge": "#e3f2e8",
"widget-sun-light-bg": "#f7e4c5",
"widget-sun-light-on": "#3a2808",
"widget-sun-light-accent": "#7d5612",
"widget-sun-light-panel": "#fbfaf9",
"widget-sun-light-onpanel": "#272117",
"widget-sun-light-badge": "#f1d29d",
"widget-sun-light-onbadge": "#3a2808",
"widget-sun-dark-bg": "#62430e",
"widget-sun-dark-on": "#f9edd7",
"widget-sun-dark-accent": "#f2d6a6",
"widget-sun-dark-panel": "#17130d",
"widget-sun-dark-onpanel": "#f0ece5",
"widget-sun-dark-badge": "#785311",
"widget-sun-dark-onbadge": "#faefdb",
"widget-lavender-light-bg": "#dbcfed",
"widget-lavender-light-on": "#1f1230",
"widget-lavender-light-accent": "#422768",
"widget-lavender-light-panel": "#faf9fb",
"widget-lavender-light-onpanel": "#1e1a23",
"widget-lavender-light-badge": "#c3aee0",
"widget-lavender-light-onbadge": "#1f1230",
"widget-lavender-dark-bg": "#341f51",
"widget-lavender-dark-on": "#e6def2",
"widget-lavender-dark-accent": "#c8b5e3",
"widget-lavender-dark-panel": "#110f15",
"widget-lavender-dark-onpanel": "#eae7ee",
"widget-lavender-dark-badge": "#402664",
"widget-lavender-dark-onbadge": "#e9e1f4",
"widget-graphite-light-bg": "#dbdde1",
"widget-graphite-light-on": "#1e2124",
"widget-graphite-light-accent": "#42464d",
"widget-graphite-light-panel": "#fafafa",
"widget-graphite-light-onpanel": "#1e1e1f",
"widget-graphite-light-badge": "#c2c6cb",
"widget-graphite-light-onbadge": "#1e2124",
"widget-graphite-dark-bg": "#34373d",
"widget-graphite-dark-on": "#e6e8ea",
"widget-graphite-dark-accent": "#c8cbd0",
"widget-graphite-dark-panel": "#111212",
"widget-graphite-dark-onpanel": "#eaebeb",
"widget-graphite-dark-badge": "#3f444a",
"widget-graphite-dark-onbadge": "#e9eaec",
"dark-accent-container": "#244a80",
"dark-on-accent-container": "#d6e3ff"
},
"pairs": [
[
@@ -396,6 +468,170 @@
"nowcast-dot",
"card",
"ui"
],
[
"widget-ocean-light-on",
"widget-ocean-light-bg"
],
[
"widget-ocean-light-accent",
"widget-ocean-light-bg"
],
[
"widget-ocean-light-onpanel",
"widget-ocean-light-panel"
],
[
"widget-ocean-light-onbadge",
"widget-ocean-light-badge"
],
[
"widget-ocean-dark-on",
"widget-ocean-dark-bg"
],
[
"widget-ocean-dark-accent",
"widget-ocean-dark-bg"
],
[
"widget-ocean-dark-onpanel",
"widget-ocean-dark-panel"
],
[
"widget-ocean-dark-onbadge",
"widget-ocean-dark-badge"
],
[
"widget-forest-light-on",
"widget-forest-light-bg"
],
[
"widget-forest-light-accent",
"widget-forest-light-bg"
],
[
"widget-forest-light-onpanel",
"widget-forest-light-panel"
],
[
"widget-forest-light-onbadge",
"widget-forest-light-badge"
],
[
"widget-forest-dark-on",
"widget-forest-dark-bg"
],
[
"widget-forest-dark-accent",
"widget-forest-dark-bg"
],
[
"widget-forest-dark-onpanel",
"widget-forest-dark-panel"
],
[
"widget-forest-dark-onbadge",
"widget-forest-dark-badge"
],
[
"widget-sun-light-on",
"widget-sun-light-bg"
],
[
"widget-sun-light-accent",
"widget-sun-light-bg"
],
[
"widget-sun-light-onpanel",
"widget-sun-light-panel"
],
[
"widget-sun-light-onbadge",
"widget-sun-light-badge"
],
[
"widget-sun-dark-on",
"widget-sun-dark-bg"
],
[
"widget-sun-dark-accent",
"widget-sun-dark-bg"
],
[
"widget-sun-dark-onpanel",
"widget-sun-dark-panel"
],
[
"widget-sun-dark-onbadge",
"widget-sun-dark-badge"
],
[
"widget-lavender-light-on",
"widget-lavender-light-bg"
],
[
"widget-lavender-light-accent",
"widget-lavender-light-bg"
],
[
"widget-lavender-light-onpanel",
"widget-lavender-light-panel"
],
[
"widget-lavender-light-onbadge",
"widget-lavender-light-badge"
],
[
"widget-lavender-dark-on",
"widget-lavender-dark-bg"
],
[
"widget-lavender-dark-accent",
"widget-lavender-dark-bg"
],
[
"widget-lavender-dark-onpanel",
"widget-lavender-dark-panel"
],
[
"widget-lavender-dark-onbadge",
"widget-lavender-dark-badge"
],
[
"widget-graphite-light-on",
"widget-graphite-light-bg"
],
[
"widget-graphite-light-accent",
"widget-graphite-light-bg"
],
[
"widget-graphite-light-onpanel",
"widget-graphite-light-panel"
],
[
"widget-graphite-light-onbadge",
"widget-graphite-light-badge"
],
[
"widget-graphite-dark-on",
"widget-graphite-dark-bg"
],
[
"widget-graphite-dark-accent",
"widget-graphite-dark-bg"
],
[
"widget-graphite-dark-onpanel",
"widget-graphite-dark-panel"
],
[
"widget-graphite-dark-onbadge",
"widget-graphite-dark-badge"
],
[
"dark-on-accent-container",
"dark-accent-container"
]
],
"font": {
+44 -44
View File
@@ -1,44 +1,44 @@
feature,area,priority,original,clone,notes
Current conditions hero (temp feels-like high/low condition),home,must,yes,yes,
Condition-based animated background,home,must,yes,yes,original artwork not reusable; draw own
Hourly forecast strip (24h+),home,must,yes,yes,fixed position
10-day forecast list,home,must,yes,yes,
Daily detail view (tap a day),home,should,yes,yes,guess: exists in original
Precipitation card with chance and amount,cards,must,yes,yes,
Wind card (speed direction gusts),cards,must,yes,yes,
UV index card,cards,must,yes,yes,
Humidity / dew point card,cards,must,yes,yes,
Pressure card,cards,should,yes,yes,
Visibility card,cards,should,yes,yes,
Sunrise / sunset card,cards,must,yes,yes,
Air quality (AQI) card,cards,should,yes,yes,Open-Meteo air-quality API (CAMS)
Pollen card,cards,could,yes,yes,Open-Meteo pollen (Europe only)
Drag to reorder cards,customize,should,yes,no,
Card order saved per city,customize,could,yes,no,
Location search by name or postal code,locations,must,yes,yes,Open-Meteo geocoding
Current location via GPS,locations,must,yes,yes,no Google Play Services; use platform LocationManager
Saved locations list,locations,must,yes,yes,
Swipe to delete a location,locations,must,yes,yes,
Swipe/pager between saved cities,locations,should,yes,yes,
Temperature unit (default C F),settings,must,yes,yes,
Units for precipitation wind pressure visibility,settings,should,yes,yes,
Theme setting (system light dark),settings,should,yes,yes,
Precipitation map with 6h nowcast and timeline scrubber,map,should,yes,no,RainViewer or DWD radar tiles + OSM base map
Pan and zoom map,map,should,yes,no,
Severe weather alerts banner on top,alerts,must,yes,no,DWD / MeteoAlarm feeds
Severe weather notification,notifications,should,yes,no,background worker
Evening tomorrow-forecast notification,notifications,could,yes,no,
Precipitation-starting notification per city,notifications,could,yes,no,needs minute nowcast
Homescreen widget,widgets,must,yes,partial,"2 of 5 widget types (Now 2x1/2x2, Forecast 4x2/4x3); no config activity yet"
AI weather brief summary,ai,could,yes,partial,"template-based text or local LLM; no Gemini; rule-based brief, no LLM"
Weather vibrations on animations,polish,could,yes,no,
Tablet two-column layout,layout,could,yes,partial,content capped at 720dp and centred; no true two-pane
Sync saved locations across devices via Google account,sync,could,yes,skip,no Google account by design
Personal insights from Calendar and Gmail,ai,could,yes,skip,needs Google data access; against project goal
Google nowcasting / MetNet models,data,could,yes,skip,proprietary model; use public forecast data
At a Glance integration,widgets,could,yes,skip,Pixel launcher system feature
Widget sizes small medium large with hourly/daily,widgets,must,yes,partial,Glance; resizable; small/medium/wide/tall done; 4x4 full and 4x1 glance missing
Widget dynamic Material You colours and condition background,widgets,should,yes,partial,condition background only; dynamic colour style missing
Widget tap opens city / refresh on schedule,widgets,must,yes,yes,
Nowcast card (precip starting with 15-min dot chart),cards,should,yes,yes,Open-Meteo minutely_15
Location preview with Save,locations,should,yes,yes,S15
feature,area,priority,original,clone,notes
Current conditions hero (temp feels-like high/low condition),home,must,yes,yes,
Condition-based animated background,home,must,yes,yes,original artwork not reusable; draw own
Hourly forecast strip (24h+),home,must,yes,yes,fixed position
10-day forecast list,home,must,yes,yes,
Daily detail view (tap a day),home,should,yes,yes,guess: exists in original
Precipitation card with chance and amount,cards,must,yes,yes,
Wind card (speed direction gusts),cards,must,yes,yes,
UV index card,cards,must,yes,yes,
Humidity / dew point card,cards,must,yes,yes,
Pressure card,cards,should,yes,yes,
Visibility card,cards,should,yes,yes,
Sunrise / sunset card,cards,must,yes,yes,
Air quality (AQI) card,cards,should,yes,yes,Open-Meteo air-quality API (CAMS)
Pollen card,cards,could,yes,yes,Open-Meteo pollen (Europe only)
Drag to reorder cards,customize,should,yes,no,
Card order saved per city,customize,could,yes,no,
Location search by name or postal code,locations,must,yes,yes,Open-Meteo geocoding
Current location via GPS,locations,must,yes,yes,no Google Play Services; use platform LocationManager
Saved locations list,locations,must,yes,yes,
Swipe to delete a location,locations,must,yes,yes,
Swipe/pager between saved cities,locations,should,yes,yes,
Temperature unit (default C F),settings,must,yes,yes,
Units for precipitation wind pressure visibility,settings,should,yes,yes,
Theme setting (system light dark),settings,should,yes,yes,
Precipitation map with 6h nowcast and timeline scrubber,map,should,yes,no,RainViewer or DWD radar tiles + OSM base map
Pan and zoom map,map,should,yes,no,
Severe weather alerts banner on top,alerts,must,yes,no,DWD / MeteoAlarm feeds
Severe weather notification,notifications,should,yes,no,background worker
Evening tomorrow-forecast notification,notifications,could,yes,no,
Precipitation-starting notification per city,notifications,could,yes,no,needs minute nowcast
Homescreen widget,widgets,must,yes,yes,5 widget types with config screen
AI weather brief summary,ai,could,yes,partial,"template-based text or local LLM; no Gemini; rule-based brief, no LLM"
Weather vibrations on animations,polish,could,yes,no,
Tablet two-column layout,layout,could,yes,partial,content capped at 720dp and centred; no true two-pane
Sync saved locations across devices via Google account,sync,could,yes,skip,no Google account by design
Personal insights from Calendar and Gmail,ai,could,yes,skip,needs Google data access; against project goal
Google nowcasting / MetNet models,data,could,yes,skip,proprietary model; use public forecast data
At a Glance integration,widgets,could,yes,skip,Pixel launcher system feature
Widget sizes small medium large with hourly/daily,widgets,must,yes,yes,Glance
Widget dynamic Material You colours and condition background,widgets,should,yes,yes,condition background only
Widget tap opens city / refresh on schedule,widgets,must,yes,yes,
Nowcast card (precip starting with 15-min dot chart),cards,should,yes,yes,Open-Meteo minutely_15
Location preview with Save,locations,should,yes,yes,S15
1 feature area priority original clone notes
2 Current conditions hero (temp feels-like high/low condition) home must yes yes
3 Condition-based animated background home must yes yes original artwork not reusable; draw own
4 Hourly forecast strip (24h+) home must yes yes fixed position
5 10-day forecast list home must yes yes
6 Daily detail view (tap a day) home should yes yes guess: exists in original
7 Precipitation card with chance and amount cards must yes yes
8 Wind card (speed direction gusts) cards must yes yes
9 UV index card cards must yes yes
10 Humidity / dew point card cards must yes yes
11 Pressure card cards should yes yes
12 Visibility card cards should yes yes
13 Sunrise / sunset card cards must yes yes
14 Air quality (AQI) card cards should yes yes Open-Meteo air-quality API (CAMS)
15 Pollen card cards could yes yes Open-Meteo pollen (Europe only)
16 Drag to reorder cards customize should yes no
17 Card order saved per city customize could yes no
18 Location search by name or postal code locations must yes yes Open-Meteo geocoding
19 Current location via GPS locations must yes yes no Google Play Services; use platform LocationManager
20 Saved locations list locations must yes yes
21 Swipe to delete a location locations must yes yes
22 Swipe/pager between saved cities locations should yes yes
23 Temperature unit (default C F) settings must yes yes
24 Units for precipitation wind pressure visibility settings should yes yes
25 Theme setting (system light dark) settings should yes yes
26 Precipitation map with 6h nowcast and timeline scrubber map should yes no RainViewer or DWD radar tiles + OSM base map
27 Pan and zoom map map should yes no
28 Severe weather alerts banner on top alerts must yes no DWD / MeteoAlarm feeds
29 Severe weather notification notifications should yes no background worker
30 Evening tomorrow-forecast notification notifications could yes no
31 Precipitation-starting notification per city notifications could yes no needs minute nowcast
32 Homescreen widget widgets must yes partial yes 2 of 5 widget types (Now 2x1/2x2, Forecast 4x2/4x3); no config activity yet 5 widget types with config screen
33 AI weather brief summary ai could yes partial template-based text or local LLM; no Gemini; rule-based brief, no LLM
34 Weather vibrations on animations polish could yes no
35 Tablet two-column layout layout could yes partial content capped at 720dp and centred; no true two-pane
36 Sync saved locations across devices via Google account sync could yes skip no Google account by design
37 Personal insights from Calendar and Gmail ai could yes skip needs Google data access; against project goal
38 Google nowcasting / MetNet models data could yes skip proprietary model; use public forecast data
39 At a Glance integration widgets could yes skip Pixel launcher system feature
40 Widget sizes small medium large with hourly/daily widgets must yes partial yes Glance; resizable; small/medium/wide/tall done; 4x4 full and 4x1 glance missing Glance
41 Widget dynamic Material You colours and condition background widgets should yes partial yes condition background only; dynamic colour style missing condition background only
42 Widget tap opens city / refresh on schedule widgets must yes yes
43 Nowcast card (precip starting with 15-min dot chart) cards should yes yes Open-Meteo minutely_15
44 Location preview with Save locations should yes yes S15
+27
View File
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
# Build, sign and publish one app as a Gitea release that Obtainium can find.
# Usage: scripts/release.sh wetter (version comes from app/build.gradle.kts)
# Needs: .giteatoken in the repo root (git-ignored) and ~/.android/nogoogleapps-release.properties
set -euo pipefail
cd "$(dirname "$0")/.."
app="${1:?app folder, e.g. wetter}"
title="$(tr '[:lower:]' '[:upper:]' <<< "${app:0:1}")${app:1}"
version="$(sed -nE 's/.*versionName = "([^"]+)".*/\1/p' "$app/app/build.gradle.kts")"
tag="$app-v$version"
api="https://git.mrblake.cc/api/v1/repos/MrBlake/NoGooleApps"
token="$(tr -d ' \n' < .giteatoken)"
[ -f ~/.android/nogoogleapps-release.properties ] || { echo "release key missing" >&2; exit 1; }
(cd "$app" && ./gradlew -q :app:assembleRelease)
apk="$app/app/build/outputs/apk/release/app-release.apk"
"${ANDROID_HOME:-$HOME/Android/Sdk}"/build-tools/36.0.0/apksigner verify "$apk"
git -c credential.helper= push -q "https://MrBlake:$token@git.mrblake.cc/MrBlake/NoGooleApps.git" HEAD:main
body="$(printf '{"tag_name":"%s","target_commitish":"%s","name":"%s %s","prerelease":true}' "$tag" "$(git rev-parse HEAD)" "$title" "$version")"
id="$(curl -sf -X POST -H "Authorization: token $token" -H "Content-Type: application/json" -d "$body" "$api/releases" \
| python3 -I -c 'import sys,json; print(json.load(sys.stdin)["id"])')"
curl -sf -X POST -H "Authorization: token $token" \
-F "attachment=@$apk;type=application/vnd.android.package-archive" \
"$api/releases/$id/assets?name=$app-$version.apk" > /dev/null
echo "published $title $version ($tag)"
+28 -4
View File
@@ -1,3 +1,5 @@
import java.util.Properties
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
@@ -15,13 +17,35 @@ android {
applicationId = "app.wetter"
minSdk = 29
targetSdk = 36
versionCode = 1
versionName = "0.1.0"
versionCode = 2
versionName = "0.2.0"
}
// Release key lives outside the repo; without it, release builds fall back to the debug key (local only).
val keyProps = Properties().apply {
val f = file(System.getProperty("user.home") + "/.android/nogoogleapps-release.properties")
if (f.exists()) f.inputStream().use { load(it) }
}
signingConfigs {
if (keyProps.isNotEmpty()) create("release") {
storeFile = file(keyProps.getProperty("storeFile"))
storePassword = keyProps.getProperty("storePassword")
keyAlias = keyProps.getProperty("keyAlias")
keyPassword = keyProps.getProperty("keyPassword")
}
}
buildTypes {
debug {
// installs next to the release app from Obtainium
applicationIdSuffix = ".debug"
resValue("string", "app_name", "Wetter (Debug)")
}
release {
resValue("string", "app_name", "Wetter")
isMinifyEnabled = true
isShrinkResources = true
signingConfig = signingConfigs.findByName("release") ?: signingConfigs.getByName("debug")
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}
@@ -58,8 +82,8 @@ dependencies {
ksp("androidx.room:room-compiler:2.7.0")
implementation("androidx.datastore:datastore-preferences:1.1.7")
implementation("androidx.work:work-runtime-ktx:2.11.0")
implementation("androidx.glance:glance-appwidget:1.1.1")
implementation("androidx.glance:glance-material3:1.1.1")
implementation("androidx.glance:glance-appwidget:1.2.0")
implementation("androidx.glance:glance-material3:1.2.0")
implementation("com.squareup.okhttp3:okhttp:4.12.0")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.9.0")
@@ -0,0 +1,214 @@
{
"formatVersion": 1,
"database": {
"version": 2,
"identityHash": "9c1a9b09f0d46a98d95c13ff8fe1ff17",
"entities": [
{
"tableName": "locations",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL, `admin` TEXT, `country_code` TEXT NOT NULL, `lat` REAL NOT NULL, `lon` REAL NOT NULL, `timezone` TEXT NOT NULL, `is_current` INTEGER NOT NULL, `sort_order` INTEGER NOT NULL, `created_at` INTEGER NOT NULL, `updated_at` INTEGER NOT NULL)",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "admin",
"columnName": "admin",
"affinity": "TEXT"
},
{
"fieldPath": "countryCode",
"columnName": "country_code",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "lat",
"columnName": "lat",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "lon",
"columnName": "lon",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "timezone",
"columnName": "timezone",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "isCurrent",
"columnName": "is_current",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "sortOrder",
"columnName": "sort_order",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "createdAt",
"columnName": "created_at",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "updatedAt",
"columnName": "updated_at",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": true,
"columnNames": [
"id"
]
},
"indices": [
{
"name": "index_locations_sort_order",
"unique": false,
"columnNames": [
"sort_order"
],
"orders": [],
"createSql": "CREATE INDEX IF NOT EXISTS `index_locations_sort_order` ON `${TABLE_NAME}` (`sort_order`)"
}
]
},
{
"tableName": "forecast_cache",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`location_id` INTEGER NOT NULL, `fetched_at` INTEGER NOT NULL, `forecast_json` TEXT NOT NULL, `air_json` TEXT, PRIMARY KEY(`location_id`), FOREIGN KEY(`location_id`) REFERENCES `locations`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
"fields": [
{
"fieldPath": "locationId",
"columnName": "location_id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "fetchedAt",
"columnName": "fetched_at",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "forecastJson",
"columnName": "forecast_json",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "airJson",
"columnName": "air_json",
"affinity": "TEXT"
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"location_id"
]
},
"foreignKeys": [
{
"table": "locations",
"onDelete": "CASCADE",
"onUpdate": "NO ACTION",
"columns": [
"location_id"
],
"referencedColumns": [
"id"
]
}
]
},
{
"tableName": "widget_config",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`app_widget_id` INTEGER NOT NULL, `location_id` INTEGER, `style` TEXT NOT NULL, `theme` TEXT NOT NULL, `opacity` INTEGER NOT NULL, PRIMARY KEY(`app_widget_id`), FOREIGN KEY(`location_id`) REFERENCES `locations`(`id`) ON UPDATE NO ACTION ON DELETE SET NULL )",
"fields": [
{
"fieldPath": "appWidgetId",
"columnName": "app_widget_id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "locationId",
"columnName": "location_id",
"affinity": "INTEGER"
},
{
"fieldPath": "style",
"columnName": "style",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "theme",
"columnName": "theme",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "opacity",
"columnName": "opacity",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"app_widget_id"
]
},
"indices": [
{
"name": "index_widget_config_location_id",
"unique": false,
"columnNames": [
"location_id"
],
"orders": [],
"createSql": "CREATE INDEX IF NOT EXISTS `index_widget_config_location_id` ON `${TABLE_NAME}` (`location_id`)"
}
],
"foreignKeys": [
{
"table": "locations",
"onDelete": "SET NULL",
"onUpdate": "NO ACTION",
"columns": [
"location_id"
],
"referencedColumns": [
"id"
]
}
]
}
],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '9c1a9b09f0d46a98d95c13ff8fe1ff17')"
]
}
}
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application>
<activity android:name=".WidgetGalleryActivity" android:exported="true" android:theme="@android:style/Theme.Material.NoActionBar" />
</application>
</manifest>
@@ -0,0 +1,108 @@
package app.wetter
import android.app.Activity
import android.graphics.Color
import android.os.Bundle
import android.util.TypedValue
import android.view.ViewGroup
import android.widget.FrameLayout
import android.widget.LinearLayout
import android.widget.ScrollView
import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp
import androidx.glance.appwidget.GlanceAppWidget
import androidx.glance.appwidget.compose
import androidx.lifecycle.lifecycleScope
import app.wetter.data.Graph
import app.wetter.widget.BarWidget
import app.wetter.widget.ClassicWidget
import app.wetter.widget.PillWidget
import app.wetter.widget.TiltWidget
import app.wetter.widget.WeatherCardWidget
import kotlinx.coroutines.launch
/**
* Debug only: renders every widget at its sizes with real data, so they can be checked
* with `adb shell am start -n app.wetter/.WidgetGalleryActivity` and a screenshot.
*/
class WidgetGalleryActivity : androidx.activity.ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Graph.init(this)
val page = intent.getIntExtra("page", 0)
val column = LinearLayout(this).apply { orientation = LinearLayout.VERTICAL; setPadding(px(16), px(48), px(16), px(48)) }
setContentView(ScrollView(this).apply { setBackgroundColor(Color.rgb(96, 120, 128)); addView(column) })
val pages: List<List<Pair<GlanceAppWidget, DpSize>>> = listOf(
listOf(
WeatherCardWidget() to DpSize(360.dp, 260.dp),
PillWidget() to DpSize(360.dp, 150.dp),
WeatherCardWidget() to DpSize(260.dp, 150.dp),
),
listOf(
WeatherCardWidget() to DpSize(360.dp, 520.dp),
BarWidget() to DpSize(360.dp, 90.dp),
),
listOf(
TiltWidget() to DpSize(180.dp, 180.dp),
ClassicWidget() to DpSize(360.dp, 170.dp),
ClassicWidget() to DpSize(170.dp, 170.dp),
PillWidget() to DpSize(170.dp, 64.dp),
),
)
if (intent.getBooleanExtra("export", false)) { exportPreviews(column); return }
lifecycleScope.launch {
for ((widget, size) in pages[page.coerceIn(0, pages.lastIndex)]) {
val views = widget.compose(this@WidgetGalleryActivity, size = size)
val frame = FrameLayout(this@WidgetGalleryActivity)
frame.addView(views.apply(this@WidgetGalleryActivity, frame))
column.addView(frame, LinearLayout.LayoutParams(px(size.width.value), px(size.height.value)).apply { bottomMargin = px(20) })
}
}
}
/** Renders each widget at its default size and writes preview_<key>.png to external files. */
private fun exportPreviews(column: LinearLayout) {
val items = listOf(
"card" to (WeatherCardWidget() to DpSize(300.dp, 230.dp)),
"pill" to (PillWidget() to DpSize(280.dp, 120.dp)),
"tilt" to (TiltWidget() to DpSize(160.dp, 160.dp)),
"bar" to (BarWidget() to DpSize(300.dp, 80.dp)),
"classic" to (ClassicWidget() to DpSize(300.dp, 170.dp)),
"clock" to (app.wetter.widget.ClockWidget() to DpSize(300.dp, 140.dp)),
)
lifecycleScope.launch {
val frames = mutableListOf<Pair<String, FrameLayout>>()
for ((key, pair) in items) {
val (widget, size) = pair
val frame = FrameLayout(this@WidgetGalleryActivity)
if (key == "clock") {
// the clock is transparent: show it over a soft wallpaper-like backdrop
app.wetter.widget.WidgetPreviewOverride.config =
app.wetter.data.WidgetConfigEntity(-1, null, "wallpaper", "dark", 0)
frame.background = android.graphics.drawable.GradientDrawable(
android.graphics.drawable.GradientDrawable.Orientation.TL_BR,
intArrayOf(Color.rgb(74, 98, 120), Color.rgb(150, 128, 112)),
).apply { cornerRadius = px(28).toFloat() }
}
val views = widget.compose(this@WidgetGalleryActivity, size = size)
app.wetter.widget.WidgetPreviewOverride.config = null
frame.addView(views.apply(this@WidgetGalleryActivity, frame))
column.addView(frame, LinearLayout.LayoutParams(px(size.width.value), px(size.height.value)).apply { bottomMargin = px(12) })
frames += key to frame
}
column.postDelayed({
val dir = getExternalFilesDir(null)!!
for ((key, frame) in frames) {
val bmp = android.graphics.Bitmap.createBitmap(frame.width, frame.height, android.graphics.Bitmap.Config.ARGB_8888)
frame.draw(android.graphics.Canvas(bmp))
java.io.File(dir, "preview_$key.png").outputStream().use { bmp.compress(android.graphics.Bitmap.CompressFormat.PNG, 100, it) }
}
android.util.Log.i("WidgetGallery", "exported ${frames.size}")
}, 1500)
}
}
private fun px(dp: Float) = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, resources.displayMetrics).toInt()
private fun px(dp: Int) = px(dp.toFloat())
}
+26 -5
View File
@@ -9,7 +9,8 @@
<application
android:name=".WetterApp"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@android:style/Theme.Material.NoActionBar">
@@ -24,13 +25,33 @@
</intent-filter>
</activity>
<receiver android:name=".widget.NowWidgetReceiver" android:exported="true" android:label="@string/widget_now_name">
<activity android:name=".widget.WidgetConfigActivity" android:exported="true" android:excludeFromRecents="true" android:taskAffinity="">
<intent-filter><action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" /></intent-filter>
</activity>
<receiver android:name=".widget.ClockReceiver" android:exported="true" android:label="@string/widget_clock_name">
<intent-filter><action android:name="android.appwidget.action.APPWIDGET_UPDATE" /></intent-filter>
<meta-data android:name="android.appwidget.provider" android:resource="@xml/widget_now" />
<meta-data android:name="android.appwidget.provider" android:resource="@xml/widget_clock" />
</receiver>
<receiver android:name=".widget.ForecastWidgetReceiver" android:exported="true" android:label="@string/widget_forecast_name">
<receiver android:name=".widget.WeatherCardReceiver" android:exported="true" android:label="@string/widget_card_name">
<intent-filter><action android:name="android.appwidget.action.APPWIDGET_UPDATE" /></intent-filter>
<meta-data android:name="android.appwidget.provider" android:resource="@xml/widget_forecast" />
<meta-data android:name="android.appwidget.provider" android:resource="@xml/widget_card" />
</receiver>
<receiver android:name=".widget.PillReceiver" android:exported="true" android:label="@string/widget_pill_name">
<intent-filter><action android:name="android.appwidget.action.APPWIDGET_UPDATE" /></intent-filter>
<meta-data android:name="android.appwidget.provider" android:resource="@xml/widget_pill" />
</receiver>
<receiver android:name=".widget.TiltReceiver" android:exported="true" android:label="@string/widget_tilt_name">
<intent-filter><action android:name="android.appwidget.action.APPWIDGET_UPDATE" /></intent-filter>
<meta-data android:name="android.appwidget.provider" android:resource="@xml/widget_tilt" />
</receiver>
<receiver android:name=".widget.BarReceiver" android:exported="true" android:label="@string/widget_bar_name">
<intent-filter><action android:name="android.appwidget.action.APPWIDGET_UPDATE" /></intent-filter>
<meta-data android:name="android.appwidget.provider" android:resource="@xml/widget_bar" />
</receiver>
<receiver android:name=".widget.ClassicReceiver" android:exported="true" android:label="@string/widget_classic_name">
<intent-filter><action android:name="android.appwidget.action.APPWIDGET_UPDATE" /></intent-filter>
<meta-data android:name="android.appwidget.provider" android:resource="@xml/widget_classic" />
</receiver>
</application>
</manifest>
+14 -3
View File
@@ -51,7 +51,10 @@ data class WidgetConfigEntity(
@PrimaryKey @androidx.room.ColumnInfo(name = "app_widget_id") val appWidgetId: Int,
/** null = follow the current location */
@androidx.room.ColumnInfo(name = "location_id") val locationId: Long?,
val style: String = "auto",
/** palette key, see WidgetStyle */
val style: String = "wallpaper",
val theme: String = "system",
val opacity: Int = 100,
)
@Dao
@@ -107,7 +110,7 @@ interface WeatherDao {
@Database(
entities = [LocationEntity::class, ForecastCacheEntity::class, WidgetConfigEntity::class],
version = 1,
version = 2,
exportSchema = true,
)
abstract class WeatherDb : RoomDatabase() {
@@ -115,6 +118,14 @@ abstract class WeatherDb : RoomDatabase() {
companion object {
fun create(context: Context) =
Room.databaseBuilder(context, WeatherDb::class.java, "weather.db").build()
Room.databaseBuilder(context, WeatherDb::class.java, "weather.db").addMigrations(MIGRATION_1_2).build()
private val MIGRATION_1_2 = object : androidx.room.migration.Migration(1, 2) {
override fun migrate(db: androidx.sqlite.db.SupportSQLiteDatabase) {
db.execSQL("ALTER TABLE widget_config ADD COLUMN theme TEXT NOT NULL DEFAULT 'system'")
db.execSQL("ALTER TABLE widget_config ADD COLUMN opacity INTEGER NOT NULL DEFAULT 100")
db.execSQL("UPDATE widget_config SET style = 'wallpaper' WHERE style = 'auto'")
}
}
}
}
@@ -25,7 +25,9 @@ class DeviceLocation(private val context: Context) {
@SuppressLint("MissingPermission")
suspend fun get(): Location? {
if (!hasPermission()) return null
val providers = listOf(LocationManager.NETWORK_PROVIDER, LocationManager.GPS_PROVIDER, LocationManager.PASSIVE_PROVIDER)
// FUSED_PROVIDER is the AOSP one (API 31+), it works without Play Services
val fused = if (android.os.Build.VERSION.SDK_INT >= 31) listOf(LocationManager.FUSED_PROVIDER) else emptyList()
val providers = (fused + listOf(LocationManager.NETWORK_PROVIDER, LocationManager.GPS_PROVIDER, LocationManager.PASSIVE_PROVIDER))
.filter { runCatching { manager.isProviderEnabled(it) }.getOrDefault(false) }
val lastKnown = providers.mapNotNull { runCatching { manager.getLastKnownLocation(it) }.getOrNull() }
.maxByOrNull { it.time }
@@ -44,7 +46,7 @@ class DeviceLocation(private val context: Context) {
}
private companion object {
const val FRESH_MS = 15 * 60 * 1000L
const val TIMEOUT_MS = 12_000L
const val FRESH_MS = 60 * 60 * 1000L
const val TIMEOUT_MS = 8_000L
}
}
@@ -17,6 +17,7 @@ import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.OkHttpClient
import okhttp3.Request
import java.io.IOException
import kotlinx.coroutines.delay
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.ZoneId
@@ -154,12 +155,24 @@ class OpenMeteo(private val http: OkHttpClient = defaultClient()) {
return Air(c.int("european_aqi"), c.num("pm2_5"), c.num("pm10"), pollen)
}
/** Open-Meteo answers 429/5xx ("service is overloaded") now and then; retry those twice with backoff. */
private suspend fun get(url: String): String = withContext(Dispatchers.IO) {
val request = Request.Builder().url(url).header("User-Agent", USER_AGENT).build()
http.newCall(request).execute().use { response ->
if (!response.isSuccessful) throw IOException("HTTP ${response.code}")
response.body?.string() ?: throw IOException("empty body")
var attempt = 0
while (true) {
val result = runCatching {
http.newCall(request).execute().use { response ->
if (!response.isSuccessful) throw HttpException(response.code)
response.body?.string() ?: throw IOException("empty body")
}
}
val error = result.exceptionOrNull() ?: return@withContext result.getOrThrow()
val retryable = error is IOException && (error !is HttpException || error.code == 429 || error.code >= 500)
if (!retryable || attempt >= 2) throw error
delay(600L * (attempt + 1) * (attempt + 1))
attempt++
}
@Suppress("UNREACHABLE_CODE") error("unreachable")
}
companion object {
@@ -189,3 +202,5 @@ private fun JsonObject.int(key: String) = num(key)?.toInt()
private fun JsonObject.arr(key: String): JsonArray = this[key]?.jsonArray ?: JsonArray(emptyList())
private fun JsonObject.numAt(key: String, i: Int) = arr(key).getOrNull(i)?.takeUnless { it is JsonNull }?.jsonPrimitive?.doubleOrNull
private fun JsonObject.intAt(key: String, i: Int) = numAt(key, i)?.toInt() ?: arr(key).getOrNull(i)?.takeUnless { it is JsonNull }?.jsonPrimitive?.intOrNull
class HttpException(val code: Int) : IOException("HTTP $code")
@@ -1,6 +1,10 @@
package app.wetter.data
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.async
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.flow.Flow
import java.util.concurrent.ConcurrentHashMap
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
@@ -18,6 +22,15 @@ class WeatherRepository(
private val device: DeviceLocation,
) {
private val currentLock = Mutex()
private val inFlight = ConcurrentHashMap<Long, CompletableDeferred<RefreshResult>>()
private val previews = ConcurrentHashMap<Place, Pair<String, String?>>()
/** Forecast and air quality at the same time; air is optional. */
private suspend fun fetch(lat: Double, lon: Double): Pair<String, String?> = coroutineScope {
val air = async { runCatching { api.airJson(lat, lon) }.getOrNull() }
val forecast = async { api.forecastJson(lat, lon) }
forecast.await() to air.await()
}
val locations: Flow<List<LocationEntity>> = dao.locations()
@@ -36,17 +49,23 @@ class WeatherRepository(
suspend fun refresh(location: LocationEntity, force: Boolean = false): RefreshResult {
val cached = dao.forecastOnce(location.id)
if (!force && cached != null && System.currentTimeMillis() - cached.fetchedAt < STALE_MS) return RefreshResult.Skipped
return runCatching {
val forecast = api.forecastJson(location.lat, location.lon)
val air = runCatching { api.airJson(location.lat, location.lon) }.getOrNull()
// a second caller for the same location waits for the running request instead of starting one
val mine = CompletableDeferred<RefreshResult>()
inFlight.putIfAbsent(location.id, mine)?.let { return it.await() }
val result = runCatching {
val (forecast, air) = fetch(location.lat, location.lon)
dao.putForecast(ForecastCacheEntity(location.id, System.currentTimeMillis(), forecast, air))
RefreshResult.Ok
}.getOrElse { RefreshResult.Failed(it) }
inFlight.remove(location.id)
mine.complete(result)
return result
}
suspend fun refreshAll(force: Boolean = false) {
updateCurrentLocation()
dao.locationsOnce().forEach { refresh(it, force) }
suspend fun refreshAll(force: Boolean = false) = coroutineScope {
val saved = dao.locationsOnce().filter { !it.isCurrent }.map { async { refresh(it, force) } }
updateCurrentLocation()?.let { refresh(it, force) }
saved.forEach { it.await() }
}
/** Device position -> the single is_current row. Returns null without permission or fix. */
@@ -77,9 +96,9 @@ class WeatherRepository(
/** Full forecast for a place that is not saved yet (S15). */
suspend fun preview(place: Place): Forecast {
val forecast = api.forecastJson(place.lat, place.lon)
val air = runCatching { api.airJson(place.lat, place.lon) }.getOrNull()
return api.parse(forecast, air, System.currentTimeMillis())
val raw = fetch(place.lat, place.lon)
previews[place] = raw
return api.parse(raw.first, raw.second, System.currentTimeMillis())
}
suspend fun save(place: Place): Long {
@@ -93,7 +112,10 @@ class WeatherRepository(
lat = place.lat, lon = place.lon, timezone = place.timezone, sortOrder = dao.nextSortOrder(),
)
)
dao.location(id)?.let { refresh(it, force = true) }
// the preview already loaded this forecast: store it instead of fetching again
val raw = previews.remove(place)
if (raw != null) dao.putForecast(ForecastCacheEntity(id, System.currentTimeMillis(), raw.first, raw.second))
else dao.location(id)?.let { refresh(it, force = true) }
return id
}
@@ -105,8 +127,9 @@ class WeatherRepository(
return config?.locationId?.let { dao.location(it) } ?: dao.currentLocation() ?: dao.locationsOnce().firstOrNull()
}
suspend fun setWidgetLocation(appWidgetId: Int, locationId: Long?) =
dao.putWidget(WidgetConfigEntity(appWidgetId, locationId))
suspend fun widgetConfig(appWidgetId: Int): WidgetConfigEntity? = dao.widget(appWidgetId)
suspend fun saveWidgetConfig(config: WidgetConfigEntity) = dao.putWidget(config)
suspend fun deleteWidget(appWidgetId: Int) = dao.deleteWidget(appWidgetId)
@@ -139,7 +139,8 @@ fun WindTile(cur: Current, units: Units, modifier: Modifier) {
val title = stringResource(R.string.card_wind)
Tile(title, Icons.Outlined.Air, CircleShape, "$title $value ${units.windUnit}, ${stringResource(R.string.wind_from, from)}", modifier, centered = true) {
// the blob points where the wind blows to
Box(Modifier.fillMaxSize(.78f).align(Alignment.Center).clip(WShapes.triangle(cur.windDir + 180f + 90f)).background(c.fillSecondary))
val blob = androidx.compose.runtime.remember(cur.windDir) { WShapes.triangle(cur.windDir + 180f + 90f) }
Box(Modifier.fillMaxSize(.78f).align(Alignment.Center).clip(blob).background(c.fillSecondary))
Column(Modifier.align(Alignment.Center), horizontalAlignment = Alignment.CenterHorizontally) {
Spacer(Modifier.height(WSpace.s12))
ValueText(value, units.windUnit, c.onFillSecondary)
@@ -0,0 +1,161 @@
package app.wetter.ui.components
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.selection.selectable
import androidx.compose.foundation.selection.selectableGroup
import androidx.compose.foundation.selection.toggleable
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.Check
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.RadioButton
import androidx.compose.material3.Switch
import androidx.compose.material3.SwitchDefaults
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.heading
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.unit.dp
import app.wetter.ui.theme.WSpace
import app.wetter.ui.theme.WType
/*
* Settings in the style of current Pixel system settings: grouped tiles with large outer
* corners and small inner ones, 2dp gaps, tonal icon circles, values as summaries,
* choices in dialogs.
*/
private val Outer = 24.dp
private val Inner = 4.dp
private fun tileShape(index: Int, count: Int): Shape = when {
count == 1 -> RoundedCornerShape(Outer)
index == 0 -> RoundedCornerShape(topStart = Outer, topEnd = Outer, bottomStart = Inner, bottomEnd = Inner)
index == count - 1 -> RoundedCornerShape(topStart = Inner, topEnd = Inner, bottomStart = Outer, bottomEnd = Outer)
else -> RoundedCornerShape(Inner)
}
class GroupScope internal constructor() {
internal val items = mutableListOf<@Composable (Shape) -> Unit>()
fun item(content: @Composable (Shape) -> Unit) { items += content }
}
@Composable
fun SettingsGroup(title: String? = null, modifier: Modifier = Modifier, content: GroupScope.() -> Unit) {
val scope = GroupScope().apply(content)
Column(modifier.padding(horizontal = WSpace.s16)) {
if (title != null) {
Text(
title, style = WType.label.copy(fontSize = WType.bodySm.fontSize), color = MaterialTheme.colorScheme.primary,
modifier = Modifier.padding(start = WSpace.s16, top = WSpace.s24, bottom = WSpace.s8).semantics { heading() },
)
} else Spacer(Modifier.padding(top = WSpace.s16))
Column(verticalArrangement = Arrangement.spacedBy(2.dp)) {
scope.items.forEachIndexed { i, item -> item(tileShape(i, scope.items.size)) }
}
}
}
@Composable
private fun Tile(shape: Shape, modifier: Modifier = Modifier, content: @Composable () -> Unit) {
Box(
modifier.fillMaxWidth().clip(shape).background(MaterialTheme.colorScheme.surfaceContainerLowest).heightIn(min = 72.dp),
contentAlignment = Alignment.CenterStart,
) { content() }
}
@Composable
private fun RowContent(icon: ImageVector?, title: String, summary: String?, trailing: (@Composable () -> Unit)?) {
Row(Modifier.fillMaxWidth().padding(horizontal = WSpace.s16, vertical = WSpace.s16), verticalAlignment = Alignment.CenterVertically) {
if (icon != null) {
Box(Modifier.size(40.dp).clip(CircleShape).background(MaterialTheme.colorScheme.primaryContainer), contentAlignment = Alignment.Center) {
Icon(icon, null, tint = MaterialTheme.colorScheme.onPrimaryContainer, modifier = Modifier.size(22.dp))
}
Spacer(Modifier.width(WSpace.s16))
}
Column(Modifier.weight(1f)) {
Text(title, style = WType.body, color = MaterialTheme.colorScheme.onSurface)
if (summary != null) Text(summary, style = WType.bodySm, color = MaterialTheme.colorScheme.onSurfaceVariant)
}
if (trailing != null) { Spacer(Modifier.width(WSpace.s12)); trailing() }
}
}
@Composable
fun SettingsItem(shape: Shape, title: String, summary: String? = null, icon: ImageVector? = null, onClick: (() -> Unit)? = null, trailing: (@Composable () -> Unit)? = null) {
Tile(shape, if (onClick != null) Modifier.clip(shape).clickable(onClick = onClick) else Modifier) { RowContent(icon, title, summary, trailing) }
}
@Composable
fun SettingsSwitch(shape: Shape, title: String, checked: Boolean, onChange: (Boolean) -> Unit, summary: String? = null, icon: ImageVector? = null) {
Tile(shape, Modifier.clip(shape).toggleable(checked, role = Role.Switch, onValueChange = onChange)) {
RowContent(icon, title, summary) {
Switch(
checked, onCheckedChange = null,
thumbContent = if (checked) { { Icon(Icons.Rounded.Check, null, Modifier.size(SwitchDefaults.IconSize)) } } else null,
)
}
}
}
/** A tile whose value is picked from a list in a dialog, like Pixel's radio settings. */
@Composable
fun <T> SettingsChoice(shape: Shape, title: String, options: List<T>, selected: T, label: (T) -> String, onPick: (T) -> Unit, icon: ImageVector? = null) {
var open by remember { mutableStateOf(false) }
SettingsItem(shape, title, label(selected), icon, onClick = { open = true })
if (open) {
AlertDialog(
onDismissRequest = { open = false },
title = { Text(title) },
text = {
Column(Modifier.selectableGroup()) {
options.forEach { o ->
Row(
Modifier.fillMaxWidth().clip(RoundedCornerShape(12.dp))
.selectable(o == selected, role = Role.RadioButton) { onPick(o); open = false }
.padding(vertical = WSpace.s12, horizontal = WSpace.s4),
verticalAlignment = Alignment.CenterVertically,
) {
RadioButton(o == selected, onClick = null)
Spacer(Modifier.width(WSpace.s16))
Text(label(o), style = WType.body)
}
}
}
},
confirmButton = { TextButton(onClick = { open = false }) { Text(androidx.compose.ui.res.stringResource(android.R.string.cancel)) } },
)
}
}
/** Free content inside a group tile (swatches, sliders). */
@Composable
fun SettingsCustom(shape: Shape, content: @Composable ColumnScope.() -> Unit) {
Tile(shape) { Column(Modifier.fillMaxWidth().padding(WSpace.s16), content = content) }
}
@@ -1,11 +1,10 @@
package app.wetter.ui.scene
import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.core.infiniteRepeatable
import androidx.compose.animation.core.rememberInfiniteTransition
import androidx.compose.animation.core.tween
import androidx.compose.animation.core.animateFloat
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.mutableFloatStateOf
import androidx.compose.runtime.withFrameNanos
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
@@ -51,19 +50,22 @@ data class SceneSpec(val condition: Condition, val isDay: Boolean, val intensity
* [animate] false draws one still frame (battery saver, reduced motion, setting off).
*/
@Composable
fun WeatherScene(spec: SceneSpec, modifier: Modifier = Modifier, animate: Boolean = true, scroll: Float = 0f) {
fun WeatherScene(spec: SceneSpec, modifier: Modifier = Modifier, animate: Boolean = true, scroll: () -> Float = { 0f }) {
val top by animateColorAsState(spec.top, tween(600), label = "top")
val bottom by animateColorAsState(spec.bottom, tween(600), label = "bottom")
val t = if (animate) {
val transition = rememberInfiniteTransition(label = "scene")
val v by transition.animateFloat(0f, 1f, infiniteRepeatable(tween(60_000, easing = LinearEasing)), label = "t")
v
} else 0.2f
// Read only inside the draw lambda: a new frame redraws the canvas, it never recomposes.
val time = remember { mutableFloatStateOf(0.2f) }
if (animate) {
LaunchedEffect(Unit) {
val start = withFrameNanos { it }
while (true) withFrameNanos { time.floatValue = ((it - start) / 60e9f + 0.2f) % 1f }
}
}
val particles = remember(spec.condition) { Particles.make(spec.condition) }
Canvas(modifier.fillMaxSize()) {
drawRect(Brush.verticalGradient(listOf(top, bottom)))
drawSceneLayers(spec, t, scroll, particles)
drawSceneLayers(spec, time.floatValue, scroll(), particles)
}
}
@@ -137,14 +139,17 @@ fun DrawScope.drawSceneLayers(spec: SceneSpec, t: Float, scroll: Float, particle
}
}
private val hillPath = Path()
private fun DrawScope.drawHill(color: Color, baseY: Float, amp: Float, wavelength: Float, phase: Float) {
val w = size.width
val path = Path().apply {
val path = hillPath.apply {
rewind()
moveTo(0f, size.height)
var x = 0f
while (x <= w + 8f) {
lineTo(x, baseY - amp * sin(x / wavelength * 2 * PI.toFloat() + phase * .2f))
x += 8f
x += 16f
}
lineTo(w, size.height)
close()
@@ -0,0 +1,112 @@
package app.wetter.ui.screens
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.rounded.ArrowBack
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.produceState
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import app.wetter.R
import app.wetter.data.Fmt
import app.wetter.data.Graph
import app.wetter.data.Settings
import app.wetter.data.Units
import app.wetter.data.conditionOf
import app.wetter.ui.components.DailyCapsules
import app.wetter.ui.components.HourlyStrip
import app.wetter.ui.components.conditionLabel
import app.wetter.ui.scene.WeatherIcon
import app.wetter.ui.theme.WSpace
import app.wetter.ui.theme.WType
import java.time.LocalDate
/** S04: one day, picked from the capsule row. */
@Composable
fun DayScreen(locationId: Long, initialDate: LocalDate, settings: Settings, onBack: () -> Unit) {
val forecast by remember(locationId) { Graph.repo.forecast(locationId) }.collectAsState(initial = null)
val location by produceState<app.wetter.data.LocationEntity?>(null, locationId) { value = Graph.repo.location(locationId) }
val f = forecast ?: return
DayContent(f, location?.name?.ifBlank { null }, initialDate, settings, onBack)
}
@Composable
fun DayContent(f: app.wetter.data.Forecast, placeName: String?, initialDate: LocalDate, settings: Settings, onBack: () -> Unit) {
var date by rememberSaveable { mutableStateOf(initialDate.toEpochDay()) }
val units = remember(settings) { Units(settings) }
val day = f.daily.firstOrNull { it.date.toEpochDay() == date } ?: f.daily.first()
val cond = conditionOf(day.code)
val onBg = MaterialTheme.colorScheme.onBackground
Box(Modifier.fillMaxSize().background(MaterialTheme.colorScheme.background)) {
LazyColumn(
Modifier.fillMaxSize(),
contentPadding = PaddingValues(bottom = WSpace.s32),
verticalArrangement = Arrangement.spacedBy(WSpace.s16),
) {
item {
Row(Modifier.statusBarsPadding().height(64.dp), verticalAlignment = Alignment.CenterVertically) {
IconButton(onClick = onBack) { Icon(Icons.AutoMirrored.Rounded.ArrowBack, stringResource(R.string.back), tint = onBg) }
Text(stringResource(R.string.daily), style = WType.headline, color = onBg)
}
}
item { DailyCapsules(f.daily, units, selected = day.date, asSection = false) { date = it.date.toEpochDay() } }
item {
Column(Modifier.padding(horizontal = WSpace.s24)) {
Text(Fmt.longDate(day.date), style = WType.bodySm, color = onBg)
Text(placeName ?: stringResource(R.string.current_location), style = WType.headline, color = onBg)
Row(verticalAlignment = Alignment.CenterVertically) {
Text("${units.temp(day.tMax)}/${units.temp(day.tMin)}", style = WType.dayRange, color = onBg)
Spacer(Modifier.width(WSpace.s8))
WeatherIcon(cond, true, 56.dp)
}
Text(stringResource(conditionLabel(cond, true)), style = WType.body, color = onBg)
}
}
item {
val hours = if (day.date == f.now.toLocalDate()) f.upcomingHours(24).filter { it.time.toLocalDate() == day.date } else f.hoursOf(day.date)
HourlyStrip(hours, units, Modifier.padding(horizontal = WSpace.s16).widthIn(max = 720.dp), markNow = day.date == f.now.toLocalDate())
}
item {
// the day's own values for the tiles that make sense per day
val dayHours = f.hoursOf(day.date)
val noon = dayHours.getOrNull(12)
val cur = if (day.date == f.now.toLocalDate() || noon == null) f.current else f.current.copy(
temp = noon.temp, code = noon.code, isDay = true, humidity = noon.humidity, windSpeed = noon.windSpeed, uv = day.uvMax,
)
app.wetter.ui.components.DetailGrid(
cur, day, if (day.date == f.now.toLocalDate()) f.air else null, units,
if (day.date == f.now.toLocalDate()) f.now else day.date.atTime(12, 0),
Modifier.padding(horizontal = WSpace.s16).navigationBarsPadding().widthIn(max = 720.dp).fillMaxWidth(),
)
}
}
}
}
@@ -0,0 +1,320 @@
package app.wetter.ui.screens
import android.Manifest
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.pager.HorizontalPager
import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.background
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.FormatListBulleted
import androidx.compose.material.icons.rounded.LocationOn
import androidx.compose.material.icons.rounded.Settings
import androidx.compose.material3.Button
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.FilledTonalButton
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.pulltorefresh.PullToRefreshBox
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.derivedStateOf
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.Alignment
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.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import app.wetter.R
import app.wetter.data.Forecast
import app.wetter.data.Graph
import app.wetter.data.LocationEntity
import app.wetter.data.RefreshResult
import app.wetter.data.Settings
import app.wetter.data.Units
import app.wetter.data.WeatherRepository
import app.wetter.data.conditionOf
import app.wetter.data.intensityOf
import app.wetter.ui.components.BriefCard
import app.wetter.ui.components.DailyCapsules
import app.wetter.ui.components.DetailGrid
import app.wetter.ui.components.HeroBlock
import app.wetter.ui.components.HourlyStrip
import app.wetter.ui.components.NowcastCard
import app.wetter.ui.components.StatusChip
import app.wetter.ui.components.buildBrief
import app.wetter.ui.components.minutesAgo
import app.wetter.ui.scene.SceneSpec
import app.wetter.ui.scene.WeatherScene
import app.wetter.ui.theme.LocalWeatherColors
import app.wetter.ui.theme.WColor
import app.wetter.ui.theme.WSpace
import app.wetter.ui.theme.WType
import kotlinx.coroutines.launch
import java.time.LocalDate
/** S01: one page per saved location, swipe between them. */
@Composable
fun HomeScreen(
settings: Settings,
initialLocationId: Long?,
animate: Boolean,
onOpenLocations: () -> Unit,
onOpenSettings: () -> Unit,
onOpenDay: (Long, LocalDate) -> Unit,
) {
val repo = Graph.repo
val locations by repo.locations.collectAsState(initial = null)
val context = LocalContext.current
var permissionAsked by remember { mutableStateOf(Graph.device.hasPermission()) }
val scope = rememberCoroutineScope()
val launcher = rememberLauncherForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) {
permissionAsked = true
scope.launch { repo.updateCurrentLocation()?.let { repo.refresh(it, force = true) } }
}
LaunchedEffect(Unit) { repo.refreshAll() }
val list = locations
when {
list == null -> Box(Modifier.fillMaxSize().background(WColor.sceneClearDayBottom))
list.isEmpty() -> PermissionPrompt(
onAllow = { launcher.launch(arrayOf(Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.POST_NOTIFICATIONS)) },
onSearch = onOpenLocations,
asked = permissionAsked && !Graph.device.hasPermission(),
)
else -> {
val start = list.indexOfFirst { it.id == initialLocationId }.coerceAtLeast(0)
val pager = rememberPagerState(initialPage = start) { list.size }
LaunchedEffect(initialLocationId, list.size) {
val i = list.indexOfFirst { it.id == initialLocationId }
if (i >= 0 && i != pager.currentPage) pager.scrollToPage(i)
}
HorizontalPager(pager, Modifier.fillMaxSize(), key = { list[it].id }) { page ->
LocationPage(
location = list[page],
settings = settings,
animate = animate && page == pager.currentPage,
pageCount = list.size,
page = page,
onOpenLocations = onOpenLocations,
onOpenSettings = onOpenSettings,
onOpenDay = { onOpenDay(list[page].id, it) },
)
}
}
}
}
@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun LocationPage(
location: LocationEntity,
settings: Settings,
animate: Boolean,
pageCount: Int,
page: Int,
onOpenLocations: () -> Unit,
onOpenSettings: () -> Unit,
onOpenDay: (LocalDate) -> Unit,
) {
val repo = Graph.repo
val forecast by remember(location.id) { repo.forecast(location.id) }.collectAsState(initial = null)
var refreshing by remember { mutableStateOf(false) }
var error by remember { mutableStateOf<Throwable?>(null) }
val scope = rememberCoroutineScope()
val refresh: (Boolean) -> Unit = { force ->
scope.launch {
refreshing = force
error = (repo.refresh(location, force) as? RefreshResult.Failed)?.error
refreshing = false
}
}
LaunchedEffect(location.id) { refresh(false) }
val f = forecast
val name = location.name.ifBlank { stringResource(R.string.current_location) }
ForecastPage(
title = name,
isCurrent = location.isCurrent,
forecast = f,
settings = settings,
animate = animate,
refreshing = refreshing,
error = error,
onRefresh = { refresh(true) },
navigation = {
IconButton(onClick = onOpenLocations) { Icon(Icons.Rounded.FormatListBulleted, stringResource(R.string.open_locations)) }
},
actions = {
IconButton(onClick = onOpenSettings) { Icon(Icons.Rounded.Settings, stringResource(R.string.settings)) }
},
pageIndicator = { if (pageCount > 1) PageDots(pageCount, page, it) },
onOpenDay = onOpenDay,
)
}
/** Shared by S01 and the unsaved preview S15. */
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun ForecastPage(
title: String,
isCurrent: Boolean,
forecast: Forecast?,
settings: Settings,
animate: Boolean,
refreshing: Boolean,
error: Throwable?,
onRefresh: () -> Unit,
navigation: @Composable () -> Unit,
actions: @Composable () -> Unit,
pageIndicator: @Composable (Color) -> Unit = {},
onOpenDay: ((LocalDate) -> Unit)? = null,
) {
val units = remember(settings) { Units(settings) }
val res = LocalContext.current.resources
val spec = forecast?.let { SceneSpec(conditionOf(it.current.code), it.current.isDay, intensityOf(it.current.code)) }
?: SceneSpec(app.wetter.data.Condition.CLOUDY, true)
val listState = rememberLazyListState()
val fg = spec.onScene
val failed = error != null
Box(Modifier.fillMaxSize()) {
WeatherScene(spec, animate = animate && settings.animations, scroll = {
if (listState.firstVisibleItemIndex == 0) listState.firstVisibleItemScrollOffset.toFloat() else 2000f
})
PullToRefreshBox(isRefreshing = refreshing, onRefresh = onRefresh, modifier = Modifier.fillMaxSize()) {
LazyColumn(
state = listState,
modifier = Modifier.fillMaxSize(),
contentPadding = PaddingValues(start = WSpace.s16, end = WSpace.s16, bottom = WSpace.s32),
verticalArrangement = Arrangement.spacedBy(WSpace.s12),
horizontalAlignment = Alignment.CenterHorizontally,
) {
item(key = "bar") {
Row(Modifier.fillMaxWidth().statusBarsPadding().height(64.dp), verticalAlignment = Alignment.CenterVertically) {
androidx.compose.runtime.CompositionLocalProvider(androidx.compose.material3.LocalContentColor provides fg) {
navigation()
Row(Modifier.weight(1f), horizontalArrangement = Arrangement.Center, verticalAlignment = Alignment.CenterVertically) {
if (isCurrent) Icon(Icons.Rounded.LocationOn, null, Modifier.size(18.dp), tint = fg)
Text(title, style = WType.headline, color = fg, maxLines = 1, overflow = TextOverflow.Ellipsis, textAlign = TextAlign.Center)
}
actions()
}
}
}
if (forecast == null) {
item(key = "loading") {
Column(Modifier.padding(top = 120.dp), horizontalAlignment = Alignment.CenterHorizontally) {
if (failed) {
Text(stringResource(errorText(error)), color = fg, style = WType.body, textAlign = TextAlign.Center)
TextButton(onClick = onRefresh) { Text(stringResource(R.string.retry), color = fg) }
} else CircularProgressIndicator(color = fg)
}
}
return@LazyColumn
}
item(key = "hero") {
Column(horizontalAlignment = Alignment.CenterHorizontally) {
HeroBlock(title, forecast, units, fg, Modifier.widthIn(max = 560.dp))
pageIndicator(fg)
val age = minutesAgo(forecast.fetchedAt)
if (failed || age >= 60) {
StatusChip(
when {
failed -> stringResource(R.string.offline)
age >= 120 -> stringResource(R.string.updated_hours, age / 60)
else -> stringResource(R.string.updated_ago, age)
},
fg,
)
}
Spacer(Modifier.height(WSpace.s16))
}
}
val max = Modifier.widthIn(max = 720.dp)
if (settings.brief) item(key = "brief") { BriefCard(remember(forecast, settings) { buildBrief(res, forecast, units) }, max) }
item(key = "nowcast") { NowcastCard(forecast.minutely, forecast, max) }
item(key = "hourly") { HourlyStrip(forecast.upcomingHours(25), units, max) }
item(key = "daily") { DailyCapsules(forecast.daily, units, max) { d -> onOpenDay?.invoke(d.date) } }
item(key = "details") {
DetailGrid(forecast.current, forecast.today, forecast.air, units, forecast.now, max.navigationBarsPadding())
}
item(key = "attribution") {
Text(stringResource(R.string.attribution), style = WType.labelSm, color = fg.copy(alpha = .8f), textAlign = TextAlign.Center, modifier = Modifier.padding(top = WSpace.s16))
}
}
}
}
}
@Composable
private fun PageDots(count: Int, current: Int, color: Color) {
Row(Modifier.padding(top = WSpace.s4), horizontalArrangement = Arrangement.spacedBy(6.dp)) {
repeat(count) { i ->
Box(
Modifier.height(8.dp).width(if (i == current) 20.dp else 8.dp).clip(RoundedCornerShape(4.dp))
.background(color.copy(alpha = if (i == current) .9f else .35f))
)
}
}
}
@Composable
private fun PermissionPrompt(onAllow: () -> Unit, onSearch: () -> Unit, asked: Boolean) {
val spec = SceneSpec(app.wetter.data.Condition.PARTLY_CLOUDY, true)
Box(Modifier.fillMaxSize()) {
WeatherScene(spec)
Column(
Modifier.align(Alignment.Center).padding(WSpace.s32).clip(RoundedCornerShape(28.dp)).background(LocalWeatherColors.current.card).padding(WSpace.s24),
horizontalAlignment = Alignment.CenterHorizontally,
) {
app.wetter.ui.scene.WeatherIcon(app.wetter.data.Condition.PARTLY_CLOUDY, true, 72.dp)
Spacer(Modifier.height(WSpace.s16))
Text(stringResource(R.string.perm_title), style = WType.headline, color = LocalWeatherColors.current.onCard, textAlign = TextAlign.Center)
Spacer(Modifier.height(WSpace.s8))
Text(stringResource(R.string.perm_body), style = WType.bodySm, color = LocalWeatherColors.current.onCardMuted, textAlign = TextAlign.Center)
Spacer(Modifier.height(WSpace.s24))
if (!asked) Button(onClick = onAllow) { Text(stringResource(R.string.perm_allow)) }
FilledTonalButton(onClick = onSearch) { Text(stringResource(R.string.perm_search)) }
}
}
}
@androidx.annotation.StringRes
private fun errorText(error: Throwable?): Int = when {
error is app.wetter.data.HttpException && (error.code == 429 || error.code >= 500) -> R.string.loading_error_busy
error is java.net.UnknownHostException || error is java.net.ConnectException || error is java.net.SocketTimeoutException -> R.string.loading_error_offline
else -> R.string.loading_error
}
@@ -0,0 +1,237 @@
package app.wetter.ui.screens
import androidx.compose.animation.animateColorAsState
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.rounded.ArrowBack
import androidx.compose.material.icons.rounded.Close
import androidx.compose.material.icons.rounded.Delete
import androidx.compose.material.icons.rounded.LocationOn
import androidx.compose.material.icons.rounded.Search
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.LinearProgressIndicator
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SnackbarDuration
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.SnackbarResult
import androidx.compose.material3.SwipeToDismissBox
import androidx.compose.material3.SwipeToDismissBoxValue
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.rememberSwipeToDismissBoxState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
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.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.CustomAccessibilityAction
import androidx.compose.ui.semantics.customActions
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import app.wetter.R
import app.wetter.data.Graph
import app.wetter.data.LocationEntity
import app.wetter.data.Place
import app.wetter.data.Settings
import app.wetter.data.Units
import app.wetter.data.conditionOf
import app.wetter.ui.components.conditionLabel
import app.wetter.ui.scene.SceneSpec
import app.wetter.ui.scene.WeatherIcon
import app.wetter.ui.theme.WRadius
import app.wetter.ui.theme.WSpace
import app.wetter.ui.theme.WType
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
private sealed interface SearchState {
data object Idle : SearchState
data object Loading : SearchState
data class Results(val places: List<Place>) : SearchState
data object Error : SearchState
}
/** S02 saved locations + S03 search in one screen: typing swaps the list for results. */
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun LocationsScreen(settings: Settings, onBack: () -> Unit, onOpen: (Long) -> Unit, onPreview: (Place) -> Unit) {
val repo = Graph.repo
val locations by repo.locations.collectAsState(initial = emptyList())
var query by rememberSaveable { mutableStateOf("") }
var state by remember { mutableStateOf<SearchState>(SearchState.Idle) }
var attempt by remember { mutableStateOf(0) }
val snackbar = remember { SnackbarHostState() }
val scope = rememberCoroutineScope()
val units = remember(settings) { Units(settings) }
val deletedText = stringResource(R.string.deleted, "%s")
val undoText = stringResource(R.string.undo)
LaunchedEffect(query, attempt) {
if (query.trim().length < 2) { state = SearchState.Idle; return@LaunchedEffect }
delay(300)
state = SearchState.Loading
state = runCatching { SearchState.Results(repo.search(query)) }.getOrElse { SearchState.Error }
}
Scaffold(
topBar = {
TopAppBar(
title = { Text(stringResource(R.string.locations)) },
navigationIcon = { IconButton(onClick = onBack) { Icon(Icons.AutoMirrored.Rounded.ArrowBack, stringResource(R.string.back)) } },
)
},
snackbarHost = { SnackbarHost(snackbar) },
) { pad ->
Column(Modifier.padding(pad).fillMaxSize()) {
OutlinedTextField(
value = query,
onValueChange = { query = it },
modifier = Modifier.fillMaxWidth().padding(horizontal = WSpace.s16),
placeholder = { Text(stringResource(R.string.search_hint)) },
leadingIcon = { Icon(Icons.Rounded.Search, null) },
trailingIcon = {
if (query.isNotEmpty()) IconButton(onClick = { query = "" }) { Icon(Icons.Rounded.Close, null) }
},
singleLine = true,
shape = RoundedCornerShape(WRadius.pill),
)
if (state == SearchState.Loading) LinearProgressIndicator(Modifier.fillMaxWidth().padding(horizontal = WSpace.s32, vertical = WSpace.s4))
else Spacer(Modifier.height(WSpace.s12))
when (val s = state) {
is SearchState.Results -> if (s.places.isEmpty()) {
Text(stringResource(R.string.search_empty), Modifier.padding(WSpace.s24), style = WType.body)
} else LazyColumn(contentPadding = PaddingValues(bottom = WSpace.s24)) {
items(s.places, key = { "${it.lat},${it.lon}" }) { p ->
Column(
Modifier.fillMaxWidth().clickable { onPreview(p) }.padding(horizontal = WSpace.s24, vertical = WSpace.s12)
) {
Text(p.name, style = WType.body)
Text(listOfNotNull(p.admin, p.countryCode).joinToString(", "), style = WType.bodySm, color = MaterialTheme.colorScheme.onSurfaceVariant)
}
}
}
SearchState.Error -> Column(Modifier.padding(WSpace.s24)) {
Text(stringResource(R.string.search_error), style = WType.body)
TextButton(onClick = { attempt++ }) { Text(stringResource(R.string.retry)) }
}
else -> LazyColumn(
contentPadding = PaddingValues(start = WSpace.s16, end = WSpace.s16, bottom = WSpace.s24),
verticalArrangement = Arrangement.spacedBy(WSpace.s8),
) {
items(locations, key = { it.id }) { loc ->
val name = loc.name.ifBlank { stringResource(R.string.current_location) }
val delete = {
scope.launch {
repo.delete(loc.id)
val r = snackbar.showSnackbar(deletedText.format(name), undoText, duration = SnackbarDuration.Short)
if (r == SnackbarResult.ActionPerformed) repo.save(Place(loc.name, loc.admin, loc.countryCode, loc.lat, loc.lon, loc.timezone))
}
Unit
}
if (loc.isCurrent) CityRow(loc, name, units) { onOpen(loc.id) }
else SwipeRow(onDelete = delete) {
val deleteLabel = stringResource(R.string.delete)
CityRow(loc, name, units, Modifier.semantics {
customActions = listOf(CustomAccessibilityAction(deleteLabel) { delete(); true })
}) { onOpen(loc.id) }
}
}
}
}
}
}
}
@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun SwipeRow(onDelete: () -> Unit, content: @Composable () -> Unit) {
val state = rememberSwipeToDismissBoxState()
LaunchedEffect(state.currentValue) {
if (state.currentValue != SwipeToDismissBoxValue.Settled) {
onDelete()
state.snapTo(SwipeToDismissBoxValue.Settled)
}
}
SwipeToDismissBox(
state = state,
backgroundContent = {
val color by animateColorAsState(
if (state.targetValue == SwipeToDismissBoxValue.Settled) MaterialTheme.colorScheme.surfaceContainer else MaterialTheme.colorScheme.error,
label = "swipe",
)
Box(
Modifier.fillMaxSize().clip(RoundedCornerShape(WRadius.lg)).background(color).padding(horizontal = WSpace.s24),
contentAlignment = Alignment.CenterEnd,
) { Icon(Icons.Rounded.Delete, null, tint = MaterialTheme.colorScheme.onError) }
},
) { content() }
}
@Composable
private fun CityRow(loc: LocationEntity, name: String, units: Units, modifier: Modifier = Modifier, onClick: () -> Unit) {
val forecast by remember(loc.id) { Graph.repo.forecast(loc.id) }.collectAsState(initial = null)
val f = forecast
val spec = f?.let { SceneSpec(conditionOf(it.current.code), it.current.isDay) } ?: SceneSpec(app.wetter.data.Condition.CLOUDY, true)
val fg = spec.onScene
Row(
modifier
.fillMaxWidth()
.clip(RoundedCornerShape(WRadius.lg))
.background(Brush.horizontalGradient(listOf(spec.top, spec.bottom)))
.clickable(onClick = onClick)
.padding(horizontal = WSpace.s20, vertical = WSpace.s16),
verticalAlignment = Alignment.CenterVertically,
) {
Column(Modifier.weight(1f)) {
Row(verticalAlignment = Alignment.CenterVertically) {
if (loc.isCurrent) { Icon(Icons.Rounded.LocationOn, null, Modifier.size(16.dp), tint = fg); Spacer(Modifier.width(4.dp)) }
Text(name, style = WType.title, color = fg, maxLines = 1, overflow = TextOverflow.Ellipsis)
}
if (f != null) {
Text(
stringResource(conditionLabel(conditionOf(f.current.code), f.current.isDay)) +
(f.today?.let { " · ${units.temp(it.tMax)} / ${units.temp(it.tMin)}" } ?: ""),
style = WType.bodySm, color = fg,
)
}
}
if (f != null) {
WeatherIcon(conditionOf(f.current.code), f.current.isDay, 36.dp)
Spacer(Modifier.width(WSpace.s8))
Text(units.temp(f.current.temp), style = WType.metric, color = fg)
}
}
}
@@ -0,0 +1,49 @@
package app.wetter.ui.screens
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.rounded.ArrowBack
import androidx.compose.material3.FilledTonalButton
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
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.res.stringResource
import app.wetter.R
import app.wetter.data.Forecast
import app.wetter.data.Graph
import app.wetter.data.Place
import app.wetter.data.Settings
import kotlinx.coroutines.launch
/** S15: a searched place, shown in full before it is saved. */
@Composable
fun PreviewScreen(place: Place, settings: Settings, onBack: () -> Unit, onSaved: (Long) -> Unit) {
var forecast by remember { mutableStateOf<Forecast?>(null) }
var error by remember { mutableStateOf<Throwable?>(null) }
var attempt by remember { mutableStateOf(0) }
val scope = rememberCoroutineScope()
LaunchedEffect(place, attempt) {
error = null
runCatching { Graph.repo.preview(place) }.onSuccess { forecast = it }.onFailure { error = it }
}
ForecastPage(
title = place.name,
isCurrent = false,
forecast = forecast,
settings = settings,
animate = true,
refreshing = false,
error = error,
onRefresh = { attempt++ },
navigation = { IconButton(onClick = onBack) { Icon(Icons.AutoMirrored.Rounded.ArrowBack, stringResource(R.string.back)) } },
actions = {
FilledTonalButton(onClick = { scope.launch { onSaved(Graph.repo.save(place)) } }) { Text(stringResource(R.string.save)) }
},
)
}
@@ -0,0 +1,98 @@
package app.wetter.ui.screens
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.rounded.ArrowBack
import androidx.compose.material.icons.outlined.Air
import androidx.compose.material.icons.outlined.AutoAwesome
import androidx.compose.material.icons.outlined.Compress
import androidx.compose.material.icons.outlined.DarkMode
import androidx.compose.material.icons.outlined.Info
import androidx.compose.material.icons.outlined.Notes
import androidx.compose.material.icons.outlined.Thermostat
import androidx.compose.material.icons.outlined.Umbrella
import androidx.compose.material.icons.outlined.Visibility
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.LargeTopAppBar
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.material3.rememberTopAppBarState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.res.stringResource
import app.wetter.R
import app.wetter.data.DistanceUnit
import app.wetter.data.Graph
import app.wetter.data.PrecipUnit
import app.wetter.data.PressureUnit
import app.wetter.data.Settings
import app.wetter.data.TempUnit
import app.wetter.data.ThemeMode
import app.wetter.data.WindUnit
import app.wetter.ui.components.SettingsChoice
import app.wetter.ui.components.SettingsGroup
import app.wetter.ui.components.SettingsItem
import app.wetter.ui.components.SettingsSwitch
import kotlinx.coroutines.launch
/** S08 + S09: units, look, data sources. */
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SettingsScreen(settings: Settings, onBack: () -> Unit) {
val scope = rememberCoroutineScope()
val set: ((Settings) -> Settings) -> Unit = { t -> scope.launch { Graph.settings.update(t) } }
val bar = TopAppBarDefaults.exitUntilCollapsedScrollBehavior(rememberTopAppBarState())
val themeLabels = mapOf(
ThemeMode.SYSTEM to stringResource(R.string.theme_system),
ThemeMode.LIGHT to stringResource(R.string.theme_light),
ThemeMode.DARK to stringResource(R.string.theme_dark),
)
Scaffold(
modifier = Modifier.nestedScroll(bar.nestedScrollConnection),
containerColor = MaterialTheme.colorScheme.surfaceContainer,
topBar = {
LargeTopAppBar(
title = { Text(stringResource(R.string.settings)) },
navigationIcon = { IconButton(onClick = onBack) { Icon(Icons.AutoMirrored.Rounded.ArrowBack, stringResource(R.string.back)) } },
colors = TopAppBarDefaults.topAppBarColors(
containerColor = MaterialTheme.colorScheme.surfaceContainer,
scrolledContainerColor = MaterialTheme.colorScheme.surfaceContainer,
),
scrollBehavior = bar,
)
},
) { pad ->
androidx.compose.foundation.layout.Column(Modifier.padding(pad).fillMaxSize().verticalScroll(rememberScrollState()).navigationBarsPadding()) {
SettingsGroup(stringResource(R.string.set_units)) {
item { SettingsChoice(it, stringResource(R.string.set_temp), TempUnit.entries, settings.temp, { u -> if (u == TempUnit.C) "Celsius (°C)" else "Fahrenheit (°F)" }, { v -> set { s -> s.copy(temp = v) } }, Icons.Outlined.Thermostat) }
item {
SettingsChoice(it, stringResource(R.string.set_wind), WindUnit.entries, settings.wind, { u ->
when (u) { WindUnit.KMH -> "km/h"; WindUnit.MS -> "m/s"; WindUnit.MPH -> "mph"; WindUnit.KN -> "Knoten (kn)" }
}, { v -> set { s -> s.copy(wind = v) } }, Icons.Outlined.Air)
}
item { SettingsChoice(it, stringResource(R.string.set_precip), PrecipUnit.entries, settings.precip, { u -> if (u == PrecipUnit.MM) "Millimeter (mm)" else "Zoll (in)" }, { v -> set { s -> s.copy(precip = v) } }, Icons.Outlined.Umbrella) }
item { SettingsChoice(it, stringResource(R.string.set_pressure), PressureUnit.entries, settings.pressure, { u -> if (u == PressureUnit.HPA) "Hektopascal (hPa)" else "Zoll Quecksilber (inHg)" }, { v -> set { s -> s.copy(pressure = v) } }, Icons.Outlined.Compress) }
item { SettingsChoice(it, stringResource(R.string.set_distance), DistanceUnit.entries, settings.distance, { u -> if (u == DistanceUnit.KM) "Kilometer (km)" else "Meilen (mi)" }, { v -> set { s -> s.copy(distance = v) } }, Icons.Outlined.Visibility) }
}
SettingsGroup(stringResource(R.string.set_look)) {
item { SettingsChoice(it, stringResource(R.string.set_theme), ThemeMode.entries, settings.theme, { m -> themeLabels.getValue(m) }, { v -> set { s -> s.copy(theme = v) } }, Icons.Outlined.DarkMode) }
item { SettingsSwitch(it, stringResource(R.string.set_animations), settings.animations, { v -> set { s -> s.copy(animations = v) } }, stringResource(R.string.set_animations_sub), Icons.Outlined.AutoAwesome) }
item { SettingsSwitch(it, stringResource(R.string.set_brief), settings.brief, { v -> set { s -> s.copy(brief = v) } }, null, Icons.Outlined.Notes) }
}
SettingsGroup(stringResource(R.string.set_about)) {
item { SettingsItem(it, stringResource(R.string.set_about), stringResource(R.string.attribution), Icons.Outlined.Info) }
}
androidx.compose.foundation.layout.Spacer(Modifier.padding(bottom = app.wetter.ui.theme.WSpace.s32))
}
}
}
@@ -63,15 +63,18 @@ private val LightScheme = lightColorScheme(
background = WColor.bg, onBackground = WColor.text,
surface = WColor.surface, onSurface = WColor.text, onSurfaceVariant = WColor.textMuted,
surfaceContainer = WColor.surfaceContainer, surfaceContainerHigh = WColor.surfaceContainerHigh,
surfaceContainerLowest = WColor.surface,
outline = WColor.borderInput, outlineVariant = WColor.border, error = WColor.danger,
)
private val DarkScheme = darkColorScheme(
primary = WColor.darkAccent, onPrimary = WColor.darkOnAccent,
primaryContainer = WColor.darkAccentContainer, onPrimaryContainer = WColor.darkOnAccentContainer,
secondaryContainer = WColor.darkFillPrimary, onSecondaryContainer = WColor.darkOnFillPrimary,
background = WColor.darkBg, onBackground = WColor.darkText,
surface = WColor.darkSurface, onSurface = WColor.darkText, onSurfaceVariant = WColor.darkTextMuted,
surfaceContainer = WColor.darkSurfaceContainer, surfaceContainerHigh = WColor.darkSurfaceContainer,
surfaceContainer = WColor.darkBg, surfaceContainerHigh = WColor.darkSurfaceContainer,
surfaceContainerLowest = WColor.darkSurfaceContainer,
outline = WColor.darkBorderInput, outlineVariant = WColor.darkBorder, error = WColor.darkDanger,
)
@@ -114,6 +114,78 @@ object WColor {
val aqiBar6 = Color(0xFF8E24AA)
val uvDotLow = Color(0xFF5CCF8A)
val uvDotOff = Color(0xFF6B5A52)
val widgetOceanLightBg = Color(0xFFCCE4F0)
val widgetOceanLightOn = Color(0xFF0F2733)
val widgetOceanLightAccent = Color(0xFF20546F)
val widgetOceanLightPanel = Color(0xFFF9FAFB)
val widgetOceanLightOnpanel = Color(0xFF192124)
val widgetOceanLightBadge = Color(0xFFA8D1E6)
val widgetOceanLightOnbadge = Color(0xFF0F2733)
val widgetOceanDarkBg = Color(0xFF194257)
val widgetOceanDarkOn = Color(0xFFDBECF5)
val widgetOceanDarkAccent = Color(0xFFB0D5E8)
val widgetOceanDarkPanel = Color(0xFF0E1315)
val widgetOceanDarkOnpanel = Color(0xFFE7ECEF)
val widgetOceanDarkBadge = Color(0xFF1F516B)
val widgetOceanDarkOnbadge = Color(0xFFDFEEF6)
val widgetForestLightBg = Color(0xFFD2E9DA)
val widgetForestLightOn = Color(0xFF162D1D)
val widgetForestLightAccent = Color(0xFF2E603F)
val widgetForestLightPanel = Color(0xFFF9FBFA)
val widgetForestLightOnpanel = Color(0xFF1B221D)
val widgetForestLightBadge = Color(0xFFB3DBC0)
val widgetForestLightOnbadge = Color(0xFF162D1D)
val widgetForestDarkBg = Color(0xFF244C32)
val widgetForestDarkOn = Color(0xFFE0F0E5)
val widgetForestDarkAccent = Color(0xFFBADEC6)
val widgetForestDarkPanel = Color(0xFF101411)
val widgetForestDarkOnpanel = Color(0xFFE8EDEA)
val widgetForestDarkBadge = Color(0xFF2D5D3D)
val widgetForestDarkOnbadge = Color(0xFFE3F2E8)
val widgetSunLightBg = Color(0xFFF7E4C5)
val widgetSunLightOn = Color(0xFF3A2808)
val widgetSunLightAccent = Color(0xFF7D5612)
val widgetSunLightPanel = Color(0xFFFBFAF9)
val widgetSunLightOnpanel = Color(0xFF272117)
val widgetSunLightBadge = Color(0xFFF1D29D)
val widgetSunLightOnbadge = Color(0xFF3A2808)
val widgetSunDarkBg = Color(0xFF62430E)
val widgetSunDarkOn = Color(0xFFF9EDD7)
val widgetSunDarkAccent = Color(0xFFF2D6A6)
val widgetSunDarkPanel = Color(0xFF17130D)
val widgetSunDarkOnpanel = Color(0xFFF0ECE5)
val widgetSunDarkBadge = Color(0xFF785311)
val widgetSunDarkOnbadge = Color(0xFFFAEFDB)
val widgetLavenderLightBg = Color(0xFFDBCFED)
val widgetLavenderLightOn = Color(0xFF1F1230)
val widgetLavenderLightAccent = Color(0xFF422768)
val widgetLavenderLightPanel = Color(0xFFFAF9FB)
val widgetLavenderLightOnpanel = Color(0xFF1E1A23)
val widgetLavenderLightBadge = Color(0xFFC3AEE0)
val widgetLavenderLightOnbadge = Color(0xFF1F1230)
val widgetLavenderDarkBg = Color(0xFF341F51)
val widgetLavenderDarkOn = Color(0xFFE6DEF2)
val widgetLavenderDarkAccent = Color(0xFFC8B5E3)
val widgetLavenderDarkPanel = Color(0xFF110F15)
val widgetLavenderDarkOnpanel = Color(0xFFEAE7EE)
val widgetLavenderDarkBadge = Color(0xFF402664)
val widgetLavenderDarkOnbadge = Color(0xFFE9E1F4)
val widgetGraphiteLightBg = Color(0xFFDBDDE1)
val widgetGraphiteLightOn = Color(0xFF1E2124)
val widgetGraphiteLightAccent = Color(0xFF42464D)
val widgetGraphiteLightPanel = Color(0xFFFAFAFA)
val widgetGraphiteLightOnpanel = Color(0xFF1E1E1F)
val widgetGraphiteLightBadge = Color(0xFFC2C6CB)
val widgetGraphiteLightOnbadge = Color(0xFF1E2124)
val widgetGraphiteDarkBg = Color(0xFF34373D)
val widgetGraphiteDarkOn = Color(0xFFE6E8EA)
val widgetGraphiteDarkAccent = Color(0xFFC8CBD0)
val widgetGraphiteDarkPanel = Color(0xFF111212)
val widgetGraphiteDarkOnpanel = Color(0xFFEAEBEB)
val widgetGraphiteDarkBadge = Color(0xFF3F444A)
val widgetGraphiteDarkOnbadge = Color(0xFFE9EAEC)
val darkAccentContainer = Color(0xFF244A80)
val darkOnAccentContainer = Color(0xFFD6E3FF)
}
object WType {
@@ -0,0 +1,64 @@
package app.wetter.widget
import android.content.Context
import android.content.res.Configuration
import android.graphics.Bitmap
import android.os.Build
import androidx.compose.material3.ColorScheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.dynamicDarkColorScheme
import androidx.compose.material3.dynamicLightColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.ui.geometry.CornerRadius
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Canvas
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.asAndroidBitmap
import androidx.compose.ui.graphics.drawscope.CanvasDrawScope
import androidx.compose.ui.graphics.drawscope.DrawScope
import androidx.compose.ui.graphics.drawscope.rotate
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.LayoutDirection
import app.wetter.data.Condition
import app.wetter.ui.components.wavyCircle
import app.wetter.ui.scene.drawWeatherIcon
import app.wetter.ui.theme.WColor
/** Colours taken from the wallpaper (Material You) on Android 12+, our own palette below that. */
data class WidgetPalette(
val bg: Color,
val onBg: Color,
val muted: Color,
val accent: Color,
val panel: Color,
val onPanel: Color,
val badge: Color,
val onBadge: Color,
)
/** Widgets cannot draw custom shapes, so icons and shaped backgrounds are rendered to bitmaps. */
object WidgetArt {
private fun render(w: Int, h: Int, block: DrawScope.() -> Unit): Bitmap {
val image = ImageBitmap(w, h)
CanvasDrawScope().draw(Density(1f), LayoutDirection.Ltr, Canvas(image), Size(w.toFloat(), h.toFloat()), block)
return image.asAndroidBitmap()
}
fun icon(condition: Condition, isDay: Boolean, px: Int = 144): Bitmap = render(px, px) { drawWeatherIcon(condition, isDay) }
/** A stadium tilted by 45°, filling a square. */
fun tiltedPill(color: Color, px: Int = 400): Bitmap = render(px, px) {
rotate(-45f) {
val w = size.width * .92f
val h = size.height * .48f
drawRoundRect(color, Offset((size.width - w) / 2, (size.height - h) / 2), Size(w, h), CornerRadius(h / 2))
}
}
/** Scalloped "cookie" badge. */
fun cookie(color: Color, px: Int = 240): Bitmap = render(px, px) {
drawPath(wavyCircle(center, size.minDimension * .44f, 10, size.minDimension * .035f), color)
}
}
@@ -0,0 +1,228 @@
package app.wetter.widget
import android.appwidget.AppWidgetManager
import android.content.Intent
import android.os.Bundle
import android.widget.FrameLayout
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.Check
import androidx.compose.material3.Button
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.FilterChip
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SegmentedButton
import androidx.compose.material3.SegmentedButtonDefaults
import androidx.compose.material3.SingleChoiceSegmentedButtonRow
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
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.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.selected
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp
import androidx.compose.ui.viewinterop.AndroidView
import androidx.glance.appwidget.GlanceAppWidget
import androidx.glance.appwidget.GlanceAppWidgetManager
import androidx.glance.appwidget.compose
import app.wetter.R
import app.wetter.data.Graph
import app.wetter.data.Settings
import app.wetter.data.WidgetConfigEntity
import app.wetter.ui.theme.WSpace
import app.wetter.ui.theme.WType
import app.wetter.ui.theme.WeatherTheme
import androidx.lifecycle.lifecycleScope
import kotlinx.coroutines.launch
import androidx.compose.material.icons.outlined.DarkMode
import androidx.compose.material.icons.outlined.LocationOn
import androidx.compose.material3.Slider
import app.wetter.ui.components.SettingsChoice
import app.wetter.ui.components.SettingsCustom
import app.wetter.ui.components.SettingsGroup
import app.wetter.ui.components.WShapes
import kotlin.math.roundToInt
/** Opens when a widget is added, and again from the launcher's "customise widget". */
class WidgetConfigActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
Graph.init(this)
val appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID)
// backing out leaves the widget unplaced, as the platform expects
setResult(RESULT_CANCELED, Intent().putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId))
if (appWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) { finish(); return }
val provider = AppWidgetManager.getInstance(this).getAppWidgetInfo(appWidgetId)?.provider?.className.orEmpty()
val (widget, size) = widgetFor(provider)
setContent {
val settings by Graph.settings.settings.collectAsState(initial = Settings())
WeatherTheme(settings.theme) {
ConfigScreen(appWidgetId, widget, size) { config ->
lifecycleScope.launch {
Graph.repo.saveWidgetConfig(config)
runCatching { refreshWidget(this@WidgetConfigActivity, widget, GlanceAppWidgetManager(this@WidgetConfigActivity).getGlanceIdBy(appWidgetId)) }
setResult(RESULT_OK, Intent().putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId))
finish()
}
}
}
}
}
companion object {
fun widgetFor(providerClass: String): Pair<GlanceAppWidget, DpSize> = when {
providerClass.endsWith("PillReceiver") -> PillWidget() to DpSize(300.dp, 130.dp)
providerClass.endsWith("TiltReceiver") -> TiltWidget() to DpSize(170.dp, 170.dp)
providerClass.endsWith("BarReceiver") -> BarWidget() to DpSize(320.dp, 84.dp)
providerClass.endsWith("ClockReceiver") -> ClockWidget() to DpSize(320.dp, 150.dp)
providerClass.endsWith("ClassicReceiver") -> ClassicWidget() to DpSize(320.dp, 160.dp)
else -> WeatherCardWidget() to DpSize(320.dp, 240.dp)
}
}
}
@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun ConfigScreen(appWidgetId: Int, widget: GlanceAppWidget, size: DpSize, onDone: (WidgetConfigEntity) -> Unit) {
val context = LocalContext.current
val locations by Graph.repo.locations.collectAsState(initial = emptyList())
var config by remember {
val d = (widget as? WeatherWidget)?.defaultStyle ?: WidgetStyle()
mutableStateOf(WidgetConfigEntity(appWidgetId, null, d.palette, d.theme, d.opacity))
}
var loaded by remember { mutableStateOf(false) }
LaunchedEffect(appWidgetId) {
Graph.repo.widgetConfig(appWidgetId)?.let { config = it }
loaded = true
}
// live preview: render the real widget with the pending settings
var preview by remember { mutableStateOf<android.widget.RemoteViews?>(null) }
LaunchedEffect(config, loaded) {
if (!loaded) return@LaunchedEffect
WidgetPreviewOverride.config = config
preview = runCatching { widget.compose(context, size = size) }.getOrNull()
WidgetPreviewOverride.config = null
}
Scaffold(
containerColor = MaterialTheme.colorScheme.surfaceContainer,
topBar = {
TopAppBar(
title = { Text(stringResource(R.string.widget_customize)) },
colors = androidx.compose.material3.TopAppBarDefaults.topAppBarColors(containerColor = MaterialTheme.colorScheme.surfaceContainer),
)
},
) { pad ->
Column(Modifier.padding(pad).fillMaxSize().verticalScroll(rememberScrollState())) {
Box(
Modifier.fillMaxWidth().height(size.height + 48.dp).padding(horizontal = WSpace.s16).clip(RoundedCornerShape(28.dp))
.background(Brush.linearGradient(listOf(Color(0xFF5F7A84), Color(0xFFB9A58F)))),
contentAlignment = Alignment.Center,
) {
preview?.let { views ->
AndroidView(
factory = { FrameLayout(it) },
update = { frame -> frame.removeAllViews(); frame.addView(views.apply(frame.context, frame)) },
modifier = Modifier.size(size),
)
}
}
val themeLabels = listOf(R.string.theme_system, R.string.theme_light, R.string.theme_dark).map { stringResource(it) }
val follow = stringResource(R.string.widget_follow)
val names = context.resources.getStringArray(R.array.widget_palettes)
val choices = listOf<Long?>(null) + locations.filter { !it.isCurrent }.map { it.id }
SettingsGroup(stringResource(R.string.widget_content)) {
item {
SettingsChoice(it, stringResource(R.string.widget_location), choices, config.locationId,
{ id -> if (id == null) follow else locations.firstOrNull { l -> l.id == id }?.name.orEmpty() },
{ id -> config = config.copy(locationId = id) }, Icons.Outlined.LocationOn)
}
}
SettingsGroup(stringResource(R.string.set_look)) {
item {
SettingsChoice(it, stringResource(R.string.set_theme), WidgetStyle.THEMES, config.theme,
{ k -> themeLabels[WidgetStyle.THEMES.indexOf(k)] }, { k -> config = config.copy(theme = k) }, Icons.Outlined.DarkMode)
}
item {
SettingsCustom(it) {
Text(stringResource(R.string.widget_colors), style = WType.body)
Text(names[WidgetStyle.PALETTES.indexOf(config.style).coerceAtLeast(0)], style = WType.bodySm, color = MaterialTheme.colorScheme.onSurfaceVariant)
Row(Modifier.horizontalScroll(rememberScrollState()).padding(top = WSpace.s12), horizontalArrangement = Arrangement.spacedBy(WSpace.s12)) {
WidgetStyle.PALETTES.forEachIndexed { i, key ->
val swatch = resolvePalette(context, WidgetStyle(key, config.theme, 100), null)
val selected = config.style == key
Box(
Modifier.size(48.dp).clip(if (selected) WShapes.cookie8 else CircleShape)
.background(Brush.linearGradient(listOf(swatch.bg, swatch.accent)))
.clickable { config = config.copy(style = key) }
.semantics { contentDescription = names[i]; this.selected = selected },
contentAlignment = Alignment.Center,
) { if (selected) Icon(Icons.Rounded.Check, null, tint = swatch.onBg) }
}
}
}
}
item {
SettingsCustom(it) {
Text(stringResource(R.string.widget_opacity), style = WType.body)
Text("${config.opacity} %", style = WType.bodySm, color = MaterialTheme.colorScheme.onSurfaceVariant)
val levels = WidgetStyle.OPACITIES.sorted()
Slider(
value = levels.indexOf(config.opacity).coerceAtLeast(0).toFloat(),
onValueChange = { v -> config = config.copy(opacity = levels[v.roundToInt()]) },
valueRange = 0f..(levels.size - 1).toFloat(),
steps = levels.size - 2,
)
if (config.opacity <= 25) Text(stringResource(R.string.widget_opacity_hint), style = WType.bodySm, color = MaterialTheme.colorScheme.onSurfaceVariant)
}
}
}
Button(onClick = { onDone(config) }, enabled = loaded, modifier = Modifier.fillMaxWidth().padding(horizontal = WSpace.s16, vertical = WSpace.s24).navigationBarsPadding().height(56.dp)) {
Text(stringResource(R.string.widget_done))
}
}
}
}
@@ -0,0 +1,81 @@
package app.wetter.widget
import android.content.Context
import android.content.res.Configuration
import android.os.Build
import androidx.compose.material3.dynamicDarkColorScheme
import androidx.compose.material3.dynamicLightColorScheme
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.lerp
import app.wetter.data.Forecast
import app.wetter.data.conditionOf
import app.wetter.ui.scene.SceneSpec
import app.wetter.ui.theme.WColor
/** What a person picked for one widget in the configuration screen. */
data class WidgetStyle(
val palette: String = WALLPAPER,
val theme: String = SYSTEM,
/** background opacity in percent: 100, 75, 50, 25 or 0 */
val opacity: Int = 100,
) {
companion object {
const val WALLPAPER = "wallpaper"
const val WEATHER = "weather"
const val SYSTEM = "system"
const val LIGHT = "light"
const val DARK = "dark"
val PALETTES = listOf(WALLPAPER, WEATHER, "ocean", "forest", "sun", "lavender", "graphite")
val THEMES = listOf(SYSTEM, LIGHT, DARK)
val OPACITIES = listOf(100, 75, 50, 25, 0)
}
}
private fun palette(bg: Color, on: Color, accent: Color, panel: Color, onPanel: Color, badge: Color, onBadge: Color) =
WidgetPalette(bg, on, on.copy(alpha = .72f), accent, panel, onPanel, badge, onBadge)
private val FIXED: Map<Pair<String, Boolean>, WidgetPalette> = mapOf(
Pair("ocean", false) to palette(WColor.widgetOceanLightBg, WColor.widgetOceanLightOn, WColor.widgetOceanLightAccent, WColor.widgetOceanLightPanel, WColor.widgetOceanLightOnpanel, WColor.widgetOceanLightBadge, WColor.widgetOceanLightOnbadge),
Pair("ocean", true) to palette(WColor.widgetOceanDarkBg, WColor.widgetOceanDarkOn, WColor.widgetOceanDarkAccent, WColor.widgetOceanDarkPanel, WColor.widgetOceanDarkOnpanel, WColor.widgetOceanDarkBadge, WColor.widgetOceanDarkOnbadge),
Pair("forest", false) to palette(WColor.widgetForestLightBg, WColor.widgetForestLightOn, WColor.widgetForestLightAccent, WColor.widgetForestLightPanel, WColor.widgetForestLightOnpanel, WColor.widgetForestLightBadge, WColor.widgetForestLightOnbadge),
Pair("forest", true) to palette(WColor.widgetForestDarkBg, WColor.widgetForestDarkOn, WColor.widgetForestDarkAccent, WColor.widgetForestDarkPanel, WColor.widgetForestDarkOnpanel, WColor.widgetForestDarkBadge, WColor.widgetForestDarkOnbadge),
Pair("sun", false) to palette(WColor.widgetSunLightBg, WColor.widgetSunLightOn, WColor.widgetSunLightAccent, WColor.widgetSunLightPanel, WColor.widgetSunLightOnpanel, WColor.widgetSunLightBadge, WColor.widgetSunLightOnbadge),
Pair("sun", true) to palette(WColor.widgetSunDarkBg, WColor.widgetSunDarkOn, WColor.widgetSunDarkAccent, WColor.widgetSunDarkPanel, WColor.widgetSunDarkOnpanel, WColor.widgetSunDarkBadge, WColor.widgetSunDarkOnbadge),
Pair("lavender", false) to palette(WColor.widgetLavenderLightBg, WColor.widgetLavenderLightOn, WColor.widgetLavenderLightAccent, WColor.widgetLavenderLightPanel, WColor.widgetLavenderLightOnpanel, WColor.widgetLavenderLightBadge, WColor.widgetLavenderLightOnbadge),
Pair("lavender", true) to palette(WColor.widgetLavenderDarkBg, WColor.widgetLavenderDarkOn, WColor.widgetLavenderDarkAccent, WColor.widgetLavenderDarkPanel, WColor.widgetLavenderDarkOnpanel, WColor.widgetLavenderDarkBadge, WColor.widgetLavenderDarkOnbadge),
Pair("graphite", false) to palette(WColor.widgetGraphiteLightBg, WColor.widgetGraphiteLightOn, WColor.widgetGraphiteLightAccent, WColor.widgetGraphiteLightPanel, WColor.widgetGraphiteLightOnpanel, WColor.widgetGraphiteLightBadge, WColor.widgetGraphiteLightOnbadge),
Pair("graphite", true) to palette(WColor.widgetGraphiteDarkBg, WColor.widgetGraphiteDarkOn, WColor.widgetGraphiteDarkAccent, WColor.widgetGraphiteDarkPanel, WColor.widgetGraphiteDarkOnpanel, WColor.widgetGraphiteDarkBadge, WColor.widgetGraphiteDarkOnbadge),
)
fun resolvePalette(context: Context, style: WidgetStyle, forecast: Forecast?): WidgetPalette {
val systemDark = context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES
val dark = when (style.theme) {
WidgetStyle.LIGHT -> false
WidgetStyle.DARK -> true
else -> systemDark
}
val base = when (style.palette) {
WidgetStyle.WALLPAPER -> wallpaper(context, dark)
WidgetStyle.WEATHER -> weather(forecast, dark)
else -> FIXED[style.palette to dark] ?: wallpaper(context, dark)
}
val a = style.opacity.coerceIn(0, 100) / 100f
return base.copy(bg = base.bg.copy(alpha = base.bg.alpha * a), panel = base.panel.copy(alpha = base.panel.alpha * a), badge = base.badge.copy(alpha = base.badge.alpha * a))
}
private fun wallpaper(context: Context, dark: Boolean): WidgetPalette {
if (Build.VERSION.SDK_INT < 31) return FIXED.getValue(("ocean" to dark))
val s = if (dark) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
return palette(s.primaryContainer, s.onPrimaryContainer, s.primary, s.surfaceContainerLowest, s.onSurface, s.secondaryContainer, s.onSecondaryContainer)
}
/** Colours of the current sky: the same gradient the app shows behind the forecast. */
private fun weather(forecast: Forecast?, dark: Boolean): WidgetPalette {
val spec = forecast?.let { SceneSpec(conditionOf(it.current.code), it.current.isDay) } ?: return FIXED.getValue(("graphite" to dark))
val bg = if (dark) lerp(spec.top, Color.Black, .35f) else spec.top
val light = !dark && spec.isLight
val on = if (light) WColor.onSceneDark else WColor.onScene
val panel = if (light) WColor.sceneCardLight else WColor.sceneCard
val onPanel = if (light) WColor.onSceneDark else WColor.onScene
return palette(bg, on, on, panel, onPanel, panel, onPanel)
}
@@ -0,0 +1,473 @@
package app.wetter.widget
import android.content.Context
import android.os.Build
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.glance.GlanceId
import androidx.glance.GlanceModifier
import androidx.glance.Image
import androidx.glance.ImageProvider
import androidx.glance.LocalContext
import androidx.glance.LocalSize
import androidx.glance.action.clickable
import androidx.glance.appwidget.GlanceAppWidget
import androidx.glance.appwidget.GlanceAppWidgetManager
import androidx.glance.appwidget.GlanceAppWidgetReceiver
import androidx.glance.appwidget.SizeMode
import androidx.glance.appwidget.action.actionStartActivity
import androidx.glance.appwidget.cornerRadius
import androidx.glance.appwidget.provideContent
import androidx.glance.appwidget.updateAll
import androidx.glance.background
import androidx.glance.layout.Alignment
import androidx.glance.layout.Box
import androidx.glance.layout.Column
import androidx.glance.layout.ContentScale
import androidx.glance.layout.Row
import androidx.glance.layout.Spacer
import androidx.glance.layout.fillMaxSize
import androidx.glance.layout.fillMaxWidth
import androidx.glance.layout.height
import androidx.glance.layout.padding
import androidx.glance.layout.size
import androidx.glance.layout.width
import androidx.glance.semantics.contentDescription
import androidx.glance.semantics.semantics
import androidx.glance.text.FontWeight
import androidx.glance.text.Text
import androidx.glance.text.TextAlign
import androidx.glance.text.TextStyle
import androidx.glance.unit.ColorProvider
import app.wetter.MainActivity
import app.wetter.R
import app.wetter.data.Forecast
import app.wetter.data.Fmt
import app.wetter.data.Graph
import app.wetter.data.LocationEntity
import app.wetter.data.Settings
import app.wetter.data.Units
import app.wetter.data.conditionOf
import app.wetter.ui.components.conditionLabel
import kotlinx.coroutines.flow.first
import kotlin.reflect.KClass
import androidx.compose.runtime.getValue
import androidx.compose.runtime.produceState
import androidx.datastore.preferences.core.longPreferencesKey
import androidx.glance.appwidget.state.updateAppWidgetState
import androidx.glance.currentState
private val DATA_VERSION = longPreferencesKey("data_version")
/** All widget types, paired with their receivers. */
val ALL_WIDGETS: List<Pair<() -> WeatherWidget, KClass<out GlanceAppWidgetReceiver>>> = listOf(
::WeatherCardWidget to WeatherCardReceiver::class,
::PillWidget to PillReceiver::class,
::TiltWidget to TiltReceiver::class,
::BarWidget to BarReceiver::class,
::ClassicWidget to ClassicReceiver::class,
::ClockWidget to ClockReceiver::class,
)
/**
* Glance's update() only recomposes a running session, it does not run provideGlance again.
* Bumping a value in the widget's state makes the composition reload settings and forecast.
*/
suspend fun refreshWidget(context: Context, widget: GlanceAppWidget, id: GlanceId) {
updateAppWidgetState(context, id) { it[DATA_VERSION] = System.nanoTime() }
widget.update(context, id)
}
suspend fun updateAllWidgets(context: Context) {
val manager = GlanceAppWidgetManager(context)
for ((make, receiver) in ALL_WIDGETS) {
val widget = make()
manager.getGlanceIds(widget.javaClass).forEach { runCatching { refreshWidget(context, widget, it) } }
}
}
/** Picker previews (Android 15+). The system rate-limits this, so failures are ignored. */
suspend fun publishWidgetPreviews(context: Context) {
if (Build.VERSION.SDK_INT < 35) return
val manager = GlanceAppWidgetManager(context)
ALL_WIDGETS.forEach { (_, receiver) -> runCatching { manager.setWidgetPreviews(receiver) } }
}
class WidgetData(val location: LocationEntity?, val forecast: Forecast?, val units: Units, val palette: WidgetPalette) {
val name: String get() = location?.name.orEmpty()
}
/** Set by the configuration screen while it renders its live preview. */
object WidgetPreviewOverride {
@Volatile var config: app.wetter.data.WidgetConfigEntity? = null
}
suspend fun loadWidgetData(context: Context, id: GlanceId?, defaultStyle: WidgetStyle = WidgetStyle()): WidgetData {
Graph.init(context)
// ids that are not real widgets (previews, the debug gallery) fall back to the current location
val appWidgetId = id?.let { runCatching { GlanceAppWidgetManager(context).getAppWidgetId(it) }.getOrNull() } ?: -1
val config = WidgetPreviewOverride.config ?: Graph.repo.widgetConfig(appWidgetId)
val location = config?.locationId?.let { Graph.repo.location(it) } ?: Graph.repo.widgetLocation(appWidgetId)
val forecast = location?.let { Graph.repo.forecastOnce(it.id) }
val settings = runCatching { Graph.settings.settings.first() }.getOrDefault(Settings())
val style = config?.let { WidgetStyle(it.style, it.theme, it.opacity) } ?: defaultStyle
return WidgetData(location, forecast, Units(settings), resolvePalette(context, style, forecast))
}
/** Base: loads data once per update, renders [Content], and offers the same content as picker preview. */
abstract class WeatherWidget : GlanceAppWidget() {
/** Style used until the person configures this widget. */
open val defaultStyle: WidgetStyle get() = WidgetStyle()
override suspend fun provideGlance(context: Context, id: GlanceId) {
val first = loadWidgetData(context, id, defaultStyle)
provideContent {
val version = currentState(DATA_VERSION) ?: 0L
val data by produceState(first, version) { if (version != 0L) value = loadWidgetData(context, id, defaultStyle) }
Root(data)
}
}
override suspend fun providePreview(context: Context, widgetCategory: Int) {
// a transparent widget would vanish against the picker, so previews always get a background
val style = defaultStyle.let { if (it.opacity < 100) it.copy(opacity = 100) else it }
val data = loadWidgetData(context, null, style)
provideContent { Root(data) }
}
@Composable
fun Root(data: WidgetData) {
val context = LocalContext.current
val f = data.forecast
if (f == null) {
Box(
GlanceModifier.fillMaxSize().cornerRadius(24.dp).background(data.palette.bg)
.clickable(actionStartActivity(MainActivity.intent(context, null))),
contentAlignment = Alignment.Center,
) { Text(context.getString(R.string.widget_pick), style = text(data.palette.onBg, 14)) }
return
}
Content(data, f)
}
@Composable
abstract fun Content(data: WidgetData, f: Forecast)
}
private fun text(color: Color, size: Int, weight: FontWeight = FontWeight.Normal, align: TextAlign = TextAlign.Start) =
TextStyle(color = ColorProvider(color), fontSize = size.sp, fontWeight = weight, textAlign = align)
@Composable
private fun open(data: WidgetData) = actionStartActivity(MainActivity.intent(LocalContext.current, data.location?.id))
@Composable
private fun Icon(f: Forecast, size: Int, code: Int = f.current.code, isDay: Boolean = f.current.isDay) =
Image(ImageProvider(WidgetArt.icon(conditionOf(code), isDay)), null, GlanceModifier.size(size.dp))
@Composable
private fun conditionText(f: Forecast): String =
LocalContext.current.getString(conditionLabel(conditionOf(f.current.code), f.current.isDay))
@Composable
private fun Attribution(p: WidgetPalette) = Text(
LocalContext.current.getString(R.string.widget_source), style = text(p.muted, 10, align = TextAlign.Center),
modifier = GlanceModifier.fillMaxWidth(),
)
/** One hour column: temperature, icon, time. */
@Composable
private fun HourCell(f: Forecast, index: Int, data: WidgetData, color: Color, modifier: GlanceModifier) {
val h = f.upcomingHours(index + 1).getOrNull(index) ?: return
val ctx = LocalContext.current
Column(modifier, horizontalAlignment = Alignment.CenterHorizontally) {
Text(data.units.temp(h.temp), style = text(color, 13, align = TextAlign.Center))
Spacer(GlanceModifier.height(4.dp))
Image(ImageProvider(WidgetArt.icon(conditionOf(h.code), h.isDay, 96)), null, GlanceModifier.size(24.dp))
Spacer(GlanceModifier.height(4.dp))
Text(if (index == 0) ctx.getString(R.string.now) else Fmt.hourLabel(h.time), style = text(color, 12, align = TextAlign.Center))
}
}
// ---------------------------------------------------------------------------------------------
// 1. Weather card: grows from a compact 3×2 to a full 4×5 with hourly panel and daily list
// ---------------------------------------------------------------------------------------------
class WeatherCardWidget : WeatherWidget() {
override val sizeMode = SizeMode.Responsive(setOf(COMPACT, MEDIUM, LARGE, FULL))
@Composable
override fun Content(data: WidgetData, f: Forecast) {
val cond = conditionText(f)
val size = LocalSize.current
val p = data.palette
val u = data.units
val ctx = LocalContext.current
val today = f.today
Column(
GlanceModifier.fillMaxSize().cornerRadius(28.dp).background(p.bg).clickable(open(data)).padding(16.dp)
.semantics { contentDescription = "${data.name} ${u.temp(f.current.temp)} $cond" },
) {
Row(GlanceModifier.fillMaxWidth(), verticalAlignment = Alignment.Top) {
Column(GlanceModifier.defaultWeight()) {
if (size.height >= LARGE.height && data.name.isNotEmpty()) {
Text(data.name, style = text(p.accent, 13, FontWeight.Medium), maxLines = 1)
Spacer(GlanceModifier.height(6.dp))
}
Row(verticalAlignment = Alignment.CenterVertically) {
Icon(f, 30)
Spacer(GlanceModifier.width(8.dp))
Text(conditionText(f), style = text(p.onBg, 16, FontWeight.Medium), maxLines = 1)
}
Spacer(GlanceModifier.height(4.dp))
Text(ctx.getString(R.string.feels_like, u.temp(f.current.feelsLike)), style = text(p.onBg, 14), maxLines = 1)
if (today != null) Text("${u.temp(today.tMax)} · ${u.temp(today.tMin)}", style = text(p.muted, 14))
}
Text(u.temp(f.current.temp), style = text(p.onBg, if (size.width >= MEDIUM.width) 56 else 44))
}
if (size.height < MEDIUM.height) {
// compact: two hours under the temperature
Spacer(GlanceModifier.defaultWeight())
Row(GlanceModifier.fillMaxWidth()) {
Spacer(GlanceModifier.defaultWeight())
HourCell(f, 0, data, p.onBg, GlanceModifier.width(48.dp))
HourCell(f, 1, data, p.onBg, GlanceModifier.width(48.dp))
}
return@Column
}
Spacer(GlanceModifier.height(12.dp))
Row(GlanceModifier.fillMaxWidth().cornerRadius(20.dp).background(p.panel).padding(vertical = 10.dp)) {
for (i in 0 until 6) HourCell(f, i, data, p.onPanel, GlanceModifier.defaultWeight())
}
if (size.height >= LARGE.height) {
Spacer(GlanceModifier.height(8.dp))
val days = f.daily.drop(1).take(if (size.height >= FULL.height) 5 else 1)
Column(GlanceModifier.fillMaxWidth().cornerRadius(20.dp).background(p.panel)) {
days.forEachIndexed { i, d ->
Row(GlanceModifier.fillMaxWidth().padding(horizontal = 14.dp, vertical = 9.dp), verticalAlignment = Alignment.CenterVertically) {
Text(
d.date.dayOfWeek.getDisplayName(java.time.format.TextStyle.FULL, java.util.Locale.getDefault()),
style = text(p.onPanel, 14), modifier = GlanceModifier.defaultWeight(),
)
Text("${u.temp(d.tMax)} ", style = text(p.onPanel, 14, FontWeight.Medium))
Text(u.temp(d.tMin), style = text(p.onPanel.copy(alpha = .7f), 14))
Spacer(GlanceModifier.width(8.dp))
Image(ImageProvider(WidgetArt.icon(conditionOf(d.code), true, 96)), null, GlanceModifier.size(22.dp))
}
if (i < days.lastIndex) Spacer(GlanceModifier.fillMaxWidth().height(1.dp).background(p.bg))
}
}
}
Spacer(GlanceModifier.defaultWeight())
Attribution(p)
}
}
companion object {
val COMPACT = DpSize(180.dp, 110.dp)
val MEDIUM = DpSize(250.dp, 180.dp)
val LARGE = DpSize(250.dp, 310.dp)
val FULL = DpSize(250.dp, 430.dp)
}
}
// ---------------------------------------------------------------------------------------------
// 2. Pill: stadium with a big icon and the temperature
// ---------------------------------------------------------------------------------------------
class PillWidget : WeatherWidget() {
override val sizeMode = SizeMode.Responsive(setOf(SMALL, WIDE))
@Composable
override fun Content(data: WidgetData, f: Forecast) {
val cond = conditionText(f)
val size = LocalSize.current
val p = data.palette
val u = data.units
val big = size.height >= WIDE.height
Row(
GlanceModifier.fillMaxSize().cornerRadius(999.dp).background(p.bg).clickable(open(data)).padding(horizontal = if (big) 24.dp else 16.dp)
.semantics { contentDescription = "${data.name} ${u.temp(f.current.temp)} $cond" },
verticalAlignment = Alignment.CenterVertically, horizontalAlignment = Alignment.CenterHorizontally,
) {
Icon(f, if (big) 84 else 36)
Spacer(GlanceModifier.width(if (big) 16.dp else 8.dp))
Column(horizontalAlignment = Alignment.CenterHorizontally) {
Text(u.temp(f.current.temp), style = text(p.accent, if (big) 56 else 30))
if (big) f.today?.let {
Row {
Text(u.temp(it.tMax) + " ", style = text(p.accent, 18))
Text(u.temp(it.tMin), style = text(p.muted, 18))
}
}
}
}
}
companion object {
val SMALL = DpSize(110.dp, 48.dp)
val WIDE = DpSize(200.dp, 110.dp)
}
}
// ---------------------------------------------------------------------------------------------
// 3. Tilted pill: a 45° stadium, temperature top right, icon bottom left
// ---------------------------------------------------------------------------------------------
class TiltWidget : WeatherWidget() {
override val sizeMode = SizeMode.Exact
@Composable
override fun Content(data: WidgetData, f: Forecast) {
val cond = conditionText(f)
val p = data.palette
val u = data.units
val size = LocalSize.current
val side = minOf(size.width.value, size.height.value)
Box(
GlanceModifier.fillMaxSize().clickable(open(data))
.semantics { contentDescription = "${data.name} ${u.temp(f.current.temp)} $cond" },
contentAlignment = Alignment.Center,
) {
Box(GlanceModifier.size(side.dp)) {
Image(ImageProvider(WidgetArt.tiltedPill(p.bg)), null, GlanceModifier.fillMaxSize(), contentScale = ContentScale.FillBounds)
Box(GlanceModifier.fillMaxSize().padding(top = (side * .22f).dp, end = (side * .2f).dp), contentAlignment = Alignment.TopEnd) {
Text(u.temp(f.current.temp), style = text(p.onBg, (side * .22f).toInt()))
}
Box(GlanceModifier.fillMaxSize().padding(bottom = (side * .2f).dp, start = (side * .2f).dp), contentAlignment = Alignment.BottomStart) {
Icon(f, (side * .28f).toInt())
}
}
}
}
}
// ---------------------------------------------------------------------------------------------
// 4. Bar: one line "today", condition, and a cookie badge with the current temperature
// ---------------------------------------------------------------------------------------------
class BarWidget : WeatherWidget() {
override val sizeMode = SizeMode.Exact
@Composable
override fun Content(data: WidgetData, f: Forecast) {
val cond = conditionText(f)
val p = data.palette
val u = data.units
val ctx = LocalContext.current
val size = LocalSize.current
val badge = minOf(size.height.value - 8f, 88f)
Row(
GlanceModifier.fillMaxSize().cornerRadius(999.dp).background(p.panel).clickable(open(data)).padding(start = 22.dp, end = 6.dp)
.semantics { contentDescription = "${data.name} ${u.temp(f.current.temp)} $cond" },
verticalAlignment = Alignment.CenterVertically,
) {
Column(GlanceModifier.defaultWeight()) {
f.today?.let { Text("${ctx.getString(R.string.today)} ${u.temp(it.tMax)} / ${u.temp(it.tMin)}", style = text(p.onPanel, 15), maxLines = 1) }
Row(verticalAlignment = Alignment.CenterVertically) {
Icon(f, 22)
Spacer(GlanceModifier.width(6.dp))
Text(conditionText(f), style = text(p.onPanel, 14), maxLines = 1)
}
}
Box(GlanceModifier.size(badge.dp), contentAlignment = Alignment.Center) {
Image(ImageProvider(WidgetArt.cookie(p.badge)), null, GlanceModifier.fillMaxSize())
Column(horizontalAlignment = Alignment.CenterHorizontally) {
Icon(f, (badge * .38f).toInt())
Text(u.temp(f.current.temp), style = text(p.onBadge, 13, FontWeight.Medium))
}
}
}
}
}
// ---------------------------------------------------------------------------------------------
// 5. Classic: rounded square, place and condition in the accent colour, hours on the right
// ---------------------------------------------------------------------------------------------
class ClassicWidget : WeatherWidget() {
override val sizeMode = SizeMode.Responsive(setOf(SQUARE, WIDE))
@Composable
override fun Content(data: WidgetData, f: Forecast) {
val cond = conditionText(f)
val p = data.palette
val u = data.units
val wide = LocalSize.current.width >= WIDE.width
Column(
GlanceModifier.fillMaxSize().cornerRadius(24.dp).background(p.bg).clickable(open(data)).padding(16.dp)
.semantics { contentDescription = "${data.name} ${u.temp(f.current.temp)} $cond" },
) {
Row(GlanceModifier.fillMaxWidth(), verticalAlignment = Alignment.Top) {
Icon(f, 30)
Spacer(GlanceModifier.defaultWeight())
Column(horizontalAlignment = Alignment.End) {
Text(data.name, style = text(p.accent, 13), maxLines = 1)
Text(conditionText(f), style = text(p.accent, 17, FontWeight.Medium), maxLines = 1)
}
}
Spacer(GlanceModifier.defaultWeight())
Row(GlanceModifier.fillMaxWidth(), verticalAlignment = Alignment.Bottom) {
Column {
Text(u.temp(f.current.temp), style = text(p.accent, 46, FontWeight.Medium))
f.today?.let {
Row {
Text(u.temp(it.tMax) + " ", style = text(p.accent, 14))
Text(u.temp(it.tMin), style = text(p.muted, 14))
}
}
}
if (wide) {
Spacer(GlanceModifier.defaultWeight())
for (i in 1..4) HourCell(f, i, data, p.onBg, GlanceModifier.width(44.dp))
}
}
}
}
companion object {
val SQUARE = DpSize(140.dp, 140.dp)
val WIDE = DpSize(250.dp, 110.dp)
}
}
class WeatherCardReceiver : GlanceAppWidgetReceiver() { override val glanceAppWidget: GlanceAppWidget = WeatherCardWidget() }
class PillReceiver : GlanceAppWidgetReceiver() { override val glanceAppWidget: GlanceAppWidget = PillWidget() }
class TiltReceiver : GlanceAppWidgetReceiver() { override val glanceAppWidget: GlanceAppWidget = TiltWidget() }
class BarReceiver : GlanceAppWidgetReceiver() { override val glanceAppWidget: GlanceAppWidget = BarWidget() }
class ClockReceiver : GlanceAppWidgetReceiver() { override val glanceAppWidget: GlanceAppWidget = ClockWidget() }
class ClassicReceiver : GlanceAppWidgetReceiver() { override val glanceAppWidget: GlanceAppWidget = ClassicWidget() }
// ---------------------------------------------------------------------------------------------
// 6. Clock: big live time, date and the current weather. Transparent by default, for a clean home screen
// ---------------------------------------------------------------------------------------------
class ClockWidget : WeatherWidget() {
override val sizeMode = SizeMode.Exact
override val defaultStyle = WidgetStyle(palette = WidgetStyle.WALLPAPER, theme = WidgetStyle.DARK, opacity = 0)
@Composable
override fun Content(data: WidgetData, f: Forecast) {
val ctx = LocalContext.current
val p = data.palette
val u = data.units
val size = LocalSize.current
// on a bare wallpaper white text with a soft shadow reads best; with a background use the palette
val fg = if (p.bg.alpha < .3f) Color.White else p.onBg
val timeSp = (size.height.value * .42f).coerceIn(40f, 96f)
val views = android.widget.RemoteViews(ctx.packageName, R.layout.widget_clock).apply {
val c = android.graphics.Color.argb((fg.alpha * 255).toInt(), (fg.red * 255).toInt(), (fg.green * 255).toInt(), (fg.blue * 255).toInt())
listOf(R.id.clock_time, R.id.clock_date, R.id.clock_sep, R.id.clock_temp).forEach { setTextColor(it, c) }
setTextViewTextSize(R.id.clock_time, android.util.TypedValue.COMPLEX_UNIT_SP, timeSp)
setImageViewBitmap(R.id.clock_icon, WidgetArt.icon(conditionOf(f.current.code), f.current.isDay, 96))
setTextViewText(R.id.clock_temp, u.temp(f.current.temp))
setContentDescription(R.id.clock_temp, "${u.temp(f.current.temp)} ${conditionText(f)}")
}
Box(
GlanceModifier.fillMaxSize().cornerRadius(28.dp).background(p.bg).clickable(open(data)),
contentAlignment = Alignment.Center,
) { androidx.glance.appwidget.AndroidRemoteViews(views) }
}
}
@@ -11,6 +11,7 @@ import androidx.work.PeriodicWorkRequestBuilder
import androidx.work.WorkManager
import androidx.work.WorkerParameters
import app.wetter.data.Graph
import app.wetter.widget.publishWidgetPreviews
import app.wetter.widget.updateAllWidgets
import java.util.concurrent.TimeUnit
@@ -21,6 +22,7 @@ class RefreshWorker(context: Context, params: WorkerParameters) : CoroutineWorke
val force = inputData.getBoolean(KEY_FORCE, false)
runCatching { Graph.repo.refreshAll(force) }
updateAllWidgets(applicationContext)
publishWidgetPreviews(applicationContext)
return Result.success()
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

@@ -1,5 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="108dp" android:height="108dp" android:viewportWidth="108" android:viewportHeight="108">
<path android:fillColor="#FF7CC4EF" android:pathData="M0,0h108v108h-108z"/>
<path android:fillColor="#FFFFB02E" android:pathData="M64,40m-16,0a16,16 0,1 1,32 0a16,16 0,1 1,-32 0"/>
<path android:fillColor="#FFF4F6F9" android:pathData="M30,74h44a12,12 0,0 0,0 -24a16,16 0,0 0,-30 -4a13,13 0,0 0,-14 28z"/>
</vector>
@@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp" android:height="108dp" android:viewportWidth="108" android:viewportHeight="108">
<path android:pathData="M0,0h108v108h-108z">
<aapt:attr name="android:fillColor">
<gradient android:type="linear" android:startX="0" android:startY="0" android:endX="0" android:endY="108"
android:startColor="#FF4E9BE6" android:endColor="#FFBFE3F7"/>
</aapt:attr>
</path>
<path android:fillColor="#FF8EC2EC" android:pathData="M0.00,108.00 L0.00,77.13 L2.00,76.77 L4.00,76.47 L6.00,76.25 L8.00,76.09 L10.00,76.01 L12.00,76.01 L14.00,76.09 L16.00,76.24 L18.00,76.46 L20.00,76.76 L22.00,77.11 L24.00,77.53 L26.00,77.99 L28.00,78.49 L30.00,79.02 L32.00,79.57 L34.00,80.13 L36.00,80.68 L38.00,81.23 L40.00,81.74 L42.00,82.23 L44.00,82.67 L46.00,83.06 L48.00,83.39 L50.00,83.65 L52.00,83.84 L54.00,83.96 L56.00,84.00 L58.00,83.96 L60.00,83.85 L62.00,83.66 L64.00,83.40 L66.00,83.07 L68.00,82.68 L70.00,82.25 L72.00,81.76 L74.00,81.25 L76.00,80.71 L78.00,80.15 L80.00,79.59 L82.00,79.04 L84.00,78.51 L86.00,78.01 L88.00,77.55 L90.00,77.13 L92.00,76.77 L94.00,76.47 L96.00,76.25 L98.00,76.09 L100.00,76.01 L102.00,76.01 L104.00,76.09 L106.00,76.24 L108.00,76.46 L108.00,108.00 Z"/>
<path android:fillColor="#FFA9D3F2" android:pathData="M0.00,108.00 L0.00,85.97 L2.00,86.20 L4.00,86.44 L6.00,86.69 L8.00,86.96 L10.00,87.23 L12.00,87.52 L14.00,87.81 L16.00,88.10 L18.00,88.38 L20.00,88.67 L22.00,88.95 L24.00,89.22 L26.00,89.48 L28.00,89.72 L30.00,89.95 L32.00,90.16 L34.00,90.35 L36.00,90.52 L38.00,90.67 L40.00,90.79 L42.00,90.88 L44.00,90.95 L46.00,90.99 L48.00,91.00 L50.00,90.98 L52.00,90.94 L54.00,90.87 L56.00,90.77 L58.00,90.65 L60.00,90.50 L62.00,90.32 L64.00,90.13 L66.00,89.92 L68.00,89.69 L70.00,89.44 L72.00,89.18 L74.00,88.91 L76.00,88.63 L78.00,88.34 L80.00,88.05 L82.00,87.76 L84.00,87.47 L86.00,87.19 L88.00,86.92 L90.00,86.65 L92.00,86.40 L94.00,86.16 L96.00,85.94 L98.00,85.74 L100.00,85.56 L102.00,85.40 L104.00,85.27 L106.00,85.16 L108.00,85.08 L108.00,108.00 Z"/>
</vector>
@@ -0,0 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp" android:height="108dp" android:viewportWidth="108" android:viewportHeight="108">
<path android:fillColor="#FFFFB02E" android:pathData="M78.41,44.00 L78.32,44.76 L78.08,45.49 L77.70,46.20 L77.25,46.87 L76.77,47.50 L76.32,48.10 L75.94,48.71 L75.65,49.33 L75.47,49.99 L75.37,50.70 L75.33,51.46 L75.29,52.25 L75.21,53.05 L75.04,53.83 L74.76,54.55 L74.33,55.19 L73.78,55.71 L73.12,56.12 L72.38,56.42 L71.61,56.64 L70.83,56.81 L70.10,56.99 L69.41,57.21 L68.80,57.50 L68.23,57.89 L67.70,58.37 L67.18,58.92 L66.64,59.50 L66.07,60.07 L65.44,60.56 L64.75,60.93 L64.02,61.14 L63.26,61.19 L62.49,61.08 L61.73,60.83 L61.00,60.50 L60.30,60.14 L59.62,59.80 L58.96,59.53 L58.29,59.36 L57.61,59.29 L56.90,59.32 L56.14,59.41 L55.36,59.50 L54.55,59.56 L53.76,59.54 L52.99,59.38 L52.30,59.08 L51.68,58.62 L51.17,58.04 L50.74,57.37 L50.39,56.64 L50.09,55.91 L49.79,55.21 L49.45,54.58 L49.06,54.02 L48.57,53.53 L48.01,53.10 L47.38,52.68 L46.71,52.25 L46.06,51.78 L45.46,51.24 L44.98,50.64 L44.64,49.95 L44.46,49.21 L44.44,48.44 L44.55,47.65 L44.75,46.87 L44.99,46.11 L45.20,45.38 L45.35,44.68 L45.41,44.00 L45.35,43.32 L45.20,42.62 L44.99,41.89 L44.75,41.13 L44.55,40.35 L44.44,39.56 L44.46,38.79 L44.64,38.05 L44.98,37.36 L45.46,36.76 L46.06,36.22 L46.71,35.75 L47.38,35.32 L48.01,34.90 L48.57,34.47 L49.06,33.98 L49.45,33.42 L49.79,32.79 L50.09,32.09 L50.39,31.36 L50.74,30.63 L51.17,29.96 L51.68,29.38 L52.30,28.92 L52.99,28.62 L53.76,28.46 L54.55,28.44 L55.36,28.50 L56.14,28.59 L56.90,28.68 L57.61,28.71 L58.29,28.64 L58.96,28.47 L59.62,28.20 L60.30,27.86 L61.00,27.50 L61.73,27.17 L62.49,26.92 L63.26,26.81 L64.02,26.86 L64.75,27.07 L65.44,27.44 L66.07,27.93 L66.64,28.50 L67.18,29.08 L67.70,29.63 L68.23,30.11 L68.80,30.50 L69.41,30.79 L70.10,31.01 L70.83,31.19 L71.61,31.36 L72.38,31.58 L73.12,31.88 L73.78,32.29 L74.33,32.81 L74.76,33.45 L75.04,34.17 L75.21,34.95 L75.29,35.75 L75.33,36.54 L75.37,37.30 L75.47,38.01 L75.65,38.67 L75.94,39.29 L76.32,39.90 L76.77,40.50 L77.25,41.13 L77.70,41.80 L78.08,42.51 L78.32,43.24 Z"/>
<path android:fillColor="#59FF9A1F" android:pathData="M61,44m-10,0a10,10 0 1,0 20,0a10,10 0 1,0 -20,0"/>
<group android:translateY="2.5"><path android:fillColor="#FFD5DEE8" android:pathData="M38,74 h30 a9,9 0 0 0 0,-18 a12,12 0 0 0 -22.5,-3.5 a10,10 0 0 0 -7.5,21.5 z"/></group>
<path android:fillColor="#FFFFFFFF" android:pathData="M38,74 h30 a9,9 0 0 0 0,-18 a12,12 0 0 0 -22.5,-3.5 a10,10 0 0 0 -7.5,21.5 z"/>
</vector>
@@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp" android:height="108dp" android:viewportWidth="108" android:viewportHeight="108">
<path android:fillColor="#FF000000" android:pathData="M78.41,44.00 L78.32,44.76 L78.08,45.49 L77.70,46.20 L77.25,46.87 L76.77,47.50 L76.32,48.10 L75.94,48.71 L75.65,49.33 L75.47,49.99 L75.37,50.70 L75.33,51.46 L75.29,52.25 L75.21,53.05 L75.04,53.83 L74.76,54.55 L74.33,55.19 L73.78,55.71 L73.12,56.12 L72.38,56.42 L71.61,56.64 L70.83,56.81 L70.10,56.99 L69.41,57.21 L68.80,57.50 L68.23,57.89 L67.70,58.37 L67.18,58.92 L66.64,59.50 L66.07,60.07 L65.44,60.56 L64.75,60.93 L64.02,61.14 L63.26,61.19 L62.49,61.08 L61.73,60.83 L61.00,60.50 L60.30,60.14 L59.62,59.80 L58.96,59.53 L58.29,59.36 L57.61,59.29 L56.90,59.32 L56.14,59.41 L55.36,59.50 L54.55,59.56 L53.76,59.54 L52.99,59.38 L52.30,59.08 L51.68,58.62 L51.17,58.04 L50.74,57.37 L50.39,56.64 L50.09,55.91 L49.79,55.21 L49.45,54.58 L49.06,54.02 L48.57,53.53 L48.01,53.10 L47.38,52.68 L46.71,52.25 L46.06,51.78 L45.46,51.24 L44.98,50.64 L44.64,49.95 L44.46,49.21 L44.44,48.44 L44.55,47.65 L44.75,46.87 L44.99,46.11 L45.20,45.38 L45.35,44.68 L45.41,44.00 L45.35,43.32 L45.20,42.62 L44.99,41.89 L44.75,41.13 L44.55,40.35 L44.44,39.56 L44.46,38.79 L44.64,38.05 L44.98,37.36 L45.46,36.76 L46.06,36.22 L46.71,35.75 L47.38,35.32 L48.01,34.90 L48.57,34.47 L49.06,33.98 L49.45,33.42 L49.79,32.79 L50.09,32.09 L50.39,31.36 L50.74,30.63 L51.17,29.96 L51.68,29.38 L52.30,28.92 L52.99,28.62 L53.76,28.46 L54.55,28.44 L55.36,28.50 L56.14,28.59 L56.90,28.68 L57.61,28.71 L58.29,28.64 L58.96,28.47 L59.62,28.20 L60.30,27.86 L61.00,27.50 L61.73,27.17 L62.49,26.92 L63.26,26.81 L64.02,26.86 L64.75,27.07 L65.44,27.44 L66.07,27.93 L66.64,28.50 L67.18,29.08 L67.70,29.63 L68.23,30.11 L68.80,30.50 L69.41,30.79 L70.10,31.01 L70.83,31.19 L71.61,31.36 L72.38,31.58 L73.12,31.88 L73.78,32.29 L74.33,32.81 L74.76,33.45 L75.04,34.17 L75.21,34.95 L75.29,35.75 L75.33,36.54 L75.37,37.30 L75.47,38.01 L75.65,38.67 L75.94,39.29 L76.32,39.90 L76.77,40.50 L77.25,41.13 L77.70,41.80 L78.08,42.51 L78.32,43.24 Z"/>
<path android:fillColor="#FF000000" android:strokeColor="#FFFFFFFF" android:strokeWidth="0" android:pathData="M38,74 h30 a9,9 0 0 0 0,-18 a12,12 0 0 0 -22.5,-3.5 a10,10 0 0 0 -7.5,21.5 z"/>
</vector>
@@ -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:gravity="center" android:padding="12dp">
<TextClock
android:id="@+id/clock_time"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:format24Hour="HH:mm" android:format12Hour="h:mm"
android:fontFamily="sans-serif-light" android:textSize="72sp" android:includeFontPadding="false"
android:letterSpacing="-0.02"
android:shadowColor="#66000000" android:shadowRadius="8" android:shadowDy="2" />
<LinearLayout
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:gravity="center_vertical" android:layout_marginTop="4dp">
<TextClock
android:id="@+id/clock_date"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:format24Hour="EEE, d. MMM" android:format12Hour="EEE, MMM d"
android:fontFamily="sans-serif-medium" android:textSize="16sp"
android:shadowColor="#66000000" android:shadowRadius="6" android:shadowDy="1" />
<TextView
android:id="@+id/clock_sep"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text=" · " android:textSize="16sp"
android:shadowColor="#66000000" android:shadowRadius="6" android:shadowDy="1" />
<ImageView
android:id="@+id/clock_icon"
android:layout_width="22dp" android:layout_height="22dp" android:importantForAccessibility="no" />
<TextView
android:id="@+id/clock_temp"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:fontFamily="sans-serif-medium" android:textSize="16sp"
android:shadowColor="#66000000" android:shadowRadius="6" android:shadowDy="1" />
</LinearLayout>
</LinearLayout>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
<monochrome android:drawable="@drawable/ic_launcher_monochrome"/>
</adaptive-icon>
+25 -5
View File
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Wetter</string>
<string name="cond_clear_day">Sonnig</string>
<string name="cond_clear_night">Klar</string>
@@ -93,6 +92,8 @@
<string name="perm_allow">Standort erlauben</string>
<string name="perm_search">Lieber einen Ort suchen</string>
<string name="loading_error">Wetterdaten konnten nicht geladen werden</string>
<string name="loading_error_busy">Der Wetterdienst ist gerade überlastet. Bitte gleich noch einmal versuchen.</string>
<string name="loading_error_offline">Keine Verbindung zum Internet</string>
<string name="set_units">Einheiten</string>
<string name="set_temp">Temperatur</string>
@@ -111,10 +112,29 @@
<string name="set_about">Datenquellen</string>
<string name="attribution">Wetterdaten: Open-Meteo.com (CC BY 4.0) · Ortsnamen: © OpenStreetMap-Mitwirkende</string>
<string name="widget_now_name">Wetter jetzt</string>
<string name="widget_now_desc">Temperatur und Wetterlage auf einen Blick</string>
<string name="widget_forecast_name">Vorhersage</string>
<string name="widget_forecast_desc">Jetzt, die nächsten Stunden und Tage</string>
<string name="widget_card_name">Wetterkarte</string>
<string name="widget_card_desc">Jetzt, die nächsten Stunden und Tage. Wächst mit der Größe.</string>
<string name="widget_pill_name">Wetter-Pille</string>
<string name="widget_pill_desc">Icon und Temperatur in einer Pille</string>
<string name="widget_tilt_name">Schräge Pille</string>
<string name="widget_tilt_desc">Temperatur in einer schrägen Form</string>
<string name="widget_bar_name">Wetterleiste</string>
<string name="widget_bar_desc">Heute auf einen Blick, eine Zeile</string>
<string name="widget_classic_name">Klassisch</string>
<string name="widget_classic_desc">Ort, Wetterlage und die nächsten Stunden</string>
<string name="widget_customize">Widget anpassen</string>
<string name="widget_location">Ort</string>
<string name="widget_content">Inhalt</string>
<string name="widget_colors">Farben</string>
<string name="widget_opacity">Deckkraft des Hintergrunds</string>
<string name="widget_opacity_hint">Bei wenig Deckkraft hängt die Lesbarkeit vom Hintergrundbild ab.</string>
<string name="widget_done">Fertig</string>
<string-array name="widget_palettes">
<item>Wallpaper</item><item>Wetterlage</item><item>Ozean</item><item>Wald</item><item>Sonne</item><item>Lavendel</item><item>Graphit</item>
</string-array>
<string name="widget_clock_name">Uhr &amp; Wetter</string>
<string name="widget_clock_desc">Große Uhrzeit, Datum und das aktuelle Wetter</string>
<string name="widget_source">Quelle: Open-Meteo</string>
<string name="widget_pick">Ort wählen</string>
<string name="widget_follow">Mein Standort (folgt dir)</string>
<string name="widget_loading">…</string>
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:description="@string/widget_bar_desc"
android:previewImage="@drawable/preview_bar"
android:initialLayout="@layout/glance_default_loading_layout"
android:minWidth="250dp" android:minHeight="60dp"
android:targetCellWidth="4" android:targetCellHeight="1"
android:minResizeWidth="200dp" android:minResizeHeight="48dp"
android:maxResizeWidth="600dp" android:maxResizeHeight="110dp"
android:resizeMode="horizontal|vertical"
android:updatePeriodMillis="3600000"
android:configure="app.wetter.widget.WidgetConfigActivity"
android:widgetFeatures="reconfigurable|configuration_optional"
android:widgetCategory="home_screen" />
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:description="@string/widget_card_desc"
android:previewImage="@drawable/preview_card"
android:initialLayout="@layout/glance_default_loading_layout"
android:minWidth="250dp" android:minHeight="180dp"
android:targetCellWidth="4" android:targetCellHeight="2"
android:minResizeWidth="180dp" android:minResizeHeight="110dp"
android:maxResizeWidth="600dp" android:maxResizeHeight="600dp"
android:resizeMode="horizontal|vertical"
android:updatePeriodMillis="3600000"
android:configure="app.wetter.widget.WidgetConfigActivity"
android:widgetFeatures="reconfigurable|configuration_optional"
android:widgetCategory="home_screen" />
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:description="@string/widget_classic_desc"
android:previewImage="@drawable/preview_classic"
android:initialLayout="@layout/glance_default_loading_layout"
android:minWidth="250dp" android:minHeight="150dp"
android:targetCellWidth="4" android:targetCellHeight="2"
android:minResizeWidth="140dp" android:minResizeHeight="150dp"
android:maxResizeWidth="400dp" android:maxResizeHeight="250dp"
android:resizeMode="horizontal|vertical"
android:updatePeriodMillis="3600000"
android:configure="app.wetter.widget.WidgetConfigActivity"
android:widgetFeatures="reconfigurable|configuration_optional"
android:widgetCategory="home_screen" />
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:description="@string/widget_clock_desc"
android:initialLayout="@layout/glance_default_loading_layout"
android:previewImage="@drawable/preview_clock"
android:minWidth="250dp" android:minHeight="110dp"
android:targetCellWidth="4" android:targetCellHeight="2"
android:minResizeWidth="180dp" android:minResizeHeight="80dp"
android:maxResizeWidth="600dp" android:maxResizeHeight="300dp"
android:resizeMode="horizontal|vertical"
android:updatePeriodMillis="3600000"
android:configure="app.wetter.widget.WidgetConfigActivity"
android:widgetFeatures="reconfigurable|configuration_optional"
android:widgetCategory="home_screen|keyguard" />
@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:description="@string/widget_forecast_desc"
android:initialLayout="@layout/glance_default_loading_layout"
android:minWidth="250dp" android:minHeight="110dp"
android:targetCellWidth="4" android:targetCellHeight="2"
android:minResizeWidth="250dp" android:minResizeHeight="110dp"
android:resizeMode="horizontal|vertical"
android:updatePeriodMillis="3600000"
android:widgetCategory="home_screen" />
@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:description="@string/widget_now_desc"
android:initialLayout="@layout/glance_default_loading_layout"
android:minWidth="110dp" android:minHeight="48dp"
android:targetCellWidth="2" android:targetCellHeight="2"
android:minResizeWidth="110dp" android:minResizeHeight="48dp"
android:resizeMode="horizontal|vertical"
android:updatePeriodMillis="3600000"
android:widgetCategory="home_screen|keyguard" />
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:description="@string/widget_pill_desc"
android:previewImage="@drawable/preview_pill"
android:initialLayout="@layout/glance_default_loading_layout"
android:minWidth="200dp" android:minHeight="110dp"
android:targetCellWidth="4" android:targetCellHeight="2"
android:minResizeWidth="110dp" android:minResizeHeight="48dp"
android:maxResizeWidth="400dp" android:maxResizeHeight="200dp"
android:resizeMode="horizontal|vertical"
android:updatePeriodMillis="3600000"
android:configure="app.wetter.widget.WidgetConfigActivity"
android:widgetFeatures="reconfigurable|configuration_optional"
android:widgetCategory="home_screen" />
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:description="@string/widget_tilt_desc"
android:previewImage="@drawable/preview_tilt"
android:initialLayout="@layout/glance_default_loading_layout"
android:minWidth="110dp" android:minHeight="110dp"
android:targetCellWidth="2" android:targetCellHeight="2"
android:minResizeWidth="80dp" android:minResizeHeight="80dp"
android:maxResizeWidth="300dp" android:maxResizeHeight="300dp"
android:resizeMode="horizontal|vertical"
android:updatePeriodMillis="3600000"
android:configure="app.wetter.widget.WidgetConfigActivity"
android:widgetFeatures="reconfigurable|configuration_optional"
android:widgetCategory="home_screen" />
@@ -0,0 +1,106 @@
package app.wetter
import androidx.compose.foundation.layout.Box
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.FormatListBulleted
import androidx.compose.material.icons.rounded.Settings
import androidx.compose.material3.FilledTonalButton
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onRoot
import app.wetter.data.Forecast
import app.wetter.data.OpenMeteo
import app.wetter.data.Quarter
import app.wetter.data.Settings
import app.wetter.data.ThemeMode
import app.wetter.ui.screens.DayContent
import app.wetter.ui.screens.ForecastPage
import app.wetter.ui.screens.SettingsScreen
import app.wetter.ui.theme.WeatherTheme
import com.github.takahirom.roborazzi.captureRoboImage
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
import org.robolectric.annotation.GraphicsMode
import java.time.LocalDateTime
/** Renders the screens on the JVM into replica/clone-screens/ for replica-diff. Data: a real Open-Meteo response. */
@RunWith(RobolectricTestRunner::class)
@GraphicsMode(GraphicsMode.Mode.NATIVE)
@Config(sdk = [35], qualifiers = "de-rDE-w412dp-h915dp-xxhdpi", application = android.app.Application::class)
class ScreenshotTest {
@get:Rule val compose = createComposeRule()
private fun fixture(): Forecast {
val f = javaClass.classLoader!!.getResource("berlin_forecast.json")!!.readText()
val a = javaClass.classLoader!!.getResource("berlin_air.json")!!.readText()
val parsed = OpenMeteo().parse(f, a, System.currentTimeMillis())
// pin "now" to the response's own current time so the shots never drift
val now = LocalDateTime.parse(Regex("\"current\":\\{\"time\":\"([^\"]+)\"").find(f)!!.groupValues[1])
return parsed.copy(clock = now)
}
private fun Forecast.with(code: Int, isDay: Boolean, rainSoon: Boolean = false): Forecast {
val minutely = if (!rainSoon) minutely else List(12) { i ->
Quarter(now.withMinute(0).plusMinutes(15L * i), if (i in 2..7) listOf(0.2, 0.5, 0.9, 1.4, 0.8, 0.3)[i - 2] else 0.0)
}
return copy(current = current.copy(code = code, isDay = isDay), minutely = minutely)
}
private fun shot(name: String, theme: ThemeMode, content: @Composable () -> Unit) {
compose.setContent { WeatherTheme(theme) { content() } }
compose.onRoot().captureRoboImage("../../replica/clone-screens/$name.png")
}
@Composable
private fun Home(f: Forecast, title: String = "Berlin", preview: Boolean = false) = ForecastPage(
title = title, isCurrent = !preview, forecast = f, settings = Settings(), animate = false,
refreshing = false, error = null, onRefresh = {},
navigation = { IconButton(onClick = {}) { Icon(Icons.Rounded.FormatListBulleted, null) } },
actions = {
if (preview) FilledTonalButton(onClick = {}) { Text("Speichern") }
else IconButton(onClick = {}) { Icon(Icons.Rounded.Settings, null) }
},
)
@Test fun parserReadsRealResponse() {
val f = fixture()
assertEquals(10, f.daily.size)
assertTrue(f.hourly.size >= 240)
assertTrue(f.upcomingHours(25).isNotEmpty())
assertTrue(f.air?.aqi != null)
}
@Test fun s01_real_light() = shot("S01-real-light", ThemeMode.LIGHT) { Home(fixture()) }
@Test fun s01_clear_day() = shot("S01-clear-day", ThemeMode.LIGHT) { Home(fixture().with(0, true)) }
@Test fun s01_clear_night_dark() = shot("S01-clear-night-dark", ThemeMode.DARK) { Home(fixture().with(0, false)) }
@Test fun s01_rain_nowcast() = shot("S01-rain-nowcast", ThemeMode.LIGHT) { Home(fixture().with(63, true, rainSoon = true)) }
@Test fun s01_snow() = shot("S01-snow", ThemeMode.LIGHT) { Home(fixture().with(73, true)) }
@Test fun s01_storm_dark() = shot("S01-storm-dark", ThemeMode.DARK) { Home(fixture().with(95, false)) }
@Config(qualifiers = "de-rDE-w412dp-h2600dp-xxhdpi")
@Test fun s01_full_light() = shot("S01-full-light", ThemeMode.LIGHT) { Home(fixture().with(2, true)) }
@Config(qualifiers = "de-rDE-w412dp-h2600dp-xxhdpi")
@Test fun s01_full_dark() = shot("S01-full-dark", ThemeMode.DARK) { Home(fixture().with(0, false)) }
@Config(qualifiers = "de-rDE-w412dp-h1800dp-xxhdpi")
@Test fun s04_day_dark() = shot("S04-day-dark", ThemeMode.DARK) {
val f = fixture()
DayContent(f, "Berlin", f.daily[1].date, Settings(), onBack = {})
}
@Test fun s15_preview() = shot("S15-preview", ThemeMode.LIGHT) { Home(fixture().with(1, true), "Zwickau", preview = true) }
@Test fun s08_settings() = shot("S08-settings", ThemeMode.LIGHT) { SettingsScreen(Settings(), onBack = {}) }
@Test fun s08_settings_dark() = shot("S08-settings-dark", ThemeMode.DARK) { SettingsScreen(Settings(), onBack = {}) }
@Config(qualifiers = "de-rDE-w840dp-h900dp-xxhdpi")
@Test fun s01_tablet() = shot("S01-tablet", ThemeMode.LIGHT) { Box { Home(fixture().with(2, true)) } }
}
@@ -0,0 +1 @@
{"latitude":52.5,"longitude":13.400002,"generationtime_ms":0.6562471389770508,"utc_offset_seconds":7200,"timezone":"Europe/Berlin","timezone_abbreviation":"GMT+2","elevation":38.0,"current_units":{"time":"iso8601","interval":"seconds","european_aqi":"EAQI","pm2_5":"μg/m³","pm10":"μg/m³","alder_pollen":"grains/m³","birch_pollen":"grains/m³","grass_pollen":"grains/m³","mugwort_pollen":"grains/m³","olive_pollen":"grains/m³","ragweed_pollen":"grains/m³"},"current":{"time":"2026-10-17T13:00","interval":3600,"european_aqi":20,"pm2_5":5.0,"pm10":5.1,"alder_pollen":0.0,"birch_pollen":0.0,"grass_pollen":0.0,"mugwort_pollen":0.0,"olive_pollen":0.0,"ragweed_pollen":0.0}}
@@ -0,0 +1 @@
{"latitude":52.512604,"longitude":13.419517,"generationtime_ms":5132.478952407837,"utc_offset_seconds":7200,"timezone":"Europe/Berlin","timezone_abbreviation":"GMT+2","elevation":38.0,"current_units":{"time":"iso8601","interval":"seconds","temperature_2m":"°C","apparent_temperature":"°C","weather_code":"wmo code","is_day":"","relative_humidity_2m":"%","dew_point_2m":"°C","wind_speed_10m":"km/h","wind_direction_10m":"°","wind_gusts_10m":"km/h","pressure_msl":"hPa","visibility":"m","uv_index":""},"current":{"time":"2026-10-17T13:45","interval":900,"temperature_2m":12.2,"apparent_temperature":10.4,"weather_code":3,"is_day":1,"relative_humidity_2m":85,"dew_point_2m":9.8,"wind_speed_10m":12.4,"wind_direction_10m":343,"wind_gusts_10m":27.7,"pressure_msl":1018.6,"visibility":23900.00,"uv_index":0.35},"minutely_15_units":{"time":"iso8601","precipitation":"mm"},"minutely_15":{"time":["2026-10-17T13:45","2026-10-17T14:00","2026-10-17T14:15","2026-10-17T14:30","2026-10-17T14:45","2026-10-17T15:00","2026-10-17T15:15","2026-10-17T15:30","2026-10-17T15:45","2026-10-17T16:00","2026-10-17T16:15","2026-10-17T16:30","2026-10-17T16:45","2026-10-17T17:00","2026-10-17T17:15","2026-10-17T17:30"],"precipitation":[0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.10,0.30,0.50,0.30,0.10,0.00,0.00,0.00]},"hourly_units":{"time":"iso8601","temperature_2m":"°C","weather_code":"wmo code","is_day":"","precipitation_probability":"%","precipitation":"mm","wind_speed_10m":"km/h","relative_humidity_2m":"%"},"hourly":{"time":["2026-10-17T00:00","2026-10-17T01:00","2026-10-17T02:00","2026-10-17T03:00","2026-10-17T04:00","2026-10-17T05:00","2026-10-17T06:00","2026-10-17T07:00","2026-10-17T08:00","2026-10-17T09:00","2026-10-17T10:00","2026-10-17T11:00","2026-10-17T12:00","2026-10-17T13:00","2026-10-17T14:00","2026-10-17T15:00","2026-10-17T16:00","2026-10-17T17:00","2026-10-17T18:00","2026-10-17T19:00","2026-10-17T20:00","2026-10-17T21:00","2026-10-17T22:00","2026-10-17T23:00","2026-10-18T00:00","2026-10-18T01:00","2026-10-18T02:00","2026-10-18T03:00","2026-10-18T04:00","2026-10-18T05:00","2026-10-18T06:00","2026-10-18T07:00","2026-10-18T08:00","2026-10-18T09:00","2026-10-18T10:00","2026-10-18T11:00","2026-10-18T12:00","2026-10-18T13:00","2026-10-18T14:00","2026-10-18T15:00","2026-10-18T16:00","2026-10-18T17:00","2026-10-18T18:00","2026-10-18T19:00","2026-10-18T20:00","2026-10-18T21:00","2026-10-18T22:00","2026-10-18T23:00","2026-10-19T00:00","2026-10-19T01:00","2026-10-19T02:00","2026-10-19T03:00","2026-10-19T04:00","2026-10-19T05:00","2026-10-19T06:00","2026-10-19T07:00","2026-10-19T08:00","2026-10-19T09:00","2026-10-19T10:00","2026-10-19T11:00","2026-10-19T12:00","2026-10-19T13:00","2026-10-19T14:00","2026-10-19T15:00","2026-10-19T16:00","2026-10-19T17:00","2026-10-19T18:00","2026-10-19T19:00","2026-10-19T20:00","2026-10-19T21:00","2026-10-19T22:00","2026-10-19T23:00","2026-10-20T00:00","2026-10-20T01:00","2026-10-20T02:00","2026-10-20T03:00","2026-10-20T04:00","2026-10-20T05:00","2026-10-20T06:00","2026-10-20T07:00","2026-10-20T08:00","2026-10-20T09:00","2026-10-20T10:00","2026-10-20T11:00","2026-10-20T12:00","2026-10-20T13:00","2026-10-20T14:00","2026-10-20T15:00","2026-10-20T16:00","2026-10-20T17:00","2026-10-20T18:00","2026-10-20T19:00","2026-10-20T20:00","2026-10-20T21:00","2026-10-20T22:00","2026-10-20T23:00","2026-10-21T00:00","2026-10-21T01:00","2026-10-21T02:00","2026-10-21T03:00","2026-10-21T04:00","2026-10-21T05:00","2026-10-21T06:00","2026-10-21T07:00","2026-10-21T08:00","2026-10-21T09:00","2026-10-21T10:00","2026-10-21T11:00","2026-10-21T12:00","2026-10-21T13:00","2026-10-21T14:00","2026-10-21T15:00","2026-10-21T16:00","2026-10-21T17:00","2026-10-21T18:00","2026-10-21T19:00","2026-10-21T20:00","2026-10-21T21:00","2026-10-21T22:00","2026-10-21T23:00","2026-10-22T00:00","2026-10-22T01:00","2026-10-22T02:00","2026-10-22T03:00","2026-10-22T04:00","2026-10-22T05:00","2026-10-22T06:00","2026-10-22T07:00","2026-10-22T08:00","2026-10-22T09:00","2026-10-22T10:00","2026-10-22T11:00","2026-10-22T12:00","2026-10-22T13:00","2026-10-22T14:00","2026-10-22T15:00","2026-10-22T16:00","2026-10-22T17:00","2026-10-22T18:00","2026-10-22T19:00","2026-10-22T20:00","2026-10-22T21:00","2026-10-22T22:00","2026-10-22T23:00","2026-10-23T00:00","2026-10-23T01:00","2026-10-23T02:00","2026-10-23T03:00","2026-10-23T04:00","2026-10-23T05:00","2026-10-23T06:00","2026-10-23T07:00","2026-10-23T08:00","2026-10-23T09:00","2026-10-23T10:00","2026-10-23T11:00","2026-10-23T12:00","2026-10-23T13:00","2026-10-23T14:00","2026-10-23T15:00","2026-10-23T16:00","2026-10-23T17:00","2026-10-23T18:00","2026-10-23T19:00","2026-10-23T20:00","2026-10-23T21:00","2026-10-23T22:00","2026-10-23T23:00","2026-10-24T00:00","2026-10-24T01:00","2026-10-24T02:00","2026-10-24T03:00","2026-10-24T04:00","2026-10-24T05:00","2026-10-24T06:00","2026-10-24T07:00","2026-10-24T08:00","2026-10-24T09:00","2026-10-24T10:00","2026-10-24T11:00","2026-10-24T12:00","2026-10-24T13:00","2026-10-24T14:00","2026-10-Line truncated
@@ -0,0 +1 @@
{"reason":"The service is overloaded","error":true}
@@ -0,0 +1 @@
{"latitude":48.853382,"longitude":2.355208,"generationtime_ms":5108.713507652283,"utc_offset_seconds":7200,"timezone":"Europe/Paris","timezone_abbreviation":"GMT+2","elevation":46.0,"current_units":{"time":"iso8601","interval":"seconds","temperature_2m":"°C","apparent_temperature":"°C","weather_code":"wmo code","is_day":"","relative_humidity_2m":"%","dew_point_2m":"°C","wind_speed_10m":"km/h","wind_direction_10m":"°","wind_gusts_10m":"km/h","pressure_msl":"hPa","visibility":"m","uv_index":""},"current":{"time":"2026-10-17T14:00","interval":900,"temperature_2m":15.1,"apparent_temperature":11.2,"weather_code":2,"is_day":1,"relative_humidity_2m":51,"dew_point_2m":5.0,"wind_speed_10m":17.8,"wind_direction_10m":21,"wind_gusts_10m":38.5,"pressure_msl":1028.0,"visibility":40940.00,"uv_index":3.30},"minutely_15_units":{"time":"iso8601","precipitation":"mm"},"minutely_15":{"time":["2026-10-17T14:00","2026-10-17T14:15","2026-10-17T14:30","2026-10-17T14:45","2026-10-17T15:00","2026-10-17T15:15","2026-10-17T15:30","2026-10-17T15:45","2026-10-17T16:00","2026-10-17T16:15","2026-10-17T16:30","2026-10-17T16:45","2026-10-17T17:00","2026-10-17T17:15","2026-10-17T17:30","2026-10-17T17:45"],"precipitation":[0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00]},"hourly_units":{"time":"iso8601","temperature_2m":"°C","weather_code":"wmo code","is_day":"","precipitation_probability":"%","precipitation":"mm","wind_speed_10m":"km/h","relative_humidity_2m":"%"},"hourly":{"time":["2026-10-17T00:00","2026-10-17T01:00","2026-10-17T02:00","2026-10-17T03:00","2026-10-17T04:00","2026-10-17T05:00","2026-10-17T06:00","2026-10-17T07:00","2026-10-17T08:00","2026-10-17T09:00","2026-10-17T10:00","2026-10-17T11:00","2026-10-17T12:00","2026-10-17T13:00","2026-10-17T14:00","2026-10-17T15:00","2026-10-17T16:00","2026-10-17T17:00","2026-10-17T18:00","2026-10-17T19:00","2026-10-17T20:00","2026-10-17T21:00","2026-10-17T22:00","2026-10-17T23:00","2026-10-18T00:00","2026-10-18T01:00","2026-10-18T02:00","2026-10-18T03:00","2026-10-18T04:00","2026-10-18T05:00","2026-10-18T06:00","2026-10-18T07:00","2026-10-18T08:00","2026-10-18T09:00","2026-10-18T10:00","2026-10-18T11:00","2026-10-18T12:00","2026-10-18T13:00","2026-10-18T14:00","2026-10-18T15:00","2026-10-18T16:00","2026-10-18T17:00","2026-10-18T18:00","2026-10-18T19:00","2026-10-18T20:00","2026-10-18T21:00","2026-10-18T22:00","2026-10-18T23:00","2026-10-19T00:00","2026-10-19T01:00","2026-10-19T02:00","2026-10-19T03:00","2026-10-19T04:00","2026-10-19T05:00","2026-10-19T06:00","2026-10-19T07:00","2026-10-19T08:00","2026-10-19T09:00","2026-10-19T10:00","2026-10-19T11:00","2026-10-19T12:00","2026-10-19T13:00","2026-10-19T14:00","2026-10-19T15:00","2026-10-19T16:00","2026-10-19T17:00","2026-10-19T18:00","2026-10-19T19:00","2026-10-19T20:00","2026-10-19T21:00","2026-10-19T22:00","2026-10-19T23:00","2026-10-20T00:00","2026-10-20T01:00","2026-10-20T02:00","2026-10-20T03:00","2026-10-20T04:00","2026-10-20T05:00","2026-10-20T06:00","2026-10-20T07:00","2026-10-20T08:00","2026-10-20T09:00","2026-10-20T10:00","2026-10-20T11:00","2026-10-20T12:00","2026-10-20T13:00","2026-10-20T14:00","2026-10-20T15:00","2026-10-20T16:00","2026-10-20T17:00","2026-10-20T18:00","2026-10-20T19:00","2026-10-20T20:00","2026-10-20T21:00","2026-10-20T22:00","2026-10-20T23:00","2026-10-21T00:00","2026-10-21T01:00","2026-10-21T02:00","2026-10-21T03:00","2026-10-21T04:00","2026-10-21T05:00","2026-10-21T06:00","2026-10-21T07:00","2026-10-21T08:00","2026-10-21T09:00","2026-10-21T10:00","2026-10-21T11:00","2026-10-21T12:00","2026-10-21T13:00","2026-10-21T14:00","2026-10-21T15:00","2026-10-21T16:00","2026-10-21T17:00","2026-10-21T18:00","2026-10-21T19:00","2026-10-21T20:00","2026-10-21T21:00","2026-10-21T22:00","2026-10-21T23:00","2026-10-22T00:00","2026-10-22T01:00","2026-10-22T02:00","2026-10-22T03:00","2026-10-22T04:00","2026-10-22T05:00","2026-10-22T06:00","2026-10-22T07:00","2026-10-22T08:00","2026-10-22T09:00","2026-10-22T10:00","2026-10-22T11:00","2026-10-22T12:00","2026-10-22T13:00","2026-10-22T14:00","2026-10-22T15:00","2026-10-22T16:00","2026-10-22T17:00","2026-10-22T18:00","2026-10-22T19:00","2026-10-22T20:00","2026-10-22T21:00","2026-10-22T22:00","2026-10-22T23:00","2026-10-23T00:00","2026-10-23T01:00","2026-10-23T02:00","2026-10-23T03:00","2026-10-23T04:00","2026-10-23T05:00","2026-10-23T06:00","2026-10-23T07:00","2026-10-23T08:00","2026-10-23T09:00","2026-10-23T10:00","2026-10-23T11:00","2026-10-23T12:00","2026-10-23T13:00","2026-10-23T14:00","2026-10-23T15:00","2026-10-23T16:00","2026-10-23T17:00","2026-10-23T18:00","2026-10-23T19:00","2026-10-23T20:00","2026-10-23T21:00","2026-10-23T22:00","2026-10-23T23:00","2026-10-24T00:00","2026-10-24T01:00","2026-10-24T02:00","2026-10-24T03:00","2026-10-24T04:00","2026-10-24T05:00","2026-10-24T06:00","2026-10-24T07:00","2026-10-24T08:00","2026-10-24T09:00","2026-10-24T10:00","2026-10-24T11:00","2026-10-24T12:00","2026-10-24T13:00","2026-10-24T14:00","2026-10-24TLine truncated
@@ -0,0 +1 @@
{"latitude":64.139565,"longitude":-21.971603,"generationtime_ms":1892.8502798080444,"utc_offset_seconds":0,"timezone":"Atlantic/Reykjavik","timezone_abbreviation":"GMT","elevation":0.0,"current_units":{"time":"iso8601","interval":"seconds","temperature_2m":"°C","apparent_temperature":"°C","weather_code":"wmo code","is_day":"","relative_humidity_2m":"%","dew_point_2m":"°C","wind_speed_10m":"km/h","wind_direction_10m":"°","wind_gusts_10m":"km/h","pressure_msl":"hPa","visibility":"m","uv_index":""},"current":{"time":"2026-10-17T12:00","interval":900,"temperature_2m":8.8,"apparent_temperature":1.5,"weather_code":3,"is_day":1,"relative_humidity_2m":75,"dew_point_2m":4.6,"wind_speed_10m":40.7,"wind_direction_10m":151,"wind_gusts_10m":72.4,"pressure_msl":1015.0,"visibility":50000.00,"uv_index":0.70},"minutely_15_units":{"time":"iso8601","precipitation":"mm"},"minutely_15":{"time":["2026-10-17T12:00","2026-10-17T12:15","2026-10-17T12:30","2026-10-17T12:45","2026-10-17T13:00","2026-10-17T13:15","2026-10-17T13:30","2026-10-17T13:45","2026-10-17T14:00","2026-10-17T14:15","2026-10-17T14:30","2026-10-17T14:45","2026-10-17T15:00","2026-10-17T15:15","2026-10-17T15:30","2026-10-17T15:45"],"precipitation":[0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.10,0.10,0.10,0.10,0.50,0.50,0.50]},"hourly_units":{"time":"iso8601","temperature_2m":"°C","weather_code":"wmo code","is_day":"","precipitation_probability":"%","precipitation":"mm","wind_speed_10m":"km/h","relative_humidity_2m":"%"},"hourly":{"time":["2026-10-17T00:00","2026-10-17T01:00","2026-10-17T02:00","2026-10-17T03:00","2026-10-17T04:00","2026-10-17T05:00","2026-10-17T06:00","2026-10-17T07:00","2026-10-17T08:00","2026-10-17T09:00","2026-10-17T10:00","2026-10-17T11:00","2026-10-17T12:00","2026-10-17T13:00","2026-10-17T14:00","2026-10-17T15:00","2026-10-17T16:00","2026-10-17T17:00","2026-10-17T18:00","2026-10-17T19:00","2026-10-17T20:00","2026-10-17T21:00","2026-10-17T22:00","2026-10-17T23:00","2026-10-18T00:00","2026-10-18T01:00","2026-10-18T02:00","2026-10-18T03:00","2026-10-18T04:00","2026-10-18T05:00","2026-10-18T06:00","2026-10-18T07:00","2026-10-18T08:00","2026-10-18T09:00","2026-10-18T10:00","2026-10-18T11:00","2026-10-18T12:00","2026-10-18T13:00","2026-10-18T14:00","2026-10-18T15:00","2026-10-18T16:00","2026-10-18T17:00","2026-10-18T18:00","2026-10-18T19:00","2026-10-18T20:00","2026-10-18T21:00","2026-10-18T22:00","2026-10-18T23:00","2026-10-19T00:00","2026-10-19T01:00","2026-10-19T02:00","2026-10-19T03:00","2026-10-19T04:00","2026-10-19T05:00","2026-10-19T06:00","2026-10-19T07:00","2026-10-19T08:00","2026-10-19T09:00","2026-10-19T10:00","2026-10-19T11:00","2026-10-19T12:00","2026-10-19T13:00","2026-10-19T14:00","2026-10-19T15:00","2026-10-19T16:00","2026-10-19T17:00","2026-10-19T18:00","2026-10-19T19:00","2026-10-19T20:00","2026-10-19T21:00","2026-10-19T22:00","2026-10-19T23:00","2026-10-20T00:00","2026-10-20T01:00","2026-10-20T02:00","2026-10-20T03:00","2026-10-20T04:00","2026-10-20T05:00","2026-10-20T06:00","2026-10-20T07:00","2026-10-20T08:00","2026-10-20T09:00","2026-10-20T10:00","2026-10-20T11:00","2026-10-20T12:00","2026-10-20T13:00","2026-10-20T14:00","2026-10-20T15:00","2026-10-20T16:00","2026-10-20T17:00","2026-10-20T18:00","2026-10-20T19:00","2026-10-20T20:00","2026-10-20T21:00","2026-10-20T22:00","2026-10-20T23:00","2026-10-21T00:00","2026-10-21T01:00","2026-10-21T02:00","2026-10-21T03:00","2026-10-21T04:00","2026-10-21T05:00","2026-10-21T06:00","2026-10-21T07:00","2026-10-21T08:00","2026-10-21T09:00","2026-10-21T10:00","2026-10-21T11:00","2026-10-21T12:00","2026-10-21T13:00","2026-10-21T14:00","2026-10-21T15:00","2026-10-21T16:00","2026-10-21T17:00","2026-10-21T18:00","2026-10-21T19:00","2026-10-21T20:00","2026-10-21T21:00","2026-10-21T22:00","2026-10-21T23:00","2026-10-22T00:00","2026-10-22T01:00","2026-10-22T02:00","2026-10-22T03:00","2026-10-22T04:00","2026-10-22T05:00","2026-10-22T06:00","2026-10-22T07:00","2026-10-22T08:00","2026-10-22T09:00","2026-10-22T10:00","2026-10-22T11:00","2026-10-22T12:00","2026-10-22T13:00","2026-10-22T14:00","2026-10-22T15:00","2026-10-22T16:00","2026-10-22T17:00","2026-10-22T18:00","2026-10-22T19:00","2026-10-22T20:00","2026-10-22T21:00","2026-10-22T22:00","2026-10-22T23:00","2026-10-23T00:00","2026-10-23T01:00","2026-10-23T02:00","2026-10-23T03:00","2026-10-23T04:00","2026-10-23T05:00","2026-10-23T06:00","2026-10-23T07:00","2026-10-23T08:00","2026-10-23T09:00","2026-10-23T10:00","2026-10-23T11:00","2026-10-23T12:00","2026-10-23T13:00","2026-10-23T14:00","2026-10-23T15:00","2026-10-23T16:00","2026-10-23T17:00","2026-10-23T18:00","2026-10-23T19:00","2026-10-23T20:00","2026-10-23T21:00","2026-10-23T22:00","2026-10-23T23:00","2026-10-24T00:00","2026-10-24T01:00","2026-10-24T02:00","2026-10-24T03:00","2026-10-24T04:00","2026-10-24T05:00","2026-10-24T06:00","2026-10-24T07:00","2026-10-24T08:00","2026-10-24T09:00","2026-10-24T10:00","2026-10-24T11:00","2026-10-24T12:00","2026-10-24T13:00","2026-10-24T14:00","2026-10-2Line truncated