7 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
57 changed files with 2018 additions and 328 deletions

No files matched your search

+3
View File
@@ -0,0 +1,3 @@
.giteatoken
*.jks
keystore.properties
+38 -11
View File
@@ -8,7 +8,7 @@
| App | Replaces | Status | Install |
| --- | --- | --- | --- |
| **Wetter** (`wetter/`) | Google Weather / Pixel Weather | alpha, in daily testing | [Obtainium](#install-with-obtainium) · F-Droid: not yet |
| **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)).
@@ -19,8 +19,26 @@ A weather app with the look and feel of Pixel Weather: an animated sky that chan
- **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, and two home-screen widgets ("Now" 2×1/2×2 and "Forecast" 4×2/4×3).
- **Coming next:** severe weather alerts (DWD / MeteoAlarm), more widget sizes and a widget configuration screen, precipitation radar map, card reordering, notifications.
- **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.
@@ -28,17 +46,26 @@ Requires Android 10 (API 29) or newer.
[Obtainium](https://github.com/ImranR98/Obtainium) installs and updates apps straight from this repository's releases, with no store in between.
**One-tap link for Wetter** (open it on your phone with Obtainium installed):
### Wetter
[Add Wetter to 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%22preferredApkIndex%22%3A0%2C%22additionalSettings%22%3A%22%7B%5C%22apkFilterRegEx%5C%22%3A%20%5C%22wetter%5C%22%2C%20%5C%22filterReleaseTitlesByRegEx%5C%22%3A%20%5C%22%5EWetter%5C%22%2C%20%5C%22includePrereleases%5C%22%3A%20true%2C%20%5C%22fallbackToOlderReleases%5C%22%3A%20true%2C%20%5C%22autoApkFilterByArch%5C%22%3A%20true%7D%22%7D)
[<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)
**Or add it by hand:** in Obtainium tap *Add app*, paste `https://git.mrblake.cc/MrBlake/NoGooleApps`, and set:
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:
- *Override source*: **Forgejo / Codeberg** (this repository runs on a self-hosted Gitea, which speaks the same release API)
- *Filter release titles by regular expression*: `^Wetter`
- *Filter APKs by regular expression*: `wetter`
| 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 |
Because several apps live in one repository, every release is titled after its app (for example `Wetter 0.1.0`) and its APK is named after it (`wetter-0.1.0.apk`). The filters above make sure Obtainium only ever picks up the weather app.
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).
@@ -83,7 +110,7 @@ cd wetter
./gradlew :app:recordRoborazziDebug # re-render replica/clone-screens/
```
Local release builds are signed with the debug key so they install over each other. Published releases will use a dedicated signing key.
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
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.

After

Width:  |  Height:  |  Size: 152 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 158 KiB

After

Width:  |  Height:  |  Size: 148 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)"
+27 -6
View File
@@ -1,3 +1,5 @@
import java.util.Properties
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
@@ -15,16 +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
// local installs only; a real release key comes with /replica-deploy
signingConfig = signingConfigs.getByName("debug")
signingConfig = signingConfigs.findByName("release") ?: signingConfigs.getByName("debug")
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}
@@ -61,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'")
}
}
}
}
@@ -127,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)
@@ -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,34 +1,35 @@
package app.wetter.ui.screens
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
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.selection.selectableGroup
import androidx.compose.foundation.selection.toggleable
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.SegmentedButton
import androidx.compose.material3.SegmentedButtonDefaults
import androidx.compose.material3.SingleChoiceSegmentedButtonRow
import androidx.compose.material3.Switch
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.material3.rememberTopAppBarState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.heading
import androidx.compose.ui.semantics.semantics
import app.wetter.R
import app.wetter.data.DistanceUnit
import app.wetter.data.Graph
@@ -38,8 +39,10 @@ import app.wetter.data.Settings
import app.wetter.data.TempUnit
import app.wetter.data.ThemeMode
import app.wetter.data.WindUnit
import app.wetter.ui.theme.WSpace
import app.wetter.ui.theme.WType
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. */
@@ -48,73 +51,48 @@ import kotlinx.coroutines.launch
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 = {
TopAppBar(
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 ->
Column(Modifier.padding(pad).verticalScroll(rememberScrollState()).padding(horizontal = WSpace.s16)) {
Header(stringResource(R.string.set_units))
Choice(stringResource(R.string.set_temp), TempUnit.entries, settings.temp, { if (it == TempUnit.C) "°C" else "°F" }) { v -> set { it.copy(temp = v) } }
Choice(stringResource(R.string.set_wind), WindUnit.entries, settings.wind, {
when (it) { WindUnit.KMH -> "km/h"; WindUnit.MS -> "m/s"; WindUnit.MPH -> "mph"; WindUnit.KN -> "kn" }
}) { v -> set { it.copy(wind = v) } }
Choice(stringResource(R.string.set_precip), PrecipUnit.entries, settings.precip, { if (it == PrecipUnit.MM) "mm" else "in" }) { v -> set { it.copy(precip = v) } }
Choice(stringResource(R.string.set_pressure), PressureUnit.entries, settings.pressure, { if (it == PressureUnit.HPA) "hPa" else "inHg" }) { v -> set { it.copy(pressure = v) } }
Choice(stringResource(R.string.set_distance), DistanceUnit.entries, settings.distance, { if (it == DistanceUnit.KM) "km" else "mi" }) { v -> set { it.copy(distance = v) } }
Header(stringResource(R.string.set_look))
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),
)
Choice(stringResource(R.string.set_theme), ThemeMode.entries, settings.theme, { themeLabels.getValue(it) }) { v -> set { it.copy(theme = v) } }
Toggle(stringResource(R.string.set_animations), stringResource(R.string.set_animations_sub), settings.animations) { v -> set { it.copy(animations = v) } }
Toggle(stringResource(R.string.set_brief), null, settings.brief) { v -> set { it.copy(brief = v) } }
Header(stringResource(R.string.set_about))
Text(stringResource(R.string.attribution), style = WType.bodySm, color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.padding(bottom = WSpace.s32))
}
}
}
@Composable
private fun Header(text: String) = Text(
text, style = WType.title, color = MaterialTheme.colorScheme.primary,
modifier = Modifier.padding(top = WSpace.s24, bottom = WSpace.s8).semantics { heading() },
)
@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun <T> Choice(label: String, options: List<T>, selected: T, name: (T) -> String, onPick: (T) -> Unit) {
Column(Modifier.padding(vertical = WSpace.s8)) {
Text(label, style = WType.body)
SingleChoiceSegmentedButtonRow(Modifier.fillMaxWidth().padding(top = WSpace.s8).selectableGroup()) {
options.forEachIndexed { i, o ->
SegmentedButton(
selected = o == selected,
onClick = { onPick(o) },
shape = SegmentedButtonDefaults.itemShape(i, options.size),
) { Text(name(o)) }
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))
}
}
}
@Composable
private fun Toggle(label: String, sub: String?, checked: Boolean, onChange: (Boolean) -> Unit) {
Row(
Modifier.fillMaxWidth().toggleable(checked, role = Role.Switch, onValueChange = onChange).padding(vertical = WSpace.s12),
verticalAlignment = Alignment.CenterVertically,
) {
Column(Modifier.weight(1f)) {
Text(label, style = WType.body)
if (sub != null) Text(sub, style = WType.bodySm, color = MaterialTheme.colorScheme.onSurfaceVariant)
}
Switch(checked, onCheckedChange = null)
}
}
@@ -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 {
@@ -1,22 +1,44 @@
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.Brush
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.scene.Particles
import app.wetter.ui.scene.SceneSpec
import app.wetter.ui.scene.drawSceneLayers
import app.wetter.ui.components.wavyCircle
import app.wetter.ui.scene.drawWeatherIcon
import app.wetter.ui.theme.WColor
/** Widgets cannot run shaders or animations, so the scene and icons are rendered to bitmaps. */
/** 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)
@@ -26,9 +48,17 @@ object WidgetArt {
fun icon(condition: Condition, isDay: Boolean, px: Int = 144): Bitmap = render(px, px) { drawWeatherIcon(condition, isDay) }
/** Still frame of the sky, small enough for the RemoteViews size limit. */
fun scene(spec: SceneSpec, w: Int = 480, h: Int = 320): Bitmap = render(w, h) {
drawRect(Brush.verticalGradient(listOf(spec.top, spec.bottom)))
drawSceneLayers(spec, t = .2f, scroll = 0f, particles = Particles.make(spec.condition))
/** 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)
}
@@ -1,6 +1,7 @@
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
@@ -12,18 +13,16 @@ import androidx.glance.Image
import androidx.glance.ImageProvider
import androidx.glance.LocalContext
import androidx.glance.LocalSize
import androidx.glance.action.ActionParameters
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.ActionCallback
import androidx.glance.appwidget.action.actionRunCallback
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
@@ -42,7 +41,7 @@ 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 as FixedColor
import androidx.glance.unit.ColorProvider
import app.wetter.MainActivity
import app.wetter.R
import app.wetter.data.Forecast
@@ -52,102 +51,256 @@ import app.wetter.data.LocationEntity
import app.wetter.data.Settings
import app.wetter.data.Units
import app.wetter.data.conditionOf
import app.wetter.data.intensityOf
import app.wetter.ui.components.conditionLabel
import app.wetter.ui.scene.SceneSpec
import app.wetter.ui.theme.WRadius
import app.wetter.work.RefreshWorker
import kotlinx.coroutines.flow.first
import java.time.LocalDate
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) {
NowWidget().updateAll(context)
ForecastWidget().updateAll(context)
val manager = GlanceAppWidgetManager(context)
for ((make, receiver) in ALL_WIDGETS) {
val widget = make()
manager.getGlanceIds(widget.javaClass).forEach { runCatching { refreshWidget(context, widget, it) } }
}
}
private class WidgetData(val location: LocationEntity?, val forecast: Forecast?, val units: Units)
/** 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) } }
}
private suspend fun load(context: Context, id: GlanceId): WidgetData {
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)
val appWidgetId = GlanceAppWidgetManager(context).getAppWidgetId(id)
val location = Graph.repo.widgetLocation(appWidgetId)
// 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())
return WidgetData(location, forecast, Units(settings))
val style = config?.let { WidgetStyle(it.style, it.theme, it.opacity) } ?: defaultStyle
return WidgetData(location, forecast, Units(settings), resolvePalette(context, style, forecast))
}
class RefreshAction : ActionCallback {
override suspend fun onAction(context: Context, glanceId: GlanceId, parameters: ActionParameters) {
RefreshWorker.runNow(context)
}
}
/** Shared frame: scene bitmap behind, rounded, tap opens the city. */
@Composable
private fun Frame(data: WidgetData, content: @Composable (SceneSpec) -> Unit) {
val context = LocalContext.current
val f = data.forecast
val spec = f?.let { SceneSpec(conditionOf(it.current.code), it.current.isDay, intensityOf(it.current.code)) }
?: SceneSpec(app.wetter.data.Condition.CLOUDY, true)
Box(
GlanceModifier.fillMaxSize().cornerRadius(WRadius.widget)
.clickable(actionStartActivity(MainActivity.intent(context, data.location?.id))),
) {
Image(ImageProvider(WidgetArt.scene(spec)), null, GlanceModifier.fillMaxSize(), contentScale = ContentScale.FillBounds)
content(spec)
}
}
private fun text(color: Color, size: Int, weight: FontWeight = FontWeight.Normal, align: TextAlign = TextAlign.Start) =
TextStyle(color = FixedColor(color), fontSize = size.sp, fontWeight = weight, textAlign = align)
/** 2×1 and 2×2: icon + temperature, larger adds city, condition, high/low. */
class NowWidget : GlanceAppWidget() {
override val sizeMode = SizeMode.Responsive(setOf(SMALL, MEDIUM))
/** 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 data = load(context, id)
provideContent { Content(data) }
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
private fun Content(data: WidgetData) {
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
Frame(data) { spec ->
val fg = spec.onScene
val f = data.forecast
if (f == null) {
Box(GlanceModifier.fillMaxSize(), contentAlignment = Alignment.Center) {
Text(context.getString(R.string.widget_loading), style = text(fg, 16))
}
return@Frame
}
val u = data.units
val cond = conditionOf(f.current.code)
val condText = context.getString(conditionLabel(cond, f.current.isDay))
val name = data.location?.name?.ifBlank { context.getString(R.string.current_location) } ?: ""
val summary = "$name ${u.temp(f.current.temp)} $condText"
if (size.height < MEDIUM.height) {
Row(
GlanceModifier.fillMaxSize().padding(horizontal = 16.dp).semantics { contentDescription = summary },
verticalAlignment = Alignment.CenterVertically, horizontalAlignment = Alignment.CenterHorizontally,
) {
Image(ImageProvider(WidgetArt.icon(cond, f.current.isDay)), null, GlanceModifier.size(40.dp))
Spacer(GlanceModifier.width(8.dp))
Text(u.temp(f.current.temp), style = text(fg, 36, FontWeight.Bold))
}
} else {
Column(GlanceModifier.fillMaxSize().padding(16.dp).semantics { contentDescription = summary }) {
Text(name, style = text(fg, 14, FontWeight.Medium), maxLines = 1)
Spacer(GlanceModifier.defaultWeight())
Row(verticalAlignment = Alignment.CenterVertically) {
Text(u.temp(f.current.temp), style = text(fg, 44, FontWeight.Bold))
Spacer(GlanceModifier.width(6.dp))
Image(ImageProvider(WidgetArt.icon(cond, f.current.isDay)), null, GlanceModifier.size(40.dp))
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))
}
Text(condText, style = text(fg, 13), maxLines = 1)
f.today?.let { Text("↑ ${u.temp(it.tMax)} ↓ ${u.temp(it.tMin)}", style = text(fg, 12)) }
}
}
}
@@ -155,88 +308,166 @@ class NowWidget : GlanceAppWidget() {
companion object {
val SMALL = DpSize(110.dp, 48.dp)
val MEDIUM = DpSize(110.dp, 110.dp)
val WIDE = DpSize(200.dp, 110.dp)
}
}
/** 4×2 hourly, 4×3 and up adds the next days. */
class ForecastWidget : GlanceAppWidget() {
override val sizeMode = SizeMode.Responsive(setOf(WIDE, TALL))
// ---------------------------------------------------------------------------------------------
// 3. Tilted pill: a 45° stadium, temperature top right, icon bottom left
// ---------------------------------------------------------------------------------------------
override suspend fun provideGlance(context: Context, id: GlanceId) {
val data = load(context, id)
provideContent { Content(data) }
}
class TiltWidget : WeatherWidget() {
override val sizeMode = SizeMode.Exact
@Composable
private fun Content(data: WidgetData) {
val context = LocalContext.current
override fun Content(data: WidgetData, f: Forecast) {
val cond = conditionText(f)
val p = data.palette
val u = data.units
val size = LocalSize.current
Frame(data) { spec ->
val fg = spec.onScene
val f = data.forecast
if (f == null) {
Box(GlanceModifier.fillMaxSize(), contentAlignment = Alignment.Center) {
Text(context.getString(R.string.widget_loading), style = text(fg, 16))
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())
}
return@Frame
}
val u = data.units
val cond = conditionOf(f.current.code)
val name = data.location?.name?.ifBlank { context.getString(R.string.current_location) } ?: ""
Column(GlanceModifier.fillMaxSize().padding(16.dp)) {
Row(GlanceModifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically) {
Column(GlanceModifier.defaultWeight()) {
Text(name, style = text(fg, 14, FontWeight.Medium), maxLines = 1)
Text(context.getString(conditionLabel(cond, f.current.isDay)), style = text(fg, 12), maxLines = 1)
}
Text(u.temp(f.current.temp), style = text(fg, 36, FontWeight.Bold))
Image(ImageProvider(WidgetArt.icon(cond, f.current.isDay)), null, GlanceModifier.size(36.dp))
Image(
ImageProvider(R.drawable.ic_refresh), context.getString(R.string.retry),
GlanceModifier.size(28.dp).padding(4.dp).clickable(actionRunCallback<RefreshAction>()),
colorFilter = androidx.glance.ColorFilter.tint(FixedColor(fg)),
)
}
}
}
// ---------------------------------------------------------------------------------------------
// 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)
}
Spacer(GlanceModifier.height(10.dp))
Row(GlanceModifier.fillMaxWidth()) {
f.upcomingHours(6).forEachIndexed { i, h ->
Column(GlanceModifier.defaultWeight(), horizontalAlignment = Alignment.CenterHorizontally) {
Text(if (i == 0) context.getString(R.string.now) else Fmt.hourLabel(h.time), style = text(fg, 11, align = TextAlign.Center))
Image(ImageProvider(WidgetArt.icon(conditionOf(h.code), h.isDay, 96)), null, GlanceModifier.size(26.dp))
Text(u.temp(h.temp), style = text(fg, 13, FontWeight.Medium, TextAlign.Center))
}
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 (size.height >= TALL.height) {
Spacer(GlanceModifier.height(12.dp))
val today = f.daily.firstOrNull()?.date
f.daily.take(5).forEach { d ->
Row(GlanceModifier.fillMaxWidth().padding(vertical = 2.dp), verticalAlignment = Alignment.CenterVertically) {
Text(
if (d.date == today) context.getString(R.string.today) else Fmt.weekdayShort(d.date),
style = text(fg, 13), modifier = GlanceModifier.width(56.dp),
)
Image(ImageProvider(WidgetArt.icon(conditionOf(d.code), true, 96)), null, GlanceModifier.size(22.dp))
Text(if (d.precipProb >= 10) " ${d.precipProb} %" else "", style = text(fg, 11), modifier = GlanceModifier.defaultWeight())
Text("${u.temp(d.tMin)} ${u.temp(d.tMax)}", style = text(fg, 13, FontWeight.Medium))
}
}
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)
val TALL = DpSize(250.dp, 250.dp)
}
}
class NowWidgetReceiver : GlanceAppWidgetReceiver() {
override val glanceAppWidget: GlanceAppWidget = NowWidget()
}
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() }
class ForecastWidgetReceiver : GlanceAppWidgetReceiver() {
override val glanceAppWidget: GlanceAppWidget = ForecastWidget()
// ---------------------------------------------------------------------------------------------
// 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>
+23 -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>
@@ -113,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" />
@@ -99,6 +99,7 @@ class ScreenshotTest {
@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)) } }