0
Fork 0
mirror of https://github.com/Droid-VM/DroidVM.git synced 2026-11-17 06:58:15 +00:00
Commit graph

5 commits

Author SHA1 Message Date
HuJK
7f23d5de83 vm: Markdown notes, on their own page and rendered where the VM is shown
A VM accumulates things worth writing down -- what it is for, how to log in,
what not to touch -- and a config field is the only place they stay attached to
the VM rather than to whoever set it up. So VMConfig grows "notes", which rides
along in a package like every other field: the notes are about the VM, not about
the phone it happens to be on.

They are edited on a page of their own. A row at the end of the editor's Basic
section carries the first line and an Edit button, because prose in a row-sized
text box is unusable the moment it is longer than a sentence. That page has
three modes -- source, rendered, both -- in the title bar rather than under it,
since a row of its own would cost the editor a line of text for a control that
is three buttons wide.

In "both", the split follows the screen's short axis: upright one pane above the
other, on its side one beside the other, so each pane keeps the longest lines it
can. It is taken from the container's own measurements rather than the display's,
which keeps it right in split-screen, in freeform, and when the keyboard takes
half the screen. The panes are sized in pixels, not weights, and that is not a
detail: a weighted LinearLayout measures its weighted children once with an
unbounded spec along the weight axis, and Compose throws outright when a
horizontally scrollable element -- which is what this renderer makes of a table
or a code block -- is measured against an infinite width. Upright that never
happens; turning the phone took the screen down every time until the weights
went.

The rendered notes appear as a card on the VM's own page and on the vmpkg import
screen, the latter being where someone handed a package finds out what they were
handed, before importing it.

Rendering is Compose, because the renderer is. It is confined to one file with
one entry point, so the editor's preview and the read-only cards cannot drift
apart -- they are the same call. Two things there are deliberate: the palette is
read off the hosting Android theme, so a card of notes sits on the same surface
colour as the card beside it instead of arriving in Compose purple; and the
heading ladder is retuned for a phone, since the library starts h1 at
displayLarge -- 57sp, right for a document on its own page and absurd in a card,
where an h1 would take a line and a half on its own.

The renderer itself is vendored rather than pulled as an artifact. Its published
builds use a newer Kotlin than AGP's built-in Kotlin plugin provides, and a
compiler refuses to read metadata from a newer one, which pinned us to 0.38.1 --
the last release built with Kotlin 2.2 -- and would have kept us there until AGP
moved. As source it compiles with whatever Kotlin the build has, so the version
becomes a choice: this takes 0.45.0, the current release, and it needs no change
to compile under 2.2.10. What is taken is the renderer and its Material 3
bindings, commonMain only -- not the Coil loaders, the Material 2 bindings, the
syntax-highlighting module, or the js/wasm/native source sets. 60 files,
Apache-2.0, under app/src/main/vendor in a root of their own so that "not ours,
and under its own licence" is structural rather than a convention, with no SPDX
header of ours added to them. One file is changed and marked in place:
MarkdownLogger declares `internal expect fun platformLog` upstream with an
`actual` per platform, which needs the Kotlin Multiplatform plugin, so the
androidMain implementation is inlined instead. The root is registered with
kotlin.srcDir, not java.srcDir -- the latter compiles nothing here and leaves
every reference unresolved, which is a confusing way to find out.

Kotlin needs no plugin: AGP 9 compiles it out of the box and already owns the
"kotlin" extension, so asking for the Kotlin plugin fails outright. Only the
Compose compiler plugin is applied, pinned to the Kotlin AGP carries. What stays
an artifact is what the renderer depends on -- the org.jetbrains markdown parser,
kotlinx collections-immutable, coroutines and Compose -- all still subject to
the metadata rule, and all currently built with an older Kotlin than ours.

Signed-off-by: HuJK <gh@hujk.org>
2026-09-03 21:43:51 +08:00
HuJK
efb636443f ci: three source checks, and a build that can unit-test a class that logs
check_arity.py walls off the constructors and methods that had grown past the
point where a caller can be read: a positional list long enough that swapping
two arguments of the same type still compiles. check_vector_icons.py holds the
drawables to one shape so an icon added in a hurry does not arrive at a
different optical size than the row it sits in. check_string_concat gets
stricter, and the two allow-lists carry the deliberate exceptions rather than
leaving the checks off.

isReturnDefaultValues lets a unit test cover a class that logs. Keeping every
testable class free of android.util.Log stopped being tenable once the classes
worth testing were the ones whose whole subject is a socket and a thread
outliving the object that owned them, and which say so out loud when they do.
Nothing asserts on a stub's return value; the stubs only let the class under
test be built.
2026-09-01 20:28:18 +08:00
HuJK
7595658e13 ci: enforce fmt() over complex string concatenation; convert existing ones
Add scripts/ci/check_string_concat.py (wired into the Checks workflow): a
Java-literal-aware scanner that fails when a bare + joins a string literal with a
runtime expression ("x=" + v), which reads better as fmt("x=%s", v). It masks
comments and string/char literals first, so + inside a literal ("wlan+", "%s+",
"\s+") and literal+literal constants are not flagged; a line can opt out with a
trailing // concat-ok comment.

A glance-obvious accumulator append stays as-is: a += statement with at most ONE
+ (s += "x" + y) reads clearly and is exempt; a += chaining two or more +
(s += "a" + b + "c") loses the exemption and is flagged. Only concatenation that
doesn't read at a glance is pushed to fmt(). The + count is scoped per statement
(to the next ; { }).

Convert the pre-existing complex concatenations across the codebase to fmt()
(mostly Log calls); route filesystem-path joins through pathJoin(). Simple
single-+ += appends are left as +=. StringUtils.pathJoin's own body keeps its +
with a // concat-ok note -- it is the canonical joiner and fmt() there would be
a hot-path cost.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TaHcvnHaZk8qqpKiS25Hbk
2026-07-07 03:18:47 +08:00
HuJK
064d4472df review (PR #34): rename VMConsoleRouter, relocate Try, harden shell calls, ASCII base strings
Addresses BigfootACA's review comments:
- Rename VmConsoleRouter -> VMConsoleRouter (VM initialism); update references.
- Move the generic Try<I,V> degradation-ladder helper to lib/utils for reuse
  (now public; javadoc de-specialised from HugePageModel).
- HugePageModel: wrap the module path in escapedString(); build strings with
  fmt() instead of + concatenation.
- HugePageActivity: fmt() for the acquire-dialog title.
- DefaultRouterWatcher: read the sysctl via shellReadFile().
- Base values/strings.xml is ASCII-only now (typographic ellipsis/em-dash ->
  "..." / "-"), and the non-ASCII allowlist narrows to values-*/strings.xml so
  the English source file is checked too.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TaHcvnHaZk8qqpKiS25Hbk
2026-07-06 13:28:02 +08:00
HuJK
8098bca7ca ci: add non-ASCII and translation-completeness PR checks
Two Python checks wired into a new Checks workflow (push + PR):

- check_ascii.py: fails on any non-ASCII byte in a tracked file, so a stray
  smart-quote, em-dash, arrow or CJK char can't slip into code, comments or
  config. Genuine i18n / natural-language files are exempt via
  scripts/ci/ascii_allow.txt (translations, privacy text, docs, ...).
- check_translations.py: fails if any values-<locale>/strings.xml is missing,
  has extra, or has stale entries vs the translatable keys in
  values/strings.xml, so nothing ships half-translated.

Fixes so the current tree passes:
- Replace the check/cross emoji in the virtualization setup step with inline
  tinted vector icons (ImageSpan over ic_check/ic_close); widen showDetail() to
  CharSequence; add status_supported/status_unsupported colors. The mode menu
  already used circle icons; only a stale glyph comment remained.
- Convert typographic dashes/arrows/minus-sign and stray CJK in the hugepage
  and Try comments to ASCII.
- Add the 4 missing zh-rTW strings (vm_exit_crash, vm_exit_guest_panic,
  vm_exit_watchdog, vm_rebooting).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TaHcvnHaZk8qqpKiS25Hbk
2026-07-05 22:20:49 +08:00