android: profile screen — nickname + Monero receiving address #148

Merged
sirius merged 2 commits from onionwire/t_54329f2b-android-profile-screen-nickname-monero-r into main 2026-09-22 12:28:49 +00:00
Owner

What

The Android half of the TUI's /profile. A Profile action on the roster's app bar opens a new ui/ProfileScreen.kt where this identity sets its nickname, bio, and the Monero receiving address friends pay to.

Why it matters

Node::wallet_receive_address() answers with the wallet child's own subaddress while the child is up, and the profile xmr_addr otherwise; with neither, the invoice path fails outright. Until now the phone had no way to set either, so every inbound invoice depended on the wallet child running.

Design

  • Route "profile", entry point is a Profile TextButton in the roster's existing TopAppBar actions, beside Lock (which is untouched). Wired through a new onOpenProfile: () -> Unit parameter and a composable("profile") in MainActivity.kt.
  • The core owns the rules. set_self_profile validates nickname (≤ 64 bytes), bio (≤ 512), newlines, and a non-empty address. The screen pre-checks the address with uniffi.onionwire_sdk.checkAddress so a typo is refused before the write, with the typed text still in the field, rather than surfacing as a store error afterwards.
  • An empty address is a real value (it clears the profile address) and is labelled with its consequence on the screen: with no address here and no running wallet child, nobody can send you an invoice.
  • The bio is carried, not owned. A save that did not touch the field writes back the value read from self_profile() immediately before the write, so a bio set in the TUI cannot be blanked from the phone.
  • Save pushes to every friend in the roster, one-shot and fail-closed per peer, mirroring src/tui.rs::save_profile. A push failure is never a save failure: the status always starts with profile saved, names the count, and lists each failure by petname (else shortId(fingerprint)).

Files

 android/app/src/main/java/com/siriusdevops/onionwire/MainActivity.kt          |   6 +
 android/app/src/main/java/com/siriusdevops/onionwire/WireViewModel.kt         |  28 ++
 android/app/src/main/java/com/siriusdevops/onionwire/ui/ProfileScreen.kt      | 448 +++ (new)
 android/app/src/main/java/com/siriusdevops/onionwire/ui/RosterScreen.kt       |   2 +
 android/app/src/test/java/com/siriusdevops/onionwire/ui/ProfileDraftTest.kt   | 252 +++ (new)
 5 files changed, 736 insertions(+)

New symbols: ProfileScreen(vm, onBack), ProfileDraft, ProfilePushOutcome, ProfileDraft.normalized(), profileSaveEnabled, profileAddressProblem, bioToWrite, friendLabel, profileStatusLine, profileAddressNotice, PROFILE_SAVED; WireViewModel.selfProfile() / setSelfProfile() / pushSelfProfile(); RosterScreen(onOpenProfile).

Verification

Unit tests (forced re-run — CI does not run Kotlin unit tests)

./gradlew :app:testDebugUnitTest --rerun -Ponionwire.abis=x86_64 → BUILD SUCCESSFUL, the whole :app suite re-executed at 2026-09-22T06:12:04Z: 163 tests, 0 failures, 0 errors, 0 skipped; ProfileDraftTest 21/21 (xml sha256 5516831f889deca58038b9c981453064cfe8466e1f2dd642490db37913a487f8).

The cases that matter: the save button is dead before the first read and while the form is unchanged, live when dirty, and indifferent to edge whitespace; an empty nickname is saveable (the core allows it, the TUI allows it, the roster already falls back to the fingerprint) — asserted explicitly; the address predicate is not even called for an empty address and sees the trimmed value that would be written; the bio rule (draft wins only when edited, otherwise the freshly stored value) has its own case; the status-line aggregation covers empty roster / all sent / partial / all failed.

Device (AVD ow35, x86_64, API 35, emulator-5560)

Built with -Ponionwire.abis=x86_64; installed APK sha256 2a305bde7561b0cb60f1a59bb44e47dbda2bf493f26905894cae3d3b0c86d19e matches the built APK. Driven by coordinates read from uiautomator dump.

check observed
roster app bar Profile [778,194][885,247] beside Lock [954,194][1033,247]
invalid address typed not-an-address → tap Save → invalid Monero address shown, not-an-address still in the field, no status line (no write)
empty roster save → profile saved
force-stop + relaunch am force-stop (pid gone) → relaunch → Unlock → Profile: lance-emu / bio set on the phone / 4AdUnd…Rge all still there
save on an unchanged form tap swallowed — no status line, i.e. the button really is disabled
push to a friend added this install's own invite as a peer (roster 1) → save → profile saved · sent to 1 friend
push failure per friend emulator network cut (svc data/wifi disable) → save → profile saved · sent to 0 of 1 friend · failed: 0a144d…34bf: connect i2mkeacc…aid.onion:80: tor: error connecting to Tor: Failed to obtain hidden service circuit

Dumps (uiautomator) are attached: before force-stop, after relaunch, the network-down failure, and the roster with the friend.

Not verified

  • Bio preservation across a foreign writer is covered by the unit tests (an_untouched_bio_writes_back_what_the_store_holds_now, an_edited_bio_writes_what_the_user_typed, padding_a_bio_is_not_an_edit) only — there is no TUI build on this host to set a bio behind the screen's back. On the device the bio round-tripped through the store and the process restart; the "field untouched wins over the fresh read" rule was not exercised end to end.
  • The arm64-v8a slice was not rebuilt locally (this shell's cargo resolves to Arch's /usr/bin/cargo, whose sysroot carries no Android targets); CI builds it via the rustup toolchain.
  • Nothing in this change touches the Rust path (src/, crates/).
## What The Android half of the TUI's `/profile`. A **Profile** action on the roster's app bar opens a new `ui/ProfileScreen.kt` where this identity sets its **nickname**, **bio**, and the **Monero receiving address** friends pay to. ## Why it matters `Node::wallet_receive_address()` answers with the wallet child's own subaddress while the child is up, and the profile `xmr_addr` otherwise; with neither, the invoice path fails outright. Until now the phone had no way to set either, so every inbound invoice depended on the wallet child running. ## Design - **Route** `"profile"`, entry point is a `Profile` `TextButton` in the roster's existing `TopAppBar` actions, beside `Lock` (which is untouched). Wired through a new `onOpenProfile: () -> Unit` parameter and a `composable("profile")` in `MainActivity.kt`. - **The core owns the rules.** `set_self_profile` validates nickname (≤ 64 bytes), bio (≤ 512), newlines, and a non-empty address. The screen pre-checks the address with `uniffi.onionwire_sdk.checkAddress` so a typo is refused **before** the write, with the typed text still in the field, rather than surfacing as a store error afterwards. - **An empty address is a real value** (it clears the profile address) and is labelled with its consequence on the screen: with no address here and no running wallet child, nobody can send you an invoice. - **The bio is carried, not owned.** A save that did not touch the field writes back the value read from `self_profile()` immediately before the write, so a bio set in the TUI cannot be blanked from the phone. - **Save pushes to every friend in the roster**, one-shot and fail-closed per peer, mirroring `src/tui.rs::save_profile`. A push failure is never a save failure: the status always starts with `profile saved`, names the count, and lists each failure by petname (else `shortId(fingerprint)`). ## Files ``` android/app/src/main/java/com/siriusdevops/onionwire/MainActivity.kt | 6 + android/app/src/main/java/com/siriusdevops/onionwire/WireViewModel.kt | 28 ++ android/app/src/main/java/com/siriusdevops/onionwire/ui/ProfileScreen.kt | 448 +++ (new) android/app/src/main/java/com/siriusdevops/onionwire/ui/RosterScreen.kt | 2 + android/app/src/test/java/com/siriusdevops/onionwire/ui/ProfileDraftTest.kt | 252 +++ (new) 5 files changed, 736 insertions(+) ``` New symbols: `ProfileScreen(vm, onBack)`, `ProfileDraft`, `ProfilePushOutcome`, `ProfileDraft.normalized()`, `profileSaveEnabled`, `profileAddressProblem`, `bioToWrite`, `friendLabel`, `profileStatusLine`, `profileAddressNotice`, `PROFILE_SAVED`; `WireViewModel.selfProfile() / setSelfProfile() / pushSelfProfile()`; `RosterScreen(onOpenProfile)`. ## Verification ### Unit tests (forced re-run — CI does not run Kotlin unit tests) `./gradlew :app:testDebugUnitTest --rerun -Ponionwire.abis=x86_64` → **BUILD SUCCESSFUL**, the whole `:app` suite re-executed at `2026-09-22T06:12:04Z`: **163 tests, 0 failures, 0 errors, 0 skipped**; `ProfileDraftTest` 21/21 (xml sha256 `5516831f889deca58038b9c981453064cfe8466e1f2dd642490db37913a487f8`). The cases that matter: the save button is dead before the first read and while the form is unchanged, live when dirty, and indifferent to edge whitespace; an **empty nickname is saveable** (the core allows it, the TUI allows it, the roster already falls back to the fingerprint) — asserted explicitly; the address predicate is not even called for an empty address and sees the *trimmed* value that would be written; the bio rule (`draft wins only when edited`, otherwise the freshly stored value) has its own case; the status-line aggregation covers empty roster / all sent / partial / all failed. ### Device (AVD `ow35`, x86_64, API 35, `emulator-5560`) Built with `-Ponionwire.abis=x86_64`; installed APK sha256 `2a305bde7561b0cb60f1a59bb44e47dbda2bf493f26905894cae3d3b0c86d19e` matches the built APK. Driven by coordinates read from `uiautomator dump`. | check | observed | | --- | --- | | roster app bar | `Profile` `[778,194][885,247]` beside `Lock` `[954,194][1033,247]` | | invalid address | typed `not-an-address` → tap Save → `invalid Monero address` shown, `not-an-address` **still in the field**, no status line (no write) | | empty roster | save → `profile saved` | | force-stop + relaunch | `am force-stop` (pid gone) → relaunch → Unlock → Profile: `lance-emu` / `bio set on the phone` / `4AdUnd…Rge` all still there | | save on an unchanged form | tap swallowed — no status line, i.e. the button really is disabled | | push to a friend | added this install's own invite as a peer (roster 1) → save → `profile saved · sent to 1 friend` | | push failure per friend | emulator network cut (`svc data/wifi disable`) → save → `profile saved · sent to 0 of 1 friend · failed: 0a144d…34bf: connect i2mkeacc…aid.onion:80: tor: error connecting to Tor: Failed to obtain hidden service circuit` | Dumps (`uiautomator`) are attached: before force-stop, after relaunch, the network-down failure, and the roster with the friend. ### Not verified - **Bio preservation across a *foreign* writer** is covered by the unit tests (`an_untouched_bio_writes_back_what_the_store_holds_now`, `an_edited_bio_writes_what_the_user_typed`, `padding_a_bio_is_not_an_edit`) only — there is no TUI build on this host to set a bio behind the screen's back. On the device the bio round-tripped through the store and the process restart; the "field untouched wins over the fresh read" rule was not exercised end to end. - The **arm64-v8a** slice was not rebuilt locally (this shell's `cargo` resolves to Arch's `/usr/bin/cargo`, whose sysroot carries no Android targets); CI builds it via the rustup toolchain. - Nothing in this change touches the Rust path (`src/`, `crates/`).
android: profile screen — nickname + Monero receiving address
All checks were successful
android-ci / android (pull_request) Successful in 12m27s
775f2e88be
The phone's half of the TUI's `/profile`. A `Profile` action on the roster's
app bar opens `ui/ProfileScreen.kt`: nickname, bio, and the Monero address
friends pay to, all three loaded from the store and written back through the
core's own validation.

