From a4ab0c89824d14615695479e59c940eef6729750 Mon Sep 17 00:00:00 2001 From: leather147 Date: Sun, 27 Sep 2026 12:41:21 +0300 Subject: [PATCH 1/3] Keep the next day's time and the homework day on the widget's smallest sizes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A 2×2 on a phone read «4 урока · Алгебра в 08:…» with two of three homework subjects over an empty lower half, and a 2×1 at the largest font read «Д… 3 предмета». The issue put the 2×2 on LARGE; it is SMALL_TALL. At about 195×226 dp, LARGE does not fit inside the box, and the cut was SMALL_TALL's 24-character budget applied to a 25-character line, from its end. The plan line now spends its budget on the subject. The count and the time are what it is for: «4 урока · Алгеб… в 08:30». On the narrow rungs it may take a second line rather than be clipped at 110 dp. SMALL_TALL lists three homework subjects after school; in 190 dp that is about 130 dp of content, 175 at the worst, and NARROW above it has three already. On the 2×1 the label is weighted and the count is not, so an enlarged font took the width from the label. From the first step above the default the count is drawn as the bare figure, «ДЗ на завтра 3», or «ДЗ на завтра нет» with a new string and its English twin. The rule is a step rather than a measurement, because Glance can measure neither text nor the box. DayPlanTest, TinyCountTest and a pinned 2×2 in WidgetSizeClassTest fail on the old code, five of them. On the emulator the 2×2 read «4 урока · Алгеб… в 08:30» over three subjects, and the 2×1 at font scale 2.0 read «ДЗ на завтра 3». Not checked: the one-line size during lessons at a large font («ПЕРЕМЕНА 7 мин»), and any phone but this emulator. Closes #174 Co-Authored-By: Claude Opus 5.5 --- .../lessons/widget/WidgetSizeClass.kt | 10 ++- .../lessons/widget/format/WidgetStrings.kt | 55 +++++++++++- .../lessons/widget/ui/LessonsWidgetBody.kt | 16 ++-- .../lessons/widget/ui/WidgetPresentation.kt | 42 ++++++++- .../widget/src/main/res/values-en/strings.xml | 2 + .../widget/src/main/res/values/strings.xml | 4 + .../lessons/widget/WidgetSizeClassTest.kt | 21 +++++ .../lessons/widget/format/DayPlanTest.kt | 89 +++++++++++++++++++ .../lessons/widget/ui/TinyCountTest.kt | 63 +++++++++++++ docs/widget.md | 17 ++++ 10 files changed, 307 insertions(+), 12 deletions(-) create mode 100644 android/widget/src/test/kotlin/com/lumenpearson/lessons/widget/format/DayPlanTest.kt create mode 100644 android/widget/src/test/kotlin/com/lumenpearson/lessons/widget/ui/TinyCountTest.kt diff --git a/android/widget/src/main/kotlin/com/lumenpearson/lessons/widget/WidgetSizeClass.kt b/android/widget/src/main/kotlin/com/lumenpearson/lessons/widget/WidgetSizeClass.kt index e116210f..318e2a5a 100644 --- a/android/widget/src/main/kotlin/com/lumenpearson/lessons/widget/WidgetSizeClass.kt +++ b/android/widget/src/main/kotlin/com/lumenpearson/lessons/widget/WidgetSizeClass.kt @@ -174,11 +174,19 @@ enum class WidgetSizeClass( * It used to match [SMALL] and leave a third of itself empty. The height * buys the two lines a pupil asks for next: what comes after this, and * whether anything is set for the next school day. + * + * Three homework rows, not [SMALL]'s two. The list is drawn only after + * school, under the state, the plan and the header, and in 190 dp that + * comes to about 130 with three one-line rows — 175 at the worst, with a + * note on the day off and the plan and the header each on two lines. With + * two, a 2×2 on a phone, which is this rung, drew two of three subjects over + * an empty lower half (#174). [NARROW], the only rung above this one at the + * same width, has three as well. */ SMALL_TALL( breakpoint = DpSize(110.dp, 190.dp), timelineRows = 0, - homeworkItems = 2, + homeworkItems = 3, homeworkChars = 24, showsSubject = true, showsMeta = true, diff --git a/android/widget/src/main/kotlin/com/lumenpearson/lessons/widget/format/WidgetStrings.kt b/android/widget/src/main/kotlin/com/lumenpearson/lessons/widget/format/WidgetStrings.kt index 6e9d89db..0b2604fd 100644 --- a/android/widget/src/main/kotlin/com/lumenpearson/lessons/widget/format/WidgetStrings.kt +++ b/android/widget/src/main/kotlin/com/lumenpearson/lessons/widget/format/WidgetStrings.kt @@ -297,6 +297,22 @@ internal object WidgetStrings { context.resources.getQuantityString(R.plurals.widget_subject_count, count, count) } + /** + * The same count without its noun: «3», or «нет» when nothing is set. + * + * For the one-line size at an enlarged font, where the count and the label + * share one line and the label is the half that gives way — at the largest + * font «ДЗ на завтра · 3 предмета» came out as «Д… 3 предмета» (#174). Read + * after «ДЗ на завтра» the figure needs no noun, and «ДЗ на завтра нет» is a + * whole Russian sentence, so the day survives and the answer does too. + */ + fun subjectFigure(context: Context, count: Int): String = + if (count == 0) { + context.resources.getString(R.string.widget_homework_none_short) + } else { + count.toString() + } + /** * The word beside the ticking figure. * @@ -328,15 +344,46 @@ internal object WidgetStrings { fun lessonCount(context: Context, count: Int): String = context.resources.getQuantityString(R.plurals.widget_lesson_count, count, count) - /** "6 уроков · Алгебра в 09:00". */ - fun dayPlan(context: Context, lessons: Int, firstSubject: String, firstAt: LocalTime): String = - context.getString( + /** + * "6 уроков · Алгебра в 09:00", in at most [maxChars] characters. + * + * When it does not fit, the subject is what gives way. The count and the + * time are the facts the line exists for, and the subject is the one part of + * it that still reads shortened. Cut from the end as a whole, the line spent + * its budget on the subject and lost the time: a 2×2 on a phone, on the rung + * whose budget is 24, read «4 урока · Алгебра в 08:…» (#174). + * + * The subject keeps at least [MIN_PLAN_SUBJECT_CHARS] characters with its + * «…». A budget too small even for that is overrun rather than met by + * cutting the time, which is why the narrow rungs give this line two lines. + */ + fun dayPlan( + context: Context, + lessons: Int, + firstSubject: String, + firstAt: LocalTime, + maxChars: Int = Int.MAX_VALUE, + ): String { + // Through `resources`, as `subjectCount` is: `Context.getString` is + // final, and in this module's unit tests a final framework method + // answers null instead of reaching a stub's resources. + fun line(subject: String) = context.resources.getString( R.string.widget_next_day_summary, lessonCount(context, lessons), - firstSubject, + subject, time(firstAt), ) + val subject = firstSubject.collapseWhitespace() + val whole = line(subject) + if (whole.length <= maxChars) return whole + val room = subject.length - (whole.length - maxChars) + return line(subject.ellipsize(room.coerceAtLeast(MIN_PLAN_SUBJECT_CHARS))) + } + + /** «Алг…»: three letters and the «…», the shortest a subject still reads as one. */ + const val MIN_PLAN_SUBJECT_CHARS = 4 + /** "каб. 214", or null when the timetable has no room for this lesson. */ fun room(context: Context, lesson: Lesson): String? = lesson.room?.takeIf { it.isNotBlank() }?.let { context.getString(R.string.widget_room, it) } diff --git a/android/widget/src/main/kotlin/com/lumenpearson/lessons/widget/ui/LessonsWidgetBody.kt b/android/widget/src/main/kotlin/com/lumenpearson/lessons/widget/ui/LessonsWidgetBody.kt index 55162ddf..12ca0af6 100644 --- a/android/widget/src/main/kotlin/com/lumenpearson/lessons/widget/ui/LessonsWidgetBody.kt +++ b/android/widget/src/main/kotlin/com/lumenpearson/lessons/widget/ui/LessonsWidgetBody.kt @@ -236,7 +236,13 @@ private fun TinyBody( ) if (homework.isKnown) { HSpace(6) - CaptionText(text = homework.subjectCount, size = size, emphasised = true) + CaptionText( + // The configuration the widget is drawn against: LocalContext + // is the localized context LessonsWidget provides. + text = tinyCountOf(homework, context.resources.configuration.fontScale), + size = size, + emphasised = true, + ) } } else { val headline = headlineOf(context, state) @@ -632,7 +638,7 @@ private fun AheadBlock( withPlan: Boolean, ) { val context = LocalContext.current - val plan = if (withPlan) dayPlanOf(context, nextDay) else null + val plan = if (withPlan) dayPlanOf(context, nextDay, size.homeworkChars) else null WidgetCard(size = size) { Column(modifier = GlanceModifier.fillMaxWidth()) { @@ -642,7 +648,7 @@ private fun AheadBlock( size = size, ) VSpace(2) - BodyText(text = plan.ellipsize(size.homeworkChars), size = size) + BodyText(text = plan, size = size, maxLines = dayPlanLines(size)) VSpace(6) } HomeworkBlock( @@ -675,7 +681,7 @@ private fun RestDayBody( size: WidgetSizeClass, ) { val context = LocalContext.current - val plan = if (size.showsMeta) dayPlanOf(context, nextDay) else null + val plan = if (size.showsMeta) dayPlanOf(context, nextDay, size.homeworkChars) else null Column(modifier = GlanceModifier.fillMaxSize()) { Column(modifier = GlanceModifier.fillMaxWidth()) { @@ -694,7 +700,7 @@ private fun RestDayBody( } if (plan != null) { VSpace(2) - CaptionText(text = plan.ellipsize(size.homeworkChars), size = size) + CaptionText(text = plan, size = size, maxLines = dayPlanLines(size)) } } VSpace(8) diff --git a/android/widget/src/main/kotlin/com/lumenpearson/lessons/widget/ui/WidgetPresentation.kt b/android/widget/src/main/kotlin/com/lumenpearson/lessons/widget/ui/WidgetPresentation.kt index df3b1cbc..2bdae6ea 100644 --- a/android/widget/src/main/kotlin/com/lumenpearson/lessons/widget/ui/WidgetPresentation.kt +++ b/android/widget/src/main/kotlin/com/lumenpearson/lessons/widget/ui/WidgetPresentation.kt @@ -10,6 +10,7 @@ import com.lumenpearson.lessons.core.model.SchoolDay import com.lumenpearson.lessons.core.model.SchoolEvent import com.lumenpearson.lessons.core.model.ribbonOf import com.lumenpearson.lessons.widget.R +import com.lumenpearson.lessons.widget.WidgetSizeClass import com.lumenpearson.lessons.widget.format.HomeworkDayLabel import com.lumenpearson.lessons.widget.format.WidgetStrings import java.time.Duration @@ -190,13 +191,28 @@ private fun minutesBetween(from: java.time.LocalTime, to: java.time.LocalTime): * Drawn under the timeline on the tallest size, where the rest of today is one * row or none by the middle of the afternoon — which is exactly the hour a pupil * is deciding what to put in a bag for tomorrow. + * + * @param maxChars the rung's budget, spent on the subject rather than on the + * time; see [WidgetStrings.dayPlan]. */ -internal fun dayPlanOf(context: Context, day: SchoolDay?): String? { +internal fun dayPlanOf(context: Context, day: SchoolDay?, maxChars: Int): String? { val lessons = day?.activeLessons.orEmpty() val first = lessons.firstOrNull() ?: return null - return WidgetStrings.dayPlan(context, lessons.size, first.subject, first.startsAt) + return WidgetStrings.dayPlan(context, lessons.size, first.subject, first.startsAt, maxChars) } +/** + * How many lines the day plan may take on [size]. + * + * Two on the narrow rungs. Their budget is a count of characters, and Glance + * clips a line that runs out of width at the pixel, with no «…»: in a column + * that really is 110 dp wide the plan's first line ends around «4 урока · + * Алгебра», and on one line the time would be the part clipped — the same loss + * [WidgetStrings.dayPlan] exists to prevent, arriving by width instead of by + * count. A 2×2 on a phone is nearer 190 dp and still takes one line. + */ +internal fun dayPlanLines(size: WidgetSizeClass): Int = if (size.isNarrow) 2 else 1 + /** * The after-school half of the product: which day the homework is for, and the * homework itself. @@ -206,6 +222,8 @@ internal fun dayPlanOf(context: Context, day: SchoolDay?): String? { * @property items homework for that day, already sorted by subject so the list * does not reshuffle between redraws. * @property subjectCount worded count for the TINY layout. + * @property subjectFigure the same count without its noun, for the TINY layout + * at an enlarged font; see [tinyCountOf]. * @property isKnown false when there is no next school day at all (end of the * cached window, or a holiday longer than the sync horizon). */ @@ -214,9 +232,27 @@ internal data class HomeworkPresentation( val shortHeader: String, val items: List, val subjectCount: String, + val subjectFigure: String, val isKnown: Boolean, ) +/** + * The count the one-line size draws beside «ДЗ на завтра». + * + * That line is a label with `defaultWeight()` and a count with its own width, so + * whatever the count takes the label loses. The worded count was sized at the + * default font, where «ДЗ на послезавтра · 3 предмета» was seen whole on a + * phone's 2×1. Any enlargement spends that width, and at the largest font the + * label came out as «Д…» beside an intact «3 предмета» (#174): the answer with + * no question. The noun is the part that can go without taking the sense with + * it, so from the first step above the default the figure stands alone. + * + * A step, not a measurement: Glance cannot ask how wide text is, and a widget + * box's real width is not handed to the composition either. + */ +internal fun tinyCountOf(homework: HomeworkPresentation, fontScale: Float): String = + if (fontScale > 1f) homework.subjectFigure else homework.subjectCount + /** * True when the homework block *is* the widget, rather than a footnote under a * timeline. @@ -253,6 +289,7 @@ internal fun homeworkOf( shortHeader = unknown, items = emptyList(), subjectCount = WidgetStrings.subjectCount(context, 0), + subjectFigure = WidgetStrings.subjectFigure(context, 0), isKnown = false, ) } @@ -268,6 +305,7 @@ internal fun homeworkOf( shortHeader = WidgetStrings.homeworkHeader(context, label, short = true), items = items, subjectCount = WidgetStrings.subjectCount(context, subjectsIn(items)), + subjectFigure = WidgetStrings.subjectFigure(context, subjectsIn(items)), isKnown = true, ) } diff --git a/android/widget/src/main/res/values-en/strings.xml b/android/widget/src/main/res/values-en/strings.xml index 2eda5592..5715b00c 100644 --- a/android/widget/src/main/res/values-en/strings.xml +++ b/android/widget/src/main/res/values-en/strings.xml @@ -42,6 +42,8 @@ HW for the day after HW for %1$s Nothing set + + none The next school day is not known yet %1$s: %2$s diff --git a/android/widget/src/main/res/values/strings.xml b/android/widget/src/main/res/values/strings.xml index 21798464..f9a9e17e 100644 --- a/android/widget/src/main/res/values/strings.xml +++ b/android/widget/src/main/res/values/strings.xml @@ -50,6 +50,10 @@ ДЗ на послезавтра ДЗ на %1$s Ничего не задано + + нет Следующий учебный день пока неизвестен %1$s: %2$s diff --git a/android/widget/src/test/kotlin/com/lumenpearson/lessons/widget/WidgetSizeClassTest.kt b/android/widget/src/test/kotlin/com/lumenpearson/lessons/widget/WidgetSizeClassTest.kt index 9acf743a..fdbda140 100644 --- a/android/widget/src/test/kotlin/com/lumenpearson/lessons/widget/WidgetSizeClassTest.kt +++ b/android/widget/src/test/kotlin/com/lumenpearson/lessons/widget/WidgetSizeClassTest.kt @@ -86,6 +86,27 @@ class WidgetSizeClassTest { } } + /** + * A 2×2 on a Pixel 10 Pro XL, about 195 × 226 dp, is [WidgetSizeClass.SMALL_TALL]. + * + * #174 said it landed on `LARGE` and blamed the rung for the start time cut + * off the plan line. `LARGE` does not fit inside the box, so neither the + * launcher nor [WidgetSizeClass.of] can choose it. The cut was + * `SMALL_TALL`'s character budget, and the half-empty widget under two + * homework rows was its row count. Pinned so that the next reading of that + * screen starts from the rung it is. + */ + @Test + fun `a phone's 2x2 is the tall small rung, and it lists three homework rows`() { + val phone2x2 = DpSize(195.dp, 226.dp) + assertEquals(WidgetSizeClass.SMALL_TALL, launcherPicks(phone2x2)) + assertEquals(WidgetSizeClass.SMALL_TALL, WidgetSizeClass.of(phone2x2)) + assertTrue( + "the 2×2 of a phone draws two homework rows over an empty lower half", + WidgetSizeClass.SMALL_TALL.homeworkItems >= 3, + ) + } + /** And a genuinely narrow one still gets the column it was written for. */ @Test fun `a two-cell-wide widget still lands on the narrow column`() { diff --git a/android/widget/src/test/kotlin/com/lumenpearson/lessons/widget/format/DayPlanTest.kt b/android/widget/src/test/kotlin/com/lumenpearson/lessons/widget/format/DayPlanTest.kt new file mode 100644 index 00000000..5a4f9fdc --- /dev/null +++ b/android/widget/src/test/kotlin/com/lumenpearson/lessons/widget/format/DayPlanTest.kt @@ -0,0 +1,89 @@ +package com.lumenpearson.lessons.widget.format + +import android.content.ContextWrapper +import android.content.res.Resources +import com.lumenpearson.lessons.widget.R +import com.lumenpearson.lessons.widget.WidgetSizeClass +import com.lumenpearson.lessons.widget.ui.dayPlanLines +import java.time.LocalTime +import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue +import org.junit.Test + +/** + * The day plan keeps its count and its time, and the subject is what gives way (#174). + * + * A 2×2 on a phone is `SMALL_TALL`, whose budget is 24 characters, and + * «4 урока · Алгебра в 08:00» is 25. Cut from the end as a whole the line read + * «4 урока · Алгебра в 08:…» — the one number on it a pupil packing a bag needs + * was the part that went. + * + * No Robolectric in this module, so the context is a stub whose only real part + * is `getResources()`, carrying the Russian format and plural. + */ +class DayPlanTest { + + @Suppress("DEPRECATION") // the only public constructor; the stub ignores its arguments + private val resources = object : Resources(null, null, null) { + override fun getString(id: Int, vararg formatArgs: Any?): String { + check(id == R.string.widget_next_day_summary) { "asked for string $id" } + return String.format("%1\$s · %2\$s в %3\$s", *formatArgs) + } + + override fun getQuantityString(id: Int, quantity: Int, vararg formatArgs: Any?): String { + check(id == R.plurals.widget_lesson_count) { "asked for plural $id" } + return "$quantity " + when { + quantity % 10 == 1 && quantity % 100 != 11 -> "урок" + quantity % 10 in 2..4 && quantity % 100 !in 12..14 -> "урока" + else -> "уроков" + } + } + } + + private val context = object : ContextWrapper(null) { + override fun getResources(): Resources = this@DayPlanTest.resources + } + + private fun plan(lessons: Int, subject: String, maxChars: Int) = + WidgetStrings.dayPlan(context, lessons, subject, LocalTime.of(8, 0), maxChars) + + @Test + fun `a plan that fits is drawn whole`() { + assertEquals("4 урока · Алгебра в 08:00", plan(4, "Алгебра", maxChars = 56)) + } + + @Test + fun `over the budget, the subject is shortened and the time is kept`() { + val budget = WidgetSizeClass.SMALL_TALL.homeworkChars + val drawn = plan(4, "Алгебра", maxChars = budget) + + assertTrue("«$drawn» lost the time", drawn.endsWith(" в 08:00")) + assertTrue("«$drawn» lost the count", drawn.startsWith("4 урока · ")) + assertTrue("«$drawn» does not say it was shortened", "…" in drawn) + assertTrue("«$drawn» is over the budget of $budget", drawn.length <= budget) + } + + @Test + fun `a long subject is what pays for the whole overrun`() { + val drawn = plan(6, "Литературное чтение", maxChars = 24) + + assertEquals("6 уроков · Лите… в 08:00", drawn) + } + + @Test + fun `the subject keeps a readable stub even when the budget cannot hold it`() { + // Ten lessons and a budget of 18: the count and the time alone are + // twenty. The time is still not the part that goes; the line overruns, + // and the narrow rungs that could be handed such a budget have two lines. + val drawn = plan(10, "Алгебра", maxChars = 18) + + assertEquals("10 уроков · Алг… в 08:00", drawn) + } + + @Test + fun `the plan may take two lines only where a column is narrow`() { + WidgetSizeClass.entries.forEach { size -> + assertEquals(size.name, if (size.isNarrow) 2 else 1, dayPlanLines(size)) + } + } +} diff --git a/android/widget/src/test/kotlin/com/lumenpearson/lessons/widget/ui/TinyCountTest.kt b/android/widget/src/test/kotlin/com/lumenpearson/lessons/widget/ui/TinyCountTest.kt new file mode 100644 index 00000000..db6eb2d2 --- /dev/null +++ b/android/widget/src/test/kotlin/com/lumenpearson/lessons/widget/ui/TinyCountTest.kt @@ -0,0 +1,63 @@ +package com.lumenpearson.lessons.widget.ui + +import android.content.ContextWrapper +import android.content.res.Resources +import com.lumenpearson.lessons.widget.R +import com.lumenpearson.lessons.widget.format.WidgetStrings +import org.junit.Assert.assertEquals +import org.junit.Test + +/** + * At an enlarged font the one-line size drops the count's noun, not the day (#174). + * + * «ДЗ на завтра» carries `defaultWeight()` and the count beside it its own + * width, so at the largest font the widget read «Д… 3 предмета»: the answer, + * with the question it answers cut to one letter. + */ +class TinyCountTest { + + @Suppress("DEPRECATION") // the only public constructor; the stub ignores its arguments + private val resources = object : Resources(null, null, null) { + override fun getString(id: Int): String { + check(id == R.string.widget_homework_none_short) { "asked for string $id" } + return "нет" + } + } + + private val context = object : ContextWrapper(null) { + override fun getResources(): Resources = this@TinyCountTest.resources + } + + private fun presentation(worded: String, figure: String) = HomeworkPresentation( + header = "Домашнее задание на завтра", + shortHeader = "ДЗ на завтра", + items = emptyList(), + subjectCount = worded, + subjectFigure = figure, + isKnown = true, + ) + + @Test + fun `at the default font the count keeps its noun`() { + assertEquals("3 предмета", tinyCountOf(presentation("3 предмета", "3"), fontScale = 1f)) + } + + @Test + fun `from the first step above the default the figure stands alone`() { + val three = presentation("3 предмета", "3") + listOf(1.15f, 1.3f, 1.5f, 1.8f, 2f).forEach { scale -> + assertEquals("at $scale", "3", tinyCountOf(three, fontScale = scale)) + } + } + + @Test + fun `a smaller font keeps the worded count`() { + assertEquals("3 предмета", tinyCountOf(presentation("3 предмета", "3"), fontScale = 0.85f)) + } + + @Test + fun `the figure is the number, and nothing set is a word`() { + assertEquals("3", WidgetStrings.subjectFigure(context, 3)) + assertEquals("нет", WidgetStrings.subjectFigure(context, 0)) + } +} diff --git a/docs/widget.md b/docs/widget.md index 1af7c6d0..580c0101 100644 --- a/docs/widget.md +++ b/docs/widget.md @@ -61,6 +61,23 @@ who had asked for bigger type lost the rest of their school day. The floor of th a widget that says nothing is a worse answer than one whose last row is clipped. `WidgetFontScaleTest` walks it. +**On the smallest sizes, what gives way is decided rather than left to the pixel** (#174). +Glance cannot ellipsize and cannot measure, so a line that runs out of room is cut wherever +the width ends. Two lines were being cut at their most useful end: + +- The next day's plan, «4 урока · Алгебра в 08:30», was cut to the rung's character budget + from the end, which is the time. `WidgetStrings.dayPlan` now spends the budget on the + subject («4 урока · Алгеб… в 08:30»), and the narrow rungs let it take a second line + rather than be clipped at 110 dp. +- On the 2×1, «ДЗ на завтра» is weighted and the count beside it is not, so at the largest + font the label came out as «Д…» beside an intact «3 предмета». From the first step above + the default font the count is drawn as the bare figure — «ДЗ на завтра 3», or «ДЗ на + завтра нет» — and the day survives. + +A 2×2 on a Pixel 10 Pro XL is about 195×226 dp, which is `SMALL_TALL`, not `LARGE`: `LARGE` +does not fit inside it. `SMALL_TALL` lists three homework subjects after school, where it +used to list two over an empty lower half. + Every block drawn inside the widget takes its corner from the rung's own padding rather than from a constant — `WidgetSizeClass.innerCorner()`, the surface's 24 dp less that padding. The rule and the four places that deliberately do not follow it are in From 675cafefef18c5cb4fd2d18950b8a3f37dde4903 Mon Sep 17 00:00:00 2001 From: leather147 Date: Sun, 27 Sep 2026 12:41:32 +0300 Subject: [PATCH 2/3] Redraw the widget when a setting it draws changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Switched to Russian on the emulator, the app redrew at once and the 2×2 widget went on saying «DAY OFF» and «HW for tomorrow». A pull-to-refresh answered 304 and did not redraw it either, and only a reinstall did. The widget draws three settings: the language, «Прогресс в виджете» and the teacher switch. It is redrawn by DATA_SYNCED, which a sync sends only when the data changed, and by its own tick, which on a day off is hours away. A settings change was neither. SettingsRepositoryImpl.update now sends DATA_SYNCED when AppSettings.drawnByWidget moves, beside the alert re-arm it already did the same way. The widget reads its settings through that projection and nothing wider, so a setting it starts to draw cannot be drawn without also being the thing that asks for a redraw. The repository reads a SettingsStore now, which LessonsPreferences implements the way it implements DiarySessionStore and ShellModeSource, so WidgetSettingsRedrawTest can hand it a map: this module's JVM tests cannot open a DataStore. Its first case fails without the call. On the emulator, Russian before the switch to English and English three seconds after it, with no reinstall in between. Not covered: a change of the system font scale, which decides the rung and the one-line count, is a configuration change rather than a setting and was not watched to see whether anything redraws after it. Closes #188 Co-Authored-By: Claude Opus 5.5 --- .../core/data/datastore/LessonsPreferences.kt | 11 +-- .../lessons/core/data/di/LessonsContainer.kt | 3 + .../lessons/core/data/repository/Models.kt | 23 ++++++ .../data/repository/SettingsRepositoryImpl.kt | 46 +++++++++--- .../repository/WidgetSettingsRedrawTest.kt | 71 +++++++++++++++++++ .../lessons/widget/LessonsWidget.kt | 8 ++- docs/widget.md | 7 ++ 7 files changed, 151 insertions(+), 18 deletions(-) create mode 100644 android/core/data/src/test/kotlin/com/lumenpearson/lessons/core/data/repository/WidgetSettingsRedrawTest.kt diff --git a/android/core/data/src/main/kotlin/com/lumenpearson/lessons/core/data/datastore/LessonsPreferences.kt b/android/core/data/src/main/kotlin/com/lumenpearson/lessons/core/data/datastore/LessonsPreferences.kt index a309be39..727bcd33 100644 --- a/android/core/data/src/main/kotlin/com/lumenpearson/lessons/core/data/datastore/LessonsPreferences.kt +++ b/android/core/data/src/main/kotlin/com/lumenpearson/lessons/core/data/datastore/LessonsPreferences.kt @@ -20,6 +20,7 @@ import com.lumenpearson.lessons.core.data.repository.DiarySessionStore import com.lumenpearson.lessons.core.data.repository.DiaryTarget import com.lumenpearson.lessons.core.data.repository.DiaryTargetCodec import com.lumenpearson.lessons.core.data.repository.Session +import com.lumenpearson.lessons.core.data.repository.SettingsStore import com.lumenpearson.lessons.core.data.repository.ShellMode import com.lumenpearson.lessons.core.data.repository.ShellModeSource import com.lumenpearson.lessons.core.data.repository.ShellState @@ -70,7 +71,7 @@ private val Context.lessonsDataStore: DataStore by preferencesDataS * screens, they are both tiny, and a single file means a single fsync and a * single flow to observe. */ -internal class LessonsPreferences(context: Context) : DiarySessionStore, ShellModeSource { +internal class LessonsPreferences(context: Context) : DiarySessionStore, ShellModeSource, SettingsStore { private val dataStore = context.applicationContext.lessonsDataStore @@ -89,13 +90,13 @@ internal class LessonsPreferences(context: Context) : DiarySessionStore, ShellMo /** Every class this device has joined, in the order they were joined. */ val sessions: Flow> = preferences.map { it.memberships() }.distinctUntilChanged() - val settings: Flow = preferences.map { it.toSettings() }.distinctUntilChanged() + override val settings: Flow = preferences.map { it.toSettings() }.distinctUntilChanged() suspend fun currentSession(): Session? = preferences.first().activeMembership() suspend fun currentSessions(): List = preferences.first().memberships() - suspend fun currentSettings(): AppSettings = preferences.first().toSettings() + override suspend fun currentSettings(): AppSettings = preferences.first().toSettings() /** * Stores a membership and makes it the one being shown. @@ -266,7 +267,7 @@ internal class LessonsPreferences(context: Context) : DiarySessionStore, ShellMo } /** Read-modify-write inside DataStore's transaction, so concurrent edits merge. */ - suspend fun updateSettings(transform: (AppSettings) -> AppSettings) { + override suspend fun updateSettings(transform: (AppSettings) -> AppSettings) { dataStore.edit { prefs -> val updated = transform(prefs.toSettings()) prefs[KEY_BASE_URL] = updated.baseUrl.trim() @@ -386,7 +387,7 @@ internal class LessonsPreferences(context: Context) : DiarySessionStore, ShellMo * few hundred bytes and DataStore serves every read after the first from * memory, so this costs one disk read per process. */ - fun languageBlocking(): AppLanguage = runBlocking { currentSettings().language } + override fun languageBlocking(): AppLanguage = runBlocking { currentSettings().language } /** * The shape of the cached schedule as of the previous sync. diff --git a/android/core/data/src/main/kotlin/com/lumenpearson/lessons/core/data/di/LessonsContainer.kt b/android/core/data/src/main/kotlin/com/lumenpearson/lessons/core/data/di/LessonsContainer.kt index 17c33b69..5c2c5346 100644 --- a/android/core/data/src/main/kotlin/com/lumenpearson/lessons/core/data/di/LessonsContainer.kt +++ b/android/core/data/src/main/kotlin/com/lumenpearson/lessons/core/data/di/LessonsContainer.kt @@ -313,6 +313,9 @@ class DefaultLessonsContainer( // the one moment that also has to answer for what is already on // the shade, and it is the only caller that may — see the KDoc. onAlertsChanged = { SchoolAlerts.onAlertsChanged(appContext) }, + // The same broadcast a sync that changed the data sends: the widget + // cannot be called from this module, and it already listens for it. + onWidgetSettingsChanged = { DataSyncBroadcast.send(appContext) }, ) } diff --git a/android/core/data/src/main/kotlin/com/lumenpearson/lessons/core/data/repository/Models.kt b/android/core/data/src/main/kotlin/com/lumenpearson/lessons/core/data/repository/Models.kt index ed413a0b..80b3fe43 100644 --- a/android/core/data/src/main/kotlin/com/lumenpearson/lessons/core/data/repository/Models.kt +++ b/android/core/data/src/main/kotlin/com/lumenpearson/lessons/core/data/repository/Models.kt @@ -383,6 +383,29 @@ data class AppSettings( } } +/** + * The settings the home-screen widget draws, and nothing else. + * + * One value that both sides read. The widget takes its language and its options + * from here and from nowhere else in [AppSettings], and a settings change asks + * it to redraw when this, and only this, has moved (#188). A setting the widget + * starts to draw belongs here, or the widget will draw it and not be told when + * it changes. + */ +data class WidgetSettings( + val language: AppLanguage, + val showProgress: Boolean, + val showTeacher: Boolean, +) + +/** @see WidgetSettings */ +val AppSettings.drawnByWidget: WidgetSettings + get() = WidgetSettings( + language = language, + showProgress = widgetShowProgress, + showTeacher = showTeacher, + ) + /** * Outcome of a sync attempt. * diff --git a/android/core/data/src/main/kotlin/com/lumenpearson/lessons/core/data/repository/SettingsRepositoryImpl.kt b/android/core/data/src/main/kotlin/com/lumenpearson/lessons/core/data/repository/SettingsRepositoryImpl.kt index 72a72f20..2ca3c6ef 100644 --- a/android/core/data/src/main/kotlin/com/lumenpearson/lessons/core/data/repository/SettingsRepositoryImpl.kt +++ b/android/core/data/src/main/kotlin/com/lumenpearson/lessons/core/data/repository/SettingsRepositoryImpl.kt @@ -8,23 +8,46 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.withContext /** - * A thin pass-through to [LessonsPreferences], plus one side effect. + * Where the settings are kept: the part of [LessonsPreferences] this repository + * reads, so that a test can hand it a map instead of a DataStore file, which + * this module's JVM tests cannot open. + */ +internal interface SettingsStore { + val settings: Flow + + fun languageBlocking(): AppLanguage + + suspend fun currentSettings(): AppSettings + + suspend fun updateSettings(transform: (AppSettings) -> AppSettings) +} + +/** + * A thin pass-through to [LessonsPreferences], plus two side effects. * * It exists anyway so that consumers depend on an interface in this package * rather than on DataStore, which keeps the storage choice replaceable and keeps * `Preferences` out of every ViewModel's imports. * - * @param onAlertsChanged re-arms the notification alarm. It belongs here rather - * than in the settings screen because a preference has one owner: turning an - * alert on from anywhere — the first-run flow, the settings page, a future - * quick setting — has to arm the chain, and only this method sees all of them. - * It is called only when the alert block actually moved, so toggling the theme - * does not go near an `AlarmManager`. + * Both side effects belong here rather than in the settings screen because a + * preference has one owner: a change from anywhere — the first-run flow, the + * settings page, a future quick setting — comes through [update], and only this + * method sees all of them. Each is called only when its own part of the settings + * actually moved, so toggling the theme goes near neither. + * + * @param onAlertsChanged re-arms the notification alarm when the alert block + * moved. + * @param onWidgetSettingsChanged asks the widget to redraw when + * [AppSettings.drawnByWidget] moved. The widget redraws on a sync that changed + * the data and on its own tick, and a settings change is neither: switched to + * Russian, the widget went on drawing English until something else woke it, + * which on a day off is hours (#188). */ internal class SettingsRepositoryImpl( - private val preferences: LessonsPreferences, + private val preferences: SettingsStore, private val ioDispatcher: CoroutineDispatcher = Dispatchers.IO, private val onAlertsChanged: () -> Unit = {}, + private val onWidgetSettingsChanged: () -> Unit = {}, ) : SettingsRepository { override val settings: Flow = preferences.settings @@ -32,13 +55,14 @@ internal class SettingsRepositoryImpl( override fun languageBlocking(): AppLanguage = preferences.languageBlocking() override suspend fun update(transform: (AppSettings) -> AppSettings) { - val before = preferences.currentSettings().alerts + val before = preferences.currentSettings() preferences.updateSettings(transform) - val after = preferences.currentSettings().alerts - if (before != after) { + val after = preferences.currentSettings() + if (before.alerts != after.alerts) { // Off the caller's thread: this is usually a view model scope on the // main dispatcher, and rescheduling reads the cached timetable. withContext(ioDispatcher) { onAlertsChanged() } } + if (before.drawnByWidget != after.drawnByWidget) onWidgetSettingsChanged() } } diff --git a/android/core/data/src/test/kotlin/com/lumenpearson/lessons/core/data/repository/WidgetSettingsRedrawTest.kt b/android/core/data/src/test/kotlin/com/lumenpearson/lessons/core/data/repository/WidgetSettingsRedrawTest.kt new file mode 100644 index 00000000..1e7d3772 --- /dev/null +++ b/android/core/data/src/test/kotlin/com/lumenpearson/lessons/core/data/repository/WidgetSettingsRedrawTest.kt @@ -0,0 +1,71 @@ +package com.lumenpearson.lessons.core.data.repository + +import com.lumenpearson.lessons.core.model.AppLanguage +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.test.UnconfinedTestDispatcher +import kotlinx.coroutines.test.runTest +import org.junit.Assert.assertEquals +import org.junit.Test + +/** + * A change to a setting the widget draws asks the widget to redraw (#188). + * + * Switched to Russian on the emulator, the app redrew at once and the widget + * went on drawing English: nothing but a sync that changed the data, or the + * widget's own tick, ever asked it to draw again, and on a day off the tick is + * hours away. + */ +@OptIn(ExperimentalCoroutinesApi::class) +class WidgetSettingsRedrawTest { + + private class MemoryStore : SettingsStore { + val current = MutableStateFlow(AppSettings()) + override val settings: Flow = current + override fun languageBlocking(): AppLanguage = current.value.language + override suspend fun currentSettings(): AppSettings = current.value + override suspend fun updateSettings(transform: (AppSettings) -> AppSettings) { + current.value = transform(current.value) + } + } + + private var redraws = 0 + + private fun repository() = SettingsRepositoryImpl( + preferences = MemoryStore(), + ioDispatcher = UnconfinedTestDispatcher(), + onWidgetSettingsChanged = { redraws++ }, + ) + + @Test + fun `every setting the widget draws asks it to redraw`() = runTest { + val repository = repository() + + repository.update { it.copy(language = AppLanguage.RUSSIAN) } + repository.update { it.copy(widgetShowProgress = false) } + repository.update { it.copy(showTeacher = false) } + + assertEquals(3, redraws) + } + + @Test + fun `a setting the widget does not draw leaves it alone`() = runTest { + val repository = repository() + + repository.update { it.copy(pitchBlack = true) } + repository.update { it.copy(hapticsEnabled = false) } + repository.update { it.copy(todayShowHero = false) } + + assertEquals(0, redraws) + } + + @Test + fun `writing the value it already has is not a change`() = runTest { + val repository = repository() + + repository.update { it.copy(language = AppLanguage.SYSTEM) } + + assertEquals(0, redraws) + } +} diff --git a/android/widget/src/main/kotlin/com/lumenpearson/lessons/widget/LessonsWidget.kt b/android/widget/src/main/kotlin/com/lumenpearson/lessons/widget/LessonsWidget.kt index 89cf5d85..93b38707 100644 --- a/android/widget/src/main/kotlin/com/lumenpearson/lessons/widget/LessonsWidget.kt +++ b/android/widget/src/main/kotlin/com/lumenpearson/lessons/widget/LessonsWidget.kt @@ -21,6 +21,7 @@ import com.lumenpearson.lessons.core.data.di.Graph import com.lumenpearson.lessons.core.data.locale.AppLocale import com.lumenpearson.lessons.core.data.repository.ShellMode import com.lumenpearson.lessons.core.data.repository.ShellModeSource +import com.lumenpearson.lessons.core.data.repository.drawnByWidget import com.lumenpearson.lessons.core.model.AppLanguage import com.lumenpearson.lessons.core.model.DayState import com.lumenpearson.lessons.core.model.DeepLink @@ -239,7 +240,10 @@ class LessonsWidget : GlanceAppWidget() { val (mode, timetable) = readModeAndTimetable(container.shellMode) { container.timetableRepository.snapshotAroundToday() } - val settings = container.settingsRepository.settings.first() + // Through `drawnByWidget` and nothing wider: it is also what decides + // whether a settings change asks this widget to redraw (#188), so a + // setting read here from anywhere else would be drawn and never updated. + val settings = container.settingsRepository.settings.first().drawnByWidget // The school's wall clock, not the phone's. These differ whenever the // device has travelled, and permanently for anyone following a school @@ -252,7 +256,7 @@ class LessonsWidget : GlanceAppWidget() { now = now, mode = mode, options = WidgetOptions( - showProgress = settings.widgetShowProgress, + showProgress = settings.showProgress, showTeacher = settings.showTeacher, // Only one trailing detail fits a phone-width row, and the room // outranks the teacher — so with both on, the teacher never diff --git a/docs/widget.md b/docs/widget.md index 580c0101..ad10c30e 100644 --- a/docs/widget.md +++ b/docs/widget.md @@ -197,6 +197,13 @@ Every redraw now bumps `WidgetRedraws` before it asks, and a composition that is re-reads when the counter moves; a redraw that starts a session reads the counter with its first snapshot and does not read twice. +**A settings change the widget draws redraws it** (#188). The widget draws three settings: +the app's language, «Прогресс в виджете» and the teacher switch. It reads them through +`AppSettings.drawnByWidget` and nothing wider, and `SettingsRepositoryImpl.update` sends +`DATA_SYNCED` when that value moves. Before, nothing did: on an emulator switched to Russian +the app redrew at once and the widget stayed English until a reinstall woke it, because a +settings change is neither a sync that changed the data nor a tick. + ## The picker `previewLayout` is what the launcher's widget picker draws, from XML, without running a line From cad84a8dcb50b04923753f8f092f236ab1d28324 Mon Sep 17 00:00:00 2001 From: leather147 Date: Sun, 27 Sep 2026 12:45:08 +0300 Subject: [PATCH 3/3] Record the widget's smallest sizes and its settings redraw, and what they left MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit HANDOVER.md opens on #189 and gains its batch: #174's diagnosis corrected (the phone's 2×2 is SMALL_TALL, not LARGE) before the fix, the fix, #188 found while checking it and fixed, what the emulator showed in both languages and at font scale 2.0, how the widget can and cannot be redrawn from a shell, and the gates on 675cafe. #187's section becomes «What the session before it added» and records its merge; the chain below shifts by one, and two references to #186's section now name it by its subject, since «What the batch before added» is shared. Section 5 says what #189 did not see: the one-line size during lessons at a large font, a system font-scale change, any other launcher. Section 7 has this batch's cost in disk. The Android test count is 1459 in its three places. Co-Authored-By: Claude Opus 5.5 --- HANDOVER.md | 145 +++++++++++++++++++++++++++++++++---------- README.md | 2 +- docs/architecture.md | 6 +- 3 files changed, 117 insertions(+), 36 deletions(-) diff --git a/HANDOVER.md b/HANDOVER.md index 23737839..716923b0 100644 --- a/HANDOVER.md +++ b/HANDOVER.md @@ -5,32 +5,36 @@ the moment of handover**, so that a new session — human or agent — continues place without reopening or redoing anything. Last updated: **27 September 2026**. **PRs #63 through #85, #128, #129, #133, #134, #140, -#166 and #186 are merged**; `main` is at `c26eace`, the merge of #186, and `dev` is level -with it. **The only thing open is the pull request carrying this paragraph, #187**, from -`agents/first-android-test`, on milestone 9, `v0.8.0 — On-device checks, 89-region e-diary -survey`. It gives the project its first instrumented tests (#110) and fixes three of the four -defects #186 filed and left open (#171, #175, #176). The section «What the last session -added» below is that batch. +#166, #186 and #187 are merged**; `main` is at `2a408d8`, the merge of #187, and `dev` is +level with it. **The only thing open is the pull request carrying this paragraph, #189**, +from `agents/widget-small-sizes`, on milestone 9, `v0.8.0 — On-device checks, 89-region +e-diary survey`. It fixes the last defect #186 filed and left open (#174, the widget's two +smallest sizes) and one found while checking that fix on the emulator (#188, a widget that +did not follow its own settings). 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. -**What #187 moves.** Android: `:core:designsystem` has an `androidTest` source set, the -first anywhere in the project, whose three tests drag the tab bar's arranging gesture by -fractions of a slot at a device's own density (#110) — run on demand, never in CI, which has -no device; the diary's two sign-in forms say «по HTTPS, прямо в дневник» once rather than -twice (#175); the join screen drops an error once the server address it was an answer from -has changed (#176); and two syncs of one class's year that overlap make one request rather -than two (#171). No server change, no schema change; `EXPECTED_REVISION` is still `0017`. +**What #189 moves.** Android, all of it in the widget: +- The next school day's plan keeps its count and its time and shortens the subject: «4 урока + · Алгеб… в 08:30», where a phone's 2×2 read «4 урока · Алгебра в 08:…». +- `SMALL_TALL`, which is what that 2×2 really is, lists three homework subjects after school + instead of two. +- At any font above the default, the 2×1 draws the count as a bare figure, «ДЗ на завтра 3», + where it read «Д… 3 предмета» (#174). +- Changing the language, «Прогресс в виджете» or the teacher switch redraws the widget at + once instead of whenever something else next woke it (#188). -**Once #187 merges, four issues are meant to close:** #110, #171, #175 and #176. **#174** -(two small widget sizes cut the wrong text) stays open and was not started. 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. What a merge closes is decided by the `Closes` -lines in the pull request body and in the commit messages, not by this paragraph — read them -against this list before merging. +No server change, no schema change; `EXPECTED_REVISION` is still `0017`. -**#186 closed all twenty-one issues it named** — #167–#170, #172, #173, #177–#185, #156, -#119, #114, #115, #116 and #117 — read back from GitHub on 27 September. +**Once #189 merges, two issues are meant to close:** #174 and #188. That leaves no defect +open that a session can fix. 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. What a +merge closes is decided by the `Closes` lines in the pull request body and in the commit +messages, not by this paragraph — read them against this list before merging. + +**#187 closed the four issues it named** (#110, #171, #175, #176), read back from GitHub on +27 September, as #186 closed its twenty-one. **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 @@ -133,10 +137,76 @@ 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: the first instrumented tests, and three defects the walkthrough left +## What the last session added: the widget's two smallest sizes, and a widget that did not follow its settings + +Open as #189, from `agents/widget-small-sizes`, on milestone 9. Two commits, one per issue, +each checked on the API 37 emulator against a local server seeded with `seed_demo`, on a +Sunday, so on the widget's day-off layout. + +- **#174, the diagnosis was corrected before the fix.** The issue said a phone's 2×2 (about + 195×226 dp) landed on `LARGE`. It cannot: `LARGE` is 250×250 and does not fit inside the + box, and both the launcher and `WidgetSizeClass.of` keep only the breakpoints that fit. It + is `SMALL_TALL`, and the screen said so twice. «4 урока · Алгебра в 08:00» is 25 + characters against that rung's budget of 24, cut from the end, so the time was what went. + Two homework rows is that rung's count. The correction went into the issue's thread first, + and `WidgetSizeClassTest` now pins where that 2×2 lands. +- **#174, the fix.** `WidgetStrings.dayPlan` spends the budget on the subject and keeps the + count and the time; the narrow rungs may give the plan a second line + (`dayPlanLines`), because at a true 110 dp Glance would otherwise clip it at the pixel. + `SMALL_TALL` lists three subjects after school: about 130 dp of its 190, 175 at the worst. + On the 2×1 the label is weighted and the count is not, so at an enlarged font the label + lost; `tinyCountOf` draws the bare figure from the first step above the default, + «ДЗ на завтра 3» or «ДЗ на завтра нет» (a new string, `widget_homework_none_short`, with + its English twin). The step is a choice, not a measurement: Glance measures neither text + nor the box. +- **#188, found while checking #174.** The app was switched to Russian and the widget stayed + English. A `304` sync did not redraw it, and only a reinstall (`MY_PACKAGE_REPLACED`) did. + Nothing redrew the widget on a settings change at all. Filed, then fixed: + `SettingsRepositoryImpl.update` sends `DATA_SYNCED` when `AppSettings.drawnByWidget` + moves, beside the alert re-arm it already did the same way, and the widget reads its three + settings through that projection only. To test it without a DataStore, the repository reads + a small `SettingsStore` interface, which `LessonsPreferences` implements the way it already + implements `DiarySessionStore` and `ShellModeSource`. + +### On the emulator + +The 2×2 read «4 урока · Алгеб… в 08:30» over three subjects, and «4 lessons · Алг… at 08:30» +in English. The 2×5 column (`NARROW`) read the same plan line. The 2×1 read «ДЗ на завтра · +3 предмета» at font scale 1.0 and «ДЗ на завтра 3» at 2.0. For #188, the 2×1 read «ДЗ на +завтра» before the app was switched to English and «HW for tomorrow 3 subjects» three seconds +after, with nothing else in between. + +**Two things about driving the widget from a shell**, which cost time and will again. First, +the shell cannot redraw it: `DATA_SYNCED` is filtered by a receiver the shell cannot reach, +and `APPWIDGET_UPDATE` is a protected broadcast. Second, a pull-to-refresh answered `304` and +redraws nothing, by design. What does redraw it is reinstalling the same APK, because +`MY_PACKAGE_REPLACED` is one of the widget's own triggers. The launcher's resize handles take +`input swipe`: a long press on the widget, then a drag from a handle. + +### Gates + +On `675cafe`: `./gradlew test` **1459** (`:core:model` 125, `:core:data` 543, +`:core:designsystem` 112, `:widget` 123, `:app` 556), thirteen more than #187's 1446 — +`DayPlanTest` 5, `TinyCountTest` 4, one in `WidgetSizeClassTest`, `WidgetSettingsRedrawTest` +3. `assembleDebug` and `assembleRelease` build. Each new test was run against the old +behaviour first: five fail for #174 and one for #188. The server was not touched, so its +gates were not run. + +### What nobody has verified in this batch + +- The one-line size **during lessons** at a large font («ПЕРЕМЕНА 7 мин», the same weighted + label beside a countdown) was not looked at. +- A change of the **system** font scale is a configuration change, not an app setting. + Whether anything redraws the widget after one was not checked: every render here was forced + with a reinstall. +- The `fontScale > 1` step was seen at 2.0 on this one emulator. +- At 195 dp the whole «4 урока · Алгебра в 08:30» would fit, and the rung's budget shortens + it anyway, because the same rung serves 110 dp. + +## What the session before it added: the first instrumented tests, and three defects the walkthrough left -Open as #187, from `agents/first-android-test`, on milestone 9. Four commits from the night of -26–27 September and one from the session that picked them up. +Merged as `2a408d8`. Four commits from the night of 26–27 September and one from the +session that picked them up. - **#110, the first `androidTest`.** `ToolbarOnDeviceTest` in `:core:designsystem` holds a tab past the device's own long-press timeout and drags it 0.7 and 0.4 of a slot in one @@ -239,7 +309,7 @@ has not been asked. #176's defect never reproduced on demand. #175's single sent looked at on a screen: reaching a password form needs a region's diary to answer. Nothing here changes what #186 could not answer: a thumb, a haptic, a real GPU, a real launcher. -## What the session before it added: the first walk of the app on a device, and the twelve defects it found +## What the batch before added: the first walk of the app on a device, and the twelve defects it found Merged as `c26eace`. **What #186 moved.** Android: the widget picker's preview draws again (#167); the widget follows a class switch made inside a live Glance session (#168); a look at @@ -2655,7 +2725,7 @@ titles of their own time, which a search no longer finds; the third column maps | 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; issues #109–#117, #130–#132, #167–#185 — 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; issues #109–#117, #130–#132, #167–#185, #188 — 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 | PR #140 (merged); issues #135–#139, #141, #145–#165 | **#142, #143 and #144 are on no milestone, deliberately**: two follow-ups and a decision that @@ -3094,7 +3164,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 # 2024 tests, ~4 min on CI, ~10 on Windows cd server && python -m mypy # clean, 100 modules -cd android && ./gradlew test # 1446 tests across the five modules +cd android && ./gradlew test # 1459 tests across the five modules cd android && ./gradlew assembleDebug assembleRelease # both assembles ``` @@ -3492,8 +3562,8 @@ device on it. #140's additions below belong to #121 where they need a live diary merge. The prose here is kept because it says *why* each one is unverifiable, which an issue title cannot. -**#186 looked at a good part of this on an emulator** (26–27 September 2026; «What the -session before it added» has the detail). The bullets it answered say so in place, and what an emulator +**#186 looked at a good part of this on an emulator** (26–27 September 2026; the section +«…the first walk of the app on a device» has the detail). The bullets it answered say so in place, and what an emulator cannot answer — a thumb, a haptic, a real GPU, a real launcher's corners — is still here. - **Not one route in `docs/diaries/` has been seen answering.** #134's 1916 routes @@ -3622,6 +3692,16 @@ cannot answer — a thumb, a haptic, a real GPU, a real launcher's corners — i sits against a launcher's own widget rounding. Below API 31 the question does not arise — `cornerRadius` is a no-op there and the launcher supplies square edges — so the check needs a phone on 31 or later and a widget resized twice. +- **#189 was seen on an emulator's launcher, and only as far as the day-off layout goes.** + The 2×1, 2×2 and 2×5 after school, at font scale 1.0 and 2.0, in both languages. Not + seen: + - the one-line size during lessons at a large font, where «ПЕРЕМЕНА» is weighted beside a + countdown the same way «ДЗ на завтра» was beside its count; + - whether a change of the *system* font scale redraws the widget by itself — it decides + the rung and the 2×1's count, it is a configuration change rather than one of the three + app settings #188 now redraws on, and every render in that check was forced with a + reinstall; + - any launcher but the emulator's. - **Nothing of #83's widget work has been seen on a launcher either, and that is the surface this batch changed most.** The font-scale division, the two weights that stop the trailing detail starving the subject, and the outer box that gives the seven day chips their gaps @@ -4426,19 +4506,20 @@ signed by a different key does not install over the one already on a phone — # 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. The emulator refused to +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. **Drop the `Teleport auto-stash` when convenient** (`stash@{0}`, over `c26eace`). It holds -what the IDE generated rather than work — «What the last session added» lists it — and +what the IDE generated rather than work — «What the session before it added» lists it — and nothing in a session here drops a stash it did not make. **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 one (which quiets «Unsupported Modules Detected»), and the third-party «Python Portable» plugin disabled, since it fails to load on every start. Everything else in the IDE's set-up -is already in place (see «What the session before it added»). +is already in place (see «…the first walk of the app on a device», the section on #186). **The tenth milestone exists, and #140 is on it.** The owner created `v0.9.0 — NetSchool e-diary, onboarding via the school's diary` on 25 September and renamed diff --git a/README.md b/README.md index 68a0ca09..84c19c1c 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, 100 modules — asks whether anything reaches for an attribute that does not exist | | `pytest -q -n auto` | 2024 tests, green, about four minutes — the command CI runs | -| `./gradlew test` | 1446 tests, green, all five modules | +| `./gradlew test` | 1459 tests, green, all five modules | | `./gradlew assembleDebug` | the APK builds | | `./gradlew assembleRelease` | the APK builds; R8 and resource shrinking pass | | `./gradlew :core:designsystem:connectedDebugAndroidTest` | 3 tests, green on an API 37 emulator — on demand only, never in CI, which has no device | diff --git a/docs/architecture.md b/docs/architecture.md index dbac9bf7..ea46c885 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -723,9 +723,9 @@ with the host. ## Testing -2024 tests on the server, 1446 on Android; `pytest -q -n auto` and `./gradlew test`, both -offline, both in CI. On Android that is `:core:model` 125, `:core:data` 540, -`:core:designsystem` 112, `:widget` 113, `:app` 556. +2024 tests on the server, 1459 on Android; `pytest -q -n auto` and `./gradlew test`, both +offline, both in CI. On Android that is `:core:model` 125, `:core:data` 543, +`:core:designsystem` 112, `:widget` 123, `:app` 556. The table below is the load-bearing part of that rather than the whole of it: