Skip to content

feat(app): tablet shares to the Mac; APK updates in place; update prompt; full screen; responsive + dark mode - #24

Merged
th3r-dev merged 6 commits into
devfrom
feat/android-share
Nov 11, 2026
Merged

th3r-dev merged 6 commits into
devfrom
feat/android-share

Conversation

@th3r-dev

@th3r-dev th3r-dev commented Nov 11, 2026 •

Copy link
Copy Markdown
Owner

Part 2 of tablet → Mac. Part 1, the host as a library, was #23. This also fixes Android updates.

1. Share this screen (Android)

Share this screen in the Android app makes the tablet a Mirror-only Mullion host:

  1. Android asks for consent (choose Entire screen). A "Mullion is sharing this screen" notification appears, with Stop sharing.
  2. The app shows the address to enter on the Mac and how many devices are watching.
  3. On the Mac: Mullion menu → Connect to Another Computer… → the tablet under Nearby (platform "Android"), or its address.
  4. The tablet shows a 6-digit code to type on the Mac, the same pairing as with a Mac, with Don't Allow to refuse.

How it works:

  • Kotlin (crates/app/android/kotlin):
    • MainActivity asks for consent.
    • ShareService, a foreground service of type mediaProjection, feeds a virtual display into the hardware H.264 encoder. Settings: Baseline, 30 fps, 6 Mbps, long side at most 1920. It repeats the last frame after 100 ms, so a still screen keeps streaming.
    • Each output buffer goes to Rust over JNI. The call's return value asks for a key frame, so Rust never calls back into Java.
  • Rust (crates/app/src/share.rs):
    • An AndroidPlatform for mullion_host. It prepends MediaCodec's SPS/PPS to every IDR (unit tested).
    • The host starts on the first share: port 47100, Extend off, pairing store in the app's files.
    • Between shares it refuses to stream.
  • Page:
    • The Share button and the sharing sheet.
    • While Android has paused the app, Rust's events wait until the page next sends a message. So the page sends a no-op poke() while waiting for Android's answer and when the app comes back.
  • Wording: /hello reports "Android". pair.js names the host instead of "the Mac", because a Mac now pairs with tablets too.
  • build-android.sh:
    • It copies our Kotlin over dx's output and adds the service and its permissions to the manifest.
    • A local rerun no longer fails on dx's template icons sitting next to ours.

2. APK updates install over the old app

Updating failed with "package conflicts". Gradle signs debug builds with ~/.android/debug.keystore, and a fresh CI runner makes a new one each time, so every beta had its own key. The workflow now writes one key there before building, from the new ANDROID_DEBUG_KEYSTORE secret, and the update link no longer says to uninstall first.

One last uninstall: apps already installed were signed with the old one-off keys, so the first install of this build still needs an uninstall. Every update after that installs in place.

Testing

  • cargo test --workspace: 74 pass, including 2 new.
  • In an Android 15 emulator:
    • consent, the foreground service and its notification all work;
    • /hello reports Android;
    • pairing, offer, ICE, DTLS and the data channel all come up;
    • a receiver decoded 1072×1920 frames;
    • Stop sharing ends the service.
  • The evidence is in the first comment.
  • Not tested: a real Mac viewing a real tablet. The emulator can't receive the Mac's connection, so the receiver in the test was the app's own page over loopback.

3. The apps ask to update

  • A newer version is offered once per start, in a card: "Mullion X is out. You have Y." with Later and Update. The small link stays as a fallback.
  • Update, the link, GitHub and Sponsor now open in the system browser (mullionNative.open, https only). Before, Android's web view did nothing with them and couldn't install a download.
  • Versions before beta.17 have no update check at all, so this build has to be installed by hand once.

4. Full screen on Android and Windows

  • Android: the page's requestFullscreen does nothing there, because dx's RustWebChromeClient.onShowCustomView only calls super. The button now has MainActivity hide the system bars. Swiping from the edge brings them back.
  • Windows: dioxus's set_fullscreen silently does nothing when the window can't name its monitor. The window now goes Borderless(None) through tao instead. Not run here: there's no Windows machine.

Evidence for both is in the second comment.

