Thin the app's comments
The same pass the server had, on the Kotlin side: comments restating what the code says are gone, and the ones recording a measurement, a constraint or an incident are kept but cut to a few lines each. 6540 comment lines to 5674, and 920 lines off the app. Two doc comments had drifted onto the item above the one they describe -- `contextAfter`'s onto `sessionWorking` in Events.kt, and `UsageMonitor`'s equivalent on the server was fixed in the previous commit. Each is back on its own item, which is the only non-comment line this diff moves. The comments are reflowed to the column limit at their own indentation: several were written wide, and ktfmt re-wrapped them into lines holding a single orphan word. `/tmp` script, not kept -- ktfmt is idempotent over the result, which is the check. Left alone deliberately: this codebase's remaining comment density is high because the comments carry things the code cannot say -- what a null means, what a number was measured against, which bug a guard exists for. Of the 238 one-line doc comments in the app, five were pure restatement of the name and were removed; the rest each say something the signature does not. ktfmtFormat, compileDebugKotlin, lintDebug and testDebugUnitTest pass; cargo test (127), clippy --all-targets and fmt still clean. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
79682f03a7
commit
edc39c7371
68 files changed
+2077
-2997
No files matched your search
@@ -26,26 +26,21 @@ import androidx.compose.ui.unit.sp
|
||||
* set and kept in step by hand.
|
||||
*
|
||||
* This replaced a hand-drawn canvas gear, whose doc comment argued against icon fonts on the
|
||||
* grounds that a system font may not have the glyph and whoever gets the empty box instead is never
|
||||
* the person who wrote it. That objection is about *relying* on a system font, and it is exactly
|
||||
* right: the answer is not to avoid glyphs but to ship them. The font here is
|
||||
* `app/build-icon-font.sh`'s output -- seventeen glyphs, 2.8 KB, subset out of the 3 MB symbols
|
||||
* font and committed -- so the codepoints below are resolved by an asset in the APK and cannot come
|
||||
* back as tofu. Adding one means adding its codepoint in *both* places; a codepoint here that the
|
||||
* script did not subset is a glyph that silently isn't there.
|
||||
* grounds that a system font may not have the glyph. That objection is about *relying* on a system
|
||||
* font, and it is exactly right: the answer is not to avoid glyphs but to ship them. The font here
|
||||
* is `app/build-icon-font.sh`'s output -- seventeen glyphs, 2.8 KB, subset out of the 3 MB symbols
|
||||
* font and committed. Adding one means adding its codepoint in *both* places; a codepoint here that
|
||||
* the script did not subset is a glyph that silently isn't there.
|
||||
*
|
||||
* The subset is the font's **Mono** face, where every glyph is exactly one em wide and one em tall.
|
||||
* That is what makes two icons the same size without either of them being given a size: the
|
||||
* proportional face's advances run from 0.46 em to 0.92 em, so a Send button and a Stop button side
|
||||
* by side came out visibly different widths, and matching them at the call site would have meant
|
||||
* one hardcoded measurement per pair. [GLYPH_SIZE] carries the cost.
|
||||
* That is what makes two icons the same size without either being given a size: the proportional
|
||||
* face's advances run from 0.46 em to 0.92 em, so a Send button and a Stop button side by side came
|
||||
* out visibly different widths. [GLYPH_SIZE] carries the cost.
|
||||
*
|
||||
* The same arrangement as dev-updater, down to the cog and the refresh arrow being the same two
|
||||
* Material Design codepoints. Those two must not drift: an icon that means "settings" in one app
|
||||
* and something else in the other is the failure this is worth preventing. The script is copied
|
||||
* rather than shared because most of what looks like duplication is the `GLYPHS` list, which has to
|
||||
* differ -- the point of subsetting is to ship only the codepoints one app draws. All Material
|
||||
* Design bar one, so they read as one family; the exception is noted where it is declared.
|
||||
* Material Design codepoints. Those two must not drift. The script is copied rather than shared
|
||||
* because most of what looks like duplication is the `GLYPHS` list, which has to differ -- the
|
||||
* point of subsetting is to ship only the codepoints one app draws.
|
||||
*/
|
||||
val NerdIcons = FontFamily(Font(R.font.nerd_icons))
|
||||
|
||||
@@ -74,8 +69,7 @@ val STOP_GLYPH = glyph(0xF04DB)
|
||||
*
|
||||
* The pair with [STOP_GLYPH] and [PLAY_GLYPH] is the point: one button in the composer says what
|
||||
* pressing it now would do to the process, and the three marks are the three answers. An interrupt
|
||||
* ends a turn and nothing else -- the CLI is still there and still holds the conversation -- which
|
||||
* is a pause, not a stop, and drawing it as a square said otherwise.
|
||||
* ends a turn and nothing else, which is a pause, not a stop.
|
||||
*/
|
||||
val PAUSE_GLYPH = glyph(0xF03E4)
|
||||
|
||||
@@ -86,8 +80,8 @@ val PLAY_GLYPH = glyph(0xF040A)
|
||||
* `md-send_clock` -- the same paper plane with a clock on it: this message will wait its turn.
|
||||
*
|
||||
* The pair with [SEND_GLYPH] is the point. Sending during a turn queues the message rather than
|
||||
* starting one, and the two buttons have to be told apart at a glance -- one glyph doing both jobs
|
||||
* while looking identical would promise something immediate and do something that waits.
|
||||
* starting one, and one glyph doing both jobs would promise something immediate and do something
|
||||
* that waits.
|
||||
*/
|
||||
val QUEUE_GLYPH = glyph(0xF1163)
|
||||
|
||||
@@ -104,8 +98,7 @@ val BELL_GLYPH = glyph(0xF009A)
|
||||
* `fa-line_chart` -- how much of the account's rate limits is gone.
|
||||
*
|
||||
* Font Awesome's rather than Material's, which is the one break in the family above: it was asked
|
||||
* for by name, and Material's chart glyphs are a bare line where this one has its axes, which is
|
||||
* what makes it read as a measurement rather than as a trend.
|
||||
* for by name, and Material's chart glyphs are a bare line where this one has its axes.
|
||||
*/
|
||||
val USAGE_GLYPH = glyph(0xF201)
|
||||
|
||||
@@ -121,9 +114,8 @@ val SPEED_GLYPH = glyph(0xF04C5)
|
||||
* `md-folder` -- the files on the machine this session runs on.
|
||||
*
|
||||
* The same codepoint dev-updater uses, and it must not drift from it, for the reason the cog and
|
||||
* the refresh arrow must not: a folder that meant something else in one of the two apps is exactly
|
||||
* the confusion sharing them prevents. Doubles as the mark on a directory row inside the explorer,
|
||||
* which is what makes the button say where it leads.
|
||||
* the refresh arrow must not. Doubles as the mark on a directory row inside the explorer, which is
|
||||
* what makes the button say where it leads.
|
||||
*/
|
||||
val FOLDER_GLYPH = glyph(0xF024B)
|
||||
|
||||
@@ -148,10 +140,9 @@ val SAVE_GLYPH = glyph(0xF0193)
|
||||
* The size an icon draws at beside a line of text.
|
||||
*
|
||||
* 17 rather than the 20 it was while the font was the proportional face. A glyph there filled at
|
||||
* most 0.83 em of its point size and most filled a good deal less, so the number was standing in
|
||||
* for the headroom above the tallest one; in the Mono face every glyph fills its em exactly, and
|
||||
* keeping 20 would have made every icon in the app step up by a fifth for no reason anybody asked
|
||||
* for. This is what the largest of them already drew at.
|
||||
* most 0.83 em of its point size, so the number was standing in for the headroom above the tallest
|
||||
* one; in the Mono face every glyph fills its em exactly, and keeping 20 would have stepped every
|
||||
* icon in the app up by a fifth.
|
||||
*/
|
||||
private val GLYPH_SIZE = 17.sp
|
||||
|
||||
@@ -165,16 +156,14 @@ private val GLYPH_EXTENT = GLYPH_SIZE.value.dp
|
||||
*
|
||||
* The ring is the whole spacing rule. Every gap around a header icon comes out of it -- one ring to
|
||||
* the screen edge, two where a button meets its neighbour -- so nothing outside has to add a gap of
|
||||
* its own, and a mark cannot end up further from the button beside it than from the edge of the
|
||||
* screen. That is what it was: the box was the size of the mark (28dp) and the separation was
|
||||
* its own. That is what it was: the box was the size of the mark (28dp) and the separation was
|
||||
* bolted on beside it, which left the two header icons 31dp apart and the outer one 14dp from the
|
||||
* edge, so a pair that acts on one screen read as two unrelated marks with one falling off it.
|
||||
* edge.
|
||||
*
|
||||
* 48dp is the platform's minimum touch target, so the square is also the whole of what a finger has
|
||||
* to find. It is what the pressed-state ripple draws, too: at 28dp that circle was inscribed in the
|
||||
* mark's own corners, and beside a title it arrived at the first letter. And it is taller than any
|
||||
* header's text, which is what lets the button fill a header row rather than sit in the middle of
|
||||
* one -- the rows add no vertical padding of their own for the same reason they add no gap.
|
||||
* to find, and what the pressed-state ripple draws: at 28dp that circle was inscribed in the mark's
|
||||
* own corners and beside a title it arrived at the first letter. And it is taller than any header's
|
||||
* text, which is what lets the button fill a header row rather than sit in the middle of one.
|
||||
*/
|
||||
private val GLYPH_BUTTON_SIZE = 48.dp
|
||||
|
||||
@@ -182,11 +171,9 @@ private val GLYPH_BUTTON_SIZE = 48.dp
|
||||
* The ring itself, for putting something that is *not* a glyph button next to one -- a title beside
|
||||
* a back arrow.
|
||||
*
|
||||
* Two glyph buttons need nothing between them: each brings its own ring and the two add up, which
|
||||
* is why a row of them sets no spacing. Text brings none, so the second ring has to be asked for.
|
||||
* Without it the pressed-state circle, which fills the whole square, arrives at the first letter of
|
||||
* the title -- and the gap a reader sees between the mark and that title is then half the one
|
||||
* between the two marks at the other end of the same row.
|
||||
* Two glyph buttons need nothing between them: each brings its own ring and the two add up. Text
|
||||
* brings none, so the second ring has to be asked for -- without it the pressed-state circle
|
||||
* arrives at the first letter of the title.
|
||||
*/
|
||||
val GLYPH_BUTTON_MARGIN = (GLYPH_BUTTON_SIZE - GLYPH_EXTENT) / 2
|
||||
|
||||
@@ -195,8 +182,7 @@ val GLYPH_BUTTON_MARGIN = (GLYPH_BUTTON_SIZE - GLYPH_EXTENT) / 2
|
||||
*
|
||||
* Its own composable so that every icon button in the app is one size and one colour without each
|
||||
* caller saying so, and so the [label] none of them displays is still there for a screen reader --
|
||||
* which is all assistive technology has to go on, and also the answer to "what was that button for"
|
||||
* six months from now.
|
||||
* which is also the answer to "what was that button for" six months from now.
|
||||
*
|
||||
* [enabled] is passed through rather than left to callers hiding the button: a control that comes
|
||||
* and goes makes its own absence the signal, and absence cannot say whether there was nothing to do
|
||||
@@ -220,9 +206,8 @@ fun GlyphButton(
|
||||
* The same square, around a mark that is not a glyph.
|
||||
*
|
||||
* A [Chevron] is drawn rather than set in a font, and a pair of them used as buttons has to be the
|
||||
* size, spacing and touch target every other icon button on this app's headers already is -- so
|
||||
* this is [GlyphButton] with the mark left to the caller rather than a second set of measurements
|
||||
* beside it. The caller still owes it a [label]: nothing here draws a word.
|
||||
* size, spacing and touch target every other icon button already is. The caller still owes it a
|
||||
* [label]: nothing here draws a word.
|
||||
*/
|
||||
@Composable
|
||||
fun MarkButton(
|
||||
@@ -245,9 +230,7 @@ fun MarkButton(
|
||||
* The square a glyph button occupies, with a spinner in it instead of a mark.
|
||||
*
|
||||
* For a button whose work is under way. It takes the button's whole box rather than the mark's, so
|
||||
* swapping one for the other leaves everything in the row exactly where it was -- a control that
|
||||
* changed the width of its header while it worked would move its neighbours at the moment somebody
|
||||
* was pressing them.
|
||||
* swapping one for the other leaves everything in the row exactly where it was.
|
||||
*/
|
||||
@Composable
|
||||
fun GlyphSpinner(label: String, modifier: Modifier = Modifier) {
|
||||
@@ -273,10 +256,9 @@ fun Glyph(
|
||||
size: TextUnit = GLYPH_SIZE,
|
||||
) {
|
||||
// Line height of the point size, which for this font is the square the glyph draws in: its
|
||||
// ascent and descent add up to exactly one em, and every glyph in the Mono face fills that em.
|
||||
// Left to the inherited body style the line box was 24sp tall around a 17sp-wide mark, so a
|
||||
// glyph took a seventh more vertical space than horizontal wherever one is drawn without a box
|
||||
// around it -- and where there is a box, that leading is what its padding is measured through.
|
||||
// ascent and descent add up to exactly one em. Left to the inherited body style the line box
|
||||
// was 24sp tall around a 17sp-wide mark, so a glyph took a seventh more vertical space than
|
||||
// horizontal.
|
||||
Text(
|
||||
glyph,
|
||||
fontFamily = NerdIcons,
|
||||
|
||||
Reference in new issue
Block a user