diff --git a/crates/app/android/res/mipmap-anydpi-v26/ic_launcher.xml b/crates/app/android/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..3ff5542 --- /dev/null +++ b/crates/app/android/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/crates/app/android/res/mipmap-hdpi/ic_launcher.png b/crates/app/android/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..d3afe15 Binary files /dev/null and b/crates/app/android/res/mipmap-hdpi/ic_launcher.png differ diff --git a/crates/app/android/res/mipmap-hdpi/ic_launcher_foreground.png b/crates/app/android/res/mipmap-hdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..7bb75b8 Binary files /dev/null and b/crates/app/android/res/mipmap-hdpi/ic_launcher_foreground.png differ diff --git a/crates/app/android/res/mipmap-mdpi/ic_launcher.png b/crates/app/android/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..cbb6039 Binary files /dev/null and b/crates/app/android/res/mipmap-mdpi/ic_launcher.png differ diff --git a/crates/app/android/res/mipmap-mdpi/ic_launcher_foreground.png b/crates/app/android/res/mipmap-mdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..2382618 Binary files /dev/null and b/crates/app/android/res/mipmap-mdpi/ic_launcher_foreground.png differ diff --git a/crates/app/android/res/mipmap-xhdpi/ic_launcher.png b/crates/app/android/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..e911a60 Binary files /dev/null and b/crates/app/android/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/crates/app/android/res/mipmap-xhdpi/ic_launcher_foreground.png b/crates/app/android/res/mipmap-xhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..e713ece Binary files /dev/null and b/crates/app/android/res/mipmap-xhdpi/ic_launcher_foreground.png differ diff --git a/crates/app/android/res/mipmap-xxhdpi/ic_launcher.png b/crates/app/android/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..3afffe2 Binary files /dev/null and b/crates/app/android/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/crates/app/android/res/mipmap-xxhdpi/ic_launcher_foreground.png b/crates/app/android/res/mipmap-xxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..de5fe67 Binary files /dev/null and b/crates/app/android/res/mipmap-xxhdpi/ic_launcher_foreground.png differ diff --git a/crates/app/android/res/mipmap-xxxhdpi/ic_launcher.png b/crates/app/android/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..f60a496 Binary files /dev/null and b/crates/app/android/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/crates/app/android/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/crates/app/android/res/mipmap-xxxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..9068e4d Binary files /dev/null and b/crates/app/android/res/mipmap-xxxhdpi/ic_launcher_foreground.png differ diff --git a/crates/app/android/res/values/ic_launcher_background.xml b/crates/app/android/res/values/ic_launcher_background.xml new file mode 100644 index 0000000..ce6c6d7 --- /dev/null +++ b/crates/app/android/res/values/ic_launcher_background.xml @@ -0,0 +1,4 @@ + + + #F7F7F5 + diff --git a/crates/app/assets/layout.js b/crates/app/assets/layout.js index aa94e79..8b278dd 100644 --- a/crates/app/assets/layout.js +++ b/crates/app/assets/layout.js @@ -71,7 +71,7 @@ async function load(first) { try { - const r = await fetch(baseUrl(hostIp) + '/screens', { cache: 'no-store', headers: mullion.authHeaders(hostIp, 'GET', '/screens') }); + const r = await mullionFetch(baseUrl(hostIp) + '/screens', { cache: 'no-store', headers: mullion.authHeaders(hostIp, 'GET', '/screens') }); if (r.status === 401) { needPairing(); return; } if (!r.ok) throw new Error((await r.text()).trim() || r.status); const v = await r.json(); @@ -375,7 +375,7 @@ board.setAttribute('aria-busy', 'true'); try { const body = JSON.stringify({ cells }); - const r = await fetch(baseUrl(hostIp) + '/screens/layout', { + const r = await mullionFetch(baseUrl(hostIp) + '/screens/layout', { method: 'POST', headers: Object.assign({ 'Content-Type': 'application/json' }, mullion.authHeaders(hostIp, 'POST', '/screens/layout', body)), body, }); const text = await r.text(); diff --git a/crates/app/assets/pair.js b/crates/app/assets/pair.js index 2dc85c1..1473129 100644 --- a/crates/app/assets/pair.js +++ b/crates/app/assets/pair.js @@ -77,8 +77,27 @@ function store(cred) { try { localStorage.setItem(KEY + cred.host_id, JSON.stringify(cred)); } catch (e) { /* */ } } function forget(hostId) { try { localStorage.removeItem(KEY + hostId); } catch (e) { /* */ } } + // A request to a Mullion host. In the apps it goes through native code + // (window.mullionNative.http, app main.rs): the Android page is https and its + // WebView blocks http:// requests as mixed content. In a browser, fetch. + // Resolves to a Response either way; network failures reject with TypeError + // and an aborted signal with AbortError, as fetch does. + async function hostFetch(url, init) { + init = init || {}; + const http = window.mullionNative && window.mullionNative.http; + if (!http) return fetch(url, Object.assign({ cache: 'no-store', credentials: 'omit' }, init)); + const abortErr = () => new DOMException('The request was aborted.', 'AbortError'); + const call = http(init.method || 'GET', url, init.headers || {}, init.body || ''); + const s = init.signal; + const r = await (s ? Promise.race([call, new Promise((_, no) => { if (s.aborted) no(abortErr()); s.addEventListener('abort', () => no(abortErr())); })]) : call); + if (r.error) throw new TypeError(r.error); + const empty = [101, 103, 204, 205, 304].includes(r.status); + return new Response(empty ? null : r.body, { status: r.status }); + } + window.mullionFetch = hostFetch; + async function post(url, body) { - const r = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body), cache: 'no-store', credentials: 'omit' }); + const r = await hostFetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) }); let data = null; try { data = await r.json(); } catch (e) { /* plain text error */ } return { status: r.status, data }; diff --git a/crates/app/assets/receiver.js b/crates/app/assets/receiver.js index 53911d3..97d3e6e 100644 --- a/crates/app/assets/receiver.js +++ b/crates/app/assets/receiver.js @@ -202,7 +202,7 @@ } async function postJSON(url, body) { - const r = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body), cache: 'no-store', credentials: 'omit' }); + const r = await mullionFetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) }); let data = null; try { data = await r.json(); } catch (e) { /* plain text */ } return { status: r.status, data }; @@ -289,7 +289,7 @@ const body = auth ? { device: auth.cred.device, sealed: mullionPair.sealOffer(auth.cred, auth.nonce, plain) } : Object.assign({ device_id: deviceId() }, plain); - const resp = await fetch(`http://${hostIp}:${port}/offer`, { + const resp = await mullionFetch(`http://${hostIp}:${port}/offer`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body), signal: ctrl.signal, }); @@ -395,7 +395,7 @@ if (outer) outer.addEventListener('abort', stop); const t0 = performance.now(); try { - const r = await fetch(`http://${ip}:${port}/hello`, { signal: ctrl.signal, cache: 'no-store', credentials: 'omit' }); + const r = await mullionFetch(`http://${ip}:${port}/hello`, { signal: ctrl.signal }); if (!r.ok) return null; const h = await r.json(); if (!h || h.app !== 'mullion') return null; diff --git a/crates/app/assets/ui.css b/crates/app/assets/ui.css index a0c0ae6..f876a27 100644 --- a/crates/app/assets/ui.css +++ b/crates/app/assets/ui.css @@ -133,6 +133,11 @@ button:has(> .i), .links a { display: inline-flex; align-items: center; justify- margin: 0; padding: 6px 10px; color: var(--ink); opacity: .55; font-size: 13px; font-weight: 600; letter-spacing: .01em; font-variant-numeric: tabular-nums; user-select: text; } .version:empty { display: none; } +/* The apps' update check (ui.js): a link just above the version. */ +.update { position: fixed; left: max(16px, env(safe-area-inset-left)); bottom: calc(max(14px, env(safe-area-inset-bottom)) + 22px); + font-size: 13px; font-weight: 600; color: var(--accent); text-decoration: none; padding: 4px 10px; } +.update:hover, .update:focus-visible { text-decoration: underline; } +.update[hidden] { display: none; } /* GitHub's sponsor heart colour; a non-text mark (4.7:1 light, 5.9:1 dark on --paper). */ .links .heart { color: #BF3989; } @media (prefers-color-scheme: dark) { .links .heart { color: #E85AAD; } } diff --git a/crates/app/assets/ui.html b/crates/app/assets/ui.html index 9c8dd32..44abc3e 100644 --- a/crates/app/assets/ui.html +++ b/crates/app/assets/ui.html @@ -69,6 +69,7 @@

+