5. Icons, responsive layout, light/dark switch

  • Icons: every action button has one next to its word (Pair, Cancel, Don't Allow, Stop sharing, Later, Update; Share this screen gets a cast icon). Android's Stop sharing notification action has one too.
  • Responsive:
    • The setup screen scrolls instead of clipping on short screens.
    • The footer flows under the card and wraps on narrow phones.
    • Touch targets are at least 44 px.
    • The two fields stack on narrow phones.
    • On screens under 560 px the toolbar shows only its icons. The words are hidden from view but still read out.
    • The title size is fluid.
  • Dark mode:
    • The footer switch cycles Auto, Light and Dark, and the device remembers the choice. It works across the whole app.
    • In dark, raised surfaces get lighter as they rise.
    • Android's app theme is now DayNight, so Auto follows the system there too.
  • CI: the network tests in nearby take turns, fixing a flaky failure on the macOS runner.

"Share this screen" in the Android app makes the tablet a Mirror-only
Mullion host. A Mac shows it with Connect to Another Computer… (or any
browser), and pairs with the 6-digit code the tablet shows, as with a Mac.

- Capture (crates/app/android/kotlin): MainActivity asks Android for consent.
  ShareService, a foreground service of type mediaProjection with a
  "Stop sharing" notification, feeds a virtual display into the hardware
  H.264 encoder: Baseline, 30 fps, 6 Mbps, long side at most 1920, repeating
  the last frame after 100 ms so a still screen keeps streaming. Each output
  buffer goes to Rust over JNI. Its return value asks for a key frame, so
  Rust never calls back into Java.
- Host (crates/app/src/share.rs): an AndroidPlatform for mullion_host.
  - MediaCodec's SPS/PPS go in front of every IDR (unit tests).
  - The host starts on the first share, on port 47100 with Extend off and its
    pairing store in the app's files.
  - Between shares it refuses to stream.
  - Pairing codes and share state go to the page over the bridge.
- Page: a Share button and a sheet with the address, the viewer count, the
  pairing code with "Don't Allow", and Stop sharing. Android holds Rust's
  events while it has paused the app, so the page pokes the bridge while
  waiting and on coming back.
- Signaling's /hello says "Android". pair.js names the host instead of "the
  Mac", since a Mac now pairs with tablets too.
- build-android.sh puts the Kotlin over dx's output and adds the service and
  its permissions to the manifest. A rerun no longer fails on dx's template
  icons sitting next to ours.

Checked: 74 tests pass. In an Android 15 emulator: consent, the service and
its notification; /hello; pairing; offer, ICE, DTLS and the data channel; a
receiver decodes 1072x1920 frames; Stop sharing ends the service.
…t one

Updating the Android app failed with "package conflicts" and had to be
uninstalled first. Gradle signs debug builds with ~/.android/debug.keystore,
and a fresh CI runner makes a new one each time, so every beta APK had its own
key and Android refuses an update signed with another. The release workflow
now writes one key, the ANDROID_DEBUG_KEYSTORE secret, there before building.
Without the secret (a fork's PR) the build warns and goes on as before.

The update link no longer says to remove the app first.

The APKs already installed were signed with the old one-off keys: the next
install needs that last uninstall, and later ones update in place.
@th3r-dev

Copy link
Copy Markdown
Owner Author

Evidence

I captured this in an Android 15 emulator (arm64) on the Mac. The files are in docs/evidence/share/.

The tablet sharing, after Android's consent. The status bar shows Android's cast icon.

Mullion on Android: Sharing this screen, address 10.0.2.16:47100, No one is watching yet, Stop sharing

The foreground-service notification, which Android requires for screen capture:

Notification shade: Mullion is sharing this screen

The tablet's host (tablet-host-log.txt):

/hello: "platform":"Android","port":47100,"extend":false
encoder: c2.android.avc.encoder 1072x1920, SPS 67 42 c0 29 (Constrained Baseline 4.1)
pairing requested by Loopback test / paired Loopback test
offer from 127.0.0.1:49212 answered (Mirror)
#1 ice: Completed / #1 dtls connected / #1 data channel open: probe
receiver: status "streaming", 1072x1920, 36 frames decoded in the first 6 s; sheet: "1 device is watching."
after Stop sharing: {"error":"Pair this device with the tablet first.","pair":true}

The receiver was the app's own page, over loopback. The Mac can't reach the emulator's UDP ports, so a Mac viewing a real tablet still needs a test on real devices.

- Update: the apps showed a newer version only as a small link at the bottom,
  and on Android the link could not open (the web view ignores a new window
  and cannot install a download). A newer version is now asked about once per
  start ("Mullion X is out. You have Y." Later / Update). Update, the link,
  GitHub and Sponsor open in the system browser through mullionNative.open
  (https only, the webbrowser crate dioxus already uses).
- Full screen, Android: the page's requestFullscreen does nothing there (dx's
  RustWebChromeClient.onShowCustomView only calls super). The Full screen
  button now asks MainActivity to hide the system bars (immersive, bars come
  back with a swipe, cutout used).
- Full screen, Windows: dioxus's set_fullscreen does nothing when the window
  cannot name its monitor; the window goes Borderless(None) through tao
  instead.

Versions before beta.17 have no update check at all and need this one
installed by hand.

Checked in an Android 15 emulator: a build stamped beta.14 asks about beta.19
and Update opens Chrome with the APK URL; full screen hides both bars (page
height 684 -> 732 CSS px) and comes back. 74 tests pass. Windows not run here.
@th3r-dev

Copy link
Copy Markdown
Owner Author

Evidence: update prompt and full screen (commit f60a55d)

Captured in an Android 15 emulator. The Mac's host name in Nearby is replaced with [Mac name].

The app asks to update on start. This build is stamped 0.1.0-beta.14:

Mullion 0.1.0-beta.19 is out. You have 0.1.0-beta.14. Later / Update

Update opens the APK in Chrome:

START u0 {act=android.intent.action.VIEW dat=https://github.com/... cmp=com.android.chrome/...IntentDispatcher} from uid 10210 (Mullion)

Full screen on Android hides the status and navigation bars. The page grows from 412×684 to 412×732 CSS px (the whole screen), and goes back on exit.

Mullion with no status bar or navigation bar

Windows full screen: not run here (no Windows machine). This PR's Windows build compiles it.

@th3r-dev th3r-dev changed the title feat(app): Android tablet shares its screen to the Mac; APK updates install in place feat(app): tablet shares its screen to the Mac; APK updates in place; update prompt; full screen Nov 11, 2026
hello_accepts_only_mullion failed once on GitHub's macOS runner (PR #24): the
sweep test starts ~250 connections at once, and on that small machine it held
up the other test's reply past hello's 1 s limit. Passed 45 of 45 locally,
also under CPU load. The three network tests now share a lock.
- Icons: Pair, Cancel, Don't Allow, Stop sharing, Later and Update have one
  next to their word, as the other buttons do. Share this screen gets a cast
  icon. Android's "Stop sharing" notification action has an icon.
- Responsive (per the ui-design responsive-design skill):
  - The setup screen scrolls when the card is taller than the screen (a
    phone in landscape), instead of clipping.
  - The footer (version, theme, GitHub, Sponsor) flows under the card
    instead of being pinned over it, and wraps on narrow phones.
  - On touch screens every control is at least 44x44 px.
  - "This device" and "Show" stack on narrow phones.
  - On screens under 560 px the toolbar keeps its icons, with the words
    hidden from view but still read out.
  - The title size is fluid.
- Dark mode (per the dark-mode-design skill):
  - A switch in the footer: Auto (follows the system), Light, Dark,
    remembered on the device. It works everywhere the page runs (the
    Windows and Android apps, the Mac viewer, browsers).
  - In dark, raised surfaces get lighter as they rise (cards #171A1E,
    dialogs #1E2227, on #0F1113). The colours fade between modes, unless
    reduced motion is on.
  - Android's app theme is now DayNight: its web view reports the page's
    colour scheme from the app theme, and dx's Light theme kept it light.

Checked: Playwright at 320 to 1280 px wide, light and dark: no horizontal
scroll, the footer never covers the card, touch targets at least 44 px. The
switch cycles and survives a reload. In the Android emulator with system dark
mode, the app opens dark. 74 tests pass.
@th3r-dev

Copy link
Copy Markdown
Owner Author

Evidence: icons, responsive layout, dark mode (commit d8a68fe)

The colour switch. The footer button cycles Auto (follows the system), Light and Dark, and the device remembers the choice. The Mac's host name is replaced with [Mac name].

Mullion in Light, switch says Light Mullion in Dark, switch says Dark Android app dark with the system in dark mode, switch on Auto

From left: Light, Dark, and the Android app on Auto with the system in dark mode. The app's theme is now DayNight. Before, dx's Light theme kept the web view light.

Checked with Playwright at 320×640, 360×740, 740×360, 820×1180 and 1280×800, in light and dark:

  • no horizontal scrolling;
  • a phone in landscape scrolls the setup screen instead of clipping it;
  • the footer never covers the card;
  • on touch screens every button and link is at least 44×44 px.

The switch cycles Auto → Light → Dark and keeps the choice after a reload.

CI: the macOS run before this one failed in nearby::tests::hello_accepts_only_mullion. That test isn't changed by this PR, and it passed 45 out of 45 times locally, also under CPU load. On the small CI machine the sweep test's ~250 parallel connections delayed its reply past the 1 s limit, so the network tests now take turns (962bc0c).

@th3r-dev th3r-dev changed the title feat(app): tablet shares its screen to the Mac; APK updates in place; update prompt; full screen feat(app): tablet shares to the Mac; APK updates in place; update prompt; full screen; responsive + dark mode Nov 11, 2026
hello_accepts_only_mullion failed on GitHub's macOS runner, at once, not on
a timeout. `write!` on an unbuffered TcpStream sends each formatted piece as
its own write. The test's listener read once, answered, and closed with the
rest of the request unread, which resets the connection. The reset can drop
the reply before the client reads it, so hello() saw nothing.

hello() now formats the request and sends it with one write_all, as lanhttp
does. Real hosts read to the end of the headers either way. The test listener
reads to the end of the headers before answering.

Undoes 962bc0c: the network tests taking turns rested on the wrong theory
(a slow machine). The failure came in ~50 ms, not after hello's 1 s limit.
@sonarqubecloud

Copy link
Copy Markdown

❌ The last analysis has failed.

See analysis details on SonarQube Cloud

@th3r-dev
th3r-dev merged commit e48b2b1 into dev Nov 11, 2026
5 of 6 checks passed
th3r-dev added a commit that referenced this pull request Nov 11, 2026
hello_accepts_only_mullion failed once on GitHub's macOS runner (PR #24): the
sweep test starts ~250 connections at once, and on that small machine it held
up the other test's reply past hello's 1 s limit. Passed 45 of 45 locally,
also under CPU load. The three network tests now share a lock.
th3r-dev added a commit that referenced this pull request Nov 12, 2026
On PR #24, a one-file fix ran all three package builds again, though two had
already passed. Now a new "changes" job (tools/ci/changed-jobs.sh) decides per
package. On a pull request a package is skipped when:
- it passed on this PR before, at some commit S (an actual build: a skip never
  counts, so reuse doesn't chain), and
- no file it builds from changed between S and this run's merge commit.

What each package builds from:
- all three: Cargo.toml/lock, crates/proto, crates/app/assets (the Mac host
  inlines the page), this workflow and tools/ci.
- macos: crates/host, tools/package-macos.sh, tools/macos.
- windows: crates/app's src, build.rs and Cargo.toml.
- android: crates/app (Kotlin, launcher icons and Dioxus.toml too),
  crates/host, tools/build-android.sh.

Diffing against the merge commit also counts what dev gained since S, so a
skip is never wrong; at worst it rebuilds more than needed. If S is gone (a
force push) or GitHub's API fails, everything builds. Pushes to dev, tags and
manual runs build everything: each release stamps a new version into all
three packages. The changes job's summary says, per package, built or reused,
and links the run where it passed.

Changes only to docs/ or brand/ no longer start a run, as with Markdown.

Dry run against PR #24's runs, with a one-file change each:
- Kotlin: android only.
- App source: windows and android.
- The page's CSS or proto: all three.
- docs: none.
- tools/package-macos.sh: macos only.
- A push to dev: all three.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant