Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
963a5e0e86 | ||
|
|
a1a56d9b50 | ||
|
|
a134b8f46f | ||
|
|
79e6031823 | ||
|
|
0c42d8570b | ||
|
|
8eb9544189 |
No files matched your search
@@ -0,0 +1,3 @@
|
||||
.giteatoken
|
||||
*.jks
|
||||
keystore.properties
|
||||
@@ -0,0 +1,114 @@
|
||||
# NoGooleApps
|
||||
|
||||
**Everyday Android apps without Google.** Privacy-friendly rebuilds of the standard Google apps, for people who want the polish of the originals without Play Services, tracking or an account. Made with GrapheneOS, CalyxOS, /e/OS and LineageOS in mind, and works the same on any stock Android phone.
|
||||
|
||||
> Not affiliated with, endorsed by or connected to Google. These are independent, clean-room rebuilds: no Google code, assets, icons, fonts or text are used.
|
||||
|
||||
## Apps
|
||||
|
||||
| App | Replaces | Status | Install |
|
||||
| --- | --- | --- | --- |
|
||||
| **Wetter** (`wetter/`) | Google Weather / Pixel Weather | alpha, in daily testing | [Obtainium](https://apps.obtainium.imranr.dev/redirect?r=obtainium://app/%7B%22id%22%3A%22app.wetter%22%2C%22url%22%3A%22https%3A%2F%2Fgit.mrblake.cc%2FMrBlake%2FNoGooleApps%22%2C%22author%22%3A%22MrBlake%22%2C%22name%22%3A%22Wetter%22%2C%22overrideSource%22%3A%22Codeberg%22%2C%22preferredApkIndex%22%3A0%2C%22additionalSettings%22%3A%22%7B%5C%22appId%5C%22%3A%5C%22app.wetter%5C%22%2C%5C%22includePrereleases%5C%22%3Atrue%2C%5C%22fallbackToOlderReleases%5C%22%3Atrue%2C%5C%22filterReleaseTitlesByRegEx%5C%22%3A%5C%22%5EWetter%20%5C%22%2C%5C%22apkFilterRegEx%5C%22%3A%5C%22%5Ewetter-.%2A%5C%5C%5C%5C.apk%24%5C%22%2C%5C%22autoApkFilterByArch%5C%22%3Afalse%2C%5C%22verifyLatestTag%5C%22%3Afalse%2C%5C%22releaseTitleAsVersion%5C%22%3Afalse%7D%22%7D) · F-Droid: not yet |
|
||||
|
||||
More apps will follow, one folder each. Each one goes through the same pipeline (see [How these apps are made](#how-these-apps-are-made)).
|
||||
|
||||
### Wetter
|
||||
|
||||
A weather app with the look and feel of Pixel Weather: an animated sky that changes with the conditions, a large hero temperature, hourly and 10-day forecasts, and shaped Material 3 Expressive detail tiles (wind, sun, UV, air quality, visibility, humidity, pressure, pollen).
|
||||
|
||||
- **No Google Play Services.** Location uses the platform's own providers (including the AOSP fused provider), so it works on GrapheneOS without sandboxed Play.
|
||||
- **No account, no tracking, no analytics.** Everything stays on the device. Coordinates are rounded to two decimals (about 1 km) before they reach the weather service.
|
||||
- **Open data sources only:** [Open-Meteo](https://open-meteo.com) for forecasts, 15-minute precipitation, air quality, pollen and place search (CC BY 4.0), and [Nominatim / OpenStreetMap](https://nominatim.org) for naming your current location.
|
||||
- **Features today:** current location and saved cities (swipe between them), search with a full preview before saving, precipitation-in-the-next-hours card, a rule-based daily summary, day detail view, units and theme settings, light and dark mode.
|
||||
- **Five home-screen widgets:** 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. 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.
|
||||
|
||||
Requires Android 10 (API 29) or newer.
|
||||
|
||||
## Install with Obtainium
|
||||
|
||||
[Obtainium](https://github.com/ImranR98/Obtainium) installs and updates apps straight from this repository's releases, with no store in between.
|
||||
|
||||
### Wetter
|
||||
|
||||
[<img src="https://raw.githubusercontent.com/ImranR98/Obtainium/main/assets/graphics/badge_obtainium.png" alt="Get it on Obtainium" height="54">](https://apps.obtainium.imranr.dev/redirect?r=obtainium://app/%7B%22id%22%3A%22app.wetter%22%2C%22url%22%3A%22https%3A%2F%2Fgit.mrblake.cc%2FMrBlake%2FNoGooleApps%22%2C%22author%22%3A%22MrBlake%22%2C%22name%22%3A%22Wetter%22%2C%22overrideSource%22%3A%22Codeberg%22%2C%22preferredApkIndex%22%3A0%2C%22additionalSettings%22%3A%22%7B%5C%22appId%5C%22%3A%5C%22app.wetter%5C%22%2C%5C%22includePrereleases%5C%22%3Atrue%2C%5C%22fallbackToOlderReleases%5C%22%3Atrue%2C%5C%22filterReleaseTitlesByRegEx%5C%22%3A%5C%22%5EWetter%20%5C%22%2C%5C%22apkFilterRegEx%5C%22%3A%5C%22%5Ewetter-.%2A%5C%5C%5C%5C.apk%24%5C%22%2C%5C%22autoApkFilterByArch%5C%22%3Afalse%2C%5C%22verifyLatestTag%5C%22%3Afalse%2C%5C%22releaseTitleAsVersion%5C%22%3Afalse%7D%22%7D)
|
||||
|
||||
Open the button on your phone with Obtainium installed and confirm the import. The link carries the complete configuration, so nothing has to be set by hand:
|
||||
|
||||
| setting | value | why |
|
||||
| --- | --- | --- |
|
||||
| Source | `https://git.mrblake.cc/MrBlake/NoGooleApps` | this repository (note the spelling: **NoGooleApps**) |
|
||||
| Override source | Forgejo (Codeberg) | the repository runs on a self-hosted Gitea, which Obtainium does not detect on its own; Gitea speaks the same release API |
|
||||
| Filter release titles | `^Wetter ` | several apps share this repository; only weather releases count |
|
||||
| Filter APKs | `^wetter-.*\.apk$` | picks the weather APK from the release assets |
|
||||
|
||||
If the button does not open Obtainium (some browsers block links to apps; the page then shows a button to tap, or enable "open links in apps" in the browser), paste this link into the phone's browser address bar, or add the app by hand with the settings above:
|
||||
|
||||
```
|
||||
obtainium://app/%7B%22id%22%3A%22app.wetter%22%2C%22url%22%3A%22https%3A%2F%2Fgit.mrblake.cc%2FMrBlake%2FNoGooleApps%22%2C%22author%22%3A%22MrBlake%22%2C%22name%22%3A%22Wetter%22%2C%22overrideSource%22%3A%22Codeberg%22%2C%22preferredApkIndex%22%3A0%2C%22additionalSettings%22%3A%22%7B%5C%22appId%5C%22%3A%5C%22app.wetter%5C%22%2C%5C%22includePrereleases%5C%22%3Atrue%2C%5C%22fallbackToOlderReleases%5C%22%3Atrue%2C%5C%22filterReleaseTitlesByRegEx%5C%22%3A%5C%22%5EWetter%20%5C%22%2C%5C%22apkFilterRegEx%5C%22%3A%5C%22%5Ewetter-.%2A%5C%5C%5C%5C.apk%24%5C%22%2C%5C%22autoApkFilterByArch%5C%22%3Afalse%2C%5C%22verifyLatestTag%5C%22%3Afalse%2C%5C%22releaseTitleAsVersion%5C%22%3Afalse%7D%22%7D
|
||||
```
|
||||
|
||||
**Releases.** Every app is published as a release titled `<App> <version>` (for example `Wetter 0.1.0`, tag `wetter-v0.1.0`) with one asset named `<app>-<version>.apk`. Obtainium shows *"no matching version"* until the first release of an app exists.
|
||||
|
||||
**F-Droid:** not available yet. The apps contain no proprietary libraries, so an F-Droid build is planned (either the main repository or a self-hosted F-Droid repo).
|
||||
|
||||
## How these apps are made
|
||||
|
||||
### The Replica pipeline
|
||||
|
||||
Every app is rebuilt with **[Replica](https://github.com/Jakeschincariol/replica-skill)**, an open set of eleven Claude Code skills by Jake Schincariol for cloning an app's *functionality and UX patterns* clean-room style. Each skill writes files the next one reads, and everything is kept in [`replica/`](replica/):
|
||||
|
||||
| Step | Skill | What it produced for Wetter |
|
||||
| --- | --- | --- |
|
||||
| 1 | `replica-recon` | [Recon map](replica/recon.md) built from public sources (help center, reviews, store listing): 15 screens, 9 user flows, components, inferred data model, [feature matrix](replica/features.csv) |
|
||||
| 2 | `replica-architect` | [Architecture](replica/architecture.md) and [schema](replica/schema.sql): native Kotlin, offline-first, no server, public APIs only |
|
||||
| 3 | `replica-design` | [Design tokens](replica/design/tokens.json) and [component specs](replica/design/components.md), WCAG AA contrast checked (70 colour pairs), generated into Compose code |
|
||||
| 4 | `replica-build` | The app itself, screen by screen, with a [build log](replica/build-log.md) and [screenshots](replica/clone-screens/) rendered from a real API response |
|
||||
| next | `replica-test`, `replica-diff`, `replica-entrepreneur`, `replica-brand`, `replica-launch`, `replica-deploy`, `replica-backend` | QA, parity scoring against the original, reading real user reviews for improvements, naming and branding, store listing, release |
|
||||
|
||||
The rules Replica enforces, and that this project follows:
|
||||
|
||||
- **Public sources and our own devices only.** No decompiling, no private APIs, no reading the original's code or network traffic.
|
||||
- **Everything written fresh.** Code, icons, weather glyphs, the animated sky and every label are made from scratch. Reference screenshots of the originals live in `replica/screens/` for layout comparison only and never ship.
|
||||
- **What cannot be cloned is left out on purpose:** Google's own forecast models, Gemini summaries, Calendar/Gmail-based insights and account sync. Open alternatives replace them where it makes sense.
|
||||
|
||||
### Built with AI, steered by a human
|
||||
|
||||
The code, the design system and this README were written by **Claude Opus 5.5** (Anthropic's model, ID `claude-opus-5-5`) running in **Claude Code**, working through the Replica skills step by step. The human side of the project (that's [@MrBlake](https://git.mrblake.cc/MrBlake)) sets direction, supplies reference screenshots, tests every build on a real Pixel phone and reports what feels wrong. Issues found that way, like stutter during scrolling or slow location, are measured on the device and fixed. A typical loop:
|
||||
|
||||
1. A skill produces its document or code; the human reviews it.
|
||||
2. The app is built and rendered to screenshots on the JVM (Roborazzi), and the screenshots are checked against the reference.
|
||||
3. The release build is installed on the phone over adb and used for real; frame timings (`dumpsys gfxinfo`) and logs guide the fixes.
|
||||
|
||||
Each commit says what changed and carries a `Co-Authored-By` line for the AI.
|
||||
|
||||
## Building from source
|
||||
|
||||
Requirements: JDK 17 or newer and the Android SDK (platform 36).
|
||||
|
||||
```bash
|
||||
cd wetter
|
||||
./gradlew :app:assembleRelease # APK in app/build/outputs/apk/release/
|
||||
./gradlew :app:testDebugUnitTest # unit + screenshot tests
|
||||
./gradlew :app:recordRoborazziDebug # re-render replica/clone-screens/
|
||||
```
|
||||
|
||||
Local release builds are signed with the debug key so they install over each other. Published releases will use a dedicated signing key.
|
||||
|
||||
## Repository layout
|
||||
|
||||
```
|
||||
replica/ recon, architecture, design system, build log, screenshots
|
||||
wetter/ the weather app (Kotlin, Jetpack Compose, Glance widgets, Room, WorkManager)
|
||||
```
|
||||
|
||||
## Credits
|
||||
|
||||
- Weather data: [Open-Meteo.com](https://open-meteo.com), CC BY 4.0
|
||||
- Place names: © [OpenStreetMap](https://www.openstreetmap.org/copyright) contributors, via Nominatim
|
||||
- UI icons: [Material Symbols](https://fonts.google.com/icons), Apache 2.0
|
||||
- Method: [Replica](https://github.com/Jakeschincariol/replica-skill) by Jake Schincariol
|
||||
|
||||
## License
|
||||
|
||||
Not chosen yet. Until a license file is added, all rights are reserved by the author.
|
||||
@@ -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 |
@@ -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 |
@@ -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
@@ -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
@@ -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,3 +1,5 @@
|
||||
import java.util.Properties
|
||||
|
||||
plugins {
|
||||
id("com.android.application")
|
||||
id("org.jetbrains.kotlin.android")
|
||||
@@ -19,12 +21,25 @@ android {
|
||||
versionName = "0.1.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 {
|
||||
release {
|
||||
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 +76,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')"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -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,65 @@
|
||||
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),
|
||||
),
|
||||
)
|
||||
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) })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun px(dp: Float) = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, resources.displayMetrics).toInt()
|
||||
private fun px(dp: Int) = px(dp.toFloat())
|
||||
}
|
||||
@@ -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,29 @@
|
||||
</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.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_now" />
|
||||
<meta-data android:name="android.appwidget.provider" android:resource="@xml/widget_card" />
|
||||
</receiver>
|
||||
<receiver android:name=".widget.ForecastWidgetReceiver" android:exported="true" android:label="@string/widget_forecast_name">
|
||||
<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_forecast" />
|
||||
<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>
|
||||
@@ -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,224 @@
|
||||
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 { widget.update(this@WidgetConfigActivity, 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("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 { mutableStateOf(WidgetConfigEntity(appWidgetId, null)) }
|
||||
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,223 @@ 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
|
||||
|
||||
suspend fun updateAllWidgets(context: Context) {
|
||||
NowWidget().updateAll(context)
|
||||
ForecastWidget().updateAll(context)
|
||||
WeatherCardWidget().updateAll(context)
|
||||
PillWidget().updateAll(context)
|
||||
TiltWidget().updateAll(context)
|
||||
BarWidget().updateAll(context)
|
||||
ClassicWidget().updateAll(context)
|
||||
}
|
||||
|
||||
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)
|
||||
listOf<KClass<out GlanceAppWidgetReceiver>>(
|
||||
WeatherCardReceiver::class, PillReceiver::class, TiltReceiver::class, BarReceiver::class, ClassicReceiver::class,
|
||||
).forEach { runCatching { manager.setWidgetPreviews(it) } }
|
||||
}
|
||||
|
||||
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?): 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) } ?: WidgetStyle()
|
||||
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() {
|
||||
override suspend fun provideGlance(context: Context, id: GlanceId) {
|
||||
val data = load(context, id)
|
||||
provideContent { Content(data) }
|
||||
val data = loadWidgetData(context, id)
|
||||
provideContent { Root(data) }
|
||||
}
|
||||
|
||||
override suspend fun providePreview(context: Context, widgetCategory: Int) {
|
||||
val data = loadWidgetData(context, null)
|
||||
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 +275,133 @@ 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 ForecastWidgetReceiver : GlanceAppWidgetReceiver() {
|
||||
override val glanceAppWidget: GlanceAppWidget = ForecastWidget()
|
||||
}
|
||||
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 ClassicReceiver : GlanceAppWidgetReceiver() { override val glanceAppWidget: GlanceAppWidget = ClassicWidget() }
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
@@ -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,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>
|
||||
@@ -113,10 +113,27 @@
|
||||
<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_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,13 @@
|
||||
<?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: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,13 @@
|
||||
<?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: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" />
|
||||
+5
-2
@@ -1,10 +1,13 @@
|
||||
<?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:description="@string/widget_classic_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:minResizeWidth="140dp" android:minResizeHeight="110dp"
|
||||
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" />
|
||||
@@ -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,13 @@
|
||||
<?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: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,13 @@
|
||||
<?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: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)) } }
|
||||
|
||||
Reference in new issue
Block a user