diff --git a/.claude/skills/github-pr/SKILL.md b/.claude/skills/github-pr/SKILL.md index 8babdc08..27bfcaa5 100644 --- a/.claude/skills/github-pr/SKILL.md +++ b/.claude/skills/github-pr/SKILL.md @@ -77,7 +77,7 @@ matched pull request's body in full. | 6 | `v0.6.0 — Dishka DI, scrolling text, in-app guide from the repo` | PRs #60–#74; issues #96, #97, #99, #101, #103, #104 | | 7 | `Dependencies — dependabot bumps` | every dependabot bump; deliberately not a version, and open for good | | 8 | `v0.7.0 — School-year calendar, day ribbon, rearrangeable tabs` | PRs #75–#85, #128; issues #98, #100, #105–#108 | -| 9 | `v0.8.0 — On-device checks, 89-region e-diary survey` | PRs #129, #133, #134, #186, #187, #189, #234, #238, #239; issues #109–#117, #130–#132, #167–#185, #188, #219–#233, #237 — **open**, the first whose work needs an emulator or a phone | +| 9 | `v0.8.0 — On-device checks, 89-region e-diary survey` | PRs #129, #133, #134, #186, #187, #189, #234, #238, #239, #241; issues #109–#117, #130–#132, #167–#185, #188, #219–#233, #237, #240, #242 — **open**, the first whose work needs an emulator or a phone | | 10 | `v0.9.0 — NetSchool e-diary, onboarding via the school's diary` | PRs #140, #214, #218; issues #135–#139, #141, #145–#165, #190–#213 — **open**, the one being worked on | All ten were renamed on 25 September 2026: every title now names what the version diff --git a/HANDOVER.md b/HANDOVER.md index b8ab2fa2..43edd8da 100644 --- a/HANDOVER.md +++ b/HANDOVER.md @@ -7,29 +7,24 @@ What every batch before the last two added is in [docs/history.md](docs/history. newest first. Last updated: **2 October 2026**. **PRs #63 through #85, #128, #129, #133, #134, #140, -#166, #186, #187, #189, #214, #218 and #234 are merged**; `main` is at `f2cebbd`, the merge -of #234, on 2 October 2026, and `dev` is level with it. **The only thing open is the pull -request carrying this paragraph, #239**, from `dev`, on milestone 9, `v0.8.0 — On-device -checks, 89-region e-diary survey`. It carries #238's two commits unchanged — a hidden -developer mode (#237), written by a scheduled cloud session, and what that session found -about the Petersburg diary the same day (#235) — and a request console on top, which the -owner asked for in another session the same afternoon. #238 is marked merged by GitHub the -moment #239's merge puts its head in `main`. The section «What the last session added» below -is that batch, both sessions' halves. +#166, #186, #187, #189, #214, #218, #234, #238 and #239 are merged**; `main` is at `4d792df`, +the merge of #239, on 2 October 2026, and `dev` was level with it when this batch began. +**The only thing open is the pull request carrying this paragraph, #241**, from `dev`, on +milestone 9, `v0.8.0 — On-device checks, 89-region e-diary survey`. It fixes two things the +owner saw in the bottom bar that afternoon — the pill 16 dp taller on every page without a +button beside it (#240), and a short label sitting in a box much wider than itself (#242) — +and records the first run of #201's Keystore seal and #202's https-only release on a device: +two API 37 emulators, one of them holding a release build signed with the owner's own key. +The section «What the last session added» below is that batch. The SHA of its own merge is for the next close-out to write. -**#238 was held as a draft because its session could not install the Android SDK**, so the -third of the `github-pr` skill's five conditions — gates run locally before the push — was -unmet for its code. The session that wrote the console had the SDK and ran the full Android -gates over the combined tree, which is what lets #239 merge on the standing authorisation. - -**#234 closed #219–#233**, read back from GitHub on 2 October. **#239 closes -#237.** **#235** is open: the production server cannot reach Petersburg's diary at all, and -the fix is the owner's choice of a Russian egress (section 7). **#236**, a phone's sign-in -showing nothing for over a minute, was filed the same day and closed as a duplicate of #233, -which #234 had already fixed. Of the device epic **#109**, **#111** and **#113** stay open -for what only a phone can say, and **#112** (a macrobenchmark module) was not started. +**#239 closed #237**, read back from GitHub on 2 October. **#241 closes #240 and #242.** +**#235** is open: the production server cannot reach Petersburg's diary at all, and the fix +is the owner's choice of a Russian egress (section 7). **#236**, a phone's sign-in showing +nothing for over a minute, was closed as a duplicate of #233, which #234 had already fixed. +Of the device epic **#109**, **#111** and **#113** stay open for what only a phone can say, +and **#112** (a macrobenchmark module) was not started. **The code expects head `0017`, and production is at `0017` since 26 September 2026 at 12:26 UTC.** `EXPECTED_REVISION` in `app/db.py` is `0017`, pinned to the real head by @@ -138,10 +133,116 @@ next, someday, done) and `needs:` (device, owner). **A session cannot create a G Project board** — Projects v2 is GraphQL-only and the toolset here is REST — so the board is the owner's to make, and these labels are what its views filter on. -## What the last session added: a developer mode (#237) with a request console, and the Petersburg diary out of the server's reach (#235) +## What the last session added: #201 and #202 on two emulators, and a bottom bar that follows its text (#240, #242) + +Open as #241, from `dev`, on milestone 9. Made on the owner's machine on 2 October 2026, with +the API 37 emulator, a local server and production read only. The owner asked for everything +the last build needed to be tested to be run; while that walk was under way `main` moved from +`eb0ab94` to `4d792df` (#234 and #239), so the walk was run again on a build of `4d792df`; +and twice the owner, watching the emulator, reported the bottom bar. + +- **#240, the pill 16 dp taller without a button beside it — filed, then fixed.** Every + settings page of a reader who does not manage the class drew the pill holding «←» and the + title 80 dp tall, where the tab bar it morphed from, and the same page beside the debug + button, drew 64 dp. Only Material's overload *without* a button runs + `minimumInteractiveBalancedPadding`, which pads the pill vertically by twice the amount the + content's interactive side inset exceeds its top one; since #183 the pill's ends were inside + our rows and its top and bottom outside them, so the 48 dp back button read as 8 dp in from + the side and 0 from the top. All of Material's padding is now inside the rows, on four + sides, and a bar without a button keeps the 80 dp slot Material gives one with a button, so + the pill does not drop 8 dp as settings open either — which the extra height had hidden. + Measured at 420 dpi: the settings pill 210 px before, 168 px after, as the tab bar's. +- **#242, a short label in a box much wider than itself — filed, then fixed.** The back + pill's title was never under 100 dp and the selected tab's label never under 80 dp (the + floor #227 kept), so «← Sync» was as wide a pill as «← Settings» and «Today» half filled + its tab. Neither floor is left. The owner set the ceiling the same afternoon, asked and + answered in the session: a label or a title grows with its text until, on a tablet + (smallest width 600 dp and up), it reaches 30 % of the window, and on a phone until it + fills what the row leaves it; past that it scrolls, as `MarqueeText` already did. The + documentation's scrolling bar takes the same rule. Seen on the emulator in English and in + Russian: «Today», «← Sync», «← Settings», «← Настройки», «← Взаимодействие», each as wide + as its text. +- **#201 on a real upgrade, twice.** The debug build installed before #201 (27 September, + this machine's debug key) was cleared, joined to a local `seed_demo` class «9А» with + `DEMO24`, and its preferences read with `run-as`: `session_list` held the membership as JSON + with `token` in plain text. The debug build of `eb0ab94`, and later of `4d792df`, was + installed over it with `install -r`: the class stayed, the first request after the upgrade + was a `304` with the migrated token, and the token now starts `gcm1:` over a 72-byte + payload whose first byte, the IV's length, is 12. After a `force-stop`, and after a reboot, + the server still answered `304`; a made-up bearer gets `401` on the same route, so the + `304` is the sealed token opening. Only the shape of the stored value was printed, never + the token. +- **#201 and #202 on the release build signed with the owner's key.** The release APK built + here and the one the APK workflow built from `4d792df` (`versionCode` 39) are both signed + `CN=lumenpearson`. Neither installs over the release on the first AVD, which CI signed with + a throwaway key in #186 and which is linked to production's «11А» as owner, so a second + AVD, `Release_Check` (Pixel 9 profile, 1080×2424 at 420 dpi, on F:), took a fresh install. + `http://10.0.2.2:8000` was refused at the address field — «The app connects to the server + only at a secure address…», «Save» disabled — and `http://127.0.0.1:8000` accepted; «9А» + joined (`/join` 200, the year 200, then 304); the class came back after a `force-stop` and + after a reboot, each time with a `304`, so the Keystore key survives both. Pointed at + `https://lessons-ruddy-zeta.vercel.app`, «About» read «Server is up»: the first time a + release build met the real server over TLS. The address went back to the local one at once. +- **#209's splits, walked on both builds.** The nine settings pages, the calendar's week, + month and day ribbon, homework and «Сегодня» opened with no `FATAL EXCEPTION`; on + `4d792df` the week list carries #220's «сейчас» line. +- **«Обновить сейчас» against a host that does not answer** says «Не удалось обновить + расписание» after about twenty seconds. On the old build the snackbar came and went + between two screenshots, which looked like silence and was not. +- **`ToolbarOnDeviceTest`**: 3 of 3 on `eb0ab94` and again on `4d792df`. + +### Driving the emulators from a shell + +- **`10.0.2.2` does not reach the host from the emulator on this machine**: `nc` times out, + while the machine's LAN address answers. `adb reverse tcp:8000 tcp:8000` with + `http://127.0.0.1:8000` is what works, and it is also the one cleartext address a release + build accepts. +- **The local server ran from the scratchpad, never from `server/`.** `app.config` reads + `.env` from the working directory, and the one in `server/` belongs to the deployment; the + server took `DATABASE_URL` pointing at a SQLite file, `RUN_BOT=false`, and an empty + `BOT_TOKEN` and `WEBHOOK_SECRET`, from its environment. +- **A fresh AVD's Gboard opened its stylus tutorial** over the first text field and swallowed + `input text`; `settings put secure stylus_handwriting_enabled 0` ends it. +- **Screens were read through `uiautomator dump`**, not through screenshots. A tap has to + wait for a sheet or the keyboard to settle, or it lands where the button used to be. +- **One Gradle daemon died** with `EXCEPTION_ACCESS_VIOLATION` in `jvm.dll`, and the second + AVD's first boot exited 139 just after «Boot completed». Both ran clean the second time; + the machine still holds the four DIMMs #214's section blamed, and two more unexpected + shutdowns were logged on 28 September. + +### Gates + +On `40889c2`: `./gradlew test assembleDebug assembleRelease detekt` BUILD SUCCESSFUL; +`./gradlew test` **1587** (`:core:model` 125, `:core:data` 615, `:core:designsystem` 130, +`:widget` 126, `:app` 591), eight more than #239's 1579 — `ToolbarPillHeightTest` 3 and +`ToolbarLabelFitTest` 5. Each was run against the toolbar before its fix first: the pill +80 px for 64 and its centre 40 px for 48; then 84 px for a 4 px «Sync», a 128 px tab for +«Today», and 322, 322 and 776 px where the caps said 379, 388 and 348. The server was not +touched, so its gates were not run. + +### What was deliberately left alone + +- The first AVD's release build, linked to production's «11А» as owner, was not uninstalled + to make room for the owner-signed build: a second AVD cost 5 GB on F: and nothing the owner + had set up. +- C: was not cleaned: it stayed between 4.5 and 7 GB free and nothing needed more. +- The developer mode (#237) was not opened. + +### What nobody has verified in this batch + +- The pill beside the debug button after #240's fix: the local class gives no manager. + Material holds that pill at 64 dp by construction. +- #242 on a tablet: the 30 % cap is held by `ToolbarLabelFitTest` only. Nor was a title long + enough to reach a phone's cap seen scrolling. +- #201 on a phone, a restore onto another phone, a wiped Keystore, and the diary's bearer, + which is sealed the same way and needed a diary session nobody opened. +- A release build joined to a production class: «11А» takes invitations only, and nothing + here wrote to production. + +## What the session before it added: a developer mode (#237) with a request console, and the Petersburg diary out of the server's reach (#235) -Open as #239, from `dev`, on milestone 9; #238, from `agents/dazzling-davinci-qtw4n8`, is -its first two commits. Made by two cloud sessions on 2 October 2026. The first began as a +Merged as #239 (`4d792df`, 2 October 2026), from `dev`, on milestone 9; #238, from +`agents/dazzling-davinci-qtw4n8`, is its first two commits and was marked merged with it. Made by two cloud sessions on 2 October 2026. The first began as a scheduled status check, turned into the owner's report that the real diary would not open, and ended with a developer mode to find out why next time. The second, asked by the owner for «отправки конкретных запросов с разными заголовками на разные эндпоинты», «ограничь нашим @@ -241,77 +342,6 @@ fixed rather than baselined. The server was not touched. - #235's measurement is from Frankfurt and from a cloud container. Whether the city's network answers a Russian VPS — the fix's premise — is unasked. -## What the session before it added: fifteen defects from the owner's phone, #219–#233 - -Merged as #234 (`f2cebbd`, 2 October 2026), from `dev`, on milestone 9. The owner sent twenty screenshots from their phone -on 2 October 2026, marked up in red, and asked for every defect to be fixed, merged into `dev` -fix by fix, then into `main`, and tested synthetically before they check it by eye. Four -read-only agents traced the causes in parallel; every fix was written and tested here, one -branch per fix. - -- **«Сегодня» and the calendar (#219, #220).** The running lesson is now the «сейчас» line - above its row and a gradient of its subject's tint, the same mark a break gets, and the - row's trailing end carries the diary's marks for it — read from `diary.db`, matched by date - and the folded subject name, on the first lesson of a subject taught twice. The calendar's - today, in its list and its day sheet, is marked the same way; it used to pass `now = null`. -- **The widget after school (#221).** The next school day's lessons fill the height under - the homework on every rung with a list, weighted and clipped rather than counted, with the - week strip under them; the 4×2 shows the state and plan above its homework. -- **Sheets (#222).** Material's drag-handle slot wraps anything in a tooltip and a ripple, so - the sheets draw their own pill and pass `null`. -- **Busy states (#223, #224).** A busy action keeps its filled colours, so its spinner is - onPrimary on primary; three view models lower their refresh flag in a `finally`, and the - pull-to-refresh indicator comes out below the status bar. -- **The bar (#225, #226, #227).** Every pick-up of a tab is felt; the carried tab stays - inside the row and an unselected disc is transparent, so it never bites the selected one; - the selected tab is as wide as its measured label. -- **Settings (#228).** The last role per class is kept in the preferences and drawn until - `/me` answers, which the shell now asks at start; the debug button is there from the first - frame after the first answer. -- **Theme reveal (#229).** A wipe on screen is never photographed again, and its job starts - undispatched so the photograph always comes down. -- **First run (#230, #231, #232).** Step bodies fade under the hero instead of being cut, - which is what left three dashes above «Дневник»; «Моей школы нет в списке» moved under the - buttons; the forgotten-password link heads the server block. -- **Sign-in deadlines (#233).** 25 s over the whole diary exchange and 10 s on the preflight - on the phone, 22 s over the server's upstream adopt, each answered with the message that - already existed. - -### Gates - -On `dev` with this close-out on top: `pytest -q -n auto` **2065** passed, one more than -#218's 2064; `ruff` clean; `python -m mypy` clean over 153 source files. `./gradlew test` -**1523** (`:core:model` 125, `:core:data` 571, `:core:designsystem` 122, `:widget` 126, -`:app` 579), twenty-three more than 1500; `assembleDebug` and `assembleRelease` build; -`./gradlew detekt` passes. Every new test was run against the old code where it compiles -there and failed: the sheet handle, the carry and the haptic, the theme reveal, the refresh -flag, the onboarding fade and gap, and the server's adopt deadline. The project's own -meta-tests caught two things in this batch's code — a `maxLines = 1` without a reason and two -compose tests silent about the clock — and `f0c434e` writes the reasons where they ask for them. - -### What was deliberately left alone - -- The drop of a carried tab still plays `CLOCK_TICK`: changing it to a strength-respecting - tap would double with the shell's page-change tap when the drop renumbers the current page. -- The welcome step's hero stays FULL; dropping it to COMPACT would free 148 dp but - `OnboardingFlowTest` pins it, and it is a design question rather than a defect. -- The calendar's lesson rows get the «сейчас» mark but not the diary's marks; only «Сегодня» - was asked for them. - -### What nobody has verified in this batch - -- None of it has been seen on a phone: there is no emulator in a cloud container. Every one - of the fifteen is the owner's to check by eye, which they asked to do. -- #221's weighted list is clipped at its own bottom edge on purpose; how a half-row sits on - each launcher rung is unseen. -- #230 rests on the owner's welcome page having been scrolled when the dashes showed; the - glyph arithmetic says so, the phone has not. -- #231 has no test: composing the school step mid-search needs a view model walked there. -- #227: on a 360 dp phone the spare width is about 88 dp, so at the largest text scales - «Календарь» can still scroll there. -- #233: a deadline landing just after the diary accepted the login leaves a session open on - the diary's side to idle out. - ## The milestones **The milestones as they are now.** The owner renamed all nine on 25 September 2026, so that @@ -331,7 +361,7 @@ maps them. The | 6 | `v0.6.0 — Dishka DI, scrolling text, in-app guide from the repo` | `v0.6.0 — One container, and nothing cut off` | closed | PRs #60–#74; issues #96, #97, #99, #101, #103, #104 | | 7 | `Dependencies — dependabot bumps` | `Dependencies` | open, for good | every dependabot bump; deliberately not a version | | 8 | `v0.7.0 — School-year calendar, day ribbon, rearrangeable tabs` | `v0.7.0 — Оптимизация` | closed | PRs #75–#85, #128; issues #98, #100, #105–#108 | -| 9 | `v0.8.0 — On-device checks, 89-region e-diary survey` | `v0.8.0 — On a device` | open | PRs #129, #133, #134, #186, #187, #189, #234, #238, #239; issues #109–#117, #130–#132, #167–#185, #188, #219–#233, #237 — the first whose work needs an emulator or a phone, and #186 the first done on one | +| 9 | `v0.8.0 — On-device checks, 89-region e-diary survey` | `v0.8.0 — On a device` | open | PRs #129, #133, #134, #186, #187, #189, #234, #238, #239, #241; issues #109–#117, #130–#132, #167–#185, #188, #219–#233, #237, #240, #242 — the first whose work needs an emulator or a phone, and #186 the first done on one | | 10 | `v0.9.0 — NetSchool e-diary, onboarding via the school's diary` | none — proposed as «v0.9.0 — A second diary», never created under that name | open | PRs #140, #214 and #218 (merged); issues #135–#139, #141, #145–#165, #190–#211 (the external audit of 27 September), #212, #213, #235, #236 | **#142, #143 and #144 are on no milestone, deliberately**: two follow-ups and a decision that @@ -545,14 +575,14 @@ cannot answer — a thumb, a haptic, a real GPU, a real launcher's corners — i the image again — a password the stack refuses to start without, every setting passed through, a non-root user — and are read by `test_compose.py` and `test_dockerfile.py`, not by a container. -- **#201's Keystore seal and #202's https-only release have never run on a device.** The - key is made and used through `AndroidKeystoreKeys`, which `SealedTokensTest` replaces - with a key held in memory under the same `AesGcmTokenCipher`; the migration that seals - an older install's plain-text tokens is tested that way too, and nobody has upgraded a - phone that held one. Which network configuration a - build carries was read out of both packaged APKs with aapt2, and how the platform then - applies it is its documentation's word. The release APK has not been pointed at a - real server. +- **#201's Keystore seal and #202's https-only release have run on emulators, not on a + phone** (2 October 2026, #241). Seen: an upgrade in place sealing a plain-text membership + and the sealed token opening after a force-stop and a reboot; a release build refusing + `http://` to anything but the loopback names at the address field, joining over + `http://127.0.0.1`, and reading production's warmup over TLS. Not seen: a restore onto + another phone or a wiped Keystore, which should read as no token; the diary's bearer, + sealed the same way, because no diary session was opened; and a release build joined to a + production class. - **Dependabot's `uv` entry (#192) has not opened a pull request yet**, so the way a bump regenerates the lock is read from dependabot-core rather than seen. The lock itself was installed on Linux and Python 3.12 by #214's CI, which ran the suite on it, and Vercel @@ -1075,20 +1105,14 @@ server for a fresh install. Each carries the label `needs:owner`. #119 (`/api/v1 `/start`) and #156 (the backup) were answered by #186 and closed at its merge on 26 September 2026. -**Give the release keystore its passwords, on your machine and nowhere else.** The keystore -handed over during #186 is PKCS12 and came without them, so nothing was signed -with it. A local release build reads `lessons.keystore.file`, `lessons.keystore.password`, -`lessons.key.alias` and `lessons.key.password` from `~/.gradle/gradle.properties` (or the -`LESSONS_KEYSTORE_*` and `LESSONS_KEY_*` variables); `docs/build.md` has the shape. Not in a -chat, not in the repository. And before that key replaces the one CI signs with: an APK -signed by a different key does not install over the one already on a phone — #117 showed the -refusal on the emulator. - **Keep some space on C:.** It had about 1.3 GB left early on 27 September, and 14 GB when #187 began, the same night; its builds and one emulator boot left 12 GB, and #189's left 9.4 GB, so each batch with a device in it costs two or three. The emulator refused to start once below 2 GB, and the AVD's Quick Boot image alone is 8.5 GB. The worktrees under -`.claude/worktrees/` each carry their own Gradle build directories. +`.claude/worktrees/` each carry their own Gradle build directories. On 2 October it had +4.5 GB at the start of #241's session and 5.6 GB at its end, nothing having been moved or +cleaned: both AVDs live on F: (`Pixel_10_Pro_XL` 12 GB, `Release_Check` 5 GB), and the +Gradle wrapper fetched 9.8.0 for `4d792df`. **Restart Android Studio once, when it is free.** Three changes wait for it, because the IDE rewrites those files on exit: `server/.venv` as the Python SDK, the root module as a Python @@ -1331,7 +1355,7 @@ The gates, both halves (`CLAUDE.md` requires running both if you touched both): cd server && ruff check app tests scripts migrations # clean cd server && pytest -q -n auto # 2065 tests, ~4 min on CI, ~10 on Windows cd server && python -m mypy # clean, 153 modules -cd android && ./gradlew test # 1579 tests across the five modules +cd android && ./gradlew test # 1587 tests across the five modules cd android && ./gradlew detekt # nothing beyond the five baselines cd android && ./gradlew assembleDebug assembleRelease # both assembles ``` diff --git a/README.md b/README.md index 61dfba01..05ca128f 100644 --- a/README.md +++ b/README.md @@ -207,7 +207,7 @@ Read this before planning a release. | `ruff check app tests scripts migrations` | clean | | `python -m mypy` | clean, 153 modules — asks whether anything reaches for an attribute that does not exist | | `pytest -q -n auto` | 2065 tests, green, about four minutes — the command CI runs | -| `./gradlew test` | 1579 tests, green, all five modules | +| `./gradlew test` | 1587 tests, green, all five modules | | `./gradlew detekt` | no finding beyond each module's baseline, all five modules | | `./gradlew assembleDebug` | the APK builds | | `./gradlew assembleRelease` | the APK builds; R8 and resource shrinking pass | @@ -233,7 +233,10 @@ twelve defects (#167–#178), and the fixes were checked on the same emulator. T requests of that night about the tab bar and the pickers (#179–#184) are held by JVM tests; on the emulator, which the owner was using at the same time, only the one-touch pickup and the pill's round end were seen. What it could not give is written in `HANDOVER.md`: a thumb, -haptics, a real GPU, Doze on a school morning, TalkBack, a real diary account. +haptics, a real GPU, Doze on a school morning, TalkBack, a real diary account. On 2 October +2026 two API 37 emulators added the bearers sealed by the Keystore (#201), through an upgrade +in place and a reboot, and a release build signed with the owner's key refusing `http://` and +reading production over TLS (#202); no phone has run either (#241). **What nothing checks automatically.** One test source set runs on a device, and only on demand: `ToolbarOnDeviceTest` in `:core:designsystem` (#110), three tests of the tab bar's diff --git a/android/core/designsystem/src/main/kotlin/com/lumenpearson/lessons/core/designsystem/component/FloatingToolbar.kt b/android/core/designsystem/src/main/kotlin/com/lumenpearson/lessons/core/designsystem/component/FloatingToolbar.kt index 73e2d04f..f0b4b775 100644 --- a/android/core/designsystem/src/main/kotlin/com/lumenpearson/lessons/core/designsystem/component/FloatingToolbar.kt +++ b/android/core/designsystem/src/main/kotlin/com/lumenpearson/lessons/core/designsystem/component/FloatingToolbar.kt @@ -28,6 +28,7 @@ import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.heightIn import androidx.compose.foundation.layout.navigationBars import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size @@ -77,6 +78,7 @@ import androidx.compose.ui.semantics.onLongClick import androidx.compose.ui.semantics.semantics import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.LocalDensity +import androidx.compose.ui.platform.testTag import androidx.compose.ui.text.rememberTextMeasurer import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.Dp @@ -123,10 +125,20 @@ data class ToolbarAction( val onClick: (at: Offset) -> Unit, ) +/** + * The pill's test tag. The pill draws no text of its own, so its height — the + * one thing #240 got wrong — cannot be asked of any node but this one. + */ +internal const val ToolbarPillTag = "lessons_toolbar_pill" + /** Width of an icon-only item, and the height of every item. */ private val ItemSize: Dp = 48.dp -/** Extra width the selected item grows by to fit its label. */ +/** + * What a label is counted as when deciding whether labels fit on the row at + * all — see [CompactScreenWidthDp] — and the least the row's spare width is + * taken to be. Not the width a label is drawn at: that is its own (#242). + */ private val LabelWidth: Dp = 80.dp /** Gap between two items while the toolbar is expanded. */ @@ -154,8 +166,24 @@ private const val CompactScreenWidthDp = 330 /** Diameter of the badge dot. */ private val BadgeSize: Dp = 8.dp -/** Longest a title may be in the toolbar's standard mode before it marquees. */ -private val TitleWidthRange = 100.dp..250.dp +/** The padding on either side of a title in the toolbar's standard mode. */ +private val TitlePadding: Dp = 8.dp + +/** + * From this smallest width the window is a tablet's — Material's medium window + * class, and the usual line between a phone and a tablet. + */ +private const val TabletSmallestWidthDp = 600 + +/** + * How much of a tablet's window a label or a title may take before it scrolls. + * + * The owner's rule (#242): every button is as wide as its text, and the text + * stops growing at 30 % of a tablet's window; on a phone it may take whatever + * the row leaves it, so that the page's name is read rather than scrolled + * wherever there is room for it. + */ +private const val TabletLabelShare = 0.3f /** * The bar at the bottom: a vibrant pill floating over the content, where the @@ -243,6 +271,7 @@ fun LessonsFloatingToolbar( val slots = items.size + if (actionButton != null) 1 else 0 val hideLabel = fontScale > LabelFontScaleLimit || (screenWidth < CompactScreenWidthDp && slots > 3) + val tablet = LocalConfiguration.current.smallestScreenWidthDp >= TabletSmallestWidthDp val colors = FloatingToolbarDefaults.vibrantFloatingToolbarColors( toolbarContentColor = scheme.onSurface, @@ -255,7 +284,8 @@ fun LessonsFloatingToolbar( modifier = modifier .fillMaxWidth() .windowInsetsPadding(WindowInsets.navigationBars) - .padding(horizontal = 16.dp, vertical = 8.dp), + .padding(horizontal = 16.dp, vertical = 8.dp) + .heightIn(min = ActionSlotHeight), contentAlignment = Alignment.Center, ) { // The two modes cross-fade into each other and the pill resizes with a @@ -299,12 +329,20 @@ fun LessonsFloatingToolbar( ) { backMode -> if (backMode) { Row( - // Material's horizontal padding, moved in here; see - // [PillContentPadding]. - modifier = Modifier.padding(horizontal = PillEndPadding), + // Material's padding, all four sides of it, moved in + // here; see [PillContentPadding]. + modifier = Modifier.padding(PillPadding), verticalAlignment = Alignment.CenterVertically, ) { - BackAndTitle(title = title, onBackClick = onBackClick ?: {}) + BackAndTitle( + title = title, + onBackClick = onBackClick ?: {}, + titleMax = textCap( + screenWidth = screenWidth.dp, + tablet = tablet, + spare = spareTitleWidth(screenWidth.dp, actionButton != null), + ), + ) } } else { ToolbarItems( @@ -325,20 +363,24 @@ fun LessonsFloatingToolbar( reordering = reordering, onReorderingChange = onReorderingChange, onReorder = onReorder, - labelMax = if (scrollableItems) { - LabelWidth - } else { - spareLabelWidth(screenWidth.dp, items.size, actionButton != null) - }, + labelMax = textCap( + screenWidth = screenWidth.dp, + tablet = tablet, + spare = if (scrollableItems) { + scrollingItemsMaxWidth(actionButton != null) - PillPadding * 2 - ItemSize + } else { + spareLabelWidth(screenWidth.dp, items.size, actionButton != null) + }, + ), ) } } } - // Nothing here: the mode morph is animated by the size transform above, - // and within a mode the pill's width already follows its tabs, which - // animate their own widths on a spring. - val pillModifier = Modifier + // Nothing but the tag: the mode morph is animated by the size transform + // above, and within a mode the pill's width already follows its tabs, + // which animate their own widths on a spring. + val pillModifier = Modifier.testTag(ToolbarPillTag) // Two call sites rather than one with a nullable argument: the overload // without the slot is what keeps a toolbar with no action button centred. @@ -469,9 +511,9 @@ private fun ToolbarItems( // padded and the window it scrolls in reaches the pill's edge: // a section scrolled half out of view goes under the pill's // round end rather than being cut off 8 dp inside it (#183). - .padding(horizontal = PillEndPadding) + .padding(PillPadding) } else { - Modifier.padding(horizontal = PillEndPadding) + Modifier.padding(PillPadding) }, verticalAlignment = Alignment.CenterVertically, ) { @@ -558,12 +600,31 @@ private fun ToolbarItems( * action button with its own gap. The terms are [scrollingItemsMaxWidth]'s. */ internal fun spareLabelWidth(screenWidth: Dp, items: Int, hasAction: Boolean): Dp { - val rest = ToolbarSideMargin * 2 + PillEndPadding * 2 + ItemSize * items + + val rest = ToolbarSideMargin * 2 + PillPadding * 2 + ItemSize * items + ItemGap * (items - 1).coerceAtLeast(0) + if (hasAction) ItemSize + ItemGap * 2 else 0.dp return (screenWidth - rest).coerceAtLeast(LabelWidth) } +/** + * The widest a title's text may grow in the standard mode: the window less the + * margins, the pill's ends, the back button and the gap after it, the title's + * own padding, and the button beside the pill if there is one. + */ +internal fun spareTitleWidth(screenWidth: Dp, hasAction: Boolean): Dp { + val rest = ToolbarSideMargin * 2 + PillPadding * 2 + ItemSize + ItemGap + TitlePadding * 2 + + if (hasAction) ItemSize + ItemGap * 2 else 0.dp + return (screenWidth - rest).coerceAtLeast(0.dp) +} + +/** + * The widest a label or a title is drawn before it scrolls (#242): what the row + * can [spare] on a phone, and on a tablet no more than [TabletLabelShare] of the + * window either. + */ +internal fun textCap(screenWidth: Dp, tablet: Boolean, spare: Dp): Dp = + if (tablet) minOf(screenWidth * TabletLabelShare, spare) else spare + /** * A tab's disc. Unselected it is transparent: it used to be the pill's own * colour, invisible everywhere except where a carried tab, drawn above its @@ -610,7 +671,19 @@ private fun scrollingItemsMaxWidth(hasAction: Boolean): Dp { private val ToolbarSideMargin: Dp = 16.dp /** - * Material's padding inside the pill, less its two ends (#183). + * How tall Material makes the bar when a button sits beside the pill: the + * button's slot, sized for a medium FAB (`FloatingToolbarDefaults.FabSizeRange`, + * internal to Material), with the 64 dp pill centred in it. + * + * A bar without a button keeps the same height, so the pill stands at one + * height on every page. Wrapping the pill alone made that bar 16 dp shorter, + * and, sitting on the bottom of the screen, it carried its pill 8 dp lower — + * the pill dropped as settings opened and rose as they closed (#240). + */ +private val ActionSlotHeight: Dp = 80.dp + +/** + * Material's padding inside the pill: none, because all of it is in the rows. * * `FloatingToolbarDefaults.ContentPadding` is 8 dp all round, and in the layout * with a button beside the pill Material scrolls its content inside it. A @@ -618,19 +691,26 @@ private val ToolbarSideMargin: Dp = 16.dp * an end — a documentation section scrolled half out of view, a held tab drawn * larger, a jiggling one — was cut off by a straight edge 8 dp in from the * pill's curve, and the round end the pill clips itself to was never reached. - * The ends' padding is [PillEndPadding] instead, inside every row, so the rows - * sit exactly where they did and everything that leaves them goes under the - * pill's own round end. + * So the ends' padding moved inside every row (#183), and everything that + * leaves a row goes under the pill's own round end. + * + * The top and bottom moved with them, because half of it inside is worse than + * either whole (#240). Without a button beside the pill Material balances the + * pill's padding against the interactive insets it reads off the content's + * alignment lines, and the back button's line said 8 dp in from the side and + * nothing from the top — so Material padded the pill by twice the difference, + * and every page without a button was 80 dp tall where it is 64 dp with one. + * With [PillPadding] on all four sides the insets agree and nothing is added. */ -private val PillContentPadding = PaddingValues(vertical = 8.dp) +private val PillContentPadding = PaddingValues(0.dp) -/** The two ends of Material's padding, drawn inside the rows; see above. */ -private val PillEndPadding: Dp = 8.dp +/** Material's padding, drawn inside every row on all four sides; see above. */ +private val PillPadding: Dp = 8.dp /** * What the cap on the scrolling row keeps back on each side of it beyond the * margins. It was a generous 16 dp estimate of Material's padding, when that - * sat outside the row; [PillEndPadding] is now inside, so this is only what + * sat outside the row; [PillPadding] is now inside, so this is only what * the estimate had to spare, and the pill is exactly as wide as it was. */ private val PillSlack: Dp = 8.dp @@ -721,9 +801,9 @@ private fun ToolbarTab( // As wide as the label, not a fixed 80 dp: «Календарь» in bold is wider // than that at the app's larger text scales and at a system font scale // from about 1.1, and a label that does not fit is a marquee that never - // stops — mid-lap it read «› Кален…» (#227). Never narrower than 80 dp, so - // the short labels and the tests' geometry are as they were, and never - // wider than the row can spare. + // stops — mid-lap it read «› Кален…» (#227). Not held to 80 dp either, the + // floor #227 kept: «Today» sat in a pill twice its width (#242). Never + // wider than [labelMax], past which it scrolls. val labelStyle = MaterialTheme.typography.labelLarge.emphasised(active = true) val measurer = rememberTextMeasurer() val density = LocalDensity.current @@ -731,7 +811,7 @@ private fun ToolbarTab( // A measurement, not a line on screen: one line is what the label is drawn on. val px = measurer.measure(item.label, labelStyle, maxLines = 1, softWrap = false).size.width // A pixel of slack for the round trip through dp. - with(density) { (px + 1).toDp() }.coerceIn(LabelWidth, labelMax.coerceAtLeast(LabelWidth)) + with(density) { (px + 1).toDp() }.coerceAtMost(labelMax) } val labelWidth by animateDpAsState( targetValue = if (selected && !hideLabel) labelFits else 0.dp, @@ -972,6 +1052,7 @@ private fun ToolbarActionButton(action: ToolbarAction) { private fun BackAndTitle( title: String?, onBackClick: () -> Unit, + titleMax: Dp, ) { val scheme = MaterialTheme.colorScheme val view = rememberHapticView() @@ -997,17 +1078,18 @@ private fun BackAndTitle( } if (title != null) { Spacer(Modifier.width(ItemGap)) - // The width range and the padding go on the box, so the title is - // measured against the room it will actually be drawn in rather than - // against the toolbar. Same reason as the label above: a title that - // fits should sit still. + // The cap and the padding go on the box, so the title is measured + // against the room it will actually be drawn in rather than against + // the toolbar. Same reason as the label above: a title that fits + // should sit still. No floor: a short title used to sit in at least + // 100 dp, and «← Sync» was as wide a pill as «← Settings» (#242). MarqueeText( text = title, style = MaterialTheme.typography.titleMedium, color = scheme.background, modifier = Modifier - .widthIn(min = TitleWidthRange.start, max = TitleWidthRange.endInclusive) - .padding(horizontal = 8.dp), + .widthIn(max = titleMax + TitlePadding * 2) + .padding(horizontal = TitlePadding), ) } } diff --git a/android/core/designsystem/src/test/kotlin/com/lumenpearson/lessons/core/designsystem/component/ToolbarLabelFitTest.kt b/android/core/designsystem/src/test/kotlin/com/lumenpearson/lessons/core/designsystem/component/ToolbarLabelFitTest.kt new file mode 100644 index 00000000..0abd548c --- /dev/null +++ b/android/core/designsystem/src/test/kotlin/com/lumenpearson/lessons/core/designsystem/component/ToolbarLabelFitTest.kt @@ -0,0 +1,185 @@ +package com.lumenpearson.lessons.core.designsystem.component + +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.rounded.Settings +import androidx.compose.ui.Modifier +import androidx.compose.ui.semantics.Role +import androidx.compose.ui.semantics.SemanticsActions +import androidx.compose.ui.semantics.SemanticsNode +import androidx.compose.ui.semantics.SemanticsProperties +import androidx.compose.ui.test.SemanticsMatcher +import androidx.compose.ui.test.hasText +import androidx.compose.ui.test.junit4.createComposeRule +import androidx.compose.ui.test.onNodeWithTag +import androidx.compose.ui.test.onNodeWithText +import androidx.compose.ui.test.onRoot +import androidx.compose.ui.text.TextLayoutResult +import androidx.compose.ui.unit.dp +import com.lumenpearson.lessons.core.designsystem.theme.LessonsTheme +import org.junit.Assert.assertEquals +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith +import org.robolectric.RobolectricTestRunner +import org.robolectric.annotation.Config + +/** + * A short label is as wide as its text, and so is the button it is in (#242). + * + * The back pill's title was never under 100 dp and the selected tab's label + * never under 80 dp, so «Sync» sat in the same pill as «Settings» and «Today» + * in a tab half empty. Asked of the text's own line: the box a label is drawn + * in is as wide as the line laid out inside it, give or take the pixel the + * measurement keeps for the round trip through dp. + * + * Robolectric's text is not a font's — a line here is a pixel or so a letter — + * but the label is measured and drawn by the same engine, so a box held wider + * than its line still shows, at 84 px for a 4 px «Sync». 411 dp wide, because + * below 330 dp a bar of three tabs and a button draws no label at all. + * + * A long one stops growing where the owner put the line (#242): on a phone at + * the width the row leaves it, on a tablet at 30 % of the window, and scrolls + * past it. Robolectric's window is drawn at one pixel to the dp, so the widths + * below are written in dp and compared as pixels. + */ +@RunWith(RobolectricTestRunner::class) +@Config(qualifiers = "w411dp") +class ToolbarLabelFitTest { + + @get:Rule + val compose = createComposeRule() + + // Both labels are drawn through `MarqueeText`, whose clock never idles once + // a line overflows; held, so no label can hang the test. + @Before + fun holdTheClock() { + compose.mainClock.autoAdvance = false + } + + @Test + fun `a short title is as wide as its text`() { + showTitle(ShortTitle) + + val title = compose.onNodeWithText(ShortTitle, useUnmergedTree = true).fetchSemanticsNode() + + assertEquals( + "«$ShortTitle» is laid out ${title.lineWidth()} px wide in a box of ${title.size.width} px", + title.lineWidth(), + title.size.width.toFloat(), + Slack, + ) + } + + @Test + fun `the selected tab is as wide as its icon and its label`() { + showTabs(selected = ShortLabel) + + val label = compose.onNodeWithText(ShortLabel, useUnmergedTree = true).fetchSemanticsNode() + val tab = compose + .onNode(hasText(ShortLabel) and SemanticsMatcher.expectValue(SemanticsProperties.Role, Role.Tab)) + .fetchSemanticsNode() + val icon = with(compose.density) { IconSlot.toPx() } + + assertEquals( + "the tab is ${tab.size.width} px for an icon of $icon px and «$ShortLabel» of ${label.lineWidth()} px", + icon + label.lineWidth(), + tab.size.width.toFloat(), + Slack, + ) + } + + @Test + fun `a long title on a phone takes the whole row before it scrolls`() { + showTitle(LongTitle) + + val window = compose.onRoot().fetchSemanticsNode().size.width + val pill = compose.onNodeWithTag(ToolbarPillTag, useUnmergedTree = true).fetchSemanticsNode().size.width + + // The bar's 16 dp margin on either side and nothing else: no button here. + assertEquals("the pill is $pill px in a $window px window", window - 32, pill) + } + + @Test + @Config(qualifiers = "sw800dp-w1000dp-h800dp") + fun `a long title on a tablet stops at 30 percent of the window`() { + showTitle(LongTitle) + + val pill = compose.onNodeWithTag(ToolbarPillTag, useUnmergedTree = true).fetchSemanticsNode().size.width + + // 8 + 48 + 8 before the title, its 8 + 300 + 8, and the pill's own 8. + assertEquals("the pill is $pill px in a 1000 px window", 388, pill) + } + + @Test + @Config(qualifiers = "sw800dp-w1000dp-h800dp") + fun `a long label on a tablet stops at 30 percent of the window`() { + showTabs(selected = LongTitle) + + val tab = compose + .onNode(hasText(LongTitle) and SemanticsMatcher.expectValue(SemanticsProperties.Role, Role.Tab)) + .fetchSemanticsNode() + .size.width + + assertEquals("the tab is $tab px in a 1000 px window", 48 + 300, tab) + } + + private fun showTitle(title: String) { + compose.setContent { + LessonsTheme { + Box(modifier = Modifier.fillMaxSize()) { + LessonsFloatingToolbar(title = title, onBackClick = {}) + } + } + } + compose.settle(frames = 30) + } + + private fun showTabs(selected: String) { + compose.setContent { + LessonsTheme { + Box(modifier = Modifier.fillMaxSize()) { + LessonsFloatingToolbar( + items = listOf(selected, "Calendar", "Homework").map { label -> + ToolbarItem(icon = Icons.Rounded.Settings, label = label) {} + }, + selectedIndex = 0, + action = ToolbarAction(Icons.Rounded.Settings, "Settings") {}, + ) + } + } + } + compose.settle(frames = 60) + } + + /** The width of the first line as laid out, which is the text's own width. */ + private fun SemanticsNode.lineWidth(): Float { + val results = mutableListOf() + config[SemanticsActions.GetTextLayoutResult].action?.invoke(results) + val layout = results.single() + return layout.getLineRight(0) - layout.getLineLeft(0) + } + + private companion object { + + /** The title in the owner's screenshot. */ + const val ShortTitle = "Sync" + + /** About half of the 80 dp the label used to be held to. */ + const val ShortLabel = "Today" + + /** + * Longer than any window here at Robolectric's pixel or so a letter, so + * it reaches whatever cap it is under. + */ + val LongTitle = "Взаимодействие с приложением ".repeat(40).trim() + + /** An icon-only tab: 48 dp, the icon and the gap before the label inside it. */ + val IconSlot = 48.dp + + /** The pixel the measurement adds, and one for rounding. */ + const val Slack = 2f + } +} diff --git a/android/core/designsystem/src/test/kotlin/com/lumenpearson/lessons/core/designsystem/component/ToolbarOverflowTest.kt b/android/core/designsystem/src/test/kotlin/com/lumenpearson/lessons/core/designsystem/component/ToolbarOverflowTest.kt index d2303ed0..2213dda6 100644 --- a/android/core/designsystem/src/test/kotlin/com/lumenpearson/lessons/core/designsystem/component/ToolbarOverflowTest.kt +++ b/android/core/designsystem/src/test/kotlin/com/lumenpearson/lessons/core/designsystem/component/ToolbarOverflowTest.kt @@ -32,9 +32,10 @@ import org.robolectric.RobolectricTestRunner * inside the window, and the button beside the pill is still there to press. */ // marquee clock: the labels are «Раздел 0» … «Раздел 7», eight characters, -// and a toolbar tab's label is drawn at the fixed `LabelWidth` of 80 dp rather -// than at the string's width — which is why this file can assert the pill's -// geometry in the first place. The long strings here are assertion messages. +// and a toolbar tab's label is drawn at its own width up to what the scrolling +// window leaves beside its icon — well over a hundred dp in this window — so +// no label here can overflow and start the marquee (#242). The long strings +// here are assertion messages. @RunWith(RobolectricTestRunner::class) class ToolbarOverflowTest { diff --git a/android/core/designsystem/src/test/kotlin/com/lumenpearson/lessons/core/designsystem/component/ToolbarPillHeightTest.kt b/android/core/designsystem/src/test/kotlin/com/lumenpearson/lessons/core/designsystem/component/ToolbarPillHeightTest.kt new file mode 100644 index 00000000..dc4020f9 --- /dev/null +++ b/android/core/designsystem/src/test/kotlin/com/lumenpearson/lessons/core/designsystem/component/ToolbarPillHeightTest.kt @@ -0,0 +1,144 @@ +package com.lumenpearson.lessons.core.designsystem.component + +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.rounded.BugReport +import androidx.compose.material.icons.rounded.Settings +import androidx.compose.material3.FloatingToolbarDefaults +import androidx.compose.ui.Modifier +import androidx.compose.ui.test.junit4.createComposeRule +import androidx.compose.ui.test.onAllNodesWithTag +import androidx.compose.ui.test.onNodeWithTag +import androidx.compose.ui.unit.dp +import com.lumenpearson.lessons.core.designsystem.theme.LessonsTheme +import org.junit.Assert.assertEquals +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith +import org.robolectric.RobolectricTestRunner + +/** + * The pill is as tall without a button beside it as with one (#240). + * + * The two cases go through different Material overloads, and only the one + * without a button balances its content's padding against the interactive + * insets it reads off the content's alignment lines. While the pill's ends were + * drawn inside the rows and its top and bottom outside them, the back button + * read as 8 dp further in from the side than from the top, and Material padded + * the pill by twice that: 80 dp on every settings page of a reader who does not + * manage the class, 64 dp on the same page with the debug button beside it. + * + * Asked of the pill's own bounds, because the bar around it measures the same + * either way: the overload with a button is a slot of 80 dp with a 64 dp pill + * centred in it, which is exactly the height the broken pill had on its own. + * That is also why only the cases without a button are here: with one, the + * modifier the tag rides on lands on that slot rather than on the pill, and + * the pill inside it is held at [FloatingToolbarDefaults.ContainerSize] by + * Material itself — the height these assert the pill without one keeps. + * + * And it stands where it stands beside a button. That slot is taller than the + * pill, so a bar without one that merely wrapped a 64 dp pill was 16 dp shorter + * and, sitting on the bottom of the screen, carried its pill 8 dp lower: the + * pill dropped as settings opened, which the 16 dp of padding had hidden. + */ +@RunWith(RobolectricTestRunner::class) +class ToolbarPillHeightTest { + + @get:Rule + val compose = createComposeRule() + + // The back mode draws its title through `MarqueeText`, whose clock never + // idles once a title overflows; held, so no title can hang the test. + @Before + fun holdTheClock() { + compose.mainClock.autoAdvance = false + } + + private val tabs = listOf("Сегодня", "Календарь", "Задания").map { label -> + ToolbarItem(icon = Icons.Rounded.Settings, label = label) {} + } + + @Test + fun `a page with no button beside the pill keeps the pill's height`() { + assertPillHeight(back = true) + } + + @Test + fun `tabs with no button beside them keep the pill's height`() { + assertPillHeight(back = false) + } + + @Test + fun `a page with no button holds its pill where a page with one does`() { + // Both bars in one composition — a rule composes once per test — each at + // the top of a box of its own, the second box one box lower. + compose.setContent { + LessonsTheme { + Column(modifier = Modifier.fillMaxSize()) { + for (action in listOf(null, ToolbarAction(Icons.Rounded.BugReport, "Отладка") {})) { + Box(modifier = Modifier.fillMaxWidth().height(BoxHeight)) { + LessonsFloatingToolbar( + title = "Синхронизация", + onBackClick = {}, + action = action, + ) + } + } + } + } + } + compose.settle(frames = 30) + + // With a button the tag is on Material's slot rather than on the pill, + // and Material centres the pill in it, so the slot's centre is the pill's. + val (alone, beside) = compose.onAllNodesWithTag(ToolbarPillTag, useUnmergedTree = true) + .fetchSemanticsNodes() + .map { it.boundsInRoot.center.y } + val box = with(compose.density) { BoxHeight.toPx() } + + assertEquals( + "the pill's centre without a button beside it is $alone px from the top of " + + "its box, and ${beside - box} px with one", + beside - box, + alone, + 0.5f, + ) + } + + private fun assertPillHeight(back: Boolean) { + compose.setContent { + LessonsTheme { + Box(modifier = Modifier.fillMaxSize()) { + LessonsFloatingToolbar( + items = if (back) emptyList() else tabs, + selectedIndex = if (back) -1 else 0, + title = if (back) "Синхронизация" else null, + onBackClick = if (back) ({}) else null, + ) + } + } + } + compose.settle(frames = 30) + + val pill = compose.onNodeWithTag(ToolbarPillTag, useUnmergedTree = true) + .fetchSemanticsNode().size.height + val expected = with(compose.density) { FloatingToolbarDefaults.ContainerSize.roundToPx() } + assertEquals( + "the pill (back mode $back, no button beside it) is $pill px, " + + "where Material's container is $expected px", + expected, + pill, + ) + } + + private companion object { + + /** Taller than either bar, so each sits at the top of its own. */ + val BoxHeight = 200.dp + } +} diff --git a/docs/architecture.md b/docs/architecture.md index 397354f3..c4d9204a 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -862,7 +862,7 @@ with the host. ## Testing -2065 tests on the server, 1579 on Android; `pytest -q -n auto` and `./gradlew test`, both +2065 tests on the server, 1587 on Android; `pytest -q -n auto` and `./gradlew test`, both offline, both in CI. On Android that is `:core:model` 125, `:core:data` 615, `:core:designsystem` 122, `:widget` 126, `:app` 591. diff --git a/docs/history.md b/docs/history.md index 902e31d3..0ca2dacf 100644 --- a/docs/history.md +++ b/docs/history.md @@ -22,11 +22,83 @@ the conventions of the file it was written in: the file; - sections 5 to 8 are `HANDOVER.md`'s, which kept their numbers; sections 1 to 4 are here, after the oldest batch; -- the last three sections hold what was taken out of `HANDOVER.md`'s sections 5, 6 and 7 the - same day, because it narrated work that is done or retold a rule `CLAUDE.md` carries. +- the sections at the end hold what was taken out of `HANDOVER.md`'s sections 5, 6 and 7, + each under the date it left: on 27 September because it narrated work that is done or + retold a rule `CLAUDE.md` carries, and since then because it stopped being true. --- +## What the batch before added: fifteen defects from the owner's phone, #219–#233 + +Merged as #234 (`f2cebbd`, 2 October 2026), from `dev`, on milestone 9. The owner sent twenty screenshots from their phone +on 2 October 2026, marked up in red, and asked for every defect to be fixed, merged into `dev` +fix by fix, then into `main`, and tested synthetically before they check it by eye. Four +read-only agents traced the causes in parallel; every fix was written and tested here, one +branch per fix. + +- **«Сегодня» and the calendar (#219, #220).** The running lesson is now the «сейчас» line + above its row and a gradient of its subject's tint, the same mark a break gets, and the + row's trailing end carries the diary's marks for it — read from `diary.db`, matched by date + and the folded subject name, on the first lesson of a subject taught twice. The calendar's + today, in its list and its day sheet, is marked the same way; it used to pass `now = null`. +- **The widget after school (#221).** The next school day's lessons fill the height under + the homework on every rung with a list, weighted and clipped rather than counted, with the + week strip under them; the 4×2 shows the state and plan above its homework. +- **Sheets (#222).** Material's drag-handle slot wraps anything in a tooltip and a ripple, so + the sheets draw their own pill and pass `null`. +- **Busy states (#223, #224).** A busy action keeps its filled colours, so its spinner is + onPrimary on primary; three view models lower their refresh flag in a `finally`, and the + pull-to-refresh indicator comes out below the status bar. +- **The bar (#225, #226, #227).** Every pick-up of a tab is felt; the carried tab stays + inside the row and an unselected disc is transparent, so it never bites the selected one; + the selected tab is as wide as its measured label. +- **Settings (#228).** The last role per class is kept in the preferences and drawn until + `/me` answers, which the shell now asks at start; the debug button is there from the first + frame after the first answer. +- **Theme reveal (#229).** A wipe on screen is never photographed again, and its job starts + undispatched so the photograph always comes down. +- **First run (#230, #231, #232).** Step bodies fade under the hero instead of being cut, + which is what left three dashes above «Дневник»; «Моей школы нет в списке» moved under the + buttons; the forgotten-password link heads the server block. +- **Sign-in deadlines (#233).** 25 s over the whole diary exchange and 10 s on the preflight + on the phone, 22 s over the server's upstream adopt, each answered with the message that + already existed. + +### Gates + +On `dev` with this close-out on top: `pytest -q -n auto` **2065** passed, one more than +#218's 2064; `ruff` clean; `python -m mypy` clean over 153 source files. `./gradlew test` +**1523** (`:core:model` 125, `:core:data` 571, `:core:designsystem` 122, `:widget` 126, +`:app` 579), twenty-three more than 1500; `assembleDebug` and `assembleRelease` build; +`./gradlew detekt` passes. Every new test was run against the old code where it compiles +there and failed: the sheet handle, the carry and the haptic, the theme reveal, the refresh +flag, the onboarding fade and gap, and the server's adopt deadline. The project's own +meta-tests caught two things in this batch's code — a `maxLines = 1` without a reason and two +compose tests silent about the clock — and `f0c434e` writes the reasons where they ask for them. + +### What was deliberately left alone + +- The drop of a carried tab still plays `CLOCK_TICK`: changing it to a strength-respecting + tap would double with the shell's page-change tap when the drop renumbers the current page. +- The welcome step's hero stays FULL; dropping it to COMPACT would free 148 dp but + `OnboardingFlowTest` pins it, and it is a design question rather than a defect. +- The calendar's lesson rows get the «сейчас» mark but not the diary's marks; only «Сегодня» + was asked for them. + +### What nobody has verified in this batch + +- None of it has been seen on a phone: there is no emulator in a cloud container. Every one + of the fifteen is the owner's to check by eye, which they asked to do. +- #221's weighted list is clipped at its own bottom edge on purpose; how a half-row sits on + each launcher rung is unseen. +- #230 rests on the owner's welcome page having been scrolled when the dashes showed; the + glyph arithmetic says so, the phone has not. +- #231 has no test: composing the school step mid-search needs a view model walked there. +- #227: on a 360 dp phone the spare width is about 88 dp, so at the largest text scales + «Календарь» can still scroll there. +- #233: a deadline landing just after the diary accepted the login leaves a session open on + the diary's side to idle out. + ## What the batch before added: three dependabot bumps, a lock SQLite writers wait for, and #214's close-out Merged as #218 (`c2f1e94`, 2 October 2026), from `ccr-b537fbdd-oi5djs`, on milestone 10. Made in a cloud session on 2 @@ -4004,3 +4076,33 @@ repository — so the request to drop it moved here too. Who dropped it is not r what the IDE generated rather than work — #187's section, «…the first instrumented tests…», lists it — and nothing in a session here drops a stash it did not make. + +## Moved out of section 5 on 2 October 2026 + +#241's session ran both on two API 37 emulators, so the bullet below became the one that +says what was seen there and what still was not. As it stood until then: + +- **#201's Keystore seal and #202's https-only release have never run on a device.** The + key is made and used through `AndroidKeystoreKeys`, which `SealedTokensTest` replaces + with a key held in memory under the same `AesGcmTokenCipher`; the migration that seals + an older install's plain-text tokens is tested that way too, and nobody has upgraded a + phone that held one. Which network configuration a + build carries was read out of both packaged APKs with aapt2, and how the platform then + applies it is its documentation's word. The release APK has not been pointed at a + real server. + +## Moved out of section 7 on 2 October 2026 + +Done by the owner. On 2 October the release APK built on the owner's machine and the one the +APK workflow built from `4d792df` (run 37014696840, `versionCode` 39) were both signed +`CN=lumenpearson`, certificate SHA-256 `d72c75b0…`, read back with `apksigner`. As it stood +until then: + +**Give the release keystore its passwords, on your machine and nowhere else.** The keystore +handed over during #186 is PKCS12 and came without them, so nothing was signed +with it. A local release build reads `lessons.keystore.file`, `lessons.keystore.password`, +`lessons.key.alias` and `lessons.key.password` from `~/.gradle/gradle.properties` (or the +`LESSONS_KEYSTORE_*` and `LESSONS_KEY_*` variables); `docs/build.md` has the shape. Not in a +chat, not in the repository. And before that key replaces the one CI signs with: an APK +signed by a different key does not install over the one already on a phone — #117 showed the +refusal on the emulator.