- The address is checked with `uniffi.onionwire_sdk.checkAddress` *before* the
  write, so a typo is refused with the typed text still in the field instead of
  surfacing as a store error afterwards. An empty address is allowed and is
  labelled with its consequence: with no profile address and no running wallet
  child the core has nothing to hand a payer.
- The bio is carried, not owned: a save that did not touch the field writes
  back the value read from the store immediately before the write, so a bio set
  in the TUI cannot be blanked from the phone.
- On save the profile is pushed to **every** friend in the roster, one-shot and
  fail-closed per friend like the TUI's `save_profile`. A push failure is not a
  save failure: the status line always starts with `profile saved` and names the
  count, with each failure listed by petname (else shortened fingerprint).

Every decision the screen makes is a pure function in the new file, covered by
`ProfileDraftTest` (21 cases) on the JVM: the save-button rule (dead until the
read lands, dead while the form is unchanged), the address branch, the bio rule,
label selection and the status-line aggregation.

Verified on AVD ow35 (x86_64 slice, emulator-5560): the roster app bar carries
`Profile`; nickname/bio/address survive `am force-stop` + relaunch; an invalid
address is refused before the write; a save with an empty roster reports
`profile saved`; with one (self-)peer in the roster a save reports
`profile saved · sent to 1 friend`, and with the emulator's network cut the same
save reports `profile saved · sent to 0 of 1 friend · failed: <label>: <tor err>`.
Merge branch 'main' into onionwire/t_54329f2b-android-profile-screen-nickname-monero-r
All checks were successful
android-ci / android (pull_request) Successful in 12m30s
dc8c3933cd
sirius merged commit c5725856ad into main 2026-09-22 12:28:49 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
sirius/onionwire!148
No description provided.