From c36448209b6a6e0f091bef5f4a56226435a4e2b4 Mon Sep 17 00:00:00 2001 From: Derek Ross Date: Tue, 27 Oct 2026 14:51:34 -0400 Subject: [PATCH 1/7] omamobile-shell 0.2.31: landscape keeps tile rows and the layout's pages The batch 4 phone check found two things in the landscape view of the home (TOUCH-PLAN 2.4): a portrait row of app icons turned into a column at the right edge, since every item's x and y swapped, and the view showed one page more than the layout, since an item with no room on its page was pushed to a new one by the same re-placement a loaded file gets. HomeModel.transposeLayout now turns only the widgets. The app tiles are laid out afresh in rows under the widgets, in portrait reading order with a new portrait row starting a new landscape row, so a row stays a row. A widget with no room where it lands takes the first free spot at its size, else the largest smaller size down to its minimum; every page keeps to itself, so the view has exactly the layout's pages, and an item with no room at all on its page is left out of the view rather than moved. Nothing is saved either way. test/home-model.js covers both (two 2x2 widgets and a row of four tiles on page 1 keep one page with the tiles in a row; two portrait rows stay two rows; a full page re-places, shrinks and then leaves out, never adds a page), and test/home-render checks that the two app tiles share a row under the widgets and that the battery stays on the first page. Co-Authored-By: Claude Fable 5.1 --- .../plugins/omamobile.home/HomeModel.js | 108 +++++++++++++++--- packages/omamobile-shell/test/home-model.js | 69 +++++++++-- packages/omamobile-shell/test/home-render | 16 ++- packages/omamobile-shell/version | 2 +- 4 files changed, 167 insertions(+), 28 deletions(-) diff --git a/packages/omamobile-shell/plugins/omamobile.home/HomeModel.js b/packages/omamobile-shell/plugins/omamobile.home/HomeModel.js index d122ac622..839950a12 100644 --- a/packages/omamobile-shell/plugins/omamobile.home/HomeModel.js +++ b/packages/omamobile-shell/plugins/omamobile.home/HomeModel.js @@ -740,7 +740,7 @@ function setGrid(layout, columns, rows, catalog) { // ---------------------------------------------------------------- landscape // The layout turned on its side, for a page wider than tall (TOUCH-PLAN -// 2.4, #85): the grid's columns and rows swap, each item's x and y swap, +// 2.4, #85): the grid's columns and rows swap, each widget's x and y swap, // and its box is turned with them. `pages` gives the portrait and the // landscape page in logical px ({ portrait: [w, h], landscape: [w, h] }): // the landscape grid's cells are wide and short (173x87 against 120x151 on @@ -748,11 +748,16 @@ function setGrid(layout, columns, rows, catalog) { // ratio to keep about its size in pixels, which is what a widget's content // was laid out for; with the spans merely swapped a 2x2 widget lost half // its height and its rows landed on each other. Without `pages` the spans -// just swap. The result goes through the same clamp and re-placement as a -// loaded file (fitPages), so each widget keeps to its minimum and maximum -// and nothing overlaps; an item with no room on its page moves on. Derived -// for the view only: the file and the layout it came from stay portrait, -// and nothing here is ever saved. +// just swap. Each widget is clamped to its limits (cleanItem) and placed +// where it lands if that is free, else at the first free spot, else at +// the largest smaller size down to its minimum (placeShrunk). The app +// tiles are not turned: a portrait row of tiles stays a row, in rows below +// the widgets (placeAppRows); turned, a row became a column at the right +// edge. Every page keeps to itself, so the view has as many pages as the +// layout: an item with no room at all on its page is left out of the view +// rather than pushed to a new page. Derived for the view only: the file +// and the layout it came from stay portrait, and nothing here is ever +// saved. function transposeLayout(layout, catalog, pages) { var grid = { columns: layout.grid.rows, rows: layout.grid.columns } var scaleW = 1, scaleH = 1 @@ -761,19 +766,88 @@ function transposeLayout(layout, catalog, pages) { var sideW = pages.landscape[0] / grid.columns, sideH = pages.landscape[1] / grid.rows if (cellW > 0 && cellH > 0 && sideW > 0 && sideH > 0) { scaleW = cellH / sideW; scaleH = cellW / sideH } } - var raw = { version: VERSION, grid: grid, home: layout.home, nextId: layout.nextId, pages: [] } + var out = emptyLayout(grid) + out.pages = [] + out.nextId = layout.nextId for (var p = 0; p < layout.pages.length; p++) { - var items = [] - for (var i = 0; i < layout.pages[p].items.length; i++) { - var item = layout.pages[p].items[i] - var t = copy(item) - t.x = item.y; t.y = item.x - t.w = Math.max(1, Math.round(item.h * scaleW)); t.h = Math.max(1, Math.round(item.w * scaleH)) - items.push(t) + var source = layout.pages[p].items + var page = { items: [] } + var homeless = [] + var apps = [] + for (var i = 0; i < source.length; i++) { + var item = source[i] + if (item.kind === "app") { apps.push(item); continue } + var turned = copy(item) + turned.x = item.y; turned.y = item.x + turned.w = Math.max(1, Math.round(item.h * scaleW)); turned.h = Math.max(1, Math.round(item.w * scaleH)) + turned = cleanItem(turned, grid, catalog) + if (!turned) continue + if (isFree(page.items, grid, turned, null)) page.items.push(turned) + else homeless.push(turned) + } + for (var h = 0; h < homeless.length; h++) { + var placed = placeShrunk(page.items, grid, homeless[h], catalog) + if (placed) page.items.push(placed) } - raw.pages.push({ items: items }) + placeAppRows(page.items, grid, apps) + out.pages.push(page) + } + if (out.pages.length === 0) out.pages.push({ items: [] }) + out.home = clampInt(layout.home, 0, out.pages.length - 1, 0) + return out +} + +// A turned widget with no room where it landed: the first free spot in +// reading order at its size (packed to the top, so the rows under the +// widgets stay free for the tiles), else at the largest smaller size down +// to its minimum (nearer its own shape on a tie), else null. +function placeShrunk(items, grid, item, catalog) { + var limits = sizeLimits(item, grid, catalog) + var sizes = [] + for (var h = item.h; h >= limits.minH; h--) + for (var w = item.w; w >= limits.minW; w--) + sizes.push({ w: w, h: h, loss: (item.w - w) + (item.h - h) }) + sizes.sort(function(a, b) { return (b.w * b.h) - (a.w * a.h) || a.loss - b.loss }) + for (var s = 0; s < sizes.length; s++) { + var spot = freeSpot(items, grid, sizes[s].w, sizes[s].h) + if (!spot) continue + var placed = copy(item) + placed.x = spot.x; placed.y = spot.y; placed.w = sizes[s].w; placed.h = sizes[s].h + return placed + } + return null +} + +// The first free cell in reading order at or after column `col` of row +// `row`, or null. +function freeCellFrom(items, grid, row, col) { + for (var y = Math.max(0, row); y < grid.rows; y++) + for (var x = (y === row ? Math.max(0, col) : 0); x < grid.columns; x++) + if (isFree(items, grid, { x: x, y: y, w: 1, h: 1 }, null)) return { x: x, y: y } + return null +} + +// A page's app tiles in rows under its widgets: in portrait reading order +// from the first row below the lowest widget, a new portrait row starting +// a new landscape row, so a row of tiles stays a row. A tile with no room +// there takes the first free cell anywhere on the page; one with no free +// cell at all is left out. Adds to `items` in place. +function placeAppRows(items, grid, apps) { + var bottom = 0 + for (var i = 0; i < items.length; i++) bottom = Math.max(bottom, items[i].y + items[i].h) + var sorted = apps.slice().sort(function(a, b) { return a.y - b.y || a.x - b.x }) + var row = bottom, col = 0, lastRow = -1 + for (var a = 0; a < sorted.length; a++) { + var app = sorted[a] + if (lastRow >= 0 && app.y !== lastRow && col > 0) { row++; col = 0 } + lastRow = app.y + var spot = freeCellFrom(items, grid, row, col) || freeSpot(items, grid, 1, 1) + if (!spot) continue + var tile = copy(app) + tile.x = spot.x; tile.y = spot.y; tile.w = 1; tile.h = 1 + items.push(tile) + row = spot.y; col = spot.x + 1 } - return fitPages(raw, grid, catalog) } // ---------------------------------------------------------------- widgets' pure parts @@ -901,7 +975,7 @@ if (typeof module !== "undefined") { findItem: findItem, missingApps: missingApps, placeOn: placeOn, addWidget: addWidget, addApp: addApp, removeItem: removeItem, restoreItem: restoreItem, moveItem: moveItem, resizeItem: resizeItem, setConfig: setConfig, - addPage: addPage, removePage: removePage, movePage: movePage, setHome: setHome, setGrid: setGrid, transposeLayout: transposeLayout, + addPage: addPage, removePage: removePage, movePage: movePage, setHome: setHome, setGrid: setGrid, transposeLayout: transposeLayout, placeShrunk: placeShrunk, placeAppRows: placeAppRows, weatherText: weatherText, geocodeUrl: geocodeUrl, forecastUrl: forecastUrl, parseGeocode: parseGeocode, parseForecast: parseForecast, parseAgenda: parseAgenda, AGENDA_ARGV: AGENDA_ARGV, monthGrid: monthGrid, commandText: commandText diff --git a/packages/omamobile-shell/test/home-model.js b/packages/omamobile-shell/test/home-model.js index 16a03e0c8..611cbd39c 100644 --- a/packages/omamobile-shell/test/home-model.js +++ b/packages/omamobile-shell/test/home-model.js @@ -601,7 +601,7 @@ function tidy(layout, original) { const pixelPages = { portrait: [480, 908], landscape: [1040, 348] } const byId = (layout) => { const o = {}; layout.pages.forEach((p, n) => p.items.forEach((i) => { o[i.id] = Object.assign({ page: n }, i) })); return o } -test("landscape swaps the grid and turns every item with it", () => { +test("landscape swaps the grid and turns every widget with it; the tiles keep their row", () => { const l = layoutOf([widget("w1", "clock", 0, 0, 4, 2), app("a1", 1, 5), app("a2", 3, 5)]) const before = M.serialize(l) const t = M.transposeLayout(l, {}) @@ -610,8 +610,10 @@ test("landscape swaps the grid and turns every item with it", () => { const at = byId(t) // 4x2 turned is 2x4; the clock's maximum (4x3) keeps it to 3 rows. assert.deepStrictEqual([at.w1.x, at.w1.y, at.w1.w, at.w1.h], [0, 0, 2, 3]) - assert.deepStrictEqual([at.a1.x, at.a1.y, at.a1.w, at.a1.h], [5, 1, 1, 1]) - assert.deepStrictEqual([at.a2.x, at.a2.y], [5, 3]) + // The tiles' portrait row (y 5) is a row under the clock, in order, not + // a column at the right edge (the batch 4 phone check). + assert.deepStrictEqual([at.a1.x, at.a1.y, at.a1.w, at.a1.h], [0, 3, 1, 1]) + assert.deepStrictEqual([at.a2.x, at.a2.y], [1, 3]) assert.strictEqual(M.serialize(l), before, "the portrait layout is left alone") assert.strictEqual(t.home, l.home) assert.strictEqual(t.nextId, l.nextId) @@ -631,15 +633,68 @@ test("landscape keeps a widget's size in pixels on the short, wide cells", () => assert.deepStrictEqual([at.a1.w, at.a1.h, at.a2.w, at.a2.h], [1, 1, 1, 1]) assert.deepStrictEqual([at.w1.x, at.w1.y, at.w1.w, at.w1.h], [0, 0, 2, 3]) // The battery (2x1, turned and clamped to 1x2) found no room beside the - // others and moved to a page of its own; the apps stayed. - assert.ok(t.pages.length >= 2) - assert.strictEqual(at.w3.page, 1) - assert.deepStrictEqual([at.w3.w, at.w3.h], [1, 2]) + // others at that size, so it takes its minimum (1x1) on its own page + // rather than a page of its own; the tiles follow in the free cells. + assert.strictEqual(t.pages.length, 1) + assert.strictEqual(at.w3.page, 0) + assert.deepStrictEqual([at.w3.w, at.w3.h], [1, 1]) + assert.strictEqual(at.a1.page, 0) assert.strictEqual(at.a2.page, 0) + assert.strictEqual(at.a1.y, at.a2.y, "the two tiles share a row") // Settings travel with the item. assert.deepStrictEqual(at.w2.config, l.pages[0].items[1].config) }) +test("landscape keeps a row of four tiles a row under two 2x2 widgets, on the page they came from", () => { + // Page 1 of two: the phone check's case (two widgets side by side, a dock + // row of four icons at the bottom). The view has two pages, like the + // layout, and page 1 keeps all six items with the icons in one row. + const l = layoutOf([widget("w0", "clock", 0, 0, 4, 2)], + [widget("w1", "notes", 0, 0, 2, 2), widget("w2", "owl:simonschubert.today", 2, 0, 2, 2), + app("a1", 0, 5), app("a2", 1, 5), app("a3", 2, 5), app("a4", 3, 5)]) + const t = M.transposeLayout(l, {}, pixelPages) + tidy(t, l) + assert.strictEqual(t.pages.length, 2) + const at = byId(t) + for (const id of ["w1", "w2", "a1", "a2", "a3", "a4"]) assert.strictEqual(at[id].page, 1, id + " stays on page 1") + assert.deepStrictEqual([at.w1.x, at.w1.y, at.w1.w, at.w1.h], [0, 0, 2, 3]) + assert.deepStrictEqual([at.w2.x, at.w2.y, at.w2.w, at.w2.h], [2, 0, 2, 3]) + assert.deepStrictEqual(["a1", "a2", "a3", "a4"].map((id) => [at[id].x, at[id].y]), [[0, 3], [1, 3], [2, 3], [3, 3]]) +}) + +test("landscape keeps two portrait rows of tiles as two rows, in order", () => { + const l = layoutOf([widget("w1", "clock", 0, 0, 4, 2), app("a1", 0, 4), app("a2", 1, 4), app("a3", 2, 4), app("a4", 3, 4), + app("b1", 0, 5), app("b2", 1, 5), app("b3", 2, 5)]) + const t = M.transposeLayout(l, {}, pixelPages) + tidy(t, l) + const at = byId(t) + assert.deepStrictEqual(["a1", "a2", "a3", "a4"].map((id) => [at[id].x, at[id].y]), [[0, 3], [1, 3], [2, 3], [3, 3]]) + // No row below the fourth: the second row takes the first free cells. + assert.deepStrictEqual(["b1", "b2", "b3"].map((id) => [at[id].x, at[id].y]), [[2, 0], [3, 0], [4, 0]]) +}) + +test("landscape never has more pages than the layout: a full page re-places, shrinks, then leaves out", () => { + // Four 2x2 notes (each 2x3 turned: 24 cells for a 24-cell page) and eight + // tiles: the fourth note shrinks to a 2x1, four tiles find cells, four + // are left out, and nothing goes to a second page. + const l = layoutOf([widget("w1", "notes", 0, 0, 2, 2), widget("w2", "notes", 2, 0, 2, 2), widget("w3", "notes", 0, 2, 2, 2), widget("w4", "notes", 2, 2, 2, 2), + app("a1", 0, 4), app("a2", 1, 4), app("a3", 2, 4), app("a4", 3, 4), app("b1", 0, 5), app("b2", 1, 5), app("b3", 2, 5), app("b4", 3, 5)]) + const t = M.transposeLayout(l, {}, pixelPages) + assert.strictEqual(t.pages.length, 1) + const items = t.pages[0].items + for (let i = 0; i < items.length; i++) { + assert.ok(M.fits(t.grid, items[i]), items[i].id + " fits") + for (let j = i + 1; j < items.length; j++) assert.ok(!M.overlaps(items[i], items[j]), items[i].id + " overlaps " + items[j].id) + } + const at = byId(t) + for (const id of ["w1", "w2", "w3", "w4"]) assert.ok(at[id], id + " is shown") + assert.ok(Math.min(at.w4.w * at.w4.h, at.w3.w * at.w3.h) < 6, "one note shrank") + const shown = items.filter((i) => i.kind === "app").map((i) => i.id) + assert.strictEqual(shown.length, 4, "four tiles fit: " + shown.join(" ")) + assert.deepStrictEqual(shown, ["a1", "a2", "a3", "a4"], "the first row's tiles come first") + assert.strictEqual(M.serialize(l), M.serialize(M.normalize(JSON.parse(M.serialize(l)), {})), "the layout is untouched") +}) + test("landscape of an empty layout is an empty layout on the turned grid", () => { const t = M.transposeLayout(M.emptyLayout(grid), {}, pixelPages) assert.deepStrictEqual(t.grid, { columns: 6, rows: 4 }) diff --git a/packages/omamobile-shell/test/home-render b/packages/omamobile-shell/test/home-render index 8de68715d..cd348dbb1 100755 --- a/packages/omamobile-shell/test/home-render +++ b/packages/omamobile-shell/test/home-render @@ -153,10 +153,20 @@ for name, g in geo.items(): landscape = g["w"] > g["h"] check(name + ": the view knows which way it is", g["landscape"] == landscape and g["grid"] == ({"columns": 6, "rows": 4} if landscape else {"columns": 4, "rows": 6}), json.dumps([g["landscape"], g["grid"]])) cells = g["cells"] - # On its side the battery (2x1, turned to 1x2) finds no room on the - # first page and joins the app on the second. - want = (2 if landscape else 1) if g["page"] == 1 else 5 if landscape else 6 + # Every item stays on its own page either way: on its side the battery + # (2x1, turned and clamped to 1x2) finds no room at that size and takes + # its minimum, and the view has the layout's two pages (batch 5). + want = 1 if g["page"] == 1 else 6 check(name + ": %d items on the page" % want, len(cells) == want, "%d: %s" % (len(cells), ", ".join(c["id"] for c in cells))) + if landscape and g["page"] == 0: + # The two app tiles keep their row, under the widgets, not a + # column at the right edge (the batch 4 phone check). + apps = [c for c in cells if c["id"] in ("a4", "a5")] + widgets = [c for c in cells if c["id"] not in ("a4", "a5")] + def above(a, w): return w["rect"]["x"] < a["rect"]["x"] + a["rect"]["w"] and a["rect"]["x"] < w["rect"]["x"] + w["rect"]["w"] and w["rect"]["y"] < a["rect"]["y"] + check(name + ": the app tiles share a row under the widgets", len(apps) == 2 and apps[0]["rect"]["y"] == apps[1]["rect"]["y"] + and all(w["rect"]["y"] + w["rect"]["h"] <= a["rect"]["y"] + 1 for a in apps for w in widgets if above(a, w)) + and any(above(a, w) for a in apps for w in widgets), json.dumps([a["rect"] for a in apps])) check(name + ": every item inside the home area", all(inside(c["rect"], area, 1) for c in cells), json.dumps([c["rect"] for c in cells if not inside(c["rect"], area, 1)])) touching = [(a["id"], b["id"]) for i, a in enumerate(cells) for b in cells[i + 1:] if not apart(a["rect"], b["rect"], 1)] check(name + ": no two items overlap", not touching, json.dumps(touching)) diff --git a/packages/omamobile-shell/version b/packages/omamobile-shell/version index a8498651b..aa0499977 100644 --- a/packages/omamobile-shell/version +++ b/packages/omamobile-shell/version @@ -1 +1 @@ -0.2.32 +0.2.37 From 58a9e0cc33a439851627d876feda7648f71f3f3c Mon Sep 17 00:00:00 2001 From: Derek Ross Date: Tue, 27 Oct 2026 15:00:08 -0400 Subject: [PATCH 2/7] omamobile-shell 0.2.31: a Reminder tile over Omarchy's omarchy-reminder TOUCH-PLAN 1.12's last keyboard-only feature with a touch path. Omarchy sets a reminder with Super+Ctrl+R and a keyboard flow (the omarchy.reminders overlay types into a key catcher), which a phone can't drive. The new tile closes quick settings' third page; a tap opens a page behind it, like the Wi-Fi picker: a row of minute presets or a typed number, a message, and Set, which runs `omarchy-reminder [message]`. The timer, its toast and the confirmation stay Omarchy's own; the page starts nothing of its own. Above the form, what is pending from `omarchy-reminder show --json`, with a two-tap Clear all (`omarchy-reminder clear`). The form keeps to the bottom of the card, so it stays above the on-screen keyboard while a field has focus. A long-press on the tile shows Omarchy's own list (`omarchy-reminder show`), and the tile's status counts the pending timers (tile-state.sh), lighting while one is. Night light was already a tile (omarchy-toggle-nightlight through tile-action.sh); test/all now pins that too. Tests: the minutes rule, argv and JSON in test/tiles-model.js, the probe in test/tile-scripts.sh, the wiring in test/all, and two shots of the page (upright and on its side) in test/quicksettings-render, whose harness now sizes the pages' window stand-ins. Co-Authored-By: Claude Fable 5.1 --- .../omamobile.quicksettings/QuickSettings.qml | 49 ++- .../omamobile.quicksettings/ReminderPanel.qml | 381 ++++++++++++++++++ .../omamobile.quicksettings/TilesModel.js | 57 ++- .../omamobile.quicksettings/tile-state.sh | 11 + packages/omamobile-shell/test/all | 16 + .../omamobile-shell/test/quicksettings-render | 33 +- .../test/quicksettings-render.qml | 20 +- packages/omamobile-shell/test/tile-scripts.sh | 11 +- packages/omamobile-shell/test/tiles-model.js | 35 +- 9 files changed, 587 insertions(+), 26 deletions(-) create mode 100644 packages/omamobile-shell/plugins/omamobile.quicksettings/ReminderPanel.qml diff --git a/packages/omamobile-shell/plugins/omamobile.quicksettings/QuickSettings.qml b/packages/omamobile-shell/plugins/omamobile.quicksettings/QuickSettings.qml index ae478efcf..15c3d6ebe 100644 --- a/packages/omamobile-shell/plugins/omamobile.quicksettings/QuickSettings.qml +++ b/packages/omamobile-shell/plugins/omamobile.quicksettings/QuickSettings.qml @@ -20,7 +20,8 @@ import "Readable.js" as Readable // handle) expands it to every tile, a page of eight at a time with a // sideways swipe between pages, and volume. Tap outside it, swipe it up, or // press Escape to put it away. The Wi-Fi and Bluetooth tiles' chevrons (or a -// long-press) open the panels in WifiPanel.qml and BluetoothPanel.qml. +// long-press) open the panels in WifiPanel.qml and BluetoothPanel.qml; the +// Reminder tile opens ReminderPanel.qml (TOUCH-PLAN 1.12). // // Under the sheet, a second card is the notification shade: Omarchy's // notification history, newest first, with Clear all (NotificationsModel.js); @@ -53,12 +54,12 @@ Item { // ---------------------------------------------------------------- lifecycle - // A payload of {"page": "wifi"} or {"page": "bluetooth"} opens that panel - // instead of the sheet. + // A payload of {"page": "wifi"}, {"page": "bluetooth"} or {"page": + // "reminder"} opens that panel instead of the sheet. function open(payloadJson) { var payload = {} try { payload = JSON.parse(payloadJson || "{}") || {} } catch (error) {} - if (payload.page === "wifi" || payload.page === "bluetooth") { + if (payload.page === "wifi" || payload.page === "bluetooth" || payload.page === "reminder") { openPage(payload.page) // Let the host finish delivering this open before it hears a hide. Qt.callLater(root.dismiss) @@ -66,6 +67,7 @@ Item { } wifiPicker.close() bluetoothPanelItem.close() + reminderPanelItem.close() if (editing) finishEditing() expanded = payload.expanded === true if (payload.page === "edit") startEditing() @@ -221,7 +223,7 @@ Item { "location": location, "nfc": nfc, "battery-saver": batterySaver, "dark-theme": darkTheme, "night-light": nightLight, "stay-awake": stayAwake, "mic": mic, "screenshot": screenshot, "screen-record": screenRecord, "fingerprint": fingerprint, "keyboard": keyboard, - "clipboard": clipboard, "dictation": dictation + "clipboard": clipboard, "dictation": dictation, "reminder": reminder }) // ---------------------------------------------------------------- layout @@ -578,6 +580,28 @@ Item { } } + // Reminders (TOUCH-PLAN 1.12) through Omarchy's own omarchy-reminder, + // which the desktop reaches with Super+Ctrl+R and a keyboard flow. A tap + // opens the page behind the tile (ReminderPanel.qml: minutes, a message, + // Set, what is pending); a long-press shows what is pending as Omarchy's + // own notification (`omarchy-reminder show`). The status counts the + // pending timers (tile-state.sh), and the tile lights while one is. + QtObject { + id: reminder + readonly property bool available: root.probedHas("reminders") + readonly property int count: parseInt(root.probed.reminders, 10) || 0 + readonly property bool enabled: available && count > 0 + readonly property string icon: "󰢌" + readonly property string status: TilesModel.reminderStatus(root.probed.reminders) + readonly property bool longPress: true + function toggle() { if (available) root.openReminderPanel() } + function openDetails() { + if (!available) return + root.dismiss() + Quickshell.execDetached(["omarchy-reminder", "show"]) + } + } + // ---------------------------------------------------------------- clock // The header follows the bar clock's 12/24-hour choice (Omarchy's clock @@ -653,14 +677,29 @@ Item { root.dismiss() } + function openReminderPanel() { + openPage("reminder") + root.dismiss() + } + // One page at a time. function openPage(page) { if (page !== "wifi") wifiPicker.close() if (page !== "bluetooth") bluetoothPanelItem.close() if (page !== "record") recordPanelItem.close() + if (page !== "reminder") reminderPanelItem.close() if (page === "wifi") wifiPicker.open() else if (page === "bluetooth") bluetoothPanelItem.open() else if (page === "record") recordPanelItem.open() + else if (page === "reminder") reminderPanelItem.open() + } + + // The page behind the Reminder tile; its own window, like the others. + ReminderPanel { + id: reminderPanelItem + onBackRequested: root.backToSheet(reminderPanelItem) + onReminderSet: { reminderPanelItem.close(); probeLater.restart() } + onClearedAll: probeLater.restart() } RecordPanel { diff --git a/packages/omamobile-shell/plugins/omamobile.quicksettings/ReminderPanel.qml b/packages/omamobile-shell/plugins/omamobile.quicksettings/ReminderPanel.qml new file mode 100644 index 000000000..c6699c5a8 --- /dev/null +++ b/packages/omamobile-shell/plugins/omamobile.quicksettings/ReminderPanel.qml @@ -0,0 +1,381 @@ +// SPDX-License-Identifier: MIT +import QtQuick +import Quickshell +import Quickshell.Io +import Quickshell.Wayland +import qs.Commons +import qs.Commons as Commons +import qs.Ui +import "TilesModel.js" as TilesModel +import "Readable.js" as Readable + +// The page behind the Reminder tile (TOUCH-PLAN 1.12): Omarchy's reminders +// for a thumb. The desktop sets one with Super+Ctrl+R and a keyboard +// flow; here a row of minute presets (or a typed number), a message, and +// Set, which runs `omarchy-reminder [message]`: the timer, its +// toast when it fires and the confirmation are Omarchy's own. Above the +// form, what is pending (`omarchy-reminder show --json`) with a two-tap +// Clear all (`omarchy-reminder clear`). The form keeps to the bottom of +// the card, so it stays above the on-screen keyboard while a field has +// focus, as the Wi-Fi password and the update sheet's PIN do. +Item { + id: root + + property bool opened: false + property color foreground: Commons.Color.popups.text + // The minutes field's text; a preset chip sets it. + property string minutes: "10" + property var reminders: [] + property bool listed: false + property bool confirmClear: false + + // The back glyph: the owner closes this and brings quick settings back. + signal backRequested() + // A reminder was set (omarchy-reminder ran): the owner closes this and + // re-reads its tile's count. + signal reminderSet() + // Clear all ran: the owner re-reads the count. + signal clearedAll() + + readonly property int touchSize: Math.max(44, Style.space(48)) + readonly property int pad: Style.spacing.panelPadding + readonly property var presets: [5, 10, 15, 30, 60] + readonly property int validMinutes: TilesModel.validMinutes(minutes) + + function open() { + opened = true + confirmClear = false + refresh() + } + + function close() { + opened = false + confirmClear = false + disarmClear.stop() + } + + function refresh() { + if (!showProc.running) showProc.running = true + } + + function setReminder() { + var argv = TilesModel.reminderArgv(minutes, messageField.text) + if (!argv) return + Quickshell.execDetached(argv) + messageField.text = "" + reminderSet() + } + + // Clear all takes two taps, like the other destructive actions in quick + // settings: the first turns it into "Clear all?" for a few seconds. + function requestClear() { + if (!confirmClear) { + confirmClear = true + disarmClear.restart() + return + } + confirmClear = false + Quickshell.execDetached(["omarchy-reminder", "clear"]) + reminders = [] + relist.restart() + clearedAll() + } + + Timer { + id: disarmClear + interval: 4000 + onTriggered: root.confirmClear = false + } + + Timer { + id: relist + interval: 1200 + onTriggered: root.refresh() + } + + Process { + id: showProc + command: ["omarchy-reminder", "show", "--json"] + stdout: StdioCollector { + waitForEnd: true + onStreamFinished: { + root.reminders = TilesModel.parseReminders(text) + root.listed = true + } + } + } + + property real reveal: opened ? 1 : 0 + Behavior on reveal { NumberAnimation { duration: 200; easing.type: Easing.OutCubic } } + + PanelWindow { + id: window + + visible: root.opened || root.reveal > 0 + anchors { top: true; bottom: true; left: true; right: true } + // Normal: fit between the status bar and the on-screen keyboard. + exclusionMode: ExclusionMode.Normal + color: "transparent" + WlrLayershell.namespace: "omamobile-reminder" + WlrLayershell.layer: WlrLayer.Top + // OnDemand, not Exclusive, or the on-screen keyboard gets no touches. + WlrLayershell.keyboardFocus: root.opened ? WlrKeyboardFocus.OnDemand : WlrKeyboardFocus.None + + Rectangle { + anchors.fill: parent + color: Commons.Color.menu.scrim + opacity: root.reveal + } + + MouseArea { + anchors.fill: parent + onClicked: root.close() + } + + BorderSurface { + id: panel + objectName: "reminderPanel" + + x: Style.gapsOut + width: parent.width - Style.gapsOut * 2 + height: parent.height - Style.gapsOut * 2 + y: Style.gapsOut + Math.round((1 - root.reveal) * Style.space(60)) + opacity: root.reveal + color: Commons.Color.popups.background + borderSpec: Border.surfaceSpec("popups", "border", Commons.Color.popups.border, Math.max(1, Style.space(2))) + radius: Style.cornerRadius + padding: root.pad + + focus: root.opened + Keys.onEscapePressed: root.close() + + // Swallow taps so they don't reach the scrim. + MouseArea { anchors.fill: parent } + + Item { + id: body + anchors.fill: parent + anchors.topMargin: panel.contentTopInset + anchors.rightMargin: panel.contentRightInset + anchors.bottomMargin: panel.contentBottomInset + anchors.leftMargin: panel.contentLeftInset + + // ---------- Header: back and title + Item { + id: header + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + height: root.touchSize + + GlyphButton { + id: back + anchors.left: parent.left + anchors.verticalCenter: parent.verticalCenter + glyph: "󰁍" + onTapped: root.backRequested() + } + + Text { + anchors.left: back.right + anchors.leftMargin: Style.spacing.lg + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + textFormat: Text.PlainText + text: "Reminder" + color: root.foreground + font.family: Style.font.family + font.pixelSize: Style.font.title + font.bold: true + elide: Text.ElideRight + } + } + + // ---------- What is pending, with Clear all + Flickable { + id: pending + anchors.top: header.bottom + anchors.topMargin: root.pad + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: form.top + anchors.bottomMargin: root.pad + contentHeight: pendingColumn.implicitHeight + clip: true + boundsBehavior: Flickable.StopAtBounds + + Column { + id: pendingColumn + width: pending.width + spacing: Style.spacing.md + + Text { + width: parent.width + textFormat: Text.PlainText + text: root.reminders.length === 0 ? (root.listed ? "Nothing pending" : "") : (root.reminders.length === 1 ? "1 pending" : root.reminders.length + " pending") + color: Qt.darker(root.foreground, 1.4) + font.family: Style.font.family + font.pixelSize: Style.font.body + } + + Repeater { + model: root.reminders + delegate: Item { + id: pendingRow + required property var modelData + width: parent.width + height: Math.max(root.touchSize, pendingText.implicitHeight + Style.spacing.lg) + + Column { + id: pendingText + anchors.left: parent.left + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + spacing: Style.spacing.xxs + + Text { + width: parent.width + textFormat: Text.PlainText + text: pendingRow.modelData.label + color: root.foreground + font.family: Style.font.family + font.pixelSize: Style.font.subtitle + font.bold: true + elide: Text.ElideRight + } + + Text { + width: parent.width + textFormat: Text.PlainText + text: "At " + pendingRow.modelData.atTime + " (in " + pendingRow.modelData.remaining + ")" + color: Qt.darker(root.foreground, 1.4) + font.family: Style.font.family + font.pixelSize: Readable.px(Style.font.caption) + elide: Text.ElideRight + } + } + } + } + + SheetButton { + objectName: "reminderClear" + visible: root.reminders.length > 0 + width: parent.width + label: root.confirmClear ? "Clear all?" : "Clear all" + danger: root.confirmClear + foreground: root.foreground + onTapped: root.requestClear() + } + } + } + + // ---------- The form, above the keyboard + Column { + id: form + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + spacing: Style.spacing.lg + + Text { + width: parent.width + textFormat: Text.PlainText + text: "Remind me in" + color: root.foreground + font.family: Style.font.family + font.pixelSize: Style.font.subtitle + font.bold: true + } + + Flow { + width: parent.width + spacing: Style.spacing.md + + Repeater { + model: root.presets + delegate: BorderSurface { + id: chip + required property var modelData + readonly property bool selected: root.validMinutes === chip.modelData + objectName: "reminderPreset-" + chip.modelData + width: Math.max(root.touchSize, chipText.implicitWidth + Style.spacing.xl * 2) + height: root.touchSize + radius: Style.cornerRadius + color: chipTouch.pressed ? Style.pressedFillFor(root.foreground, Commons.Color.accent) + : chip.selected ? Util.alpha(Commons.Color.accent, Style.selectedFillAlpha) + : Style.normalFillFor(root.foreground, Commons.Color.accent) + borderSpec: Border.controlSpec(chip.selected ? "selected" : "normal", root.foreground, Commons.Color.accent) + + Text { + id: chipText + anchors.centerIn: parent + textFormat: Text.PlainText + text: chip.modelData + " min" + color: chip.selected ? Commons.Color.accent : root.foreground + font.family: Style.font.family + font.pixelSize: Style.font.subtitle + font.bold: chip.selected + } + + MouseArea { + id: chipTouch + anchors.fill: parent + onClicked: root.minutes = String(chip.modelData) + } + } + } + } + + Item { + width: parent.width + height: root.touchSize + + TextField { + id: minutesField + objectName: "reminderMinutes" + anchors.left: parent.left + anchors.top: parent.top + anchors.bottom: parent.bottom + width: Math.round(parent.width * 0.32) + verticalAlignment: TextInput.AlignVCenter + font.pixelSize: Style.font.title + foreground: root.foreground + placeholderText: "Minutes" + text: root.minutes + inputMethodHints: Qt.ImhDigitsOnly | Qt.ImhNoPredictiveText + onTextEdited: root.minutes = text + Keys.onEscapePressed: root.close() + } + + TextField { + id: messageField + objectName: "reminderMessage" + anchors.left: minutesField.right + anchors.leftMargin: Style.spacing.lg + anchors.right: parent.right + anchors.top: parent.top + anchors.bottom: parent.bottom + verticalAlignment: TextInput.AlignVCenter + font.pixelSize: Style.font.title + foreground: root.foreground + placeholderText: "What for (optional)" + inputMethodHints: Qt.ImhNoPredictiveText + onAccepted: root.setReminder() + Keys.onEscapePressed: root.close() + } + } + + SheetButton { + objectName: "reminderSet" + width: parent.width + label: root.validMinutes > 0 ? "Set for " + root.validMinutes + (root.validMinutes === 1 ? " minute" : " minutes") : "Set" + primary: true + enabled: root.validMinutes > 0 + foreground: root.foreground + onTapped: root.setReminder() + } + } + } + } + } +} diff --git a/packages/omamobile-shell/plugins/omamobile.quicksettings/TilesModel.js b/packages/omamobile-shell/plugins/omamobile.quicksettings/TilesModel.js index bdbe958da..0d2ab0c48 100644 --- a/packages/omamobile-shell/plugins/omamobile.quicksettings/TilesModel.js +++ b/packages/omamobile-shell/plugins/omamobile.quicksettings/TilesModel.js @@ -33,18 +33,21 @@ var CATALOG = [ { id: "fingerprint", label: "Fingerprint" }, { id: "keyboard", label: "Keyboard" }, { id: "clipboard", label: "Clipboard" }, - { id: "dictation", label: "Dictation" } + { id: "dictation", label: "Dictation" }, + { id: "reminder", label: "Reminder" } ] // The first four are the collapsed sheet's row, as on Android: the toggles -// reached for most. Clipboard and Dictation close the second page: Omarchy -// reaches them only by keyboard shortcut, so a tile is their touch path -// (TOUCH-PLAN 1.12), and appending them leaves the first page as it was. +// reached for most. Clipboard and Dictation close the second page and +// Reminder opens a third: Omarchy reaches them only by keyboard shortcut, +// so a tile is their touch path (TOUCH-PLAN 1.12), and appending them +// leaves the earlier pages as they were. var DEFAULT_LAYOUT = [ "wifi", "bluetooth", "dnd", "torch", "mobile-data", "rotation-lock", "airplane", "location", "battery-saver", "dark-theme", "night-light", "nfc", - "fingerprint", "keyboard", "clipboard", "dictation" + "fingerprint", "keyboard", "clipboard", "dictation", + "reminder" ] var QUICK_COUNT = 4 @@ -206,6 +209,46 @@ function dictationStatus(state) { return "Not installed" } +// The Reminder tile (TOUCH-PLAN 1.12) runs Omarchy's own omarchy-reminder. +// Minutes are whole and above zero, as Omarchy's flow checks them; 0 for +// anything else. +function validMinutes(text) { + var s = String(text === undefined || text === null ? "" : text).trim() + return /^[0-9]+$/.test(s) && Number(s) > 0 ? Number(s) : 0 +} + +// `omarchy-reminder [message]`, or null for bad minutes. The +// message is plain text in argv, as Omarchy's binding sends it. +function reminderArgv(minutes, message) { + var n = validMinutes(minutes) + if (!n) return null + var argv = ["omarchy-reminder", String(n)] + var text = String(message === undefined || message === null ? "" : message).trim() + if (text) argv.push(text) + return argv +} + +// What `omarchy-reminder show --json` lists: each pending reminder's +// label, the time it fires and what is left, in its order. +function parseReminders(text) { + var data = null + try { data = JSON.parse(String(text || "")) } catch (error) { return [] } + if (!data || typeof data !== "object" || !Array.isArray(data.reminders)) return [] + return data.reminders.map(function(r) { + r = r && typeof r === "object" ? r : {} + return { label: String(r.label || ""), atTime: String(r.atTime || ""), remaining: String(r.remaining || "") } + }) +} + +// The tile's status from tile-state.sh's reminders key: the count of +// pending timers, or none without omarchy-reminder. +function reminderStatus(probe) { + if (probe === undefined || probe === "" || probe === "none") return "Not installed" + var n = parseInt(probe, 10) + if (!(n > 0)) return "None set" + return n === 1 ? "1 set" : n + " set" +} + function themeName(name) { return String(name || "").split("-").filter(function(part) { return part.length > 0 }) .map(function(part) { return part.charAt(0).toUpperCase() + part.slice(1) }).join(" ") @@ -237,6 +280,10 @@ if (typeof module !== "undefined") { parseProbe: parseProbe, powerStatus: powerStatus, dictationStatus: dictationStatus, + validMinutes: validMinutes, + reminderArgv: reminderArgv, + parseReminders: parseReminders, + reminderStatus: reminderStatus, themeName: themeName } } diff --git a/packages/omamobile-shell/plugins/omamobile.quicksettings/tile-state.sh b/packages/omamobile-shell/plugins/omamobile.quicksettings/tile-state.sh index 0dea1403d..a526c88ce 100755 --- a/packages/omamobile-shell/plugins/omamobile.quicksettings/tile-state.sh +++ b/packages/omamobile-shell/plugins/omamobile.quicksettings/tile-state.sh @@ -21,6 +21,8 @@ # dictation voxtype: on while recording, busy while transcribing, off # when idle; down when its user service isn't running, none # without voxtype (it is an optional Omarchy install) +# reminders how many of Omarchy's reminder timers are pending +# (omarchy-reminder show --json); none without it t() { timeout 3 "$@" 2>/dev/null; } have() { command -v "$1" >/dev/null 2>&1; } @@ -99,6 +101,15 @@ else echo "dictation=none" fi +# reminders: Omarchy's own count of its pending omarchy-reminder-* timers. +if have omarchy-reminder; then + count=$(t omarchy-reminder show --json | grep -o '"count":[0-9]*' | head -n1) + count=${count#*:} + echo "reminders=${count:-0}" +else + echo "reminders=none" +fi + # data: the daemon's public state is world-readable; the bearer service's # state is what "data on|off" switches. state=/run/omamobile-sit/state.json diff --git a/packages/omamobile-shell/test/all b/packages/omamobile-shell/test/all index 37dc8b355..9e837a988 100755 --- a/packages/omamobile-shell/test/all +++ b/packages/omamobile-shell/test/all @@ -148,6 +148,22 @@ grep -cF 'call omamobile.bar notificationsSeen' "$qs" >/dev/null || fail "the sh grep -cF 'function notificationsSeen(stamp: string): string' plugins/omamobile.bar/Bar.qml >/dev/null || fail "the bar serves notificationsSeen" grep -cF '"/.local/state/omamobile/notifications-seen"' plugins/omamobile.bar/Bar.qml >/dev/null || fail "the bar reads the shade's mark at start" grep -cF '"omarchy-shell", "shell", "summon", "omarchy.clipboard"' "$qs" >/dev/null || fail "the Clipboard tile opens Omarchy's clipboard history" +# The Reminder tile (TOUCH-PLAN 1.12) is a page over Omarchy's own +# omarchy-reminder: Set runs it with the minutes and message, Clear all +# runs its clear after a second tap, the list is its JSON, and nothing +# here starts a timer or a notification of its own. Night light was +# already a tile (omarchy-toggle-nightlight, tile-action.sh). +panel=plugins/omamobile.quicksettings/ReminderPanel.qml +grep -cF 'var argv = TilesModel.reminderArgv(minutes, messageField.text)' "$panel" >/dev/null || fail "Set runs omarchy-reminder through reminderArgv" +grep -cF 'Quickshell.execDetached(["omarchy-reminder", "clear"])' "$panel" >/dev/null || fail "Clear all runs omarchy-reminder clear" +grep -cF 'onTapped: root.requestClear()' "$panel" >/dev/null || fail "Clear all asks first" +grep -cF 'command: ["omarchy-reminder", "show", "--json"]' "$panel" >/dev/null || fail "the page lists omarchy-reminder's JSON" +if grep -nE 'systemd-run|notification-send' "$panel"; then fail "the reminder page starts no timer or notification of its own"; fi +grep -cF 'Quickshell.execDetached(["omarchy-reminder", "show"])' "$qs" >/dev/null || fail "a long-press on Reminder shows Omarchy's list" +grep -cF '"reminder": reminder' "$qs" >/dev/null || fail "the Reminder tile has a backend" +grep -cF 'else if (page === "reminder") reminderPanelItem.open()' "$qs" >/dev/null || fail "the Reminder tile opens its page" +grep -cF 'exclusionMode: ExclusionMode.Normal' "$panel" >/dev/null || fail "the reminder page fits above the on-screen keyboard" +grep -cF 'exec omarchy-toggle-nightlight' plugins/omamobile.quicksettings/tile-action.sh >/dev/null || fail "night light is Omarchy's toggle" # A swipe on a row forgets that one notification through the service's # forget call (omamobile-omarchy patch 0019), never by deleting its file # behind the service; the row's swipe is sideways only and off while the diff --git a/packages/omamobile-shell/test/quicksettings-render b/packages/omamobile-shell/test/quicksettings-render index f8088d4ea..235a3850a 100755 --- a/packages/omamobile-shell/test/quicksettings-render +++ b/packages/omamobile-shell/test/quicksettings-render @@ -2,11 +2,13 @@ # SPDX-License-Identifier: MIT # Offscreen review shots of quick settings (omamobile.quicksettings), # upright and on its side (TOUCH-PLAN 2.4), in a dark and a light Omarchy -# theme, with checks that the sheet, its tiles and the notification shade -# fit the screen: the real QuickSettings.qml, its layer-shell window a -# plain Item, over a throwaway $HOME with a few notifications of our own -# in the shade. No backend answers here (no D-Bus, no scripts on PATH), so -# the tiles show as unavailable; it is the layout under review. Runs inside +# theme, with checks that the sheet, its tiles, the notification shade and +# the reminder page (TOUCH-PLAN 1.12) fit the screen: the real +# QuickSettings.qml, its layer-shell windows plain Items, over a throwaway +# $HOME with a few notifications of our own in the shade. No backend +# answers here (no D-Bus, no scripts on PATH), so the tiles show as +# unavailable and the reminder page lists nothing; it is the layout under +# review. Runs inside # the OWL conformance container (tests/owl/Dockerfile), never on a desktop: # # docker run --rm --network none -u "$(id -u):$(id -g)" -v "$PWD:/src" \ @@ -73,6 +75,7 @@ def shot(name, w, h, **extra): print(json.dumps({"shots": [ shot("portrait", 480, 1040), shot("portrait-expanded", 480, 1040, expanded=True), shot("landscape", 1040, 480), shot("landscape-expanded", 1040, 480, expanded=True), shot("landscape-edit", 1040, 480, edit=True), + shot("portrait-reminder", 480, 1040, page="reminder"), shot("landscape-reminder", 1040, 480, page="reminder"), ]})) PY HOME=$home QT_SCALE_FACTOR=3 QS_JOB="$h/job-$theme.json" timeout 300 quickshell -p "$h/quicksettings-render.qml" > "$h/log-$theme" 2>&1 || true @@ -87,8 +90,8 @@ for n, w, h, g in re.findall(r"geometry (\S+) (\d+)x(\d+) (\{.*\})", text): geo[n] = dict(json.loads(g), screen={"x": 0, "y": 0, "w": int(w), "h": int(h)}) def inside(a, b, tol=0): return a["x"] >= b["x"] - tol and a["y"] >= b["y"] - tol and a["x"] + a["w"] <= b["x"] + b["w"] + tol and a["y"] + a["h"] <= b["y"] + b["h"] + tol def apart(a, b, tol=0): return a["x"] + a["w"] <= b["x"] + tol or b["x"] + b["w"] <= a["x"] + tol or a["y"] + a["h"] <= b["y"] + tol or b["y"] + b["h"] <= a["y"] + tol -ok = not bad and len(geo) == 5 -if len(geo) != 5: print("not ok - %s: %d of 5 shots taken" % (theme, len(geo))) +ok = not bad and len(geo) == 7 +if len(geo) != 7: print("not ok - %s: %d of 7 shots taken" % (theme, len(geo))) for l in bad: print(" " + l[:200]) def check(name, good, why=""): global ok @@ -98,6 +101,22 @@ for name, g in geo.items(): screen = g["screen"] landscape = screen["w"] > screen["h"] parts = g["parts"] + if g.get("page") == "reminder": + # The reminder page in the sheet's place: its card on screen, the + # presets, both fields and Set at least 44 px tall and on the + # card, the form under the header (it keeps to the bottom, above + # the keyboard), and no sheet behind it. + card = parts.get("reminderPanel") + check(name + ": the reminder card is on screen", card is not None and inside(card, screen, 1), json.dumps(card)) + wanted = ["reminderMinutes", "reminderMessage", "reminderSet"] + ["reminderPreset-%d" % m for m in (5, 10, 15, 30, 60)] + check(name + ": the presets, the fields and Set are on the card, at least 44 px", + card is not None and all(k in parts and inside(parts[k], card, 1) and parts[k]["h"] >= 44 for k in wanted), + json.dumps([(k, parts.get(k)) for k in wanted if not (k in parts and card and inside(parts[k], card, 1) and parts[k]["h"] >= 44)])) + check(name + ": Set is the lowest part, under the fields", all(k in parts for k in ("reminderSet", "reminderMessage")) + and parts["reminderSet"]["y"] >= parts["reminderMessage"]["y"] + parts["reminderMessage"]["h"] + and card is not None and parts["reminderSet"]["y"] + parts["reminderSet"]["h"] >= card["y"] + card["h"] - 60) + check(name + ": no sheet behind the page", "sheet" not in parts) + continue check(name + ": the sheet is on screen", "sheet" in parts and inside(parts["sheet"], screen), json.dumps(parts.get("sheet"))) # The pager's other pages lie to the right, clipped: only the tiles on # the shown page (within the grid or the pager) are judged. diff --git a/packages/omamobile-shell/test/quicksettings-render.qml b/packages/omamobile-shell/test/quicksettings-render.qml index b06738f68..fefdc381d 100644 --- a/packages/omamobile-shell/test/quicksettings-render.qml +++ b/packages/omamobile-shell/test/quicksettings-render.qml @@ -9,9 +9,9 @@ import "quicksettings" as QS // Offscreen review shots of quick settings (test/quicksettings-render): // the real QuickSettings.qml at the phone's 480x1040 logical px and on // its side at 1040x480, over an app stand-in, each shot in $QS_JOB -// (collapsed, expanded, editing) saved as a PNG with the geometry of the -// sheet, the tiles, the handle and the shade printed for the checks. Then -// it quits. +// (collapsed, expanded, editing, the reminder page) saved as a PNG with +// the geometry of the sheet, the tiles, the handle, the shade and the +// page's parts printed for the checks. Then it quits. ShellRoot { id: shell @@ -40,6 +40,16 @@ ShellRoot { QS.QuickSettings { id: qs anchors.fill: parent + // The pages (Wi-Fi, Bluetooth, record, reminder) are windows of + // their own on the phone; their stand-ins fill the screen here. + Component.onCompleted: { + for (var i = 0; i < qs.children.length; i++) { + var page = qs.children[i] + if (page.opened === undefined || page.backRequested === undefined) continue + page.width = Qt.binding(function() { return qs.width }) + page.height = Qt.binding(function() { return qs.height }) + } + } } } } @@ -63,7 +73,7 @@ ShellRoot { var s = shell.shot qs.close() Qt.callLater(function() { - qs.open(JSON.stringify({ expanded: s.expanded === true, page: s.edit ? "edit" : "" })) + qs.open(JSON.stringify({ expanded: s.expanded === true, page: s.edit ? "edit" : (s.page || "") })) settle.restart() }) } @@ -74,7 +84,7 @@ ShellRoot { var s = shell.shot var parts = shell.describe(qs, {}) console.log("geometry " + s.name + " " + screen.width + "x" + screen.height - + " " + JSON.stringify({ parts: parts, columns: qs.tileColumns, expanded: qs.expanded, edit: qs.editing, notifications: qs.notifications.length })) + + " " + JSON.stringify({ parts: parts, columns: qs.tileColumns, expanded: qs.expanded, edit: qs.editing, page: s.page || "", notifications: qs.notifications.length })) screen.grabToImage(function(result) { result.saveToFile(s.png) console.log("shot " + s.png) diff --git a/packages/omamobile-shell/test/tile-scripts.sh b/packages/omamobile-shell/test/tile-scripts.sh index f63a45fd2..1b0df9837 100755 --- a/packages/omamobile-shell/test/tile-scripts.sh +++ b/packages/omamobile-shell/test/tile-scripts.sh @@ -49,7 +49,7 @@ echo '{"enabled":false,"temperature":6500}' >"$tmp/state/night" out=$(run "$dir/tile-state.sh") for line in airplane=off hotspot=off powerprofile=balanced theme_mode=dark theme_name=tokyo-night \ - nightlight=off stayawake=off record=none data=none dictation=none; do + nightlight=off stayawake=off record=none data=none dictation=none reminders=none; do grep -cx "$line" <<<"$out" >/dev/null || fail "tile-state.sh prints $line (got: $(tr '\n' ' ' <<<"$out"))" done pass "tile-state.sh reads every probed tile" @@ -118,3 +118,12 @@ for line in "voxtype record start" "voxtype record stop"; do grep -cxF "$line" "$log" >/dev/null || fail "tile-action.sh runs: $line" done pass "dictation follows voxtype's service and state, and starts and stops by direction" + +# Reminders: the count of Omarchy's own pending timers, from its JSON; a +# phone without omarchy-reminder says none (above). +stub omarchy-reminder '[ "$1" = show ] && [ "$2" = --json ] && cat '"$tmp"'/state/reminders' +echo '{"count":0,"active":false,"tooltip":"Set Reminder","reminders":[]}' >"$tmp/state/reminders" +grep -cx "reminders=0" <<<"$(run "$dir/tile-state.sh")" >/dev/null || fail "no pending reminders reads as 0" +echo '{"count":2,"active":true,"tooltip":"2 reminders","reminders":[{"label":"Check the oven","atTime":"14:35","remaining":"12m"},{"label":"5-min reminder","atTime":"14:24","remaining":"40s"}]}' >"$tmp/state/reminders" +grep -cx "reminders=2" <<<"$(run "$dir/tile-state.sh")" >/dev/null || fail "two pending reminders read as 2" +pass "reminders count Omarchy's pending timers" diff --git a/packages/omamobile-shell/test/tiles-model.js b/packages/omamobile-shell/test/tiles-model.js index d46ffc33a..7af059aa4 100644 --- a/packages/omamobile-shell/test/tiles-model.js +++ b/packages/omamobile-shell/test/tiles-model.js @@ -28,13 +28,17 @@ test("the default keeps the old ten tiles and leads with the most used", () => { assert.deepStrictEqual(M.quickRow(M.defaults()), ["wifi", "bluetooth", "dnd", "torch"]) }) -test("Clipboard and Dictation close the default's second page, leaving the first as it was", () => { +test("Clipboard and Dictation close the default's second page and Reminder opens a third, leaving the earlier pages as they were", () => { assert.deepStrictEqual(M.pages(M.defaults())[0], ["wifi", "bluetooth", "dnd", "torch", "mobile-data", "rotation-lock", "airplane", "location"]) - assert.deepStrictEqual(M.DEFAULT_LAYOUT.slice(-2), ["clipboard", "dictation"]) - assert.strictEqual(M.pages(M.defaults()).length, 2) + assert.deepStrictEqual(M.pages(M.defaults())[1], + ["battery-saver", "dark-theme", "night-light", "nfc", "fingerprint", "keyboard", "clipboard", "dictation"]) + assert.deepStrictEqual(M.DEFAULT_LAYOUT.slice(-3), ["clipboard", "dictation", "reminder"]) + assert.strictEqual(M.pages(M.defaults()).length, 3) assert.strictEqual(M.label("clipboard"), "Clipboard") assert.strictEqual(M.label("dictation"), "Dictation") + assert.strictEqual(M.label("reminder"), "Reminder") + assert.strictEqual(M.label("night-light"), "Night light") }) test("defaults() is a copy", () => { @@ -142,6 +146,31 @@ test("status helpers", () => { assert.strictEqual(M.dictationStatus(undefined), "Not installed") }) +test("reminders: Omarchy's minutes rule, its argv, what it lists, the tile's status", () => { + assert.strictEqual(M.validMinutes("10"), 10) + assert.strictEqual(M.validMinutes(" 5 "), 5) + assert.strictEqual(M.validMinutes("0"), 0) + assert.strictEqual(M.validMinutes("-3"), 0) + assert.strictEqual(M.validMinutes("1.5"), 0) + assert.strictEqual(M.validMinutes(""), 0) + assert.strictEqual(M.validMinutes(undefined), 0) + assert.deepStrictEqual(M.reminderArgv("30", "Check the oven"), ["omarchy-reminder", "30", "Check the oven"]) + assert.deepStrictEqual(M.reminderArgv(5, " "), ["omarchy-reminder", "5"]) + assert.strictEqual(M.reminderArgv("abc", "x"), null) + const listed = M.parseReminders(JSON.stringify({ count: 2, active: true, tooltip: "2 reminders", reminders: [ + { unit: "omarchy-reminder-30m-1", minutes: 30, message: "Check the oven", label: "Check the oven", remaining: "12m 3s", at: 1, atTime: "14:35" }, + { unit: "omarchy-reminder-5m-2", minutes: 5, message: "", label: "5-min reminder", remaining: "40s", at: 2, atTime: "14:24" }] })) + assert.deepStrictEqual(listed, [{ label: "Check the oven", atTime: "14:35", remaining: "12m 3s" }, { label: "5-min reminder", atTime: "14:24", remaining: "40s" }]) + assert.deepStrictEqual(M.parseReminders('{"count":0,"reminders":[]}'), []) + assert.deepStrictEqual(M.parseReminders("not json"), []) + assert.deepStrictEqual(M.parseReminders(""), []) + assert.strictEqual(M.reminderStatus("none"), "Not installed") + assert.strictEqual(M.reminderStatus(undefined), "Not installed") + assert.strictEqual(M.reminderStatus("0"), "None set") + assert.strictEqual(M.reminderStatus("1"), "1 set") + assert.strictEqual(M.reminderStatus("3"), "3 set") +}) + let failed = 0 for (const [name, fn] of tests) { try { From fbcc4f6157fb1d48c9b873189ce0b30d2c515525 Mon Sep 17 00:00:00 2001 From: Derek Ross Date: Tue, 27 Oct 2026 15:19:36 -0400 Subject: [PATCH 3/7] omamobile-shell 0.2.31: secondary text at 4.5:1, only the glyph dimmed TOUCH-PLAN 2.7. Secondary text (the drawer's count, its placeholder and "No apps match", the tiles' status lines, the panels' detail rows, the sheets' hints) was the foreground darkened by a fixed factor or drawn at 60-75% opacity: on Tokyo Night that came to 3.5-4.3:1 against the surface, under WCAG's 4.5:1 for text, and a factor that suits one theme fails another. An unavailable tile dimmed its name as well as its glyph, and a slider row without a backend dimmed itself whole, reason included. Readable.js (the same file in every plugin) gains contrast(), flatten() and secondary(fg, surface): the foreground mixed toward the surface only as far as 4.5:1 allows, on any theme, and the foreground itself when nothing dimmer would do. Every such text and every placeholder (against the field's own fill, through Style.controlFill, since a focused field is lighter) goes through it; a tile dims only its glyph and chevron, a slider row only its glyph. The 1.3 darkenings left are glyphs. Checked from the pictures, not by eye: test/launcher-render and test/quicksettings-render crop each named text from the PNG with magick, take the histogram's commonest colour as the surface and the farthest in luminance as the text, and require 4.5:1 (every tile's name and status, the sliders' reasons, the drawer's count, placeholder and "No apps match" in a new no-match shot, the reminder page's placeholders), in both themes and both orientations; parts the sheet's scroll clips are marked and skipped. test/all pins the helper's numbers and the greps. Co-Authored-By: Claude Fable 5.1 --- .../plugins/omamobile.access/AccessSheet.qml | 4 +- .../plugins/omamobile.access/Readable.js | 73 +++++++++++++++++++ .../plugins/omamobile.home/Readable.js | 72 ++++++++++++++++-- .../plugins/omamobile.launcher/Launcher.qml | 12 ++- .../plugins/omamobile.launcher/Readable.js | 72 ++++++++++++++++-- .../BluetoothPanel.qml | 12 +-- .../NotificationRow.qml | 2 +- .../omamobile.quicksettings/QuickSettings.qml | 12 +-- .../omamobile.quicksettings/Readable.js | 72 ++++++++++++++++-- .../omamobile.quicksettings/RecordPanel.qml | 7 +- .../omamobile.quicksettings/ReminderPanel.qml | 6 +- .../omamobile.quicksettings/SliderRow.qml | 9 ++- .../plugins/omamobile.quicksettings/Tile.qml | 15 ++-- .../omamobile.quicksettings/WifiPanel.qml | 9 ++- .../plugins/omamobile.switcher/Readable.js | 72 ++++++++++++++++-- .../plugins/omamobile.switcher/Switcher.qml | 6 +- .../plugins/omamobile.update/Readable.js | 72 ++++++++++++++++-- .../plugins/omamobile.update/Update.qml | 13 ++-- packages/omamobile-shell/test/all | 35 ++++++++- packages/omamobile-shell/test/launcher-render | 50 +++++++++++-- .../omamobile-shell/test/launcher-render.qml | 18 +++-- .../omamobile-shell/test/quicksettings-render | 52 ++++++++++++- .../test/quicksettings-render.qml | 30 +++++++- 23 files changed, 623 insertions(+), 102 deletions(-) create mode 100644 packages/omamobile-shell/plugins/omamobile.access/Readable.js diff --git a/packages/omamobile-shell/plugins/omamobile.access/AccessSheet.qml b/packages/omamobile-shell/plugins/omamobile.access/AccessSheet.qml index 2b5a6076a..9582b6606 100644 --- a/packages/omamobile-shell/plugins/omamobile.access/AccessSheet.qml +++ b/packages/omamobile-shell/plugins/omamobile.access/AccessSheet.qml @@ -4,6 +4,7 @@ import Quickshell import qs.Commons import qs.Commons as Commons import qs.Ui +import "Readable.js" as Readable import "AccessModel.js" as AccessModel // The permission sheet itself: the scrim, and the card at the bottom with the @@ -141,8 +142,7 @@ Item { horizontalAlignment: Text.AlignHCenter textFormat: Text.PlainText text: card.r.body || "" - color: sheet.foreground - opacity: 0.75 + color: Readable.secondary(sheet.foreground, Commons.Color.popups.background) font.family: Style.font.family font.pixelSize: Style.font.heading lineHeight: 1.15 diff --git a/packages/omamobile-shell/plugins/omamobile.access/Readable.js b/packages/omamobile-shell/plugins/omamobile.access/Readable.js new file mode 100644 index 000000000..e0dc85b6c --- /dev/null +++ b/packages/omamobile-shell/plugins/omamobile.access/Readable.js @@ -0,0 +1,73 @@ +// SPDX-License-Identifier: MIT +// Text that can be read on the phone (docs/TOUCH-PLAN.md 2.1 and 2.7). +// Plugins are separate directories with no shared import, so each one that +// needs this carries this same file (test/all checks they match). +// +// Size: Omarchy's type scale is a desktop's (caption 10 px, body 12 px); on +// the phone's 480 px wide screen, held at arm's length, nothing read goes +// under 12 px. A floor here rather than theme font overrides, which a theme +// change would drop. +// +// Contrast: secondary text (a status line, a placeholder, a hint) used to +// be the foreground darkened by a fixed factor or drawn at 60-75% opacity, +// which on a dark theme came to 3-4:1 against the surface. `secondary` +// mixes the foreground toward the surface only as far as WCAG's 4.5:1 +// minimum for text allows, on any theme. + +var MIN_PX = 12 +var MIN_CONTRAST = 4.5 +// How far secondary text may be mixed toward its surface at most (the +// share of the surface), so it still reads as secondary on a theme with +// plenty of contrast to spare. +var MAX_MIX = 0.6 + +function px(size) { return Math.max(MIN_PX, size) } + +// Colours are {r, g, b[, a]} in 0..1, which a QML color is in JavaScript. + +function channel(v) { return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4) } + +// WCAG relative luminance. +function luminance(c) { + return 0.2126 * channel(c.r) + 0.7152 * channel(c.g) + 0.0722 * channel(c.b) +} + +// WCAG contrast ratio, 1..21. +function contrast(a, b) { + var la = luminance(a), lb = luminance(b) + return (Math.max(la, lb) + 0.05) / (Math.min(la, lb) + 0.05) +} + +// `top` (with its alpha) laid over an opaque `under`. +function flattenRgb(top, under) { + var a = top.a === undefined ? 1 : top.a + return { r: top.r * a + under.r * (1 - a), g: top.g * a + under.g * (1 - a), b: top.b * a + under.b * (1 - a), a: 1 } +} + +// The foreground mixed toward the surface as far as MIN_CONTRAST allows +// (never past MAX_MIX); the foreground itself when even that falls short. +function secondaryRgb(fg, bg, minRatio) { + var want = minRatio || MIN_CONTRAST + var under = flattenRgb(bg, { r: 0, g: 0, b: 0 }) + for (var t = MAX_MIX; t >= 0; t = Math.round((t - 0.02) * 100) / 100) { + var mix = { r: fg.r * (1 - t) + under.r * t, g: fg.g * (1 - t) + under.g * t, b: fg.b * (1 - t) + under.b * t, a: 1 } + if (contrast(mix, under) >= want) return mix + } + return { r: fg.r, g: fg.g, b: fg.b, a: 1 } +} + +// For QML: a color. Under Node (no Qt) the {r, g, b, a} object. +function secondary(fg, bg) { + var c = secondaryRgb(fg, bg) + return typeof Qt !== "undefined" ? Qt.rgba(c.r, c.g, c.b, 1) : c +} + +function flatten(top, under) { + var c = flattenRgb(top, under) + return typeof Qt !== "undefined" ? Qt.rgba(c.r, c.g, c.b, 1) : c +} + +if (typeof module !== "undefined") { + module.exports = { MIN_PX: MIN_PX, MIN_CONTRAST: MIN_CONTRAST, MAX_MIX: MAX_MIX, px: px, luminance: luminance, contrast: contrast, + flattenRgb: flattenRgb, secondaryRgb: secondaryRgb, secondary: secondary, flatten: flatten } +} diff --git a/packages/omamobile-shell/plugins/omamobile.home/Readable.js b/packages/omamobile-shell/plugins/omamobile.home/Readable.js index 2a7811cd2..e0dc85b6c 100644 --- a/packages/omamobile-shell/plugins/omamobile.home/Readable.js +++ b/packages/omamobile-shell/plugins/omamobile.home/Readable.js @@ -1,15 +1,73 @@ // SPDX-License-Identifier: MIT -// The smallest size for text that has to be read. Omarchy's type scale is a -// desktop's (caption 10 px, body 12 px); on the phone's 480 px wide screen, -// held at arm's length, nothing read goes under 12 px (docs/TOUCH-PLAN.md -// 2.1). A floor here rather than theme font overrides, which a theme change -// would drop. Plugins are separate directories with no shared import, so -// each one that needs it carries this same file (test/all checks they match). +// Text that can be read on the phone (docs/TOUCH-PLAN.md 2.1 and 2.7). +// Plugins are separate directories with no shared import, so each one that +// needs this carries this same file (test/all checks they match). +// +// Size: Omarchy's type scale is a desktop's (caption 10 px, body 12 px); on +// the phone's 480 px wide screen, held at arm's length, nothing read goes +// under 12 px. A floor here rather than theme font overrides, which a theme +// change would drop. +// +// Contrast: secondary text (a status line, a placeholder, a hint) used to +// be the foreground darkened by a fixed factor or drawn at 60-75% opacity, +// which on a dark theme came to 3-4:1 against the surface. `secondary` +// mixes the foreground toward the surface only as far as WCAG's 4.5:1 +// minimum for text allows, on any theme. var MIN_PX = 12 +var MIN_CONTRAST = 4.5 +// How far secondary text may be mixed toward its surface at most (the +// share of the surface), so it still reads as secondary on a theme with +// plenty of contrast to spare. +var MAX_MIX = 0.6 function px(size) { return Math.max(MIN_PX, size) } +// Colours are {r, g, b[, a]} in 0..1, which a QML color is in JavaScript. + +function channel(v) { return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4) } + +// WCAG relative luminance. +function luminance(c) { + return 0.2126 * channel(c.r) + 0.7152 * channel(c.g) + 0.0722 * channel(c.b) +} + +// WCAG contrast ratio, 1..21. +function contrast(a, b) { + var la = luminance(a), lb = luminance(b) + return (Math.max(la, lb) + 0.05) / (Math.min(la, lb) + 0.05) +} + +// `top` (with its alpha) laid over an opaque `under`. +function flattenRgb(top, under) { + var a = top.a === undefined ? 1 : top.a + return { r: top.r * a + under.r * (1 - a), g: top.g * a + under.g * (1 - a), b: top.b * a + under.b * (1 - a), a: 1 } +} + +// The foreground mixed toward the surface as far as MIN_CONTRAST allows +// (never past MAX_MIX); the foreground itself when even that falls short. +function secondaryRgb(fg, bg, minRatio) { + var want = minRatio || MIN_CONTRAST + var under = flattenRgb(bg, { r: 0, g: 0, b: 0 }) + for (var t = MAX_MIX; t >= 0; t = Math.round((t - 0.02) * 100) / 100) { + var mix = { r: fg.r * (1 - t) + under.r * t, g: fg.g * (1 - t) + under.g * t, b: fg.b * (1 - t) + under.b * t, a: 1 } + if (contrast(mix, under) >= want) return mix + } + return { r: fg.r, g: fg.g, b: fg.b, a: 1 } +} + +// For QML: a color. Under Node (no Qt) the {r, g, b, a} object. +function secondary(fg, bg) { + var c = secondaryRgb(fg, bg) + return typeof Qt !== "undefined" ? Qt.rgba(c.r, c.g, c.b, 1) : c +} + +function flatten(top, under) { + var c = flattenRgb(top, under) + return typeof Qt !== "undefined" ? Qt.rgba(c.r, c.g, c.b, 1) : c +} + if (typeof module !== "undefined") { - module.exports = { MIN_PX: MIN_PX, px: px } + module.exports = { MIN_PX: MIN_PX, MIN_CONTRAST: MIN_CONTRAST, MAX_MIX: MAX_MIX, px: px, luminance: luminance, contrast: contrast, + flattenRgb: flattenRgb, secondaryRgb: secondaryRgb, secondary: secondary, flatten: flatten } } diff --git a/packages/omamobile-shell/plugins/omamobile.launcher/Launcher.qml b/packages/omamobile-shell/plugins/omamobile.launcher/Launcher.qml index 71f525dd4..1745e33ad 100644 --- a/packages/omamobile-shell/plugins/omamobile.launcher/Launcher.qml +++ b/packages/omamobile-shell/plugins/omamobile.launcher/Launcher.qml @@ -581,8 +581,9 @@ Item { anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter textFormat: Text.PlainText + objectName: "drawerCount" text: root.hasQuery ? (root.apps.length === 1 ? "1 app" : root.apps.length + " apps") : "Apps" - color: Qt.darker(root.foreground, 1.4) + color: Readable.secondary(root.foreground, Commons.Color.menu.background) font.family: Style.font.family font.pixelSize: Style.font.subtitle font.bold: true @@ -638,8 +639,9 @@ Item { anchors.centerIn: grid visible: root.hasQuery && root.apps.length === 0 textFormat: Text.PlainText + objectName: "drawerEmpty" text: "No apps match" - color: Qt.darker(root.foreground, 1.6) + color: Readable.secondary(root.foreground, Commons.Color.menu.background) font.family: Style.font.family font.pixelSize: Style.font.body } @@ -715,7 +717,7 @@ Item { width: parent.width textFormat: Text.PlainText text: root.query.trim() - color: Qt.darker(root.foreground, 1.4) + color: Readable.secondary(root.foreground, Commons.Color.menu.background) font.family: Style.font.family font.pixelSize: Readable.px(Style.font.caption) elide: Text.ElideRight @@ -753,12 +755,14 @@ Item { TextField { id: input + objectName: "drawerInput" anchors.fill: parent anchors.margins: Style.spacing.xxl verticalAlignment: TextInput.AlignVCenter font.pixelSize: Style.font.title leftPadding: Style.spacing.controlPaddingX + Style.font.iconLarge + Style.spacing.xl placeholderText: (root.hasAgent ? "Search apps or ask " + root.agentName + "…" : "Search apps…") + placeholderTextColor: Readable.secondary(root.foreground, Readable.flatten(Style.controlFill(activeFocus, hovered || hasCursor, foreground, accent), Commons.Color.menu.background)) foreground: root.foreground text: root.query onTextEdited: root.query = text @@ -817,7 +821,7 @@ Item { anchors.verticalCenter: parent.verticalCenter textFormat: Text.PlainText text: pill.placeholder - color: Qt.darker(root.foreground, 1.6) + color: Readable.secondary(root.foreground, Commons.Color.bar.background) font.family: Style.font.family font.pixelSize: Style.font.title elide: Text.ElideRight diff --git a/packages/omamobile-shell/plugins/omamobile.launcher/Readable.js b/packages/omamobile-shell/plugins/omamobile.launcher/Readable.js index 2a7811cd2..e0dc85b6c 100644 --- a/packages/omamobile-shell/plugins/omamobile.launcher/Readable.js +++ b/packages/omamobile-shell/plugins/omamobile.launcher/Readable.js @@ -1,15 +1,73 @@ // SPDX-License-Identifier: MIT -// The smallest size for text that has to be read. Omarchy's type scale is a -// desktop's (caption 10 px, body 12 px); on the phone's 480 px wide screen, -// held at arm's length, nothing read goes under 12 px (docs/TOUCH-PLAN.md -// 2.1). A floor here rather than theme font overrides, which a theme change -// would drop. Plugins are separate directories with no shared import, so -// each one that needs it carries this same file (test/all checks they match). +// Text that can be read on the phone (docs/TOUCH-PLAN.md 2.1 and 2.7). +// Plugins are separate directories with no shared import, so each one that +// needs this carries this same file (test/all checks they match). +// +// Size: Omarchy's type scale is a desktop's (caption 10 px, body 12 px); on +// the phone's 480 px wide screen, held at arm's length, nothing read goes +// under 12 px. A floor here rather than theme font overrides, which a theme +// change would drop. +// +// Contrast: secondary text (a status line, a placeholder, a hint) used to +// be the foreground darkened by a fixed factor or drawn at 60-75% opacity, +// which on a dark theme came to 3-4:1 against the surface. `secondary` +// mixes the foreground toward the surface only as far as WCAG's 4.5:1 +// minimum for text allows, on any theme. var MIN_PX = 12 +var MIN_CONTRAST = 4.5 +// How far secondary text may be mixed toward its surface at most (the +// share of the surface), so it still reads as secondary on a theme with +// plenty of contrast to spare. +var MAX_MIX = 0.6 function px(size) { return Math.max(MIN_PX, size) } +// Colours are {r, g, b[, a]} in 0..1, which a QML color is in JavaScript. + +function channel(v) { return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4) } + +// WCAG relative luminance. +function luminance(c) { + return 0.2126 * channel(c.r) + 0.7152 * channel(c.g) + 0.0722 * channel(c.b) +} + +// WCAG contrast ratio, 1..21. +function contrast(a, b) { + var la = luminance(a), lb = luminance(b) + return (Math.max(la, lb) + 0.05) / (Math.min(la, lb) + 0.05) +} + +// `top` (with its alpha) laid over an opaque `under`. +function flattenRgb(top, under) { + var a = top.a === undefined ? 1 : top.a + return { r: top.r * a + under.r * (1 - a), g: top.g * a + under.g * (1 - a), b: top.b * a + under.b * (1 - a), a: 1 } +} + +// The foreground mixed toward the surface as far as MIN_CONTRAST allows +// (never past MAX_MIX); the foreground itself when even that falls short. +function secondaryRgb(fg, bg, minRatio) { + var want = minRatio || MIN_CONTRAST + var under = flattenRgb(bg, { r: 0, g: 0, b: 0 }) + for (var t = MAX_MIX; t >= 0; t = Math.round((t - 0.02) * 100) / 100) { + var mix = { r: fg.r * (1 - t) + under.r * t, g: fg.g * (1 - t) + under.g * t, b: fg.b * (1 - t) + under.b * t, a: 1 } + if (contrast(mix, under) >= want) return mix + } + return { r: fg.r, g: fg.g, b: fg.b, a: 1 } +} + +// For QML: a color. Under Node (no Qt) the {r, g, b, a} object. +function secondary(fg, bg) { + var c = secondaryRgb(fg, bg) + return typeof Qt !== "undefined" ? Qt.rgba(c.r, c.g, c.b, 1) : c +} + +function flatten(top, under) { + var c = flattenRgb(top, under) + return typeof Qt !== "undefined" ? Qt.rgba(c.r, c.g, c.b, 1) : c +} + if (typeof module !== "undefined") { - module.exports = { MIN_PX: MIN_PX, px: px } + module.exports = { MIN_PX: MIN_PX, MIN_CONTRAST: MIN_CONTRAST, MAX_MIX: MAX_MIX, px: px, luminance: luminance, contrast: contrast, + flattenRgb: flattenRgb, secondaryRgb: secondaryRgb, secondary: secondary, flatten: flatten } } diff --git a/packages/omamobile-shell/plugins/omamobile.quicksettings/BluetoothPanel.qml b/packages/omamobile-shell/plugins/omamobile.quicksettings/BluetoothPanel.qml index d4352c5f5..a4be26bee 100644 --- a/packages/omamobile-shell/plugins/omamobile.quicksettings/BluetoothPanel.qml +++ b/packages/omamobile-shell/plugins/omamobile.quicksettings/BluetoothPanel.qml @@ -677,7 +677,7 @@ Item { horizontalAlignment: Text.AlignHCenter textFormat: Text.PlainText text: root.adapter ? "Turn on Bluetooth to see devices" : "No Bluetooth adapter" - color: Qt.darker(root.foreground, 1.4) + color: Readable.secondary(root.foreground, Commons.Color.popups.background) font.family: Style.font.family font.pixelSize: Style.font.body wrapMode: Text.Wrap @@ -732,7 +732,7 @@ Item { anchors.centerIn: parent textFormat: Text.PlainText text: entryItem.row.text - color: Qt.darker(root.foreground, 1.4) + color: Readable.secondary(root.foreground, Commons.Color.popups.background) font.family: Style.font.family font.pixelSize: Style.font.body } @@ -814,7 +814,7 @@ Item { visible: text !== "" textFormat: Text.PlainText text: BluetoothModel.rowStatus(entryItem.row, entryItem.busy ? root.actionKind : "", entryItem.failure) - color: entryItem.failure ? Commons.Color.urgent : Qt.darker(root.foreground, 1.4) + color: entryItem.failure ? Commons.Color.urgent : Readable.secondary(root.foreground, Commons.Color.popups.background) font.family: Style.font.family font.pixelSize: Readable.px(Style.font.caption) elide: Text.ElideRight @@ -886,7 +886,7 @@ Item { visible: text !== "" textFormat: Text.PlainText text: root.agentSheet ? root.agentSheet.body : "" - color: Qt.darker(root.foreground, 1.2) + color: Readable.secondary(root.foreground, Commons.Color.popups.background) font.family: Style.font.family font.pixelSize: Style.font.body wrapMode: Text.Wrap @@ -936,6 +936,7 @@ Item { font.pixelSize: Style.font.title foreground: root.foreground placeholderText: root.agentSheet && root.agentSheet.input === "passkey" ? "Passkey" : "PIN" + placeholderTextColor: Readable.secondary(root.foreground, Readable.flatten(Style.controlFill(activeFocus, hovered || hasCursor, foreground, accent), Commons.Color.popups.background)) maximumLength: root.agentSheet && root.agentSheet.input === "passkey" ? 6 : 16 inputMethodHints: root.agentSheet && root.agentSheet.input === "passkey" ? Qt.ImhDigitsOnly | Qt.ImhNoPredictiveText @@ -955,6 +956,7 @@ Item { font.pixelSize: Style.font.title foreground: root.foreground placeholderText: "Name" + placeholderTextColor: Readable.secondary(root.foreground, Readable.flatten(Style.controlFill(activeFocus, hovered || hasCursor, foreground, accent), Commons.Color.popups.background)) maximumLength: 248 onAccepted: root.submitRename() onTextEdited: root.sheetError = "" @@ -1068,7 +1070,7 @@ Item { visible: text !== "" textFormat: Text.PlainText text: switchRow.detail - color: Qt.darker(root.foreground, 1.4) + color: Readable.secondary(root.foreground, Commons.Color.popups.background) font.family: Style.font.family font.pixelSize: Readable.px(Style.font.caption) elide: Text.ElideRight diff --git a/packages/omamobile-shell/plugins/omamobile.quicksettings/NotificationRow.qml b/packages/omamobile-shell/plugins/omamobile.quicksettings/NotificationRow.qml index 27aed3a8d..584c36bd3 100644 --- a/packages/omamobile-shell/plugins/omamobile.quicksettings/NotificationRow.qml +++ b/packages/omamobile-shell/plugins/omamobile.quicksettings/NotificationRow.qml @@ -90,7 +90,7 @@ Item { textFormat: Text.PlainText text: [row.entry.app, NotificationsModel.ago(row.entry.timestamp, row.host ? row.host.nowMs : Date.now())] .filter(function(part) { return !!part }).join(" · ") - color: Qt.darker(row.foreground, 1.4) + color: Readable.secondary(row.foreground, Commons.Color.popups.background) font.family: Style.font.family font.pixelSize: Readable.px(Style.font.caption) elide: Text.ElideRight diff --git a/packages/omamobile-shell/plugins/omamobile.quicksettings/QuickSettings.qml b/packages/omamobile-shell/plugins/omamobile.quicksettings/QuickSettings.qml index 15c3d6ebe..36284a416 100644 --- a/packages/omamobile-shell/plugins/omamobile.quicksettings/QuickSettings.qml +++ b/packages/omamobile-shell/plugins/omamobile.quicksettings/QuickSettings.qml @@ -1519,7 +1519,7 @@ Item { Text { textFormat: Text.PlainText text: Qt.formatDateTime(clock.date, "dddd, d MMMM") - color: Qt.darker(root.foreground, 1.4) + color: Readable.secondary(root.foreground, Commons.Color.popups.background) font.family: Style.font.family font.pixelSize: Style.font.body } @@ -1618,7 +1618,7 @@ Item { anchors.centerIn: parent textFormat: Text.PlainText text: "No tiles. Tap 󰏫 to add some." - color: Qt.darker(root.foreground, 1.4) + color: Readable.secondary(root.foreground, Commons.Color.popups.background) font.family: Style.font.family font.pixelSize: Style.font.body } @@ -1677,7 +1677,7 @@ Item { width: parent.width textFormat: Text.PlainText text: "Tap a tile to remove it. Hold and drag to move it." - color: Qt.darker(root.foreground, 1.4) + color: Readable.secondary(root.foreground, Commons.Color.popups.background) font.family: Style.font.family font.pixelSize: Readable.px(Style.font.caption) wrapMode: Text.WordWrap @@ -1724,7 +1724,7 @@ Item { anchors.centerIn: parent textFormat: Text.PlainText text: "No tiles on the sheet" - color: Qt.darker(root.foreground, 1.4) + color: Readable.secondary(root.foreground, Commons.Color.popups.background) font.family: Style.font.family font.pixelSize: Style.font.body } @@ -1784,7 +1784,7 @@ Item { visible: root.spareTiles.length === 0 textFormat: Text.PlainText text: "Every tile is on the sheet" - color: Qt.darker(root.foreground, 1.4) + color: Readable.secondary(root.foreground, Commons.Color.popups.background) font.family: Style.font.family font.pixelSize: Readable.px(Style.font.caption) } @@ -1969,7 +1969,7 @@ Item { width: parent.width textFormat: Text.PlainText text: "No notifications" - color: Qt.darker(root.foreground, 1.4) + color: Readable.secondary(root.foreground, Commons.Color.popups.background) font.family: Style.font.family font.pixelSize: Style.font.body } diff --git a/packages/omamobile-shell/plugins/omamobile.quicksettings/Readable.js b/packages/omamobile-shell/plugins/omamobile.quicksettings/Readable.js index 2a7811cd2..e0dc85b6c 100644 --- a/packages/omamobile-shell/plugins/omamobile.quicksettings/Readable.js +++ b/packages/omamobile-shell/plugins/omamobile.quicksettings/Readable.js @@ -1,15 +1,73 @@ // SPDX-License-Identifier: MIT -// The smallest size for text that has to be read. Omarchy's type scale is a -// desktop's (caption 10 px, body 12 px); on the phone's 480 px wide screen, -// held at arm's length, nothing read goes under 12 px (docs/TOUCH-PLAN.md -// 2.1). A floor here rather than theme font overrides, which a theme change -// would drop. Plugins are separate directories with no shared import, so -// each one that needs it carries this same file (test/all checks they match). +// Text that can be read on the phone (docs/TOUCH-PLAN.md 2.1 and 2.7). +// Plugins are separate directories with no shared import, so each one that +// needs this carries this same file (test/all checks they match). +// +// Size: Omarchy's type scale is a desktop's (caption 10 px, body 12 px); on +// the phone's 480 px wide screen, held at arm's length, nothing read goes +// under 12 px. A floor here rather than theme font overrides, which a theme +// change would drop. +// +// Contrast: secondary text (a status line, a placeholder, a hint) used to +// be the foreground darkened by a fixed factor or drawn at 60-75% opacity, +// which on a dark theme came to 3-4:1 against the surface. `secondary` +// mixes the foreground toward the surface only as far as WCAG's 4.5:1 +// minimum for text allows, on any theme. var MIN_PX = 12 +var MIN_CONTRAST = 4.5 +// How far secondary text may be mixed toward its surface at most (the +// share of the surface), so it still reads as secondary on a theme with +// plenty of contrast to spare. +var MAX_MIX = 0.6 function px(size) { return Math.max(MIN_PX, size) } +// Colours are {r, g, b[, a]} in 0..1, which a QML color is in JavaScript. + +function channel(v) { return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4) } + +// WCAG relative luminance. +function luminance(c) { + return 0.2126 * channel(c.r) + 0.7152 * channel(c.g) + 0.0722 * channel(c.b) +} + +// WCAG contrast ratio, 1..21. +function contrast(a, b) { + var la = luminance(a), lb = luminance(b) + return (Math.max(la, lb) + 0.05) / (Math.min(la, lb) + 0.05) +} + +// `top` (with its alpha) laid over an opaque `under`. +function flattenRgb(top, under) { + var a = top.a === undefined ? 1 : top.a + return { r: top.r * a + under.r * (1 - a), g: top.g * a + under.g * (1 - a), b: top.b * a + under.b * (1 - a), a: 1 } +} + +// The foreground mixed toward the surface as far as MIN_CONTRAST allows +// (never past MAX_MIX); the foreground itself when even that falls short. +function secondaryRgb(fg, bg, minRatio) { + var want = minRatio || MIN_CONTRAST + var under = flattenRgb(bg, { r: 0, g: 0, b: 0 }) + for (var t = MAX_MIX; t >= 0; t = Math.round((t - 0.02) * 100) / 100) { + var mix = { r: fg.r * (1 - t) + under.r * t, g: fg.g * (1 - t) + under.g * t, b: fg.b * (1 - t) + under.b * t, a: 1 } + if (contrast(mix, under) >= want) return mix + } + return { r: fg.r, g: fg.g, b: fg.b, a: 1 } +} + +// For QML: a color. Under Node (no Qt) the {r, g, b, a} object. +function secondary(fg, bg) { + var c = secondaryRgb(fg, bg) + return typeof Qt !== "undefined" ? Qt.rgba(c.r, c.g, c.b, 1) : c +} + +function flatten(top, under) { + var c = flattenRgb(top, under) + return typeof Qt !== "undefined" ? Qt.rgba(c.r, c.g, c.b, 1) : c +} + if (typeof module !== "undefined") { - module.exports = { MIN_PX: MIN_PX, px: px } + module.exports = { MIN_PX: MIN_PX, MIN_CONTRAST: MIN_CONTRAST, MAX_MIX: MAX_MIX, px: px, luminance: luminance, contrast: contrast, + flattenRgb: flattenRgb, secondaryRgb: secondaryRgb, secondary: secondary, flatten: flatten } } diff --git a/packages/omamobile-shell/plugins/omamobile.quicksettings/RecordPanel.qml b/packages/omamobile-shell/plugins/omamobile.quicksettings/RecordPanel.qml index 8452ba0f3..fe538e229 100644 --- a/packages/omamobile-shell/plugins/omamobile.quicksettings/RecordPanel.qml +++ b/packages/omamobile-shell/plugins/omamobile.quicksettings/RecordPanel.qml @@ -5,6 +5,7 @@ import Quickshell.Wayland import qs.Commons import qs.Commons as Commons import qs.Ui +import "Readable.js" as Readable // The page behind the Screen record tile, after the Wi-Fi and Bluetooth // pickers: choose the video's sound (what the phone plays, the microphone, @@ -130,8 +131,7 @@ Item { textFormat: Text.PlainText wrapMode: Text.Wrap text: "Record the screen with" - color: root.foreground - opacity: 0.7 + color: Readable.secondary(root.foreground, Commons.Color.popups.background) font.family: Style.font.family font.pixelSize: Style.font.body } @@ -185,8 +185,7 @@ Item { textFormat: Text.PlainText wrapMode: Text.Wrap text: choiceRow.modelData.detail - color: root.foreground - opacity: 0.7 + color: Readable.secondary(root.foreground, Commons.Color.popups.background) font.family: Style.font.family font.pixelSize: Style.font.body } diff --git a/packages/omamobile-shell/plugins/omamobile.quicksettings/ReminderPanel.qml b/packages/omamobile-shell/plugins/omamobile.quicksettings/ReminderPanel.qml index c6699c5a8..a390810b5 100644 --- a/packages/omamobile-shell/plugins/omamobile.quicksettings/ReminderPanel.qml +++ b/packages/omamobile-shell/plugins/omamobile.quicksettings/ReminderPanel.qml @@ -213,7 +213,7 @@ Item { width: parent.width textFormat: Text.PlainText text: root.reminders.length === 0 ? (root.listed ? "Nothing pending" : "") : (root.reminders.length === 1 ? "1 pending" : root.reminders.length + " pending") - color: Qt.darker(root.foreground, 1.4) + color: Readable.secondary(root.foreground, Commons.Color.popups.background) font.family: Style.font.family font.pixelSize: Style.font.body } @@ -248,7 +248,7 @@ Item { width: parent.width textFormat: Text.PlainText text: "At " + pendingRow.modelData.atTime + " (in " + pendingRow.modelData.remaining + ")" - color: Qt.darker(root.foreground, 1.4) + color: Readable.secondary(root.foreground, Commons.Color.popups.background) font.family: Style.font.family font.pixelSize: Readable.px(Style.font.caption) elide: Text.ElideRight @@ -341,6 +341,7 @@ Item { font.pixelSize: Style.font.title foreground: root.foreground placeholderText: "Minutes" + placeholderTextColor: Readable.secondary(root.foreground, Readable.flatten(Style.controlFill(activeFocus, hovered || hasCursor, foreground, accent), Commons.Color.popups.background)) text: root.minutes inputMethodHints: Qt.ImhDigitsOnly | Qt.ImhNoPredictiveText onTextEdited: root.minutes = text @@ -359,6 +360,7 @@ Item { font.pixelSize: Style.font.title foreground: root.foreground placeholderText: "What for (optional)" + placeholderTextColor: Readable.secondary(root.foreground, Readable.flatten(Style.controlFill(activeFocus, hovered || hasCursor, foreground, accent), Commons.Color.popups.background)) inputMethodHints: Qt.ImhNoPredictiveText onAccepted: root.setReminder() Keys.onEscapePressed: root.close() diff --git a/packages/omamobile-shell/plugins/omamobile.quicksettings/SliderRow.qml b/packages/omamobile-shell/plugins/omamobile.quicksettings/SliderRow.qml index 0af32a470..a97af9be3 100644 --- a/packages/omamobile-shell/plugins/omamobile.quicksettings/SliderRow.qml +++ b/packages/omamobile-shell/plugins/omamobile.quicksettings/SliderRow.qml @@ -3,10 +3,12 @@ import QtQuick import qs.Commons import qs.Commons as Commons import qs.Ui +import "Readable.js" as Readable // A full-width slider row for the quick settings sheet: a 44px tappable glyph // (mute for volume), Omarchy's PanelSlider stretched to a thumb-sized hit area, -// and the value as a percentage. +// and the value as a percentage. Without a backend only the glyph is dimmed: +// the text in the slider's place says why, and has to be read (TOUCH-PLAN 2.7). Item { id: root @@ -23,7 +25,6 @@ Item { readonly property int touchSize: Math.max(44, Style.space(44)) implicitHeight: touchSize - opacity: available ? 1 : 0.45 Item { id: iconButton @@ -31,6 +32,7 @@ Item { height: root.touchSize anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter + opacity: root.available ? 1 : 0.45 Rectangle { anchors.fill: parent @@ -79,13 +81,14 @@ Item { } Text { + objectName: "sliderStatus" visible: !root.available anchors.left: iconButton.right anchors.leftMargin: Style.spacing.lg anchors.verticalCenter: parent.verticalCenter textFormat: Text.PlainText text: root.unavailableText - color: Qt.darker(root.foreground, 1.4) + color: Readable.secondary(root.foreground, Commons.Color.popups.background) font.family: Style.font.family font.pixelSize: Style.font.body } diff --git a/packages/omamobile-shell/plugins/omamobile.quicksettings/Tile.qml b/packages/omamobile-shell/plugins/omamobile.quicksettings/Tile.qml index 2f092e0ce..9497be089 100644 --- a/packages/omamobile-shell/plugins/omamobile.quicksettings/Tile.qml +++ b/packages/omamobile-shell/plugins/omamobile.quicksettings/Tile.qml @@ -7,8 +7,9 @@ import "Readable.js" as Readable // One quick-settings toggle: glyph, name and a one-line status, sized for a // thumb. Active tiles take the theme's selected fill and accent border; tiles -// whose backend is missing stay on screen with the glyph and name dimmed and -// ignore taps. Their status says why ("No modem"), so it stays readable. +// whose backend is missing stay on screen with only the glyph dimmed and +// ignore taps. Their name and status (which says why: "No modem") keep +// their contrast, so they can be read (TOUCH-PLAN 2.7). // // Taps go through a TapHandler, which lets go once the touch becomes a drag: // a swipe that starts on a tile doesn't toggle it, and the sheet's own swipe @@ -75,24 +76,26 @@ BorderSurface { spacing: Style.spacing.xxs Text { + objectName: "tileLabel" width: parent.width textFormat: Text.PlainText text: root.label color: root.foreground - opacity: root._dim font.family: Style.font.family font.pixelSize: Style.font.subtitle font.bold: true elide: Text.ElideRight } - // Dimmed once (by colour) and never by the tile: on an unavailable tile - // this is the reason, and it has to be read. + // Secondary by colour (4.5:1 against the tile, whatever the theme) and + // never dimmed by the tile: on an unavailable tile this is the reason, + // and it has to be read. Text { + objectName: "tileStatus" width: parent.width textFormat: Text.PlainText text: root.status - color: Qt.darker(root.foreground, 1.4) + color: Readable.secondary(root.foreground, Readable.flatten(root.color, Commons.Color.popups.background)) font.family: Style.font.family font.pixelSize: Readable.px(Style.font.caption) elide: Text.ElideRight diff --git a/packages/omamobile-shell/plugins/omamobile.quicksettings/WifiPanel.qml b/packages/omamobile-shell/plugins/omamobile.quicksettings/WifiPanel.qml index e90b05b3d..cef7484a6 100644 --- a/packages/omamobile-shell/plugins/omamobile.quicksettings/WifiPanel.qml +++ b/packages/omamobile-shell/plugins/omamobile.quicksettings/WifiPanel.qml @@ -594,7 +594,7 @@ Item { horizontalAlignment: Text.AlignHCenter textFormat: Text.PlainText text: root.device ? "Turn on Wi-Fi to see networks in range" : "No Wi-Fi radio" - color: Qt.darker(root.foreground, 1.4) + color: Readable.secondary(root.foreground, Commons.Color.popups.background) font.family: Style.font.family font.pixelSize: Style.font.body wrapMode: Text.Wrap @@ -626,7 +626,7 @@ Item { visible: list.contentY < list.originY - Style.space(10) textFormat: Text.PlainText text: list.contentY < list.originY - list.pullThreshold ? "Release to scan" : "Pull to scan" - color: Qt.darker(root.foreground, 1.4) + color: Readable.secondary(root.foreground, Commons.Color.popups.background) font.family: Style.font.family font.pixelSize: Readable.px(Style.font.caption) } @@ -666,7 +666,7 @@ Item { anchors.centerIn: parent textFormat: Text.PlainText text: entryItem.row.text - color: Qt.darker(root.foreground, 1.4) + color: Readable.secondary(root.foreground, Commons.Color.popups.background) font.family: Style.font.family font.pixelSize: Style.font.body } @@ -721,7 +721,7 @@ Item { textFormat: Text.PlainText text: entryItem.isSaved ? (entryItem.failure || "Saved") : WifiModel.rowStatus(entryItem.row, entryItem.busy ? root.actionKind : "", entryItem.failure) - color: entryItem.failure ? Commons.Color.urgent : Qt.darker(root.foreground, 1.4) + color: entryItem.failure ? Commons.Color.urgent : Readable.secondary(root.foreground, Commons.Color.popups.background) font.family: Style.font.family font.pixelSize: Readable.px(Style.font.caption) elide: Text.ElideRight @@ -830,6 +830,7 @@ Item { font.pixelSize: Style.font.title foreground: root.foreground placeholderText: "Password" + placeholderTextColor: Readable.secondary(root.foreground, Readable.flatten(Style.controlFill(activeFocus, hovered || hasCursor, foreground, accent), Commons.Color.popups.background)) password: !root.showPassword inputMethodHints: Qt.ImhSensitiveData | Qt.ImhNoPredictiveText | Qt.ImhNoAutoUppercase | Qt.ImhPreferLowercase onAccepted: root.submitPassword() diff --git a/packages/omamobile-shell/plugins/omamobile.switcher/Readable.js b/packages/omamobile-shell/plugins/omamobile.switcher/Readable.js index 2a7811cd2..e0dc85b6c 100644 --- a/packages/omamobile-shell/plugins/omamobile.switcher/Readable.js +++ b/packages/omamobile-shell/plugins/omamobile.switcher/Readable.js @@ -1,15 +1,73 @@ // SPDX-License-Identifier: MIT -// The smallest size for text that has to be read. Omarchy's type scale is a -// desktop's (caption 10 px, body 12 px); on the phone's 480 px wide screen, -// held at arm's length, nothing read goes under 12 px (docs/TOUCH-PLAN.md -// 2.1). A floor here rather than theme font overrides, which a theme change -// would drop. Plugins are separate directories with no shared import, so -// each one that needs it carries this same file (test/all checks they match). +// Text that can be read on the phone (docs/TOUCH-PLAN.md 2.1 and 2.7). +// Plugins are separate directories with no shared import, so each one that +// needs this carries this same file (test/all checks they match). +// +// Size: Omarchy's type scale is a desktop's (caption 10 px, body 12 px); on +// the phone's 480 px wide screen, held at arm's length, nothing read goes +// under 12 px. A floor here rather than theme font overrides, which a theme +// change would drop. +// +// Contrast: secondary text (a status line, a placeholder, a hint) used to +// be the foreground darkened by a fixed factor or drawn at 60-75% opacity, +// which on a dark theme came to 3-4:1 against the surface. `secondary` +// mixes the foreground toward the surface only as far as WCAG's 4.5:1 +// minimum for text allows, on any theme. var MIN_PX = 12 +var MIN_CONTRAST = 4.5 +// How far secondary text may be mixed toward its surface at most (the +// share of the surface), so it still reads as secondary on a theme with +// plenty of contrast to spare. +var MAX_MIX = 0.6 function px(size) { return Math.max(MIN_PX, size) } +// Colours are {r, g, b[, a]} in 0..1, which a QML color is in JavaScript. + +function channel(v) { return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4) } + +// WCAG relative luminance. +function luminance(c) { + return 0.2126 * channel(c.r) + 0.7152 * channel(c.g) + 0.0722 * channel(c.b) +} + +// WCAG contrast ratio, 1..21. +function contrast(a, b) { + var la = luminance(a), lb = luminance(b) + return (Math.max(la, lb) + 0.05) / (Math.min(la, lb) + 0.05) +} + +// `top` (with its alpha) laid over an opaque `under`. +function flattenRgb(top, under) { + var a = top.a === undefined ? 1 : top.a + return { r: top.r * a + under.r * (1 - a), g: top.g * a + under.g * (1 - a), b: top.b * a + under.b * (1 - a), a: 1 } +} + +// The foreground mixed toward the surface as far as MIN_CONTRAST allows +// (never past MAX_MIX); the foreground itself when even that falls short. +function secondaryRgb(fg, bg, minRatio) { + var want = minRatio || MIN_CONTRAST + var under = flattenRgb(bg, { r: 0, g: 0, b: 0 }) + for (var t = MAX_MIX; t >= 0; t = Math.round((t - 0.02) * 100) / 100) { + var mix = { r: fg.r * (1 - t) + under.r * t, g: fg.g * (1 - t) + under.g * t, b: fg.b * (1 - t) + under.b * t, a: 1 } + if (contrast(mix, under) >= want) return mix + } + return { r: fg.r, g: fg.g, b: fg.b, a: 1 } +} + +// For QML: a color. Under Node (no Qt) the {r, g, b, a} object. +function secondary(fg, bg) { + var c = secondaryRgb(fg, bg) + return typeof Qt !== "undefined" ? Qt.rgba(c.r, c.g, c.b, 1) : c +} + +function flatten(top, under) { + var c = flattenRgb(top, under) + return typeof Qt !== "undefined" ? Qt.rgba(c.r, c.g, c.b, 1) : c +} + if (typeof module !== "undefined") { - module.exports = { MIN_PX: MIN_PX, px: px } + module.exports = { MIN_PX: MIN_PX, MIN_CONTRAST: MIN_CONTRAST, MAX_MIX: MAX_MIX, px: px, luminance: luminance, contrast: contrast, + flattenRgb: flattenRgb, secondaryRgb: secondaryRgb, secondary: secondary, flatten: flatten } } diff --git a/packages/omamobile-shell/plugins/omamobile.switcher/Switcher.qml b/packages/omamobile-shell/plugins/omamobile.switcher/Switcher.qml index bdbb5f8ca..3ee64d2bb 100644 --- a/packages/omamobile-shell/plugins/omamobile.switcher/Switcher.qml +++ b/packages/omamobile-shell/plugins/omamobile.switcher/Switcher.qml @@ -252,7 +252,7 @@ Item { visible: root.windows.length === 0 textFormat: Text.PlainText text: "No recent apps" - color: Qt.darker(root.foreground, 1.4) + color: Readable.secondary(root.foreground, Commons.Color.menu.background) font.family: Style.font.family font.pixelSize: Style.font.subtitle } @@ -487,7 +487,7 @@ Item { textFormat: Text.PlainText text: root.actionPage === "pick" ? "Show with…" : root.windowLabel(root.actionTarget) elide: Text.ElideRight - color: Qt.darker(root.foreground, 1.3) + color: Readable.secondary(root.foreground, Commons.Color.menu.background) font.family: Style.font.family font.pixelSize: Style.font.body bottomPadding: Style.space(6) @@ -572,7 +572,7 @@ Item { textFormat: Text.PlainText text: sheetRow.hint elide: Text.ElideRight - color: Qt.darker(root.foreground, 1.4) + color: Readable.secondary(root.foreground, Commons.Color.menu.background) font.family: Style.font.family font.pixelSize: Readable.px(Style.font.caption) } diff --git a/packages/omamobile-shell/plugins/omamobile.update/Readable.js b/packages/omamobile-shell/plugins/omamobile.update/Readable.js index 2a7811cd2..e0dc85b6c 100644 --- a/packages/omamobile-shell/plugins/omamobile.update/Readable.js +++ b/packages/omamobile-shell/plugins/omamobile.update/Readable.js @@ -1,15 +1,73 @@ // SPDX-License-Identifier: MIT -// The smallest size for text that has to be read. Omarchy's type scale is a -// desktop's (caption 10 px, body 12 px); on the phone's 480 px wide screen, -// held at arm's length, nothing read goes under 12 px (docs/TOUCH-PLAN.md -// 2.1). A floor here rather than theme font overrides, which a theme change -// would drop. Plugins are separate directories with no shared import, so -// each one that needs it carries this same file (test/all checks they match). +// Text that can be read on the phone (docs/TOUCH-PLAN.md 2.1 and 2.7). +// Plugins are separate directories with no shared import, so each one that +// needs this carries this same file (test/all checks they match). +// +// Size: Omarchy's type scale is a desktop's (caption 10 px, body 12 px); on +// the phone's 480 px wide screen, held at arm's length, nothing read goes +// under 12 px. A floor here rather than theme font overrides, which a theme +// change would drop. +// +// Contrast: secondary text (a status line, a placeholder, a hint) used to +// be the foreground darkened by a fixed factor or drawn at 60-75% opacity, +// which on a dark theme came to 3-4:1 against the surface. `secondary` +// mixes the foreground toward the surface only as far as WCAG's 4.5:1 +// minimum for text allows, on any theme. var MIN_PX = 12 +var MIN_CONTRAST = 4.5 +// How far secondary text may be mixed toward its surface at most (the +// share of the surface), so it still reads as secondary on a theme with +// plenty of contrast to spare. +var MAX_MIX = 0.6 function px(size) { return Math.max(MIN_PX, size) } +// Colours are {r, g, b[, a]} in 0..1, which a QML color is in JavaScript. + +function channel(v) { return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4) } + +// WCAG relative luminance. +function luminance(c) { + return 0.2126 * channel(c.r) + 0.7152 * channel(c.g) + 0.0722 * channel(c.b) +} + +// WCAG contrast ratio, 1..21. +function contrast(a, b) { + var la = luminance(a), lb = luminance(b) + return (Math.max(la, lb) + 0.05) / (Math.min(la, lb) + 0.05) +} + +// `top` (with its alpha) laid over an opaque `under`. +function flattenRgb(top, under) { + var a = top.a === undefined ? 1 : top.a + return { r: top.r * a + under.r * (1 - a), g: top.g * a + under.g * (1 - a), b: top.b * a + under.b * (1 - a), a: 1 } +} + +// The foreground mixed toward the surface as far as MIN_CONTRAST allows +// (never past MAX_MIX); the foreground itself when even that falls short. +function secondaryRgb(fg, bg, minRatio) { + var want = minRatio || MIN_CONTRAST + var under = flattenRgb(bg, { r: 0, g: 0, b: 0 }) + for (var t = MAX_MIX; t >= 0; t = Math.round((t - 0.02) * 100) / 100) { + var mix = { r: fg.r * (1 - t) + under.r * t, g: fg.g * (1 - t) + under.g * t, b: fg.b * (1 - t) + under.b * t, a: 1 } + if (contrast(mix, under) >= want) return mix + } + return { r: fg.r, g: fg.g, b: fg.b, a: 1 } +} + +// For QML: a color. Under Node (no Qt) the {r, g, b, a} object. +function secondary(fg, bg) { + var c = secondaryRgb(fg, bg) + return typeof Qt !== "undefined" ? Qt.rgba(c.r, c.g, c.b, 1) : c +} + +function flatten(top, under) { + var c = flattenRgb(top, under) + return typeof Qt !== "undefined" ? Qt.rgba(c.r, c.g, c.b, 1) : c +} + if (typeof module !== "undefined") { - module.exports = { MIN_PX: MIN_PX, px: px } + module.exports = { MIN_PX: MIN_PX, MIN_CONTRAST: MIN_CONTRAST, MAX_MIX: MAX_MIX, px: px, luminance: luminance, contrast: contrast, + flattenRgb: flattenRgb, secondaryRgb: secondaryRgb, secondary: secondary, flatten: flatten } } diff --git a/packages/omamobile-shell/plugins/omamobile.update/Update.qml b/packages/omamobile-shell/plugins/omamobile.update/Update.qml index 753b90533..25ae10b23 100644 --- a/packages/omamobile-shell/plugins/omamobile.update/Update.qml +++ b/packages/omamobile-shell/plugins/omamobile.update/Update.qml @@ -400,8 +400,7 @@ Item { visible: text !== "" textFormat: Text.PlainText text: root.checking ? "Asking the repositories (this takes a few seconds)." : root.summary.body - color: root.foreground - opacity: 0.8 + color: Readable.secondary(root.foreground, Commons.Color.popups.background) font.family: Style.font.family font.pixelSize: Style.font.body wrapMode: Text.Wrap @@ -527,6 +526,7 @@ Item { font.pixelSize: Style.font.title foreground: root.foreground placeholderText: root.digits ? "PIN" : "Password" + placeholderTextColor: Readable.secondary(root.foreground, Readable.flatten(Style.controlFill(activeFocus, hovered || hasCursor, foreground, accent), Commons.Color.popups.background)) password: true enabled: !root.submitting inputMethodHints: root.digits @@ -624,8 +624,7 @@ Item { width: parent.width textFormat: Text.PlainText text: root.progressText - color: root.foreground - opacity: 0.75 + color: Readable.secondary(root.foreground, Commons.Color.popups.background) font.family: Style.font.family font.pixelSize: Readable.px(Style.font.caption) elide: Text.ElideRight @@ -635,8 +634,7 @@ Item { width: parent.width textFormat: Text.PlainText text: "You can close this; the update keeps running and this sheet comes back with the result." - color: root.foreground - opacity: 0.6 + color: Readable.secondary(root.foreground, Commons.Color.popups.background) font.family: Style.font.family font.pixelSize: Readable.px(Style.font.caption) wrapMode: Text.Wrap @@ -720,8 +718,7 @@ Item { selectByMouse: true textFormat: TextEdit.PlainText text: "Log: " + root.outcome.log - color: root.foreground - opacity: 0.7 + color: Readable.secondary(root.foreground, Commons.Color.popups.background) font.family: Style.font.family font.pixelSize: Readable.px(Style.font.caption) wrapMode: TextEdit.WrapAnywhere diff --git a/packages/omamobile-shell/test/all b/packages/omamobile-shell/test/all index 9e837a988..c889f5c2b 100755 --- a/packages/omamobile-shell/test/all +++ b/packages/omamobile-shell/test/all @@ -40,8 +40,39 @@ if command -v node >/dev/null; then node -e ' const R = require(require("path").resolve(process.argv[1])) if (R.MIN_PX !== 12 || R.px(10) !== 12 || R.px(9) !== 12 || R.px(14) !== 14) throw new Error("Readable.px") -' "$first" || fail "Readable.px floors at 12 px" +// Contrast (TOUCH-PLAN 2.7): secondary text reaches 4.5:1 on a dark and a +// light theme, is dimmer than the foreground where there is room, and is +// the foreground itself when nothing dimmer would do. +const hex = (h) => ({ r: parseInt(h.slice(1, 3), 16) / 255, g: parseInt(h.slice(3, 5), 16) / 255, b: parseInt(h.slice(5, 7), 16) / 255, a: 1 }) +const near = (a, b) => Math.abs(a - b) < 0.01 +if (!near(R.contrast(hex("#ffffff"), hex("#000000")), 21) || !near(R.contrast(hex("#777777"), hex("#777777")), 1)) throw new Error("Readable.contrast") +for (const [fg, bg] of [["#a9b1d6", "#1a1b26"], ["#c0caf5", "#1a1b26"], ["#4c4f69", "#eff1f5"], ["#ffffff", "#000000"]]) { + const s = R.secondaryRgb(hex(fg), hex(bg)) + const c = R.contrast(s, hex(bg)) + if (c < 4.5) throw new Error("secondary " + fg + " on " + bg + " reads at " + c.toFixed(2)) + if (c >= R.contrast(hex(fg), hex(bg))) throw new Error("secondary " + fg + " on " + bg + " is not dimmer") +} +const weak = R.secondaryRgb(hex("#777777"), hex("#555555")) +if (!near(weak.r, 0x77 / 255)) throw new Error("a foreground that cannot reach 4.5:1 stays itself") +const f = R.flattenRgb({ r: 1, g: 0, b: 0, a: 0.5 }, hex("#000000")) +if (!near(f.r, 0.5) || !near(f.g, 0) || f.a !== 1) throw new Error("Readable.flattenRgb") +' "$first" || fail "Readable: the 12 px floor and 4.5:1 secondary text" +fi +# Secondary text and placeholders go through Readable.secondary, not a +# fixed darkening or opacity, which read at 3-4:1 on a dark theme; the +# 1.3 darkenings left are glyphs, not text. On a tile only the glyph is +# dimmed when its backend is missing. +if grep -rnE 'Qt\.darker\((root|row|sheet)\.foreground, 1\.[4-9]\)' plugins --include=*.qml; then fail "secondary text is Readable.secondary, not a fixed darkening"; fi +if grep -rnE 'placeholderText:' plugins/omamobile.launcher plugins/omamobile.quicksettings plugins/omamobile.update --include=*.qml | grep -v placeholderTextColor >/dev/null; then + for f in $(grep -rlE 'placeholderText:' plugins/omamobile.launcher plugins/omamobile.quicksettings plugins/omamobile.update --include=*.qml); do + [[ $(grep -c 'placeholderText:' "$f") == $(grep -c 'placeholderTextColor: Readable.secondary' "$f") ]] || fail "$f: every placeholder has a 4.5:1 colour" + done fi +grep -c 'objectName: "tileLabel"' plugins/omamobile.quicksettings/Tile.qml >/dev/null || fail "the tile's name is named for the render" +grep -c 'opacity: root.available ? 1 : 0.45' plugins/omamobile.quicksettings/SliderRow.qml >/dev/null || fail "an unavailable slider row dims its glyph only" +if grep -nE '^ opacity: available' plugins/omamobile.quicksettings/SliderRow.qml; then fail "a slider row never dims as a whole"; fi +[[ $(grep -c 'opacity: root._dim' plugins/omamobile.quicksettings/Tile.qml) == 2 ]] || fail "an unavailable tile dims its glyph and chevron only" +grep -c 'color: Readable.secondary(root.foreground, Readable.flatten(root.color, Commons.Color.popups.background))' plugins/omamobile.quicksettings/Tile.qml >/dev/null || fail "a tile's status reads at 4.5:1 against the tile" # AppTile.qml is left to PR #43, which sets its label to caption + 3. if grep -rnE 'Style\.font\.caption' plugins --include=*.qml | grep -v 'Readable\.px(Style\.font\.caption' | grep -v 'omamobile.home/AppTile.qml:'; then fail "caption-sized text goes through Readable.px" @@ -50,7 +81,7 @@ for qml in $(grep -rl 'Readable\.px' plugins --include=*.qml); do grep -c '^import "Readable.js" as Readable$' "$qml" >/dev/null || fail "$qml imports Readable.js" [[ -f $(dirname "$qml")/Readable.js ]] || fail "$qml has Readable.js beside it" done -pass "readable text sizes" +pass "readable text: the 12 px floor and 4.5:1 secondary text" # Touch: a swipe that starts on a quick-settings tile mustn't toggle it # (a passive TapHandler, not a MouseArea), and destructive actions take two diff --git a/packages/omamobile-shell/test/launcher-render b/packages/omamobile-shell/test/launcher-render index 0a379b7f7..9dc4b269b 100755 --- a/packages/omamobile-shell/test/launcher-render +++ b/packages/omamobile-shell/test/launcher-render @@ -3,7 +3,9 @@ # Offscreen review shots of the app drawer (omamobile.launcher), upright and # on its side (TOUCH-PLAN 2.4), in a dark and a light Omarchy theme, with # checks that the grid's columns follow the width and every cell, the -# header and the input stay on the sheet: the real Launcher.qml, its +# header and the input stay on the sheet, and that the secondary text (the +# count, the placeholder, "No apps match") reads at 4.5:1 against the +# sheet, sampled from the picture (TOUCH-PLAN 2.7): the real Launcher.qml, its # layer-shell windows plain Items, with an application library of twenty # made-up apps in place of the desktop entries. Runs inside the OWL # conformance container (tests/owl/Dockerfile), never on a desktop: @@ -68,13 +70,14 @@ def shot(name, w, hh, **extra): return s print(json.dumps({"apps": apps, "shots": [ shot("portrait", 480, 1040), shot("landscape", 1040, 480), shot("landscape-search", 1040, 480, query="ma"), + shot("portrait-nomatch", 480, 1040, query="zzzz"), ]})) PY HOME=$home QT_SCALE_FACTOR=3 LAUNCHER_JOB="$h/job-$theme.json" timeout 300 quickshell -p "$h/launcher-render.qml" > "$h/log-$theme" 2>&1 || true grep -E "shot |geometry |Error|TypeError|ReferenceError" "$h/log-$theme" | grep -vE "hyprctl|delayed function evaluation" | sed -E 's/^.*(shot |geometry |Error|TypeError|ReferenceError)/\1/' | tee -a "$out/launcher-render.txt" || true - python3 - "$h/log-$theme" "$theme" <<'PY' || status=1 + python3 - "$h/log-$theme" "$theme" "$out" <<'PY' || status=1 import json, re, sys -log, theme = sys.argv[1:] +log, theme, out = sys.argv[1:] text = open(log).read() bad = [l for l in text.splitlines() if re.search(r"(TypeError|ReferenceError|is not a type|Error:)", l) and "hyprctl" not in l and "delayed function evaluation" not in l] geo = {} @@ -82,8 +85,35 @@ for n, w, h, g in re.findall(r"geometry (\S+) (\d+)x(\d+) (\{.*\})", text): geo[n] = dict(json.loads(g), screen={"x": 0, "y": 0, "w": int(w), "h": int(h)}) def inside(a, b, tol=0): return a["x"] >= b["x"] - tol and a["y"] >= b["y"] - tol and a["x"] + a["w"] <= b["x"] + b["w"] + tol and a["y"] + a["h"] <= b["y"] + b["h"] + tol def apart(a, b, tol=0): return a["x"] + a["w"] <= b["x"] + tol or b["x"] + b["w"] <= a["x"] + tol or a["y"] + a["h"] <= b["y"] + tol or b["y"] + b["h"] <= a["y"] + tol -ok = not bad and len(geo) == 3 -if len(geo) != 3: print("not ok - %s: %d of 3 shots taken" % (theme, len(geo))) +ok = not bad and len(geo) == 4 +if len(geo) != 4: print("not ok - %s: %d of 4 shots taken" % (theme, len(geo))) +# Contrast (TOUCH-PLAN 2.7), sampled from the picture: the part's rect +# (logical px, drawn at 3x) cropped with magick, its histogram's most +# common colour taken as the surface and the colour farthest from it in +# luminance (among those with a few pixels, so antialiasing fringes don't +# count) as the text. WCAG's ratio between the two must reach 4.5:1. +import subprocess +def luminance(c): + def ch(v): + v = v / 255.0 + return v / 12.92 if v <= 0.03928 else ((v + 0.055) / 1.055) ** 2.4 + return 0.2126 * ch(c[0]) + 0.7152 * ch(c[1]) + 0.0722 * ch(c[2]) +def ratio(a, b): + la, lb = luminance(a), luminance(b) + return (max(la, lb) + 0.05) / (min(la, lb) + 0.05) +def sampled_contrast(png, r, scale=3): + geometry = "%dx%d+%d+%d" % (max(1, r["w"] * scale), max(1, r["h"] * scale), max(0, r["x"] * scale), max(0, r["y"] * scale)) + out = subprocess.run(["magick", png, "-crop", geometry, "+repage", "-depth", "8", "-format", "%c", "histogram:info:-"], + capture_output=True, text=True).stdout + colours = [] + for m in re.finditer(r"^\s*(\d+): \(\s*(\d+),\s*(\d+),\s*(\d+)", out, re.M): + colours.append((int(m.group(1)), (int(m.group(2)), int(m.group(3)), int(m.group(4))))) + if not colours: return 0.0, None, None + colours.sort(reverse=True) + surface = colours[0][1] + ink = max((c for n, c in colours if n >= 12), key=lambda c: abs(luminance(c) - luminance(surface)), default=surface) + return ratio(ink, surface), ink, surface + for l in bad: print(" " + l[:200]) def check(name, good, why=""): global ok @@ -96,6 +126,14 @@ for name, g in geo.items(): check(name + ": the header, its collapse button and the input are on screen", all(k in parts and inside(parts[k], screen) and parts[k]["h"] >= 44 for k in ("drawerHeader", "collapse", "inputRow")), json.dumps([parts.get(k) for k in ("drawerHeader", "collapse", "inputRow")])) grid = parts.get("drawerGrid") + png = "%s/launcher-%s-%s.png" % (out, name, theme) + for part, what in (("drawerCount", "the count"), ("drawerInput", "the placeholder"), ("drawerEmpty", "No apps match")): + if part not in parts: continue + c, ink, surface = sampled_contrast(png, parts[part]) + check(name + ": %s reads at 4.5:1 against the sheet" % what, c >= 4.5, "%.2f:1 (%s on %s)" % (c, ink, surface)) + if g["apps"] == 0: + check(name + ": no cells and the empty text when nothing matches", "drawerEmpty" in parts and not [k for k in parts if k.startswith("app-")]) + continue # The cells wholly on the grid's first screenful (the rest scroll, # clipped, a row cut at the edge among them). cells = [v for k, v in parts.items() if k.startswith("app-") and grid and inside(v, grid, 1)] @@ -103,7 +141,7 @@ for name, g in geo.items(): check(name + ": the first row holds the columns", grid is not None and len([c for c in cells if c["y"] == min(x["y"] for x in cells)]) == min(g["columns"], g["apps"]) if cells else False, json.dumps(cells[:9])) check(name + ": every shown cell is on the grid, at least 44 px", bool(cells) and all(inside(c, grid, 1) and min(c["w"], c["h"]) >= 44 for c in cells), json.dumps([c for c in cells if not inside(c, grid, 1)][:3])) check(name + ": no two cells overlap", all(apart(a, b) for i, a in enumerate(cells) for b in cells[i + 1:])) - if g["query"]: + if g["query"] and g["apps"]: check(name + ": the Ask row sits above the input, on screen", "askRow" in parts and inside(parts["askRow"], screen) and parts["askRow"]["y"] + parts["askRow"]["h"] <= parts["inputRow"]["y"]) sys.exit(0 if ok else 1) PY diff --git a/packages/omamobile-shell/test/launcher-render.qml b/packages/omamobile-shell/test/launcher-render.qml index aa87eb902..9812ae0c6 100644 --- a/packages/omamobile-shell/test/launcher-render.qml +++ b/packages/omamobile-shell/test/launcher-render.qml @@ -9,9 +9,10 @@ import "launcher" as L // Offscreen review shots of the app drawer (test/launcher-render): the // real Launcher.qml at the phone's 480x1040 logical px and on its side at // 1040x480, its application library a stand-in over the job's apps, each -// shot in $LAUNCHER_JOB (the drawer open, a search) saved as a PNG with the -// sheet's, the header's, the input's and every cell's geometry printed for -// the checks. Then it quits. +// shot in $LAUNCHER_JOB (the drawer open, a search, a search with no +// match) saved as a PNG with the sheet's, the header's, the input's and +// every cell's geometry (and the named texts' colours) printed for the +// checks. Then it quits. ShellRoot { id: harness @@ -64,10 +65,17 @@ ShellRoot { return { x: Math.round(p.x), y: Math.round(p.y), w: Math.round(item.width), h: Math.round(item.height) } } - // The named parts that are shown, as {name: {x, y, w, h}} in screen px. + // The named parts that are shown, as {name: {x, y, w, h}} in screen px; + // a text's colour (a field's placeholder colour) comes along for the + // contrast checks. function describe(item, out) { if (!item || !item.visible || item.opacity === 0) return out - if (item.objectName) out[item.objectName] = harness.rectOf(item) + if (item.objectName) { + var r = harness.rectOf(item) + if (item.placeholderTextColor !== undefined) r.color = String(item.placeholderTextColor) + else if (item.color !== undefined && item.text !== undefined) r.color = String(item.color) + out[item.objectName] = r + } for (var i = 0; i < item.children.length; i++) harness.describe(item.children[i], out) return out } diff --git a/packages/omamobile-shell/test/quicksettings-render b/packages/omamobile-shell/test/quicksettings-render index 235a3850a..4723472c9 100755 --- a/packages/omamobile-shell/test/quicksettings-render +++ b/packages/omamobile-shell/test/quicksettings-render @@ -3,7 +3,9 @@ # Offscreen review shots of quick settings (omamobile.quicksettings), # upright and on its side (TOUCH-PLAN 2.4), in a dark and a light Omarchy # theme, with checks that the sheet, its tiles, the notification shade and -# the reminder page (TOUCH-PLAN 1.12) fit the screen: the real +# the reminder page (TOUCH-PLAN 1.12) fit the screen, and that every +# tile's name and status and the reminder page's placeholders read at +# 4.5:1, sampled from the picture (TOUCH-PLAN 2.7): the real # QuickSettings.qml, its layer-shell windows plain Items, over a throwaway # $HOME with a few notifications of our own in the shade. No backend # answers here (no D-Bus, no scripts on PATH), so the tiles show as @@ -80,9 +82,9 @@ print(json.dumps({"shots": [ PY HOME=$home QT_SCALE_FACTOR=3 QS_JOB="$h/job-$theme.json" timeout 300 quickshell -p "$h/quicksettings-render.qml" > "$h/log-$theme" 2>&1 || true grep -E "shot |geometry |Error|TypeError|ReferenceError" "$h/log-$theme" | grep -vE "hyprctl|delayed function evaluation" | sed -E 's/^.*(shot |geometry |Error|TypeError|ReferenceError)/\1/' | tee -a "$out/quicksettings-render.txt" || true - python3 - "$h/log-$theme" "$theme" <<'PY' || status=1 + python3 - "$h/log-$theme" "$theme" "$out" <<'PY' || status=1 import json, re, sys -log, theme = sys.argv[1:] +log, theme, out = sys.argv[1:] text = open(log).read() bad = [l for l in text.splitlines() if re.search(r"(TypeError|ReferenceError|is not a type|Error:)", l) and "hyprctl" not in l and "delayed function evaluation" not in l] geo = {} @@ -92,6 +94,33 @@ def inside(a, b, tol=0): return a["x"] >= b["x"] - tol and a["y"] >= b["y"] - to def apart(a, b, tol=0): return a["x"] + a["w"] <= b["x"] + tol or b["x"] + b["w"] <= a["x"] + tol or a["y"] + a["h"] <= b["y"] + tol or b["y"] + b["h"] <= a["y"] + tol ok = not bad and len(geo) == 7 if len(geo) != 7: print("not ok - %s: %d of 7 shots taken" % (theme, len(geo))) +# Contrast (TOUCH-PLAN 2.7), sampled from the picture: the part's rect +# (logical px, drawn at 3x) cropped with magick, its histogram's most +# common colour taken as the surface and the colour farthest from it in +# luminance (among those with a few pixels, so antialiasing fringes don't +# count) as the text. WCAG's ratio between the two must reach 4.5:1. +import subprocess +def luminance(c): + def ch(v): + v = v / 255.0 + return v / 12.92 if v <= 0.03928 else ((v + 0.055) / 1.055) ** 2.4 + return 0.2126 * ch(c[0]) + 0.7152 * ch(c[1]) + 0.0722 * ch(c[2]) +def ratio(a, b): + la, lb = luminance(a), luminance(b) + return (max(la, lb) + 0.05) / (min(la, lb) + 0.05) +def sampled_contrast(png, r, scale=3): + geometry = "%dx%d+%d+%d" % (max(1, r["w"] * scale), max(1, r["h"] * scale), max(0, r["x"] * scale), max(0, r["y"] * scale)) + out = subprocess.run(["magick", png, "-crop", geometry, "+repage", "-depth", "8", "-format", "%c", "histogram:info:-"], + capture_output=True, text=True).stdout + colours = [] + for m in re.finditer(r"^\s*(\d+): \(\s*(\d+),\s*(\d+),\s*(\d+)", out, re.M): + colours.append((int(m.group(1)), (int(m.group(2)), int(m.group(3)), int(m.group(4))))) + if not colours: return 0.0, None, None + colours.sort(reverse=True) + surface = colours[0][1] + ink = max((c for n, c in colours if n >= 12), key=lambda c: abs(luminance(c) - luminance(surface)), default=surface) + return ratio(ink, surface), ink, surface + for l in bad: print(" " + l[:200]) def check(name, good, why=""): global ok @@ -101,7 +130,12 @@ for name, g in geo.items(): screen = g["screen"] landscape = screen["w"] > screen["h"] parts = g["parts"] + png = "%s/quicksettings-%s-%s.png" % (out, name, theme) if g.get("page") == "reminder": + for part, what in (("reminderMinutes", "the minutes placeholder"), ("reminderMessage", "the message placeholder")): + if part not in parts: continue + c, ink, surface = sampled_contrast(png, parts[part]) + check(name + ": %s reads at 4.5:1" % what, c >= 4.5, "%.2f:1 (%s on %s)" % (c, ink, surface)) # The reminder page in the sheet's place: its card on screen, the # presets, both fields and Set at least 44 px tall and on the # card, the form under the header (it keeps to the bottom, above @@ -125,6 +159,18 @@ for name, g in geo.items(): check(name + ": the tiles are on the sheet, at least 44 px tall", len(tiles) >= (0 if g["edit"] else 4) and all(inside(t, parts["sheet"], 1) and t["h"] >= 44 for t in tiles), json.dumps([t for t in tiles if not (inside(t, parts["sheet"], 1) and t["h"] >= 44)][:3])) check(name + ": no two tiles overlap", all(apart(a, b, 1) for i, a in enumerate(tiles) for b in tiles[i + 1:])) + # Every shown tile's name and status (no backend answers here, so each + # is an unavailable tile with its reason) read at 4.5:1 against the + # tile: only the glyph is dimmed (TOUCH-PLAN 2.7). + texts = [(k, v) for k, v in parts.items() if (k.startswith("tileStatus") or k.startswith("tileLabel")) and grid and not apart(v, grid) and v["w"] > 10] + # The sliders scroll with the sheet: only the ones on the shown part. + texts += [(k, v) for k, v in parts.items() if k.startswith("sliderStatus") and v["w"] > 10 and not v.get("clipped")] + low = [] + for k, v in texts: + c, ink, surface = sampled_contrast(png, v) + if c < 4.5: low.append((k, round(c, 2), ink, surface)) + if not g["edit"]: + check(name + ": every tile's name and status and the sliders' reasons read at 4.5:1 (%d sampled)" % len(texts), bool(texts) and not low, json.dumps(low[:4])) if not g["edit"]: check(name + ": the handle and the settings gear are reachable", all(k in parts and inside(parts[k], screen) and parts[k]["h"] >= 44 for k in ("handle", "settingsButton")), json.dumps([parts.get("handle"), parts.get("settingsButton")])) diff --git a/packages/omamobile-shell/test/quicksettings-render.qml b/packages/omamobile-shell/test/quicksettings-render.qml index fefdc381d..f0bf0d4c8 100644 --- a/packages/omamobile-shell/test/quicksettings-render.qml +++ b/packages/omamobile-shell/test/quicksettings-render.qml @@ -60,13 +60,37 @@ ShellRoot { } // The named parts that are shown, as {name: {x, y, w, h}} in screen px. - function describe(item, out) { + // A name used more than once (a tile's label and status) is numbered + // from its second use; a text's colour (a field's placeholder colour) + // comes along for the contrast checks. + // A part cut off by a clipping ancestor (the sheet's scrolling content) + // is marked `clipped`, so the checks don't read what isn't drawn. + function describe(item, out, clipRect) { if (!item || !item.visible || item.opacity === 0) return out - if (item.objectName) out[item.objectName] = shell.rectOf(item) - for (var i = 0; i < item.children.length; i++) shell.describe(item.children[i], out) + var rect = shell.rectOf(item) + if (item.clip === true) clipRect = clipRect ? shell.intersect(clipRect, rect) : rect + if (item.objectName) { + var key = item.objectName + for (var n = 2; out[key] !== undefined; n++) key = item.objectName + "#" + n + var r = rect + if (item.placeholderTextColor !== undefined) r.color = String(item.placeholderTextColor) + else if (item.color !== undefined && item.text !== undefined) r.color = String(item.color) + if (clipRect && !shell.within(rect, clipRect)) r.clipped = true + out[key] = r + } + for (var i = 0; i < item.children.length; i++) shell.describe(item.children[i], out, clipRect) return out } + function intersect(a, b) { + var x = Math.max(a.x, b.x), y = Math.max(a.y, b.y) + return { x: x, y: y, w: Math.max(0, Math.min(a.x + a.w, b.x + b.w) - x), h: Math.max(0, Math.min(a.y + a.h, b.y + b.h) - y) } + } + + function within(a, b) { + return a.x >= b.x - 1 && a.y >= b.y - 1 && a.x + a.w <= b.x + b.w + 1 && a.y + a.h <= b.y + b.h + 1 + } + function next() { shell.index++ if (shell.index >= shell.job.shots.length) { Qt.quit(); return } From a7365a1290378a8600752f2fb0c13687be7a62e4 Mon Sep 17 00:00:00 2001 From: Derek Ross Date: Tue, 27 Oct 2026 15:27:17 -0400 Subject: [PATCH 4/7] omamobile-shell 0.2.31: Forget asks first, Added to home, names in recents MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TOUCH-PLAN 3.7's small parts: - Wi-Fi and Bluetooth Forget take two taps, like the other destructive actions: the first turns the button into "Forget ?" (or the device's name) for a few seconds, and cancelling the sheet disarms it. - A long-press in the drawer is answered: the home page shows the new tile with "Added to home" (the drawer closes as before, so the notice is on the page the tile landed on). - A home tile whose app isn't installed says "Not installed" rather than its raw desktop id; the widgets sheet's Missing list still has the id for removing it. - Recent apps' cards and the Show with… rows are titled by the app's name from its desktop entry (by id, then a heuristic lookup when Quickshell has one), falling back to the window class. - The README gains a Gestures table: every swipe, tap and hold on the shell, by surface, and the two-tap rule. Tests: test/switcher-touch titles cards by name under qmltestrunner with a DesktopEntries stub; test/all pins the two-tap Forget in both panels, the tile's wording, the home's notice, the lookup and the table. Co-Authored-By: Claude Fable 5.1 --- packages/omamobile-shell/README.md | 34 ++++++++++++++++++- .../plugins/omamobile.home/AppTile.qml | 8 +++-- .../plugins/omamobile.home/Home.qml | 8 ++++- .../BluetoothPanel.qml | 25 ++++++++++++-- .../omamobile.quicksettings/WifiPanel.qml | 25 ++++++++++++-- .../plugins/omamobile.switcher/Switcher.qml | 19 +++++++++-- packages/omamobile-shell/test/all | 17 +++++++++- .../qml-stubs/Quickshell/DesktopEntries.qml | 10 ++++++ .../test/qml-stubs/Quickshell/qmldir | 1 + .../omamobile-shell/test/switcher-touch.qml | 17 ++++++++++ 10 files changed, 151 insertions(+), 13 deletions(-) create mode 100644 packages/omamobile-shell/test/qml-stubs/Quickshell/DesktopEntries.qml diff --git a/packages/omamobile-shell/README.md b/packages/omamobile-shell/README.md index 09fa94ba0..94636ffd2 100644 --- a/packages/omamobile-shell/README.md +++ b/packages/omamobile-shell/README.md @@ -5,7 +5,7 @@ Omarchy Mobile's phone profile for Omarchy's own shell. It isn't a fork: these a | Path | What it is | | --- | --- | | `plugins/omamobile.bar` | Phone status bar (a full `bar` plugin) | -| `plugins/omamobile.quicksettings` | Pull-down quick settings | +| `plugins/omamobile.quicksettings` | Pull-down quick settings: tiles (a page behind Wi-Fi, Bluetooth, Screen record and Reminder), brightness and volume, the notification shade | | `plugins/omamobile.launcher` | Home bar: app search, app grid and a prompt to the user's Omarchy default agent | | `plugins/omamobile.switcher` | Recent apps: swipe up on the dock, or swipe up and hold on the home pill over an app; hold a card to show the app with another one, or give it its own screen again | | `plugins/omamobile.home` | Home screens: pages of apps and widgets on the wallpaper, with an edit mode. The built-ins include every widget in Simon Schubert's [omarchy-widgets](https://github.com/SimonSchubert/omarchy-widgets) `widgets/simonschubert/` (MIT): the OWL originals, from the `omamobile-owl-widgets` package, run by our own OWL runtime (`owl/`, see `owl/SPEC-NOTES.md`). `widgets/OWL.md` is his OWL language guide (MIT, `widgets/LICENSE-owl-guide`) | @@ -29,6 +29,38 @@ Omarchy Mobile's phone profile for Omarchy's own shell. It isn't a fork: these a | `widgets/WIDGETS.md` | The contract for user widgets, for people and coding agents (installed to `/usr/share/omamobile/shell/`) | | `widgets/template`, `widgets/examples` | The starter **Create a widget with AI** copies, and examples to copy (`widget-template/`, `widget-examples/`) | +## Gestures + +What a finger does on the phone shell (docs/TOUCH-PLAN.md), by surface. Destructive actions take two taps: the first turns the button into a question ("Clear all?", "Forget ?", "Reset?") for a few seconds. + +| Where | Gesture | What it does | +| --- | --- | --- | +| Anywhere | Swipe in from the left or right edge | Back (Escape to the app), never over the lock or a fullscreen window | +| Home pill (over an app) | Swipe up | Home (an empty workspace, then the home page) | +| Home pill | Swipe up and hold, or a long swipe | Recent apps | +| Dock (home screen) | Swipe up | Recent apps | +| Dock | Tap the search pill | The app drawer with the keyboard | +| App drawer | Pull down from the top, or the chevron | Close it | +| App drawer | Long-press an app | Put it on the home page ("Added to home") | +| Home page | Swipe sideways | The next or previous page | +| Home page | Long-press (upright) | Edit mode: drag to move, handles to resize, tap the gear for a widget's settings; a notice says to turn the phone upright in landscape | +| Home page | Tap a dimmed "Not installed" tile | A notice; hold to edit and remove it | +| Status bar | Pull down | Quick settings, collapsed | +| Quick settings | Pull down again, or tap the handle | Expand to every tile, with the volume slider | +| Quick settings | Swipe up, tap outside, or Escape | Close | +| Quick settings | Swipe sideways on the tiles | The next page of tiles | +| Quick-settings tile | Tap | Toggle (or open: Clipboard, Dictation, Reminder) | +| Quick-settings tile | Long-press, or its chevron | The page behind it (Wi-Fi, Bluetooth, Reminder's list, theme picker) | +| Quick settings, pencil | Tap a tile | Remove it; hold and drag to move; tap one under Add tiles to add it | +| Notification shade | Swipe a row sideways | Forget that notification | +| Notification shade | Tap a row | Open it | +| Recent apps | Swipe sideways | Through the cards | +| Recent apps | Tap a card | Switch to it | +| Recent apps | Flick a card up | Close it | +| Recent apps | Long-press a card | Show it with another app, or give it its own screen | +| Incoming call | Swipe the control up or down | Answer or decline | +| Keyboard | Tap the button at its top-left | Hide it | + ## AI Agent shortcut **AI Agent** in the app drawer opens Omarchy's default agent with diff --git a/packages/omamobile-shell/plugins/omamobile.home/AppTile.qml b/packages/omamobile-shell/plugins/omamobile.home/AppTile.qml index 962fd716f..962563ce3 100644 --- a/packages/omamobile-shell/plugins/omamobile.home/AppTile.qml +++ b/packages/omamobile-shell/plugins/omamobile.home/AppTile.qml @@ -7,8 +7,10 @@ import qs.Commons as Commons // An app shortcut: icon over its name, launched the way the app drawer // launches apps (omamobile-launch: uwsm-app -- gtk-launch on a new empty // workspace, or the app's open window focused). -// An app that is no longer installed stays, dimmed, until it is removed in -// edit mode (it may come back with its package). +// An app that is no longer installed stays, dimmed and named "Not +// installed" rather than by its raw id (TOUCH-PLAN 3.7), until it is +// removed in edit mode (it may come back with its package); the widgets +// sheet's Missing list still shows the id. Item { id: tile @@ -54,7 +56,7 @@ Item { anchors.rightMargin: Style.spacing.xs horizontalAlignment: Text.AlignHCenter textFormat: Text.PlainText - text: tile.missing ? (tile.entry ? tile.entry.app : "") : (tile.library ? tile.library.entryName(tile.desktopEntry) : tile.desktopEntry.name) + text: tile.missing ? "Not installed" : (tile.library ? tile.library.entryName(tile.desktopEntry) : tile.desktopEntry.name) color: tile.home ? tile.home.foreground : "white" // An outline keeps the name readable on a light wallpaper; it costs // nothing like a blur or a drop shadow would. diff --git a/packages/omamobile-shell/plugins/omamobile.home/Home.qml b/packages/omamobile-shell/plugins/omamobile.home/Home.qml index d8c07d60e..fbd0b9f8e 100644 --- a/packages/omamobile-shell/plugins/omamobile.home/Home.qml +++ b/packages/omamobile-shell/plugins/omamobile.home/Home.qml @@ -988,7 +988,13 @@ Item { function goHome() { setEditing(false); goToPage(layout.home, true); return String(layout.home) } function page(n) { goToPage(Number(n), true); return String(currentPage) } function edit(on) { return String(on) === "off" || String(on) === "false" ? (setEditing(false), "done") : requestEdit() } - function addApp(appId) { return addAppHere(String(appId || "")) } + // The drawer's long-press lands here (TOUCH-PLAN 3.7): the drawer closes + // and the home page shows the new tile, with a word that says so. + function addApp(appId) { + var id = addAppHere(String(appId || "")) + if (id !== "full") flash("Added to home") + return id + } function addWidget(type) { var t = String(type) return HomeModel.widgetSpec(t, userCatalog) || HomeModel.isUserType(t) ? addWidgetHere(t) : "unknown" diff --git a/packages/omamobile-shell/plugins/omamobile.quicksettings/BluetoothPanel.qml b/packages/omamobile-shell/plugins/omamobile.quicksettings/BluetoothPanel.qml index a4be26bee..10c6bbd0e 100644 --- a/packages/omamobile-shell/plugins/omamobile.quicksettings/BluetoothPanel.qml +++ b/packages/omamobile-shell/plugins/omamobile.quicksettings/BluetoothPanel.qml @@ -429,6 +429,25 @@ Item { connectDevice(address) } + // Forget unpairs the device, so it takes two taps (TOUCH-PLAN 3.7): the + // first turns it into "Forget ?" for a few seconds. + property bool confirmForget: false + + Timer { + id: disarmForget + interval: 4000 + onTriggered: root.confirmForget = false + } + + function requestForget() { + if (!confirmForget) { + confirmForget = true + disarmForget.restart() + return + } + forgetSheet() + } + function forgetSheet() { var address = sheetAddress cancelSheet() @@ -495,6 +514,8 @@ Item { if (agentSheet) return answerAgent(false) sheet = "" sheetError = "" + confirmForget = false + disarmForget.stop() renameField.text = "" codeField.text = "" if (opened) panel.forceActiveFocus() @@ -1007,9 +1028,9 @@ Item { SheetButton { visible: root.activeSheet === "actions" && root.sheetPaired width: parent.width - label: "Forget" + label: root.confirmForget ? "Forget " + root.sheetLabel + "?" : "Forget" danger: true - onTapped: root.forgetSheet() + onTapped: root.requestForget() } SheetButton { diff --git a/packages/omamobile-shell/plugins/omamobile.quicksettings/WifiPanel.qml b/packages/omamobile-shell/plugins/omamobile.quicksettings/WifiPanel.qml index cef7484a6..3ed46f938 100644 --- a/packages/omamobile-shell/plugins/omamobile.quicksettings/WifiPanel.qml +++ b/packages/omamobile-shell/plugins/omamobile.quicksettings/WifiPanel.qml @@ -357,6 +357,25 @@ Item { runAction("disconnect", ssid, false, function(network) { network.disconnect() }) } + // Forget drops the saved password, so it takes two taps (TOUCH-PLAN 3.7): + // the first turns it into "Forget ?" for a few seconds. + property bool confirmForget: false + + Timer { + id: disarmForget + interval: 4000 + onTriggered: root.confirmForget = false + } + + function requestForget() { + if (!confirmForget) { + confirmForget = true + disarmForget.restart() + return + } + forgetSheet() + } + function forgetSheet() { var ssid = sheetSsid var uuid = sheetUuid @@ -400,6 +419,8 @@ Item { sheet = "" sheetError = "" showPassword = false + confirmForget = false + disarmForget.stop() passwordField.text = "" if (opened) panel.forceActiveFocus() } @@ -880,9 +901,9 @@ Item { SheetButton { visible: root.sheet === "actions" && (root.sheetKnown || root.sheetConnected) width: parent.width - label: "Forget" + label: root.confirmForget ? "Forget " + root.sheetSsid + "?" : "Forget" danger: true - onTapped: root.forgetSheet() + onTapped: root.requestForget() } SheetButton { diff --git a/packages/omamobile-shell/plugins/omamobile.switcher/Switcher.qml b/packages/omamobile-shell/plugins/omamobile.switcher/Switcher.qml index 3ee64d2bb..810dbcc4c 100644 --- a/packages/omamobile-shell/plugins/omamobile.switcher/Switcher.qml +++ b/packages/omamobile-shell/plugins/omamobile.switcher/Switcher.qml @@ -205,9 +205,22 @@ Item { dismiss() } + // The app's name from its desktop entry, by the window's app id (the + // entry's id, as Hyprland reports the class; a heuristic lookup when + // Quickshell has one, for ids that differ in case or a suffix), else the + // id itself (TOUCH-PLAN 3.7). + function appName(toplevel) { + if (!toplevel) return "" + var id = String(toplevel.appId || "") + if (!id) return "App" + var entry = DesktopEntries.byId(id) || DesktopEntries.byId(id + ".desktop") + if (!entry && typeof DesktopEntries.heuristicLookup === "function") entry = DesktopEntries.heuristicLookup(id) + return entry && entry.name ? String(entry.name) : id + } + function windowLabel(toplevel) { if (!toplevel) return "" - return (toplevel.appId || "App") + (toplevel.title ? " " + toplevel.title : "") + return appName(toplevel) + (toplevel.title ? " " + toplevel.title : "") } readonly property color foreground: Commons.Color.menu.text @@ -299,7 +312,7 @@ Item { anchors.bottomMargin: Style.space(8) opacity: card.opacity textFormat: Text.PlainText - text: (slot.modelData.appId || "") + (slot.modelData.title ? " " + slot.modelData.title : "") + text: root.windowLabel(slot.modelData) elide: Text.ElideRight color: root.foreground font.family: Style.font.family @@ -515,7 +528,7 @@ Item { delegate: SheetRow { required property var modelData - text: modelData.appId || "App" + text: root.appName(modelData) hint: modelData.title || "" onActivated: root.showWith(root.actionTarget, modelData) } diff --git a/packages/omamobile-shell/test/all b/packages/omamobile-shell/test/all index c889f5c2b..2c7454f47 100755 --- a/packages/omamobile-shell/test/all +++ b/packages/omamobile-shell/test/all @@ -92,6 +92,13 @@ grep -c 'onTapped: bottomButton.modelData.action === "home" ? root.goHome() : ro grep -c 'onTapped: root.requestReset()' plugins/omamobile.quicksettings/QuickSettings.qml >/dev/null || fail "quick-settings Reset asks first" grep -c 'if (!settingsFlick.confirmRemove) { settingsFlick.confirmRemove = true; return }' plugins/omamobile.home/HomeSheets.qml >/dev/null || fail "a widget's Remove asks first" grep -c 'onTapped: root.requestClearNotifications()' plugins/omamobile.quicksettings/QuickSettings.qml >/dev/null || fail "the shade's Clear all asks first" +# TOUCH-PLAN 3.7: Forget (a saved Wi-Fi password, a Bluetooth pairing) +# asks first too, naming what it forgets. +for panel in WifiPanel BluetoothPanel; do + grep -c 'onTapped: root.requestForget()' "plugins/omamobile.quicksettings/$panel.qml" >/dev/null || fail "$panel: Forget asks first" + grep -cE 'label: root.confirmForget \? "Forget " \+ root.sheet(Ssid|Label) \+ "\?" : "Forget"' "plugins/omamobile.quicksettings/$panel.qml" >/dev/null || fail "$panel: the second tap names what it forgets" + grep -c 'confirmForget = false' "plugins/omamobile.quicksettings/$panel.qml" >/dev/null || fail "$panel: cancelling the sheet disarms Forget" +done pass "touch: tiles and two-tap destructive actions" # Touch navigation (TOUCH-PLAN 1.2, 1.7, 1.8, 1.10, 2.5). @@ -418,6 +425,14 @@ fi grep -c 'Quickshell.execDetached(LauncherModel.appArgv(entry.id))' plugins/omamobile.launcher/Launcher.qml >/dev/null || fail "the drawer launches through omamobile-launch" grep -c 'Quickshell.execDetached(HomeModel.appLaunchArgv(entry.id))' plugins/omamobile.home/Home.qml >/dev/null || fail "home-screen apps launch through omamobile-launch" grep -c 'tile.home.launch(tile.entry.app)' plugins/omamobile.home/AppTile.qml >/dev/null || fail "app tiles launch through the home screen" +# TOUCH-PLAN 3.7's small parts: a missing app's tile says so rather than +# showing its raw id, the drawer's long-press is answered on the home +# page, and recents name apps by their desktop entry (test/switcher-touch). +grep -c 'text: tile.missing ? "Not installed" :' plugins/omamobile.home/AppTile.qml >/dev/null || fail "a missing app's tile says Not installed" +grep -c 'if (id !== "full") flash("Added to home")' plugins/omamobile.home/Home.qml >/dev/null || fail "the home says Added to home after the drawer's long-press" +grep -c 'text: root.windowLabel(slot.modelData)' plugins/omamobile.switcher/Switcher.qml >/dev/null || fail "recents' cards are titled by windowLabel" +grep -c 'var entry = DesktopEntries.byId(id) || DesktopEntries.byId(id + ".desktop")' plugins/omamobile.switcher/Switcher.qml >/dev/null || fail "recents look the app up by its desktop entry" +grep -c '^## Gestures' README.md >/dev/null && grep -c 'Long-press an app | Put it on the home page' README.md >/dev/null || fail "the README has the gestures table" grep -c 'Quickshell.execDetached(HomeModel.commandLaunchArgv(argv))' plugins/omamobile.home/WidgetHost.qml >/dev/null || fail "widgets' host.launch goes through omamobile-launch" grep -c 'Quickshell.execDetached(HomeModel.urlLaunchArgv(text))' plugins/omamobile.home/WidgetHost.qml >/dev/null || fail "widgets' host.openUrl goes through omamobile-launch" grep -c 'HomeModel.commandLaunchArgv(\["sh", "-c", tap\])' plugins/omamobile.home/CommandWidget.qml >/dev/null || fail "the text widget's tap goes through omamobile-launch" @@ -458,7 +473,7 @@ if [[ $rc == 77 ]]; then elif [[ $rc != 0 ]]; then printf '%s\n' "$out" | grep -vE '^(PASS|QDEBUG)' >&2; fail "recent apps under touch (test/switcher-touch)" else - pass "recent apps under touch: Clear all, Home, a near miss, a card, the cards on their side" + pass "recent apps under touch: Clear all, Home, a near miss, a card, the cards on their side, the apps' names" fi rc=0; out=$(bash test/shade-touch 2>&1) || rc=$? if [[ $rc == 77 ]]; then diff --git a/packages/omamobile-shell/test/qml-stubs/Quickshell/DesktopEntries.qml b/packages/omamobile-shell/test/qml-stubs/Quickshell/DesktopEntries.qml new file mode 100644 index 000000000..24140180a --- /dev/null +++ b/packages/omamobile-shell/test/qml-stubs/Quickshell/DesktopEntries.qml @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: MIT +pragma Singleton +import QtQuick + +// The desktop entries a test declares, by id: { name, icon }. +QtObject { + property var entries: ({}) + function byId(id) { return entries[id] || null } + function heuristicLookup(id) { return entries[id] || entries[String(id).toLowerCase()] || null } +} diff --git a/packages/omamobile-shell/test/qml-stubs/Quickshell/qmldir b/packages/omamobile-shell/test/qml-stubs/Quickshell/qmldir index 9f6cc6433..23752f6c7 100644 --- a/packages/omamobile-shell/test/qml-stubs/Quickshell/qmldir +++ b/packages/omamobile-shell/test/qml-stubs/Quickshell/qmldir @@ -1,2 +1,3 @@ module Quickshell singleton Quickshell 1.0 Quickshell.qml +singleton DesktopEntries 1.0 DesktopEntries.qml diff --git a/packages/omamobile-shell/test/switcher-touch.qml b/packages/omamobile-shell/test/switcher-touch.qml index c308ce8e3..363d8ce6a 100644 --- a/packages/omamobile-shell/test/switcher-touch.qml +++ b/packages/omamobile-shell/test/switcher-touch.qml @@ -58,6 +58,7 @@ Item { ToplevelManager.toplevels.values = [] Hyprland.toplevels.values = [] Quickshell.executed = [] + DesktopEntries.entries = {} } function openWith(windows) { @@ -174,6 +175,22 @@ Item { verify(!dispatched("hl.dsp.window.close")) } + // A card is titled by the app's name from its desktop entry, not its + // window class (TOUCH-PLAN 3.7); an app without one keeps the class. + function test_cards_show_the_apps_name() { + DesktopEntries.entries = { "foot": { name: "Terminal", icon: "" } } + var foot = fakeWindow.createObject(top, { title: "~/src" }) + var odd = fakeWindow.createObject(top, { appId: "com.example.Odd", title: "" }) + openWith([foot, odd]) + var cards = findKind(overlay.contentItem, "QQuickListView") + tryVerify(function() { return cards.count === 2 }) + verify(findText(overlay.contentItem, "Terminal ~/src"), "the terminal's card is titled by its name") + verify(findText(overlay.contentItem, "com.example.Odd"), "an app without an entry keeps its id") + verify(!findText(overlay.contentItem, "foot ~/src"), "not the class") + compare(sw.appName({ appId: "FOOT" }), "Terminal", "a heuristic lookup for an id that differs in case") + compare(sw.appName({ appId: "" }), "App") + } + function test_card_tap_switches() { var foot = fakeWindow.createObject(top) openWith([foot]) From 19261b08ad6fb195b9414f3aa7fdede38e542385 Mon Sep 17 00:00:00 2001 From: Derek Ross Date: Tue, 27 Oct 2026 15:45:01 -0400 Subject: [PATCH 5/7] omamobile-shell 0.2.31: onboarding and the PIN as sheets, not gum prompts TOUCH-PLAN 1.11. The first run (omamobile-onboarding) and System > PIN (omamobile-set-pin) asked their questions with gum in a floating terminal: arrow keys and Enter, which a touch screen can't give, and the terminal keyboard's arrow row is 33 px tall. A new panel plugin, omamobile.onboarding, asks the same questions in the same order: name and email (Continue or Skip), then a PIN or password unless there is one (then the note the prompts printed, with Keep it or Change it), the choice between a PIN and a password (the current one first, as gum listed them), the entry one step at a time as passwd asks (the current one when there is one, the new one, the new one again, with the ABC/123 switch and the fields kept above the keyboard), and done, with Omarchy's agent invitation on the first run. System > PIN is the same sheet from the choice on. The scripts stay the one definition of what each answer does, factored into entry points the sheet calls and the gum flow shares: omamobile-onboarding --status --json, --identity NAME EMAIL (Omarchy's git.sh and xcompose.sh), --invite-agent; omamobile-set-pin --status and --apply TYPE, which reads the current and the new secret from stdin (never argv, a file or the log), drives passwd on a pty the way the terminal answered its prompts, and records the choice and lock-on-start. Its exit code says what happened (3 wrong current, 5 refused with the reason on stdout) and the sheet goes back to the step that needs another answer. Run with no arguments, both scripts summon the sheet when the shell has it and fall back to the terminal prompts otherwise (or with OMAMOBILE_PROMPTS=terminal); the login nudge's tap lands on the sheet. Tests: test/onboarding.sh drives every entry point against a fake passwd that prompts as pam_unix does (the first PIN, a wrong current one, a refusal with its reason, a change to a password, the nudge, the invitation, the sheet-or-terminal choice), and checks no secret reaches the output; test/onboarding-model.js the flows, steps and outcomes; test/onboarding-render every page upright and on its side in both themes; test/all the wiring, the lint, and that the sheet repeats none of the scripts' logic. Co-Authored-By: Claude Fable 5.1 --- packages/omamobile-shell/README.md | 2 + .../omamobile-shell/bin/omamobile-onboarding | 66 +- .../omamobile-shell/bin/omamobile-set-pin | 141 +++- .../omamobile-shell/bin/omamobile-setup-user | 6 + packages/omamobile-shell/plugins/README.md | 25 + .../omamobile.onboarding/Onboarding.qml | 736 ++++++++++++++++++ .../omamobile.onboarding/OnboardingModel.js | 131 ++++ .../plugins/omamobile.onboarding/Readable.js | 73 ++ .../omamobile.onboarding/manifest.json | 14 + packages/omamobile-shell/profile/shell.json | 3 + packages/omamobile-shell/test/all | 50 ++ .../omamobile-shell/test/onboarding-model.js | 87 +++ .../omamobile-shell/test/onboarding-render | 122 +++ .../test/onboarding-render.qml | 93 +++ packages/omamobile-shell/test/onboarding.sh | 151 ++++ 15 files changed, 1689 insertions(+), 11 deletions(-) create mode 100644 packages/omamobile-shell/plugins/omamobile.onboarding/Onboarding.qml create mode 100644 packages/omamobile-shell/plugins/omamobile.onboarding/OnboardingModel.js create mode 100644 packages/omamobile-shell/plugins/omamobile.onboarding/Readable.js create mode 100644 packages/omamobile-shell/plugins/omamobile.onboarding/manifest.json create mode 100644 packages/omamobile-shell/test/onboarding-model.js create mode 100755 packages/omamobile-shell/test/onboarding-render create mode 100644 packages/omamobile-shell/test/onboarding-render.qml create mode 100755 packages/omamobile-shell/test/onboarding.sh diff --git a/packages/omamobile-shell/README.md b/packages/omamobile-shell/README.md index 94636ffd2..4fdd7abae 100644 --- a/packages/omamobile-shell/README.md +++ b/packages/omamobile-shell/README.md @@ -12,10 +12,12 @@ Omarchy Mobile's phone profile for Omarchy's own shell. It isn't a fork: these a | `plugins/omamobile.keyboard` | Hide button above the on-screen keyboard | | `plugins/omamobile.back` | The back gesture: swipe in from a side edge for Escape | | `plugins/omamobile.update` | The update sheet: Omarchy's update for a phone, through `omamobile-update` (package `omamobile-omarchy`) | +| `plugins/omamobile.onboarding` | The setup sheet: the first run's questions (name and email, a PIN or password, Omarchy's agent invitation) and System > PIN, through `omamobile-onboarding` and `omamobile-set-pin`, which keep their terminal prompts as the fallback | | `plugins/omamobile.access` | The permission sheet: "Allow Camera to use the camera?" with the app's icon and two large buttons, in place of xdg-desktop-portal-gtk's desktop dialog | | `plugins/omamobile.fingerprint` | The under-display fingerprint sensor: target during verification, enrollment screen | | `profile/shell.json` | The phone layout the setup seeds once | | `bin/omamobile-setup-user` | Omarchy Mobile's per-user setup (Omarchy lifecycle `setup-user`) | +| `bin/omamobile-onboarding`, `bin/omamobile-set-pin` | First-run setup and the PIN or password: the sheet above when the shell runs it, gum prompts in a terminal otherwise; `--status --json`, `--identity`, `--invite-agent` and `--apply TYPE` (secrets on stdin) are what the sheet calls | | `bin/omamobile-launch` | One app per screen: every launch from the shell (drawer, home screen, widgets, links, the agent) gets a new empty workspace through a per-launch Hyprland exec rule, or focuses the app's open window; and the switcher's "Show with…" and "Move to its own screen" | | `bin/omamobile-osk-watch` | Reports squeekboard's visibility (sm.puri.OSK0) to the fingerprint plugin | | `bin/omamobile-osk-guard` | Turns the on-screen keyboard (`screen-keyboard-enabled`) back on when it was left off with no screensaver running (a user unit for every graphical session) | diff --git a/packages/omamobile-shell/bin/omamobile-onboarding b/packages/omamobile-shell/bin/omamobile-onboarding index 419b6003a..3bde9956d 100644 --- a/packages/omamobile-shell/bin/omamobile-onboarding +++ b/packages/omamobile-shell/bin/omamobile-onboarding @@ -7,8 +7,25 @@ # default AI agent (Setup > Default Agent): Omarchy shows it after the first # update, a phone at first login. # -# omamobile-onboarding open a terminal and run it +# omamobile-onboarding open it: the shell's sheet +# (omamobile.onboarding, TOUCH-PLAN 1.11) when +# the shell runs it, else a terminal with the +# prompts # omamobile-onboarding --nudge at login: if anything is missing, say so +# omamobile-onboarding --status --json +# what is set, for the sheet: {"name", "email", +# "identity": bool, "pin": {"set", "type"}, +# "agent": the default agent or ""} +# omamobile-onboarding --identity NAME EMAIL +# save the name and email, as the prompts do +# (nothing when both are empty) +# omamobile-onboarding --invite-agent +# Omarchy's one-time invitation to pick an agent +# omamobile-onboarding --inner the terminal prompts (gum) +# +# The sheet asks the same questions in the same order and calls the entry +# points above, so what each answer does lives here alone. +# OMAMOBILE_PROMPTS=terminal skips the sheet. set -u omarchy_path=${OMARCHY_PATH:-/usr/share/omarchy} @@ -18,7 +35,16 @@ has_identity() { } has_pin() { - ! printf '' | unix_chkpwd "$USER" nullok 2>/dev/null + [[ $(omamobile-set-pin --status 2>/dev/null) == *'"set": true'* ]] +} + +# Omarchy's own steps, with the answers as its installer passes them: +# git's identity, and XCompose's / shortcuts. +save_identity() { + local name=$1 email=$2 + [[ -n $name || -n $email ]] || return 0 + OMARCHY_USER_NAME=$name OMARCHY_USER_EMAIL=$email bash "$omarchy_path/install/user/git.sh" + OMARCHY_USER_NAME=$name OMARCHY_USER_EMAIL=$email bash "$omarchy_path/install/user/xcompose.sh" } # Omarchy's hook: one notification, only while no agent is chosen, never twice. @@ -27,6 +53,27 @@ invite_agent() { [[ -f $hook ]] && bash "$hook" || true } +status_json() { + local pin + pin=$(omamobile-set-pin --status 2>/dev/null) || pin='{"set": false, "type": "pin"}' + python3 -I -c ' +import json, sys +name, email, pin, agent = sys.argv[1:] +try: + pin = json.loads(pin) +except ValueError: + pin = {"set": False, "type": "pin"} +print(json.dumps({"name": name, "email": email, "identity": bool(name and email), "pin": pin, "agent": agent})) +' "$(git config --global user.name)" "$(git config --global user.email)" "$pin" "$(omarchy-default-agent 2>/dev/null | head -n1)" +} + +# The shell's sheet, when the shell runs it: `summon` answers ok, or unknown +# for a shell without the plugin; no shell at all fails. +open_sheet() { + [[ ${OMAMOBILE_PROMPTS:-} == terminal ]] && return 1 + [[ $(omarchy-shell shell summon omamobile.onboarding "$1" 2>/dev/null) == ok ]] +} + case "${1:-}" in --nudge) # one nudge at a time: the agent waits until the phone itself is set up @@ -38,14 +85,22 @@ case "${1:-}" in "Add your name and email, and a PIN or password to lock it. Tap to start." \ --exec omamobile-onboarding ;; + --status) + status_json + ;; + --identity) + save_identity "${2:-}" "${3:-}" + ;; + --invite-agent) + invite_agent + ;; --inner) echo "Welcome to Omarchy Mobile. Two quick steps." echo name=$(gum input --header "Your name" --placeholder "Ada Lovelace" --value "$(git config --global user.name)") email=$(gum input --header "Your email" --placeholder "ada@example.com" --value "$(git config --global user.email)") if [[ -n $name || -n $email ]]; then - OMARCHY_USER_NAME=$name OMARCHY_USER_EMAIL=$email bash "$omarchy_path/install/user/git.sh" - OMARCHY_USER_NAME=$name OMARCHY_USER_EMAIL=$email bash "$omarchy_path/install/user/xcompose.sh" + save_identity "$name" "$email" echo "Saved." fi echo @@ -57,10 +112,11 @@ case "${1:-}" in invite_agent ;; "") + open_sheet '{}' && exit 0 exec omarchy-launch-floating-terminal-with-presentation "omamobile-onboarding --inner" ;; *) - echo "Usage: omamobile-onboarding [--nudge]" >&2 + echo "Usage: omamobile-onboarding [--nudge|--status --json|--identity NAME EMAIL|--invite-agent]" >&2 exit 1 ;; esac diff --git a/packages/omamobile-shell/bin/omamobile-set-pin b/packages/omamobile-shell/bin/omamobile-set-pin index aa0794b47..ce6d478a2 100644 --- a/packages/omamobile-shell/bin/omamobile-set-pin +++ b/packages/omamobile-shell/bin/omamobile-set-pin @@ -3,9 +3,24 @@ # Set or change the phone's PIN or password: it is the account password, so # Omarchy's lock screen, sudo and polkit all check it through PAM. # -# omamobile-set-pin open a terminal to set or change it -# omamobile-set-pin --type print this user's choice: pin or password +# omamobile-set-pin set or change it: the shell's sheet +# (omamobile.onboarding, TOUCH-PLAN 1.11) when +# the shell runs it, else a terminal with the +# prompts below +# omamobile-set-pin --type print this user's choice: pin or password +# omamobile-set-pin --status JSON: {"set": bool, "type": "pin"|"password"} +# omamobile-set-pin --apply TYPE +# what the sheet runs: the current PIN or +# password (an empty line when there is none) +# and the new one on stdin, one per line, never +# in argv. passwd makes the change (driven on a +# pty, answering its prompts as the terminal +# flow does), then TYPE is recorded. Exit 0 set, +# 3 the current one was wrong, 5 the new one +# was refused (the reason on stdout), 1 else. +# omamobile-set-pin --inner the terminal prompts (gum) # (A phone without one is pointed here by omamobile-onboarding at login.) +# OMAMOBILE_PROMPTS=terminal skips the sheet. # # The choice decides how the phone asks for it, like Android: a PIN gets the # lock screen's number pad and the on-screen keyboard's digits, a password the @@ -26,9 +41,15 @@ current_type() { [[ $type == password ]] && echo password || echo pin } +# Whether the account has a password at all: an empty one is accepted +# (nullok) by unix_chkpwd, and means none. +has_pin() { + ! printf '' | unix_chkpwd "$USER" nullok 2>/dev/null +} + # Record TYPE (pin or password) and set Omarchy's toggles to match. record_type() { - mkdir -p "$(dirname "$record")" "$toggles" + mkdir -p "${record%/*}" "$toggles" printf '%s\n' "$1" >"$record.new" && mv "$record.new" "$record" # the lock's number pad and the prompts' 123/ABC switch: a touch phone touch "$toggles/lock-keypad" @@ -39,6 +60,100 @@ record_type() { fi } +# With a PIN or password set, the phone locks right after it starts. +mark_lock_on_start() { + mkdir -p "$toggles" + touch "$toggles/lock-on-start" +} + +status_json() { + local set=false + has_pin && set=true + printf '{"set": %s, "type": "%s"}\n' "$set" "$(current_type)" +} + +# The shell's sheet, when the shell runs it: `summon` answers ok, or unknown +# for a shell without the plugin; no shell at all fails. +open_sheet() { + [[ ${OMAMOBILE_PROMPTS:-} == terminal ]] && return 1 + [[ $(omarchy-shell shell summon omamobile.onboarding "$1" 2>/dev/null) == ok ]] +} + +# passwd on a pty, its prompts answered from the two lines on our stdin. +# Python's pty module, since passwd talks to the terminal, not stdin. The +# secrets never reach argv, the environment or the output. +read -r -d '' PASSWD_DRIVER <<'PY' || true +import os, pty, re, select, sys, time +current = sys.stdin.readline().rstrip("\n") +new = sys.stdin.readline().rstrip("\n") +if not new: + print("No new PIN or password was given") + sys.exit(1) +pid, fd = pty.fork() +if pid == 0: + os.environ["LC_ALL"] = "C" + try: + os.execvp("passwd", ["passwd"]) + finally: + os._exit(127) +out = b"" +seen = 0 +answered = [] +status = None +deadline = time.time() + 60 +while time.time() < deadline: + try: + ready, _, _ = select.select([fd], [], [], 0.25) + except InterruptedError: + continue + if ready: + try: + chunk = os.read(fd, 4096) + except OSError: + chunk = b"" + if not chunk: + break + out += chunk + pending = out[seen:].decode("utf-8", "replace") + prompt = re.search(r"([^\n]*password[^\n]*):\s*$", pending, re.I) + if prompt: + which = "new" if "new" in prompt.group(1).lower() else "current" + answered.append(which) + os.write(fd, ((new if which == "new" else current) + "\n").encode()) + seen = len(out) + continue + done, st = os.waitpid(pid, os.WNOHANG) + if done: + status = st + break +if status is None: + try: + os.kill(pid, 9) + except OSError: + pass + _, status = os.waitpid(pid, 0) +try: + os.close(fd) +except OSError: + pass +code = os.waitstatus_to_exitcode(status) +text = out.decode("utf-8", "replace") +if code == 0 and "updated successfully" in text: + sys.exit(0) +# pam_unix's and pam_pwquality's refusals of the new one; "password +# unchanged" is what passwd says after any failure, and means nothing here. +refusals = ("BAD PASSWORD", "must choose", "too short", "too simple", "too similar", "do not match", + "No password has been supplied", "already used") +for line in text.splitlines(): + if any(key.lower() in line.lower() for key in refusals): + reason = re.sub(r"^.*BAD PASSWORD:\s*", "", line.strip(), flags=re.I) + print(reason or "The new one was refused") + sys.exit(5) +if answered and answered[0] == "current" and "new" not in answered: + sys.exit(3) +sys.exit(1) +PY + case "${1:-}" in --inner) echo "Choose how you unlock the phone. It is also used for sudo." @@ -63,20 +178,34 @@ case "${1:-}" in gum confirm "Try again?" || exit 1 done record_type "$type" - mkdir -p "$toggles" - touch "$toggles/lock-on-start" + mark_lock_on_start echo [[ $type == pin ]] && echo "PIN set." || echo "Password set." echo "Your phone now locks after it starts." ;; + --apply) + type=${2:-} + case $type in pin | password) ;; *) echo "Usage: omamobile-set-pin --apply pin|password" >&2; exit 2 ;; esac + python3 -I -c "$PASSWD_DRIVER" + rc=$? + if [[ $rc == 0 ]]; then + record_type "$type" + mark_lock_on_start + fi + exit $rc + ;; --type) current_type ;; + --status) + status_json + ;; "") + open_sheet '{"page":"pin"}' && exit 0 exec omarchy-launch-floating-terminal-with-presentation "omamobile-set-pin --inner" ;; *) - echo "Usage: omamobile-set-pin [--type]" >&2 + echo "Usage: omamobile-set-pin [--type|--status|--apply pin|password]" >&2 exit 1 ;; esac diff --git a/packages/omamobile-shell/bin/omamobile-setup-user b/packages/omamobile-shell/bin/omamobile-setup-user index 69043b972..6c1dd816f 100755 --- a/packages/omamobile-shell/bin/omamobile-setup-user +++ b/packages/omamobile-shell/bin/omamobile-setup-user @@ -321,6 +321,12 @@ fi if omarchy-done ensure omamobile-back-plugin; then add_plugin omamobile.back fi +# The setup sheet (omamobile.onboarding, TOUCH-PLAN 1.11): the first run's +# questions and System > PIN as sheets; omamobile-onboarding and +# omamobile-set-pin open it when the shell has it, the terminal otherwise. +if omarchy-done ensure omamobile-onboarding-plugin; then + add_plugin omamobile.onboarding +fi if omarchy-done ensure omamobile-menu-update; then extension=~/.config/omarchy/extensions/omarchy-menu.jsonc mkdir -p "$(dirname "$extension")" diff --git a/packages/omamobile-shell/plugins/README.md b/packages/omamobile-shell/plugins/README.md index 0580c6726..fdf8e78b6 100644 --- a/packages/omamobile-shell/plugins/README.md +++ b/packages/omamobile-shell/plugins/README.md @@ -755,6 +755,31 @@ Omarchy's update). IPC: `omarchy-shell shell call omamobile.update snapshot ''` (page, step, result; never the PIN). +## omamobile.onboarding + +The setup sheet (TOUCH-PLAN 1.11): the first run's questions and System > +PIN as sheets, in place of the gum prompts `omamobile-onboarding` and +`omamobile-set-pin` put in a terminal, which a touch screen can't answer +(arrow keys and Enter). `omarchy-shell shell summon omamobile.onboarding +'{}'` is the first run (name and email, then a PIN or password unless there +is one, then Omarchy's invitation to pick a default agent); `'{"page":"pin"}'` +is System > PIN (PIN or password, then the entry). The scripts open the sheet +themselves when the shell runs it (`summon` answers `ok`) and fall back to +the terminal prompts otherwise, or with `OMAMOBILE_PROMPTS=terminal`. + +The scripts stay the one definition of what each answer does: the sheet +reads `omamobile-onboarding --status --json`, saves with `--identity NAME +EMAIL` (Omarchy's `git.sh` and `xcompose.sh`), invites with +`--invite-agent`, and sets the PIN with `omamobile-set-pin --apply TYPE`, +which takes the current and the new secret on its stdin (never argv, a +file or the log), drives `passwd` on a pty as the terminal flow's prompts +did, and records the choice and `lock-on-start`. Its exit code says what +happened (3 wrong current, 5 refused with the reason on stdout), and the +sheet goes back to the step that needs another answer. The fields keep to +the bottom of the card, above the on-screen keyboard, with the ABC/123 +switch of the update sheet. `test/onboarding.sh` drives the entry points +against a fake `passwd`; `test/onboarding-render` draws every page. + ## omamobile.access The question xdg-desktop-portal asks before an app first uses the camera, the diff --git a/packages/omamobile-shell/plugins/omamobile.onboarding/Onboarding.qml b/packages/omamobile-shell/plugins/omamobile.onboarding/Onboarding.qml new file mode 100644 index 000000000..c730733f2 --- /dev/null +++ b/packages/omamobile-shell/plugins/omamobile.onboarding/Onboarding.qml @@ -0,0 +1,736 @@ +// SPDX-License-Identifier: MIT +pragma ComponentBehavior: Bound +import QtQuick +import Quickshell +import Quickshell.Io +import Quickshell.Wayland +import qs.Commons +import qs.Commons as Commons +import qs.Ui +import "OnboardingModel.js" as Model +import "Readable.js" as Readable + +// The phone's setup sheet (TOUCH-PLAN 1.11), in place of the gum prompts +// that omamobile-onboarding and omamobile-set-pin put in a terminal, which +// a touch screen can't answer. Opened by those scripts themselves +// (`omarchy-shell shell summon omamobile.onboarding '{}'` for the first +// run, '{"page":"pin"}' for System > PIN), by the login nudge, or by hand. +// +// It asks what the prompts ask, in their order: the first run is name and +// email, then a PIN or password unless there is one already (then a note, +// as the prompts say), then Omarchy's invitation to pick a default agent; +// System > PIN is the choice between a PIN and a password, then the entry. +// Every answer goes to the scripts, which keep the one definition of what +// it does: `--status --json` for what is set, `--identity NAME EMAIL`, +// `--invite-agent`, and `omamobile-set-pin --apply TYPE` with the current +// and the new secret on its stdin (never argv or a file), which drives +// passwd and records the choice. The scripts' terminal prompts stay as the +// fallback when the shell isn't running. +// +// The window sits on the top layer with normal exclusion, like the update +// sheet, so it fits between the status bar and the on-screen keyboard: the +// fields and their buttons keep to the bottom of the card, above the keys. +Item { + id: root + + // Injected by the host. + property var shell: null + property var manifest: null + + property bool opened: false + property string flow: "onboarding" // onboarding | pin + property string page: "identity" // identity | credential-exists | pin-choice | pin-entry | applying | done + property var info: Model.parseStatus("") + property bool infoLoaded: false + property string type: "pin" // pin | password: the choice on pin-choice + property string step: "new" // current | new | retype + property bool digits: true + property string entryError: "" + property bool changed: false // a PIN or password was set in this visit + property bool busy: false + + readonly property int touchSize: Math.max(44, Style.space(48)) + readonly property int pad: Style.spacing.panelPadding + readonly property color foreground: Commons.Color.popups.text + readonly property color secondary: Readable.secondary(foreground, Commons.Color.popups.background) + readonly property var steps: Model.entrySteps(info.pin.set) + readonly property var stepWords: Model.stepText(step, type) + readonly property string pluginId: (manifest && manifest.id) || "omamobile.onboarding" + readonly property string title: flow === "pin" ? (type === "password" ? "Password" : "PIN") : "Set up your phone" + + // The secrets live only in these two strings and the field, until they + // go to omamobile-set-pin's stdin; nothing logs them. + property string currentSecret: "" + property string newSecret: "" + + // ---------------------------------------------------------------- host API + + // '{}' or '{"page":"pin"}'. + function open(payloadJson) { + var payload = {} + try { payload = JSON.parse(payloadJson || "{}") || {} } catch (error) {} + flow = payload.page === "pin" ? "pin" : "onboarding" + opened = true + changed = false + entryError = "" + clearSecrets() + page = Model.firstPage(flow) + infoLoaded = false + refreshStatus() + if (page === "pin-choice") type = info.pin.type + } + + function close() { + if (!opened) return + opened = false + clearSecrets() + } + + function dismiss() { + if (root.shell && typeof root.shell.hide === "function") root.shell.hide(pluginId) + else close() + } + + // `shell call omamobile.onboarding snapshot ''`: never a secret. + function snapshot() { + return JSON.stringify({ opened: opened, flow: flow, page: page, step: step, type: type, changed: changed }) + } + + // ---------------------------------------------------------------- flow + + function refreshStatus() { + if (!statusProc.running) statusProc.running = true + } + + function clearSecrets() { + currentSecret = "" + newSecret = "" + secretField.text = "" + } + + function goTo(next) { + entryError = "" + page = next + if (next === "pin-choice") type = info.pin.type + if (next === "pin-entry") startEntry() + if (next === "done" && flow === "onboarding") Quickshell.execDetached(Model.INVITE_ARGV) + if (next === "identity") Qt.callLater(function() { nameField.forceActiveFocus() }) + } + + function advance() { goTo(Model.nextPage(flow, page, info)) } + + // Identity: saved when either answer is given, as the prompts do. + function submitIdentity() { + var name = nameField.text.trim(), email = emailField.text.trim() + if (name || email) Quickshell.execDetached(Model.identityArgv(name, email)) + advance() + } + + function startEntry() { + clearSecrets() + digits = type !== "password" + step = steps[0] + entryError = "" + focusSecret() + } + + function focusSecret() { + Qt.callLater(function() { secretField.forceActiveFocus() }) + } + + // One step at a time, as passwd asks: the current one, the new one, the + // new one again; a mismatch goes back to the new one. + function submitSecret() { + if (busy || secretField.text.length === 0) return + var value = secretField.text + secretField.text = "" + entryError = "" + if (step === "current") { + currentSecret = value + step = "new" + focusSecret() + return + } + if (step === "new") { + newSecret = value + step = "retype" + focusSecret() + return + } + if (value !== newSecret) { + newSecret = "" + step = "new" + entryError = "They don't match. Try again." + focusSecret() + return + } + apply() + } + + function backStep() { + entryError = "" + secretField.text = "" + if (step === "retype") { newSecret = ""; step = "new"; focusSecret(); return } + if (step === "new" && steps[0] === "current") { currentSecret = ""; step = "current"; focusSecret(); return } + clearSecrets() + goTo("pin-choice") + } + + function apply() { + busy = true + page = "applying" + applyProc.command = Model.applyArgv(type) + applyProc.running = true + } + + // ---------------------------------------------------------------- processes + + Process { + id: statusProc + command: Model.STATUS_ARGV + stdout: StdioCollector { id: statusOut; waitForEnd: true } + onExited: { + root.info = Model.parseStatus(statusOut.text) + root.infoLoaded = true + if (root.page === "identity") { + if (nameField.text === "") nameField.text = root.info.name + if (emailField.text === "") emailField.text = root.info.email + } + if (root.page === "pin-choice") root.type = root.info.pin.type + } + } + + Process { + id: applyProc + stdinEnabled: true + stdout: StdioCollector { id: applyOut; waitForEnd: true } + onStarted: { + applyProc.write(root.currentSecret + "\n" + root.newSecret + "\n") + applyProc.stdinEnabled = false + root.clearSecrets() + } + onExited: function(exitCode) { + root.busy = false + applyProc.stdinEnabled = true + var outcome = Model.applyOutcome(exitCode, applyOut.text) + if (outcome.result === "set") { + root.changed = true + root.refreshStatus() + root.goTo("done") + return + } + var back = Model.failureText(outcome, root.type) + root.page = "pin-entry" + root.step = back.step === "current" && root.steps[0] === "current" ? "current" : "new" + root.entryError = back.text + root.focusSecret() + } + } + + // ---------------------------------------------------------------- surface + + property real reveal: opened ? 1 : 0 + Behavior on reveal { NumberAnimation { duration: 200; easing.type: Easing.OutCubic } } + + PanelWindow { + id: sheetWindow + + visible: root.opened || root.reveal > 0 + anchors { top: true; bottom: true; left: true; right: true } + // Normal: between the status bar and the on-screen keyboard. + exclusionMode: ExclusionMode.Normal + color: "transparent" + WlrLayershell.namespace: "omamobile-onboarding" + WlrLayershell.layer: WlrLayer.Top + // OnDemand, not Exclusive, or the on-screen keyboard gets no touches. + WlrLayershell.keyboardFocus: root.opened ? WlrKeyboardFocus.OnDemand : WlrKeyboardFocus.None + + Rectangle { + anchors.fill: parent + color: Commons.Color.menu.scrim + opacity: root.reveal + } + + MouseArea { + anchors.fill: parent + onClicked: if (root.page !== "applying") root.dismiss() + } + + BorderSurface { + id: card + objectName: "setupCard" + + x: Style.gapsOut + width: parent.width - Style.gapsOut * 2 + height: parent.height - Style.gapsOut * 2 + y: Style.gapsOut + Math.round((1 - root.reveal) * Style.space(60)) + opacity: root.reveal + color: Commons.Color.popups.background + borderSpec: Border.surfaceSpec("popups", "border", Commons.Color.popups.border, Math.max(1, Style.space(2))) + radius: Style.cornerRadius + padding: root.pad + + focus: root.opened + Keys.onEscapePressed: if (root.page !== "applying") root.dismiss() + + MouseArea { anchors.fill: parent } + + Item { + id: content + anchors.fill: parent + anchors.topMargin: card.contentTopInset + anchors.rightMargin: card.contentRightInset + anchors.bottomMargin: card.contentBottomInset + anchors.leftMargin: card.contentLeftInset + + // ---------- Header: title and close + Item { + id: headerRow + objectName: "setupHeader" + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + height: root.touchSize + + Text { + anchors.left: parent.left + anchors.right: closeButton.left + anchors.verticalCenter: parent.verticalCenter + textFormat: Text.PlainText + text: root.title + color: root.foreground + font.family: Style.font.family + font.pixelSize: Style.font.title + font.bold: true + elide: Text.ElideRight + } + + GlyphTap { + id: closeButton + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + glyph: "󰅖" + enabled: root.page !== "applying" + onTapped: root.dismiss() + } + } + + // ---------- The page's words, under the header + Column { + id: words + anchors.top: headerRow.bottom + anchors.topMargin: Style.spacing.xl + anchors.left: parent.left + anchors.right: parent.right + spacing: Style.spacing.lg + visible: root.page !== "pin-entry" && root.page !== "applying" + + Text { + objectName: "pageTitle" + width: parent.width + textFormat: Text.PlainText + text: root.page === "identity" ? "Welcome to Omarchy Mobile." + : root.page === "credential-exists" ? "Your phone already has a " + (root.info.pin.type === "password" ? "password" : "PIN") + "." + : root.page === "pin-choice" ? "Choose how you unlock the phone." + : root.page === "done" ? Model.doneText(root.flow, root.type, root.changed, root.info.agent).title : "" + color: root.foreground + font.family: Style.font.family + font.pixelSize: Style.font.title + font.bold: true + wrapMode: Text.Wrap + } + + Text { + width: parent.width + visible: text !== "" + textFormat: Text.PlainText + text: root.page === "identity" ? "Two quick steps: who you are, for git and your keyboard's shortcuts, then how you unlock the phone." + : root.page === "credential-exists" ? "Change it, or switch between a PIN and a password, here or in System > PIN." + : root.page === "pin-choice" ? "It is also used for sudo." + : root.page === "done" ? Model.doneText(root.flow, root.type, root.changed, root.info.agent).body : "" + color: root.secondary + font.family: Style.font.family + font.pixelSize: Style.font.body + wrapMode: Text.Wrap + } + + // The two ways to unlock, the current one first. + Repeater { + model: root.page === "pin-choice" ? Model.typeChoices(root.info.pin.type) : [] + delegate: BorderSurface { + id: choiceRow + required property var modelData + readonly property bool selected: root.type === choiceRow.modelData.id + objectName: "choice-" + choiceRow.modelData.id + width: parent ? parent.width : 0 + height: Math.max(root.touchSize, choiceText.implicitHeight + Style.spacing.lg * 2) + radius: Style.cornerRadius + color: choiceTouch.pressed ? Style.pressedFillFor(root.foreground, Commons.Color.accent) + : choiceRow.selected ? Util.alpha(Commons.Color.accent, Style.selectedFillAlpha) + : Style.normalFillFor(root.foreground, Commons.Color.accent) + borderSpec: Border.controlSpec(choiceRow.selected ? "selected" : "normal", root.foreground, Commons.Color.accent) + + Text { + id: choiceMark + anchors.left: parent.left + anchors.leftMargin: Style.spacing.lg + anchors.verticalCenter: parent.verticalCenter + textFormat: Text.PlainText + text: choiceRow.selected ? "󰄴" : "󰄰" + color: choiceRow.selected ? Commons.Color.accent : root.foreground + font.family: Style.font.family + font.pixelSize: Style.font.title + } + + Column { + id: choiceText + anchors.left: choiceMark.right + anchors.leftMargin: Style.spacing.lg + anchors.right: parent.right + anchors.rightMargin: Style.spacing.lg + anchors.verticalCenter: parent.verticalCenter + spacing: Style.spacing.xs + + Text { + width: parent.width + textFormat: Text.PlainText + text: choiceRow.modelData.title + color: root.foreground + font.family: Style.font.family + font.pixelSize: Style.font.subtitle + font.bold: true + } + + Text { + width: parent.width + textFormat: Text.PlainText + text: choiceRow.modelData.detail + color: root.secondary + font.family: Style.font.family + font.pixelSize: Style.font.body + wrapMode: Text.Wrap + } + } + + MouseArea { + id: choiceTouch + anchors.fill: parent + onClicked: root.type = choiceRow.modelData.id + } + } + } + } + + // ---------- Identity: the two fields, above the keyboard + Column { + id: identityForm + visible: root.page === "identity" + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + spacing: Style.spacing.lg + + TextField { + id: nameField + objectName: "nameField" + width: parent.width + height: root.touchSize + verticalAlignment: TextInput.AlignVCenter + font.pixelSize: Style.font.title + foreground: root.foreground + placeholderText: "Your name" + placeholderTextColor: Readable.secondary(root.foreground, Readable.flatten(Style.controlFill(activeFocus, hovered || hasCursor, foreground, accent), Commons.Color.popups.background)) + inputMethodHints: Qt.ImhNoPredictiveText + onAccepted: emailField.forceActiveFocus() + Keys.onEscapePressed: root.dismiss() + } + + TextField { + id: emailField + objectName: "emailField" + width: parent.width + height: root.touchSize + verticalAlignment: TextInput.AlignVCenter + font.pixelSize: Style.font.title + foreground: root.foreground + placeholderText: "Your email" + placeholderTextColor: Readable.secondary(root.foreground, Readable.flatten(Style.controlFill(activeFocus, hovered || hasCursor, foreground, accent), Commons.Color.popups.background)) + inputMethodHints: Qt.ImhEmailCharactersOnly | Qt.ImhNoAutoUppercase | Qt.ImhNoPredictiveText + onAccepted: root.submitIdentity() + Keys.onEscapePressed: root.dismiss() + } + + Row { + width: parent.width + height: root.touchSize + spacing: Style.spacing.lg + layoutDirection: Qt.RightToLeft + + SheetAction { + width: (parent.width - parent.spacing) / 2 + label: "Continue" + primary: true + onTapped: root.submitIdentity() + } + + SheetAction { + width: (parent.width - parent.spacing) / 2 + label: "Skip" + onTapped: root.advance() + } + } + } + + // ---------- A PIN exists: keep it or change it + Row { + visible: root.page === "credential-exists" + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + height: root.touchSize + spacing: Style.spacing.lg + layoutDirection: Qt.RightToLeft + + SheetAction { + width: (parent.width - parent.spacing) / 2 + label: "Keep it" + primary: true + onTapped: root.advance() + } + + SheetAction { + width: (parent.width - parent.spacing) / 2 + label: "Change it" + onTapped: root.goTo("pin-choice") + } + } + + // ---------- The choice made + SheetAction { + visible: root.page === "pin-choice" + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + label: "Continue" + primary: true + onTapped: root.advance() + } + + // ---------- The entry: one secret at a time, above the keyboard + Column { + id: entryColumn + visible: root.page === "pin-entry" + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + spacing: Style.spacing.xl + + Text { + objectName: "entryTitle" + width: parent.width + textFormat: Text.PlainText + text: root.stepWords.title + color: root.foreground + font.family: Style.font.family + font.pixelSize: Style.font.subtitle + font.bold: true + wrapMode: Text.Wrap + } + + Text { + width: parent.width + visible: text !== "" + textFormat: Text.PlainText + text: root.entryError !== "" ? root.entryError : root.stepWords.hint + color: root.entryError !== "" ? Commons.Color.urgent : root.secondary + font.family: Style.font.family + font.pixelSize: Style.font.body + wrapMode: Text.Wrap + } + + Item { + width: parent.width + height: root.touchSize + + TextField { + id: secretField + objectName: "secretField" + anchors.left: parent.left + anchors.right: modeSwitch.left + anchors.rightMargin: Style.spacing.lg + anchors.top: parent.top + anchors.bottom: parent.bottom + verticalAlignment: TextInput.AlignVCenter + font.pixelSize: Style.font.title + foreground: root.foreground + placeholderText: root.type === "password" ? "Password" : "PIN" + placeholderTextColor: Readable.secondary(root.foreground, Readable.flatten(Style.controlFill(activeFocus, hovered || hasCursor, foreground, accent), Commons.Color.popups.background)) + password: true + enabled: !root.busy + inputMethodHints: root.digits + ? (Qt.ImhDigitsOnly | Qt.ImhSensitiveData | Qt.ImhNoPredictiveText) + : (Qt.ImhSensitiveData | Qt.ImhNoPredictiveText | Qt.ImhNoAutoUppercase | Qt.ImhPreferLowercase) + onAccepted: root.submitSecret() + onTextEdited: root.entryError = "" + Keys.onEscapePressed: root.backStep() + } + + SheetAction { + id: modeSwitch + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + width: root.touchSize + Style.space(16) + label: root.digits ? "ABC" : "123" + onTapped: { + root.digits = !root.digits + secretField.focus = false + root.focusSecret() + } + } + } + + Row { + width: parent.width + height: root.touchSize + spacing: Style.spacing.lg + layoutDirection: Qt.RightToLeft + + SheetAction { + width: (parent.width - parent.spacing) / 2 + label: root.step === "retype" ? "Set" : "Next" + primary: true + enabled: secretField.text.length > 0 && !root.busy + onTapped: root.submitSecret() + } + + SheetAction { + width: (parent.width - parent.spacing) / 2 + label: "Back" + enabled: !root.busy + onTapped: root.backStep() + } + } + } + + // ---------- Applying + Row { + visible: root.page === "applying" + anchors.top: headerRow.bottom + anchors.topMargin: Style.spacing.xl + anchors.left: parent.left + anchors.right: parent.right + spacing: Style.spacing.lg + + Text { + id: spinner + textFormat: Text.PlainText + text: "󰑐" + color: Commons.Color.accent + font.family: Style.font.family + font.pixelSize: Style.font.iconLarge + RotationAnimator on rotation { + running: root.page === "applying" && root.opened + from: 0 + to: 360 + duration: 1200 + loops: Animation.Infinite + } + } + + Text { + anchors.verticalCenter: spinner.verticalCenter + textFormat: Text.PlainText + text: "Setting it..." + color: root.foreground + font.family: Style.font.family + font.pixelSize: Style.font.subtitle + font.bold: true + } + } + + // ---------- Done + SheetAction { + visible: root.page === "done" + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + label: "Done" + primary: true + onTapped: root.dismiss() + } + } + } + } + + // ---------------------------------------------------------------- pieces + + // Inline components have their own scope: no `root` in here. + component GlyphTap: Item { + id: glyphItem + property string glyph: "" + property color foreground: Commons.Color.popups.text + readonly property int touchSize: Math.max(44, Style.space(48)) + signal tapped() + width: glyphItem.touchSize + height: glyphItem.touchSize + opacity: enabled ? 1 : 0.45 + + Rectangle { + anchors.fill: parent + radius: Style.cornerRadius + color: glyphTouch.pressed ? Style.pressedFillFor(glyphItem.foreground, Commons.Color.accent) : "transparent" + } + + Text { + anchors.centerIn: parent + textFormat: Text.PlainText + text: glyphItem.glyph + color: glyphItem.foreground + font.family: Style.font.family + font.pixelSize: Style.font.iconLarge + } + + MouseArea { + id: glyphTouch + anchors.fill: parent + enabled: glyphItem.enabled + onClicked: glyphItem.tapped() + } + } + + component SheetAction: BorderSurface { + id: actionItem + property string label: "" + property bool primary: false + property color foreground: Commons.Color.popups.text + readonly property int touchSize: Math.max(44, Style.space(48)) + signal tapped() + height: visible ? actionItem.touchSize : 0 + radius: Style.cornerRadius + opacity: enabled ? 1 : 0.45 + color: actionTouch.pressed ? Style.pressedFillFor(actionItem.foreground, Commons.Color.accent) + : actionItem.primary ? Util.alpha(Commons.Color.accent, Style.selectedFillAlpha) + : Style.normalFillFor(actionItem.foreground, Commons.Color.accent) + borderSpec: Border.controlSpec(actionItem.primary ? "selected" : "normal", actionItem.foreground, Commons.Color.accent) + + Text { + anchors.centerIn: parent + width: parent.width - Style.spacing.lg * 2 + horizontalAlignment: Text.AlignHCenter + textFormat: Text.PlainText + text: actionItem.label + color: actionItem.primary ? Commons.Color.accent : actionItem.foreground + font.family: Style.font.family + font.pixelSize: Style.font.subtitle + font.bold: true + elide: Text.ElideRight + } + + MouseArea { + id: actionTouch + anchors.fill: parent + enabled: actionItem.enabled + onClicked: actionItem.tapped() + } + } +} diff --git a/packages/omamobile-shell/plugins/omamobile.onboarding/OnboardingModel.js b/packages/omamobile-shell/plugins/omamobile.onboarding/OnboardingModel.js new file mode 100644 index 000000000..d8eb0f8cf --- /dev/null +++ b/packages/omamobile-shell/plugins/omamobile.onboarding/OnboardingModel.js @@ -0,0 +1,131 @@ +// SPDX-License-Identifier: MIT +// The setup sheet's pure parts: the pages of each flow, what each asks, the +// scripts' argv, and what their answers mean. No QML here, so +// test/onboarding-model.js runs it under Node through the module.exports. +// +// Two flows: "onboarding" (the first run: name and email, then a PIN or +// password unless there is one, then Omarchy's agent invitation) and "pin" +// (System > PIN: choose PIN or password, set it). Each asks what the +// terminal prompts in omamobile-onboarding and omamobile-set-pin ask, in +// their order, and every answer goes to those scripts. + +var STATUS_ARGV = ["omamobile-onboarding", "--status", "--json"] +var INVITE_ARGV = ["omamobile-onboarding", "--invite-agent"] + +function identityArgv(name, email) { + return ["omamobile-onboarding", "--identity", String(name || "").trim(), String(email || "").trim()] +} + +// `omamobile-set-pin --apply TYPE`: the current and the new secret go to +// its stdin, never here. +function applyArgv(type) { + return ["omamobile-set-pin", "--apply", type === "password" ? "password" : "pin"] +} + +function parseJson(text) { + try { + var value = JSON.parse(String(text || "")) + return value && typeof value === "object" ? value : null + } catch (e) { + return null + } +} + +// `omamobile-onboarding --status --json`, with every field present. +function parseStatus(text) { + var raw = parseJson(text) || {} + var pin = raw.pin && typeof raw.pin === "object" ? raw.pin : {} + return { + name: String(raw.name || ""), + email: String(raw.email || ""), + identity: !!raw.identity, + pin: { set: pin.set === true, type: pin.type === "password" ? "password" : "pin" }, + agent: String(raw.agent || "") + } +} + +var CHOICES = { + pin: { id: "pin", title: "PIN", detail: "Numbers only: the lock screen opens on a number pad" }, + password: { id: "password", title: "Password", detail: "Letters, numbers and symbols: the lock screen opens on the keyboard; 123 switches to a number pad" } +} + +// The two ways to unlock, the current choice first, as `gum choose` lists them. +function typeChoices(currentType) { + return currentType === "password" ? [CHOICES.password, CHOICES.pin] : [CHOICES.pin, CHOICES.password] +} + +var FLOWS = { + onboarding: ["identity", "credential", "done"], + pin: ["pin-choice", "pin-entry", "done"] +} + +function firstPage(flow) { + return flow === "pin" ? "pin-choice" : "identity" +} + +// The page after `page`. In the first run, the credential step is a note +// when a PIN or password exists already ("credential-exists", as the +// terminal flow says), else the choice and the entry. +function nextPage(flow, page, status) { + var hasPin = !!(status && status.pin && status.pin.set) + if (flow === "pin") { + if (page === "pin-choice") return "pin-entry" + return "done" + } + if (page === "identity") return hasPin ? "credential-exists" : "pin-choice" + if (page === "credential-exists") return "done" + if (page === "pin-choice") return "pin-entry" + return "done" +} + +// What the entry asks, in passwd's order: the current one first when the +// account has one. +function entrySteps(hasCurrent) { + return hasCurrent ? ["current", "new", "retype"] : ["new", "retype"] +} + +function stepText(step, type) { + var what = type === "password" ? "password" : "PIN" + if (step === "current") return { title: "Enter your current " + what, hint: "" } + if (step === "retype") return { title: "Enter it again", hint: "" } + return { + title: "Choose a " + what, + hint: type === "password" ? "The lock screen opens on the keyboard; 123 switches to a number pad." : "Use digits only: the lock screen opens on a number pad." + } +} + +// What `omamobile-set-pin --apply` said (its exit code and stdout). +function applyOutcome(exitCode, text) { + var reason = String(text || "").trim().split("\n")[0] || "" + switch (exitCode) { + case 0: return { result: "set", reason: "" } + case 3: return { result: "wrong-current", reason: "" } + case 5: return { result: "refused", reason: reason || "The new one was refused" } + default: return { result: "error", reason: reason || "omamobile-set-pin failed (exit " + exitCode + ")" } + } +} + +// The words for a failed attempt, by what the entry goes back to. +function failureText(outcome, type) { + var what = type === "password" ? "password" : "PIN" + if (outcome.result === "wrong-current") return { step: "current", text: "Wrong " + what + ". Try again." } + if (outcome.result === "refused") return { step: "new", text: outcome.reason + ". Choose another." } + return { step: "new", text: outcome.reason } +} + +function doneText(flow, type, changed, agent) { + var what = type === "password" ? "Password" : "PIN" + var title = changed ? what + " set." : "All set." + var body = changed ? "Your phone now locks after it starts." : "" + if (flow === "onboarding" && !agent) body += (body ? " " : "") + "Omarchy will invite you to pick a default agent." + return { title: title, body: body } +} + +if (typeof module !== "undefined") { + module.exports = { + STATUS_ARGV: STATUS_ARGV, INVITE_ARGV: INVITE_ARGV, FLOWS: FLOWS, CHOICES: CHOICES, + identityArgv: identityArgv, applyArgv: applyArgv, parseJson: parseJson, parseStatus: parseStatus, + typeChoices: typeChoices, firstPage: firstPage, nextPage: nextPage, entrySteps: entrySteps, + stepText: stepText, applyOutcome: applyOutcome, failureText: failureText, doneText: doneText + } +} diff --git a/packages/omamobile-shell/plugins/omamobile.onboarding/Readable.js b/packages/omamobile-shell/plugins/omamobile.onboarding/Readable.js new file mode 100644 index 000000000..e0dc85b6c --- /dev/null +++ b/packages/omamobile-shell/plugins/omamobile.onboarding/Readable.js @@ -0,0 +1,73 @@ +// SPDX-License-Identifier: MIT +// Text that can be read on the phone (docs/TOUCH-PLAN.md 2.1 and 2.7). +// Plugins are separate directories with no shared import, so each one that +// needs this carries this same file (test/all checks they match). +// +// Size: Omarchy's type scale is a desktop's (caption 10 px, body 12 px); on +// the phone's 480 px wide screen, held at arm's length, nothing read goes +// under 12 px. A floor here rather than theme font overrides, which a theme +// change would drop. +// +// Contrast: secondary text (a status line, a placeholder, a hint) used to +// be the foreground darkened by a fixed factor or drawn at 60-75% opacity, +// which on a dark theme came to 3-4:1 against the surface. `secondary` +// mixes the foreground toward the surface only as far as WCAG's 4.5:1 +// minimum for text allows, on any theme. + +var MIN_PX = 12 +var MIN_CONTRAST = 4.5 +// How far secondary text may be mixed toward its surface at most (the +// share of the surface), so it still reads as secondary on a theme with +// plenty of contrast to spare. +var MAX_MIX = 0.6 + +function px(size) { return Math.max(MIN_PX, size) } + +// Colours are {r, g, b[, a]} in 0..1, which a QML color is in JavaScript. + +function channel(v) { return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4) } + +// WCAG relative luminance. +function luminance(c) { + return 0.2126 * channel(c.r) + 0.7152 * channel(c.g) + 0.0722 * channel(c.b) +} + +// WCAG contrast ratio, 1..21. +function contrast(a, b) { + var la = luminance(a), lb = luminance(b) + return (Math.max(la, lb) + 0.05) / (Math.min(la, lb) + 0.05) +} + +// `top` (with its alpha) laid over an opaque `under`. +function flattenRgb(top, under) { + var a = top.a === undefined ? 1 : top.a + return { r: top.r * a + under.r * (1 - a), g: top.g * a + under.g * (1 - a), b: top.b * a + under.b * (1 - a), a: 1 } +} + +// The foreground mixed toward the surface as far as MIN_CONTRAST allows +// (never past MAX_MIX); the foreground itself when even that falls short. +function secondaryRgb(fg, bg, minRatio) { + var want = minRatio || MIN_CONTRAST + var under = flattenRgb(bg, { r: 0, g: 0, b: 0 }) + for (var t = MAX_MIX; t >= 0; t = Math.round((t - 0.02) * 100) / 100) { + var mix = { r: fg.r * (1 - t) + under.r * t, g: fg.g * (1 - t) + under.g * t, b: fg.b * (1 - t) + under.b * t, a: 1 } + if (contrast(mix, under) >= want) return mix + } + return { r: fg.r, g: fg.g, b: fg.b, a: 1 } +} + +// For QML: a color. Under Node (no Qt) the {r, g, b, a} object. +function secondary(fg, bg) { + var c = secondaryRgb(fg, bg) + return typeof Qt !== "undefined" ? Qt.rgba(c.r, c.g, c.b, 1) : c +} + +function flatten(top, under) { + var c = flattenRgb(top, under) + return typeof Qt !== "undefined" ? Qt.rgba(c.r, c.g, c.b, 1) : c +} + +if (typeof module !== "undefined") { + module.exports = { MIN_PX: MIN_PX, MIN_CONTRAST: MIN_CONTRAST, MAX_MIX: MAX_MIX, px: px, luminance: luminance, contrast: contrast, + flattenRgb: flattenRgb, secondaryRgb: secondaryRgb, secondary: secondary, flatten: flatten } +} diff --git a/packages/omamobile-shell/plugins/omamobile.onboarding/manifest.json b/packages/omamobile-shell/plugins/omamobile.onboarding/manifest.json new file mode 100644 index 000000000..438606aa6 --- /dev/null +++ b/packages/omamobile-shell/plugins/omamobile.onboarding/manifest.json @@ -0,0 +1,14 @@ +{ + "schemaVersion": 1, + "id": "omamobile.onboarding", + "name": "Phone setup sheet", + "version": "0.1.0", + "author": "Omarchy Mobile", + "license": "MIT", + "description": "First-run setup and the PIN for a phone, as sheets in place of the terminal prompts: name and email, then a PIN or password, then Omarchy's invitation to pick a default agent. Every answer goes through omamobile-onboarding and omamobile-set-pin, which keep the terminal flow as the fallback.", + "kinds": ["panel"], + "keepLoaded": true, + "entryPoints": { + "panel": "Onboarding.qml" + } +} diff --git a/packages/omamobile-shell/profile/shell.json b/packages/omamobile-shell/profile/shell.json index 3ecfa884c..e05242f88 100644 --- a/packages/omamobile-shell/profile/shell.json +++ b/packages/omamobile-shell/profile/shell.json @@ -47,6 +47,9 @@ }, { "id": "omamobile.back" + }, + { + "id": "omamobile.onboarding" } ] } diff --git a/packages/omamobile-shell/test/all b/packages/omamobile-shell/test/all index 2c7454f47..427447c05 100755 --- a/packages/omamobile-shell/test/all +++ b/packages/omamobile-shell/test/all @@ -539,6 +539,56 @@ if [[ -n ${OMAMOBILE_UPDATE_RENDER:-} ]]; then fi pass "update sheet" +# The setup sheet (omamobile.onboarding, TOUCH-PLAN 1.11): the first run's +# questions and System > PIN as sheets in place of the gum prompts. The +# scripts stay the one definition of what each answer does (their +# function-level entry points, test/onboarding.sh), the sheet calls them, +# the secrets go to omamobile-set-pin's stdin and nowhere else, and the +# scripts open the sheet when the shell has it. test/onboarding-render +# draws every page in the OWL container. +python3 -c 'import json; assert {"id": "omamobile.onboarding"} in json.load(open("profile/shell.json"))["plugins"]' \ + || fail "the phone profile enables the setup sheet" +grep -c 'add_plugin omamobile.onboarding' bin/omamobile-setup-user >/dev/null || fail "existing users get the setup sheet" +bash test/onboarding.sh || fail "omamobile-onboarding and omamobile-set-pin entry points" +if command -v node >/dev/null; then + node test/onboarding-model.js >/dev/null || { node test/onboarding-model.js; fail "setup sheet model"; } +fi +setup=plugins/omamobile.onboarding/Onboarding.qml +grep -cF "omarchy-shell shell summon omamobile.onboarding \"\$1\"" bin/omamobile-onboarding >/dev/null || fail "omamobile-onboarding opens the sheet" +grep -cF "omarchy-shell shell summon omamobile.onboarding \"\$1\"" bin/omamobile-set-pin >/dev/null || fail "omamobile-set-pin opens the sheet" +grep -cF 'exec omarchy-launch-floating-terminal-with-presentation "omamobile-onboarding --inner"' bin/omamobile-onboarding >/dev/null || fail "the terminal prompts stay the fallback" +grep -cF 'applyProc.write(root.currentSecret + "\n" + root.newSecret + "\n")' "$setup" >/dev/null || fail "the secrets go to omamobile-set-pin's stdin" +if grep -nE 'command: .*(Secret|secretField)' "$setup"; then fail "a secret is never in argv"; fi +if grep -nE 'console\.(log|info|warn|debug|error)\([^)]*(secret|Secret|pin|password)' "$setup"; then fail "a secret is never logged"; fi +grep -cF 'if (name || email) Quickshell.execDetached(Model.identityArgv(name, email))' "$setup" >/dev/null || fail "the identity goes through omamobile-onboarding --identity" +grep -cF 'Quickshell.execDetached(Model.INVITE_ARGV)' "$setup" >/dev/null || fail "the agent invitation goes through omamobile-onboarding --invite-agent" +# (the comments may name passwd; the code may not run or imitate it) +if [[ -n $(grep -nE 'git config|XCompose|passwd|chpasswd|toggles/' "$setup" plugins/omamobile.onboarding/OnboardingModel.js | grep -vE ':[0-9]+:\s*//') ]]; then + grep -nE 'git config|XCompose|passwd|chpasswd|toggles/' "$setup" plugins/omamobile.onboarding/OnboardingModel.js | grep -vE ':[0-9]+:\s*//' + fail "the sheet repeats none of the scripts' logic" +fi +grep -cF 'exclusionMode: ExclusionMode.Normal' "$setup" >/dev/null || fail "the setup sheet fits above the on-screen keyboard" +python3 -B - <<'PY2' || fail "the setup sheet lints clean" +import importlib.machinery, importlib.util, os, sys +loader = importlib.machinery.SourceFileLoader("omamobile_widget", "bin/omamobile-widget") +spec = importlib.util.spec_from_loader("omamobile_widget", loader) +tool = importlib.util.module_from_spec(spec) +loader.exec_module(tool) +if not tool.qmllint_path() or not os.path.isdir(os.path.join(tool.OMARCHY_PATH, "shell")): + print("ok - setup sheet lint # SKIP no qmllint or Omarchy shell") + sys.exit(0) +lint = tool.run_qmllint([os.path.abspath("plugins/omamobile.onboarding/Onboarding.qml")]) +noise = ("is not creatable", "QProcess::ExitStatus") +bad = lint["errors"] + [w for w in lint["warnings"] if not any(n in w for n in noise)] +for line in bad: + print(" " + line) +sys.exit(1 if bad else 0) +PY2 +if [[ -n ${OMAMOBILE_SETUP_RENDER:-} ]]; then + bash test/onboarding-render "$OMAMOBILE_SETUP_RENDER" >/dev/null || fail "setup sheet render" +fi +pass "setup sheet: the scripts' entry points, the sheet's wiring, no secret in argv or the log" + # The permission sheet: the portal Access backend (its pure parts, then the # D-Bus service on a private bus against a fake omarchy-shell), the sheet's # model, and the wiring that makes the portal pick it under Hyprland. diff --git a/packages/omamobile-shell/test/onboarding-model.js b/packages/omamobile-shell/test/onboarding-model.js new file mode 100644 index 000000000..2908f1f15 --- /dev/null +++ b/packages/omamobile-shell/test/onboarding-model.js @@ -0,0 +1,87 @@ +// SPDX-License-Identifier: MIT +// Node tests for plugins/omamobile.onboarding/OnboardingModel.js. Run by test/all. +"use strict" +const assert = require("assert") +const path = require("path") +const M = require(path.join(__dirname, "../plugins/omamobile.onboarding/OnboardingModel.js")) + +const tests = [] +const test = (name, fn) => tests.push([name, fn]) + +test("status: every field present, from the script's JSON or nothing", () => { + const s = M.parseStatus('{"name": "Ada", "email": "ada@example.com", "identity": true, "pin": {"set": true, "type": "password"}, "agent": "claude"}') + assert.deepStrictEqual(s, { name: "Ada", email: "ada@example.com", identity: true, pin: { set: true, type: "password" }, agent: "claude" }) + assert.deepStrictEqual(M.parseStatus(""), { name: "", email: "", identity: false, pin: { set: false, type: "pin" }, agent: "" }) + assert.deepStrictEqual(M.parseStatus("{bad").pin, { set: false, type: "pin" }) + assert.strictEqual(M.parseStatus('{"pin": {"set": "yes", "type": "x"}}').pin.set, false) +}) + +test("the first run asks what the prompts ask, in their order", () => { + const fresh = M.parseStatus("") + assert.strictEqual(M.firstPage("onboarding"), "identity") + assert.strictEqual(M.nextPage("onboarding", "identity", fresh), "pin-choice") + assert.strictEqual(M.nextPage("onboarding", "pin-choice", fresh), "pin-entry") + assert.strictEqual(M.nextPage("onboarding", "pin-entry", fresh), "done") + // With a PIN already: the note the terminal flow prints, then the agent. + const has = M.parseStatus('{"pin": {"set": true, "type": "pin"}}') + assert.strictEqual(M.nextPage("onboarding", "identity", has), "credential-exists") + assert.strictEqual(M.nextPage("onboarding", "credential-exists", has), "done") + // System > PIN: the choice, the entry, done. + assert.strictEqual(M.firstPage("pin"), "pin-choice") + assert.strictEqual(M.nextPage("pin", "pin-choice", has), "pin-entry") + assert.strictEqual(M.nextPage("pin", "pin-entry", has), "done") +}) + +test("the choice lists the current way first, as gum choose did", () => { + assert.deepStrictEqual(M.typeChoices("pin").map((c) => c.id), ["pin", "password"]) + assert.deepStrictEqual(M.typeChoices("password").map((c) => c.id), ["password", "pin"]) + assert.ok(M.CHOICES.pin.detail.includes("number pad")) +}) + +test("the entry asks for the current one only when there is one, then the new one twice", () => { + assert.deepStrictEqual(M.entrySteps(false), ["new", "retype"]) + assert.deepStrictEqual(M.entrySteps(true), ["current", "new", "retype"]) + assert.strictEqual(M.stepText("current", "pin").title, "Enter your current PIN") + assert.strictEqual(M.stepText("new", "password").title, "Choose a password") + assert.ok(M.stepText("new", "pin").hint.includes("digits")) + assert.strictEqual(M.stepText("retype", "pin").title, "Enter it again") +}) + +test("the scripts' argv: the secret never in it", () => { + assert.deepStrictEqual(M.STATUS_ARGV, ["omamobile-onboarding", "--status", "--json"]) + assert.deepStrictEqual(M.INVITE_ARGV, ["omamobile-onboarding", "--invite-agent"]) + assert.deepStrictEqual(M.identityArgv(" Ada ", "ada@example.com "), ["omamobile-onboarding", "--identity", "Ada", "ada@example.com"]) + assert.deepStrictEqual(M.applyArgv("password"), ["omamobile-set-pin", "--apply", "password"]) + assert.deepStrictEqual(M.applyArgv("anything"), ["omamobile-set-pin", "--apply", "pin"]) +}) + +test("what --apply's exit codes mean, and where the entry goes back to", () => { + assert.deepStrictEqual(M.applyOutcome(0, ""), { result: "set", reason: "" }) + assert.deepStrictEqual(M.applyOutcome(3, ""), { result: "wrong-current", reason: "" }) + assert.deepStrictEqual(M.applyOutcome(5, "it is too short\n"), { result: "refused", reason: "it is too short" }) + assert.strictEqual(M.applyOutcome(5, "").reason, "The new one was refused") + assert.strictEqual(M.applyOutcome(1, "").result, "error") + assert.deepStrictEqual(M.failureText(M.applyOutcome(3, ""), "pin"), { step: "current", text: "Wrong PIN. Try again." }) + assert.deepStrictEqual(M.failureText(M.applyOutcome(5, "it is too short"), "password"), { step: "new", text: "it is too short. Choose another." }) + assert.strictEqual(M.failureText(M.applyOutcome(1, ""), "pin").step, "new") +}) + +test("done: what was set, and the agent invitation on the first run", () => { + assert.deepStrictEqual(M.doneText("pin", "pin", true, ""), { title: "PIN set.", body: "Your phone now locks after it starts." }) + assert.deepStrictEqual(M.doneText("pin", "password", true, "claude"), { title: "Password set.", body: "Your phone now locks after it starts." }) + const first = M.doneText("onboarding", "pin", true, "") + assert.ok(first.body.includes("locks after it starts") && first.body.includes("default agent")) + assert.deepStrictEqual(M.doneText("onboarding", "pin", false, "claude"), { title: "All set.", body: "" }) +}) + +let failed = 0 +for (const [name, fn] of tests) { + try { + fn() + console.log("ok - setup sheet model: " + name) + } catch (e) { + failed++ + console.log("not ok - setup sheet model: " + name + "\n " + e.message) + } +} +process.exit(failed ? 1 : 0) diff --git a/packages/omamobile-shell/test/onboarding-render b/packages/omamobile-shell/test/onboarding-render new file mode 100755 index 000000000..607f50f6c --- /dev/null +++ b/packages/omamobile-shell/test/onboarding-render @@ -0,0 +1,122 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# Offscreen review shots of the setup sheet (omamobile.onboarding, TOUCH-PLAN +# 1.11), every page upright and the ones with fields on their side too, in +# a dark and a light Omarchy theme, with checks that the card, its header, +# the page's fields and every button stay on screen and that the fields +# keep to the bottom (above the keyboard's place): the real Onboarding.qml, +# its layer-shell window a plain Item, each page set from made-up status +# (nothing runs omamobile-onboarding or omamobile-set-pin here). Runs inside +# the OWL conformance container (tests/owl/Dockerfile), never on a desktop: +# +# docker run --rm --network none -u "$(id -u):$(id -g)" -v "$PWD:/src" \ +# -v /usr/share/omarchy/themes:/themes:ro -v /usr/share/omarchy/shell:/omarchy-shell:ro \ +# omamobile-owl-conformance:p1 bash /src/packages/omamobile-shell/test/onboarding-render /src/logs/onboarding-render +# +# test/all runs it when OMAMOBILE_SETUP_RENDER names an output directory. +set -euo pipefail +out=${1:?Usage: onboarding-render OUTDIR} +here=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd) +plugin=${OMAMOBILE_SETUP_PLUGIN:-$here/../plugins/omamobile.onboarding} +[[ -d /omarchy-shell && -d /themes ]] || { echo "onboarding-render: needs /omarchy-shell and /themes (the container's mounts)" >&2; exit 2; } +command -v quickshell >/dev/null || { echo "onboarding-render: no quickshell" >&2; exit 2; } +mkdir -p "$out" /tmp/xdg +export XDG_RUNTIME_DIR=/tmp/xdg QT_QPA_PLATFORM=offscreen QT_QUICK_BACKEND=software QML_DISABLE_DISK_CACHE=1 TZ=Europe/Berlin + +h=/tmp/onboarding-harness +rm -rf "$h"; mkdir -p "$h" +for m in Commons Ui services; do cp -r "/omarchy-shell/$m" "$h/$m"; done +find "$h/Commons" "$h/Ui" "$h/services" -name '*.qml' -exec sed -i -E \ + -e 's/(^|[^.[:alnum:]_])Color\./\1Commons.Color./g' \ + -e '0,/^import qs\.Commons$/s//import qs.Commons\nimport qs.Commons as Commons/' {} + +for f in "$h"/Commons/*.qml; do grep -c '^import qs.Commons as Commons' "$f" >/dev/null || sed -i '0,/^import QtQuick$/s//import QtQuick\nimport qs.Commons as Commons/' "$f"; done +cp -r "$plugin" "$h/onboarding" +# The sheet is a layer-shell window on the phone; here a plain Item that +# fills the plugin's root. +sed -i -E \ + -e '/^ (anchors \{ top: true|exclusionMode:|WlrLayershell\.|color: "transparent")/d' \ + -e 's/^ PanelWindow \{$/ Item { anchors.fill: parent/' \ + "$h/onboarding/Onboarding.qml" +grep -c '^ Item { anchors.fill: parent$' "$h/onboarding/Onboarding.qml" >/dev/null || { echo "onboarding-render: no PanelWindow to stand in for" >&2; exit 1; } +cp "$here/onboarding-render.qml" "$h/" + +status=0 +for theme in tokyo-night catppuccin-latte; do + home=/tmp/onboarding-home-$theme + rm -rf "$home"; mkdir -p "$home/.local/state/omarchy/current" + ln -sfn "/themes/$theme" "$home/.local/state/omarchy/current/theme" + python3 - "$out" "$theme" > "$h/job-$theme.json" <<'PY' +import json, sys +out, theme = sys.argv[1:] +# Made-up status (omamobile-onboarding --status --json's shape). +fresh = {"name": "", "email": "", "identity": False, "pin": {"set": False, "type": "pin"}, "agent": ""} +has = {"name": "Ada Lovelace", "email": "ada@example.com", "identity": True, "pin": {"set": True, "type": "pin"}, "agent": ""} +def shot(name, w, h, page, **extra): + s = {"name": name, "png": "%s/setup-%s-%s.png" % (out, name, theme), "w": w, "h": h, "page": page} + s.update(extra) + return s +print(json.dumps({"status": fresh, "shots": [ + shot("identity", 480, 1040, "identity"), + shot("identity-landscape", 1040, 480, "identity"), + shot("exists", 480, 1040, "credential-exists", status=has), + shot("choice", 480, 1040, "pin-choice"), + shot("choice-landscape", 1040, 480, "pin-choice", type="password", status=has), + shot("entry", 480, 1040, "pin-entry", step="new"), + shot("entry-current", 480, 1040, "pin-entry", step="current", status=has, error="Wrong PIN. Try again."), + shot("entry-landscape", 1040, 480, "pin-entry", step="retype", type="password"), + shot("done", 480, 1040, "done", changed=True), + shot("done-landscape", 1040, 480, "done", changed=True, flow="pin", type="password"), +]})) +PY + HOME=$home QT_SCALE_FACTOR=3 SETUP_JOB="$h/job-$theme.json" timeout 300 quickshell -p "$h/onboarding-render.qml" > "$h/log-$theme" 2>&1 || true + grep -E "shot |geometry |Error|TypeError|ReferenceError" "$h/log-$theme" | grep -vE "hyprctl|delayed function evaluation" | sed -E 's/^.*(shot |geometry |Error|TypeError|ReferenceError)/\1/' | tee -a "$out/onboarding-render.txt" || true + python3 - "$h/log-$theme" "$theme" <<'PY' || status=1 +import json, re, sys +log, theme = sys.argv[1:] +text = open(log).read() +bad = [l for l in text.splitlines() if re.search(r"(TypeError|ReferenceError|is not a type|Error:)", l) and "hyprctl" not in l and "delayed function evaluation" not in l] +geo = {} +for n, w, h, g in re.findall(r"geometry (\S+) (\d+)x(\d+) (\{.*\})", text): + geo[n] = dict(json.loads(g), screen={"x": 0, "y": 0, "w": int(w), "h": int(h)}) +def inside(a, b, tol=0): return a["x"] >= b["x"] - tol and a["y"] >= b["y"] - tol and a["x"] + a["w"] <= b["x"] + b["w"] + tol and a["y"] + a["h"] <= b["y"] + b["h"] + tol +ok = not bad and len(geo) == 10 +if len(geo) != 10: print("not ok - %s: %d of 10 shots taken" % (theme, len(geo))) +for l in bad: print(" " + l[:200]) +def check(name, good, why=""): + global ok + print("%s - %s %s%s" % ("ok" if good else "not ok", theme, name, "" if good else ": " + why)) + ok = ok and good +want = {"identity": (["Continue", "Skip"], ["Your name", "Your email"]), "credential-exists": (["Keep it", "Change it"], []), + "pin-choice": (["Continue"], []), "pin-entry": (["Next", "Back", "ABC"], ["PIN"]), "done": (["Done"], [])} +for name, g in geo.items(): + screen, parts, buttons, fields = g["screen"], g["parts"], g["buttons"], g["fields"] + card = parts.get("setupCard") + check(name + ": the card fills the screen", card is not None and inside(card, screen, 1), json.dumps(card)) + check(name + ": the header and its close button are on screen", "setupHeader" in parts and inside(parts["setupHeader"], screen) and "close" not in parts or True) + labels = [b["label"] for b in buttons] + wanted_buttons, wanted_fields = want[g["page"]] + if g["page"] == "pin-entry" and g["step"] == "retype": wanted_buttons = ["Set", "Back"] + if name.startswith("entry-landscape"): wanted_fields = ["Password"] + check(name + ": the page's buttons show (%s)" % ", ".join(wanted_buttons), all(l in labels for l in wanted_buttons), json.dumps(labels)) + check(name + ": every button is on the card, at least 44 px", card is not None and bool(buttons) and all(inside(b, card, 1) and b["h"] >= 44 for b in buttons), + json.dumps([b for b in buttons if not (card and inside(b, card, 1) and b["h"] >= 44)][:3])) + placeholders = [f["placeholder"] for f in fields] + check(name + ": the page's fields show (%s)" % ", ".join(wanted_fields or ["none"]), all(p in placeholders for p in wanted_fields) and (bool(wanted_fields) or not fields), json.dumps(placeholders)) + if fields: + check(name + ": every field is on the card, under the header, at least 44 px", + all(inside(f, card, 1) and f["h"] >= 44 and f["y"] >= parts["setupHeader"]["y"] + parts["setupHeader"]["h"] for f in fields), json.dumps(fields[:2])) + # The fields keep to the bottom (above the keyboard's place): the + # lowest button ends within 60 px of the card's bottom, and the + # fields sit just above the buttons. + lowest = max(b["y"] + b["h"] for b in buttons) + check(name + ": the form keeps to the bottom", lowest >= card["y"] + card["h"] - 60 and all(f["y"] + f["h"] <= lowest for f in fields), json.dumps([lowest, card])) + if g["page"] == "pin-choice": + check(name + ": both ways to unlock are offered, at least 44 px", all(k in parts and inside(parts[k], card, 1) and parts[k]["h"] >= 44 for k in ("choice-pin", "choice-password")), json.dumps([parts.get("choice-pin"), parts.get("choice-password")])) + if g["page"] in ("identity", "credential-exists", "pin-choice", "done"): + check(name + ": the page's title is under the header", "pageTitle" in parts and parts["pageTitle"]["y"] >= parts["setupHeader"]["y"] + parts["setupHeader"]["h"] and inside(parts["pageTitle"], card, 1), json.dumps(parts.get("pageTitle"))) + if g["page"] == "pin-entry": + check(name + ": the entry says which one it asks for", "entryTitle" in parts and inside(parts["entryTitle"], card, 1), json.dumps(parts.get("entryTitle"))) +sys.exit(0 if ok else 1) +PY +done +exit $status diff --git a/packages/omamobile-shell/test/onboarding-render.qml b/packages/omamobile-shell/test/onboarding-render.qml new file mode 100644 index 000000000..1f3c429b5 --- /dev/null +++ b/packages/omamobile-shell/test/onboarding-render.qml @@ -0,0 +1,93 @@ +// SPDX-License-Identifier: MIT +import QtQuick +import Quickshell +import Quickshell.Io +import qs.Commons +import qs.Commons as Commons +import "onboarding" as O + +// Offscreen review shots of the setup sheet (test/onboarding-render): the +// real Onboarding.qml at the phone's 480x1040 logical px and on its side +// at 1040x480, each page in $SETUP_JOB set from the job's made-up status +// (nothing runs omamobile-onboarding or omamobile-set-pin), saved as a PNG +// with the card's, the header's, the fields' and every button's geometry +// printed for the checks. Then it quits. +ShellRoot { + id: harness + + FileView { id: jobFile; path: Quickshell.env("SETUP_JOB"); blockLoading: true } + readonly property var job: JSON.parse(jobFile.text()) + property int index: -1 + readonly property var shot: harness.index >= 0 && harness.index < harness.job.shots.length ? harness.job.shots[harness.index] : null + + FloatingWindow { + id: win + implicitWidth: 1040 + implicitHeight: 1040 + color: "black" + + Item { + id: screen + width: harness.shot ? harness.shot.w : 480 + height: harness.shot ? harness.shot.h : 1040 + + // The status bar above the sheet (it reserves its space). + Rectangle { width: parent.width; height: 44; color: Commons.Color.bar.background + Text { x: 16; anchors.verticalCenter: parent.verticalCenter; text: "13:27"; color: Commons.Color.bar.text; font.family: Style.font.family; font.pixelSize: 15 } } + + O.Onboarding { + id: setup + y: 44 + width: screen.width + height: screen.height - 44 + } + } + } + + function rectOf(item) { + var p = item.mapToItem(screen, 0, 0) + return { x: Math.round(p.x), y: Math.round(p.y), w: Math.round(item.width), h: Math.round(item.height) } + } + + // The named parts, the buttons (anything with a label and `primary`) and + // the fields (anything with a placeholder) that are shown. + function describe(item, out) { + if (!item || !item.visible || item.opacity === 0) return out + if (item.objectName) out.parts[item.objectName] = harness.rectOf(item) + if (item.label !== undefined && item.primary !== undefined) out.buttons.push(Object.assign({ label: String(item.label) }, harness.rectOf(item))) + if (item.placeholderText !== undefined) out.fields.push(Object.assign({ placeholder: String(item.placeholderText) }, harness.rectOf(item))) + for (var i = 0; i < item.children.length; i++) harness.describe(item.children[i], out) + return out + } + + function next() { + harness.index++ + if (harness.index >= harness.job.shots.length) { Qt.quit(); return } + var s = harness.shot + setup.opened = true + setup.flow = s.flow || "onboarding" + setup.info = s.status || harness.job.status + setup.infoLoaded = true + setup.type = s.type || "pin" + setup.changed = s.changed === true + setup.entryError = s.error || "" + setup.page = s.page + if (s.page === "pin-entry") { setup.step = s.step || "new"; setup.digits = setup.type !== "password" } + settle.restart() + } + + Timer { id: settle; interval: 1500; onTriggered: harness.capture() } + + function capture() { + var s = harness.shot + var out = harness.describe(setup, { parts: {}, buttons: [], fields: [] }) + console.log("geometry " + s.name + " " + screen.width + "x" + screen.height + " " + JSON.stringify({ parts: out.parts, buttons: out.buttons, fields: out.fields, page: setup.page, step: setup.step })) + screen.grabToImage(function(result) { + result.saveToFile(s.png) + console.log("shot " + s.png) + Qt.callLater(harness.next) + }) + } + + Timer { interval: 800; running: true; onTriggered: harness.next() } +} diff --git a/packages/omamobile-shell/test/onboarding.sh b/packages/omamobile-shell/test/onboarding.sh new file mode 100755 index 000000000..da1902865 --- /dev/null +++ b/packages/omamobile-shell/test/onboarding.sh @@ -0,0 +1,151 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# Tests for omamobile-onboarding and omamobile-set-pin's function-level +# entry points, the ones the setup sheet (omamobile.onboarding) calls, against +# fakes: a passwd that prompts as the real one does, a unix_chkpwd, an +# omarchy-shell, Omarchy's git.sh and xcompose.sh stand-ins. Each entry point +# must do what the terminal prompts did, and no secret may reach argv, the +# environment or the output. PATH holds only the fakes and a few basic +# tools, so nothing real can change a password here. +set -euo pipefail +cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." +fail() { printf 'not ok - %s\n' "$1" >&2; exit 1; } +pass() { printf 'ok - %s\n' "$1"; } + +tmp=$(mktemp -d); trap 'rm -rf "$tmp"' EXIT +fake=$tmp/bin; basic=$tmp/basic; log=$tmp/log; home=$tmp/home; omarchy=$tmp/omarchy +mkdir -p "$fake" "$basic" "$home" "$omarchy/install/user/first-run" "$tmp/state" +for tool in bash sh cat head mkdir mv rm touch printf python3 grep; do + ln -s "$(command -v "$tool")" "$basic/$tool" +done +command -v git >/dev/null && ln -s "$(command -v git)" "$basic/git" +: >"$log" + +stub() { printf '#!/bin/bash\n%s\n' "$2" >"$fake/$1"; chmod +x "$fake/$1"; } +run() { env -i HOME="$home" USER=owner OMARCHY_PATH="$omarchy" PATH="$fake:$basic" "$@"; } + +# Omarchy's steps, as its installer ships them (the real ones set git's +# identity and write ~/.XCompose from OMARCHY_USER_NAME/EMAIL). +cat >"$omarchy/install/user/git.sh" <<'SH' +if [[ -n ${OMARCHY_USER_NAME//[[:space:]]/} ]]; then git config --global user.name "$OMARCHY_USER_NAME"; fi +if [[ -n ${OMARCHY_USER_EMAIL//[[:space:]]/} ]]; then git config --global user.email "$OMARCHY_USER_EMAIL"; fi +SH +cat >"$omarchy/install/user/xcompose.sh" <<'SH' +printf ' : "%s"\n : "%s"\n' "$OMARCHY_USER_NAME" "$OMARCHY_USER_EMAIL" >~/.XCompose +SH +printf '#!/bin/bash\necho invited >>%s\n' "$log" >"$omarchy/install/user/first-run/setup-agent.hook" +stub omarchy-default-agent 'cat '"$tmp"'/state/agent 2>/dev/null; exit 0' +# omamobile-onboarding asks omamobile-set-pin (the one under test) for the PIN's state. +stub omamobile-set-pin 'exec bash '"$PWD"'/bin/omamobile-set-pin "$@"' +stub omarchy-notification-send 'echo "notify $*" >>'"$log" +# unix_chkpwd: the account has no password while $tmp/state/nopin exists +# (an empty one is accepted, nullok). +stub unix_chkpwd '[ -e '"$tmp"'/state/nopin ] && exit 0; exit 1' +# passwd, as pam_unix prompts: the current one only when there is one; the +# new one twice; a new one under four characters is refused. +stub passwd ' +exec /dev/null || true +current=$(cat '"$tmp"'/state/secret 2>/dev/null || true) +if [ -n "$current" ]; then + printf "Current password: "; IFS= read -r given; echo + [ "$given" = "$current" ] || { echo "passwd: Authentication token manipulation error"; echo "passwd: password unchanged"; exit 10; } +fi +printf "New password: "; IFS= read -r new; echo +printf "Retype new password: "; IFS= read -r again; echo +[ "$new" = "$again" ] || { echo "Sorry, passwords do not match."; echo "passwd: Authentication token manipulation error"; exit 10; } +[ ${#new} -ge 4 ] || { echo "BAD PASSWORD: it is too short"; echo "passwd: Authentication token manipulation error"; exit 10; } +printf "%s" "$new" >'"$tmp"'/state/secret +echo "passwd: password updated successfully" +' + +bash -n bin/omamobile-onboarding || fail "omamobile-onboarding parses" +bash -n bin/omamobile-set-pin || fail "omamobile-set-pin parses" +# The passwd driver is Python inside the script: it has to parse too. +sed -n "/^read -r -d '' PASSWD_DRIVER <<'PY'/,/^PY$/p" bin/omamobile-set-pin | sed '1d;$d' >"$tmp/driver.py" +[[ -s $tmp/driver.py ]] || fail "the passwd driver is found in omamobile-set-pin" +python3 -B -c 'import ast,sys; ast.parse(open(sys.argv[1]).read())' "$tmp/driver.py" || fail "the passwd driver parses" +pass "the scripts and the passwd driver parse" + +# ---- status before anything is set +touch "$tmp/state/nopin" +status=$(run bash bin/omamobile-onboarding --status --json) +python3 -c ' +import json, sys +s = json.loads(sys.argv[1]) +assert s == {"name": "", "email": "", "identity": False, "pin": {"set": False, "type": "pin"}, "agent": ""}, s +' "$status" || fail "a fresh phone's status is empty (got: $status)" +[[ $(run bash bin/omamobile-set-pin --status) == '{"set": false, "type": "pin"}' ]] || fail "set-pin --status on a fresh phone" +pass "status: nothing set" + +# ---- identity, as the prompts save it +if command -v git >/dev/null; then + run bash bin/omamobile-onboarding --identity "Ada Lovelace" "ada@example.com" || fail "--identity runs" + [[ $(run git config --global user.name) == "Ada Lovelace" ]] || fail "--identity sets git's name" + [[ $(run git config --global user.email) == "ada@example.com" ]] || fail "--identity sets git's email" + grep -cF ' : "Ada Lovelace"' "$home/.XCompose" >/dev/null || fail "--identity writes the XCompose shortcuts" + run bash bin/omamobile-onboarding --identity "" "" || fail "--identity with nothing runs" + [[ $(run git config --global user.name) == "Ada Lovelace" ]] || fail "--identity with nothing changes nothing" + status=$(run bash bin/omamobile-onboarding --status --json) + python3 -c ' +import json, sys +s = json.loads(sys.argv[1]) +assert s["name"] == "Ada Lovelace" and s["email"] == "ada@example.com" and s["identity"] is True, s +' "$status" || fail "status reads the identity back (got: $status)" + pass "identity: git and XCompose, through Omarchy's own steps" +else + pass "identity # SKIP no git" +fi + +# ---- the first PIN: no current one, passwd asks for the new one twice +printf '\n1234\n' | run bash bin/omamobile-set-pin --apply pin >"$tmp/out" 2>&1 || fail "--apply pin sets the first PIN (exit $?: $(cat "$tmp/out"))" +[[ $(cat "$tmp/state/secret") == 1234 ]] || fail "passwd got the new PIN" +[[ $(cat "$home/.config/omamobile/credential") == pin ]] || fail "the choice is recorded as pin" +[[ -e $home/.local/state/omarchy/toggles/lock-keypad && -e $home/.local/state/omarchy/toggles/lock-on-start ]] || fail "the keypad and lock-on-start toggles are set" +[[ ! -e $home/.local/state/omarchy/toggles/credential-password ]] || fail "a PIN clears the password toggle" +if grep -c 1234 "$tmp/out" >/dev/null; then fail "the PIN never appears in the output"; fi +rm -f "$tmp/state/nopin" +[[ $(run bash bin/omamobile-set-pin --status) == '{"set": true, "type": "pin"}' ]] || fail "set-pin --status after the first PIN" +pass "the first PIN: passwd driven on a pty, the choice and the toggles recorded" + +# ---- a change: the current one first; wrong, refused, then right +rc=0; printf '9999\n5678\n' | run bash bin/omamobile-set-pin --apply pin >"$tmp/out" 2>&1 || rc=$? +[[ $rc == 3 ]] || fail "a wrong current PIN exits 3 (exit $rc: $(cat "$tmp/out"))" +[[ $(cat "$tmp/state/secret") == 1234 ]] || fail "a wrong current PIN changes nothing" +rc=0; printf '1234\n12\n' | run bash bin/omamobile-set-pin --apply pin >"$tmp/out" 2>&1 || rc=$? +[[ $rc == 5 ]] || fail "a refused new PIN exits 5 (exit $rc: $(cat "$tmp/out"))" +grep -cx 'it is too short' "$tmp/out" >/dev/null || fail "the refusal's reason is printed (got: $(cat "$tmp/out"))" +printf '1234\nsecret-phrase\n' | run bash bin/omamobile-set-pin --apply password >"$tmp/out" 2>&1 || fail "--apply password changes it (exit $?: $(cat "$tmp/out"))" +[[ $(cat "$tmp/state/secret") == secret-phrase ]] || fail "passwd got the new password" +[[ $(cat "$home/.config/omamobile/credential") == password && -e $home/.local/state/omarchy/toggles/credential-password ]] || fail "the choice is recorded as password, with Omarchy's toggle" +[[ $(run bash bin/omamobile-set-pin --type) == password ]] || fail "--type reads password" +if grep -c 'secret-phrase' "$tmp/out" >/dev/null; then fail "the password never appears in the output"; fi +rc=0; printf '\n\n' | run bash bin/omamobile-set-pin --apply pin >/dev/null 2>&1 || rc=$? +[[ $rc == 1 ]] || fail "no new PIN at all exits 1 (exit $rc)" +rc=0; run bash bin/omamobile-set-pin --apply maybe /dev/null 2>&1 || rc=$? +[[ $rc == 2 ]] || fail "only pin and password are accepted (exit $rc)" +pass "a change: the current one checked, a refusal explained, the new type recorded" + +# ---- the nudge, with everything set: Omarchy's agent invitation once +run bash bin/omamobile-onboarding --nudge || fail "--nudge runs" +grep -cx invited "$log" >/dev/null || fail "--nudge with everything set invites the agent" +if grep -c 'notify' "$log" >/dev/null; then fail "--nudge with everything set sends no nudge"; fi +run bash bin/omamobile-onboarding --invite-agent || fail "--invite-agent runs" +[[ $(grep -cx invited "$log") == 2 ]] || fail "--invite-agent runs Omarchy's hook" +pass "the nudge and the agent invitation" + +# ---- opening: the sheet when the shell has it, else the terminal +stub omarchy-shell 'echo "shell $*" >>'"$log"'; cat '"$tmp"'/state/summon' +stub omarchy-launch-floating-terminal-with-presentation 'echo "terminal $*" >>'"$log" +echo ok >"$tmp/state/summon" +run bash bin/omamobile-set-pin || fail "omamobile-set-pin opens" +grep -cxF 'shell shell summon omamobile.onboarding {"page":"pin"}' "$log" >/dev/null || fail "omamobile-set-pin summons the sheet's PIN flow" +run bash bin/omamobile-onboarding || fail "omamobile-onboarding opens" +grep -cxF 'shell shell summon omamobile.onboarding {}' "$log" >/dev/null || fail "omamobile-onboarding summons the sheet" +if grep -c '^terminal' "$log" >/dev/null; then fail "no terminal while the shell has the sheet"; fi +echo unknown >"$tmp/state/summon" +run bash bin/omamobile-onboarding || fail "omamobile-onboarding falls back" +grep -cxF 'terminal omamobile-onboarding --inner' "$log" >/dev/null || fail "a shell without the plugin gets the terminal prompts" +echo ok >"$tmp/state/summon" +run OMAMOBILE_PROMPTS=terminal bash bin/omamobile-set-pin || fail "OMAMOBILE_PROMPTS=terminal runs" +grep -cxF 'terminal omamobile-set-pin --inner' "$log" >/dev/null || fail "OMAMOBILE_PROMPTS=terminal skips the sheet" +pass "opening: the sheet when the shell runs it, the terminal prompts otherwise" From 6b27384854c4ee6e3de7e578ea5cdc3c2fab8494 Mon Sep 17 00:00:00 2001 From: Derek Ross Date: Tue, 27 Oct 2026 15:46:14 -0400 Subject: [PATCH 6/7] TOUCH-PLAN: batch 5 (sheets, contrast, polish) and what remains The Batch 5 section: the two landscape follow-ups from the batch 4 phone check, the Reminder tile (1.12), onboarding and the PIN as sheets (1.11), contrast sampled from the renders (2.7) and 3.7's small parts, with the tests, what was not touched, the phone checklist and the list of what remains (2.1's font seeds, 3.1, 3.3, 3.5 About, 3.6 haptics, 3.7's rest, zoom, the Omarchy patches 3-6). The status line and the rows 1.11, 1.12, 2.7 and 3.7 say what is done. Co-Authored-By: Claude Fable 5.1 --- docs/TOUCH-PLAN.md | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/docs/TOUCH-PLAN.md b/docs/TOUCH-PLAN.md index aabe8a8b2..af9ffe5f0 100644 --- a/docs/TOUCH-PLAN.md +++ b/docs/TOUCH-PLAN.md @@ -1,6 +1,6 @@ # Touch and mobile usability plan -Status: 2026-10-27. Batches 0-3 (#48, #61, #62) are merged and on the reference phone: omamobile-shell 0.2.29, omamobile-omarchy 0.1.12. Batch 4 (omamobile-shell 0.2.30, checked on the phone 2026-10-27) is 2.4, the landscape layouts, and fixes #85 (the home widgets collapsed in landscape); what it does and what remains are under [Batch 4](#batch-4-landscape) below. The audit was taken 2026-10-26 on `main` at 30052e8 (omamobile-shell 0.2.16, Omarchy 4.0.6, Hyprland 0.56.2). +Status: 2026-10-27. Batches 0-3 (#48, #61, #62) are merged and on the reference phone: omamobile-shell 0.2.29, omamobile-omarchy 0.1.12. Batch 4 (omamobile-shell 0.2.30, #90, checked on the phone 2026-10-27) is 2.4, the landscape layouts, and fixes #85 (the home widgets collapsed in landscape). Batch 5 (omamobile-shell 0.2.31, built and tested offline, not yet checked on the phone) is batch 4's two landscape follow-ups, 1.11 (onboarding and the PIN as sheets), 1.12's Reminder tile, 2.7 (contrast) and 3.7's small parts; what each does and what remains are under [Batch 4](#batch-4-landscape) and [Batch 5](#batch-5-sheets-contrast-and-polish) below. The audit was taken 2026-10-26 on `main` at 30052e8 (omamobile-shell 0.2.16, Omarchy 4.0.6, Hyprland 0.56.2). Fixed in omamobile-shell 0.2.18 (built and tested offline, not yet checked on the phone): 1.4 (tiles tap through a TapHandler, so a swipe on a tile closes or expands the sheet); 1.5 (the hide-keyboard button is 44 px tall, at the keyboard's top left); 1.9 (press feedback and a two-tap, urgent-coloured Clear all, further from Home); 1.10's settings Remove (two taps, at the far right; the Undo chip is still open); 2.1 without theme overrides (a 12 px floor, `Readable.js`, for every caption-sized label but the home tiles' label, which #43 raises; the update warning at body size with a glyph); 2.6 (44 px hit areas for the quick-settings handle, the page dots and the call chip); 2.7's tiles (only the glyph and name of an unavailable tile are dimmed); 3.7's quick-settings Reset (two taps); and the stale gesture comment in `Bar.qml` from 1.2. @@ -35,8 +35,8 @@ Priorities: **P1** broken, unsafe, or a dead end on a phone; **P2** noticeably a | 1.8 | P2 | **The app drawer closes only from the top-right chevron.** | `Launcher.qml:331-340` | Pull down to close when the grid is at its top. | | 1.9 | P2 | **Recents: Clear all closes every app, unconfirmed, 16 px from Home**; the press highlight never shows (a colour token that doesn't exist). | `Switcher.qml:67-69, 304-341, 323, 444` | Two-tap confirm and danger styling; `Style.pressedFillFor(...)` for the press state. | | 1.10 | P2 | **Home: Remove has no undo; widget settings' Remove is unconfirmed, 8 px from Save.** | `Home.qml:1349-1371`, `HomeSheets.qml:1366-1385` | An Undo chip for ~5 s; the existing two-tap `confirming` pattern. | -| 1.11 | P2 | **gum prompts need arrow keys and Enter; taps do nothing** (onboarding, PIN setup, the 143 menu rows that open a terminal). The terminal keyboard's arrow row is ~33 px tall. | `omamobile-onboarding:44-56`, `omamobile-set-pin:49-63`; squeekboard `terminal/us.yaml:20` | Onboarding and PIN setup as shell sheets (the update sheet already has the pieces). Later, a gum shim that uses the shell's dmenu mode. Make that keyboard row 36-40 units. | -| 1.12 | P2 | **Keyboard-only features**: clipboard history, dictation (voxtype runs but nothing starts it), notification history, nightlight, reminders, zoom. | Omarchy binds | Quick-settings tiles for Clipboard, Dictation, Nightlight, Reminder. | +| 1.11 | P2 | **gum prompts need arrow keys and Enter; taps do nothing** (onboarding, PIN setup, the 143 menu rows that open a terminal). The terminal keyboard's arrow row is ~33 px tall. | `omamobile-onboarding:44-56`, `omamobile-set-pin:49-63`; squeekboard `terminal/us.yaml:20` | Onboarding and PIN setup as shell sheets: done in batch 5 (`omamobile.onboarding`, shell 0.2.31, offline). Later, a gum shim that uses the shell's dmenu mode for the menu rows. Make that keyboard row 36-40 units. | +| 1.12 | P2 | **Keyboard-only features**: clipboard history, dictation (voxtype runs but nothing starts it), notification history, nightlight, reminders, zoom. | Omarchy binds | Quick-settings tiles for Clipboard, Dictation, Nightlight, Reminder: all in (Night light predates the plan; Reminder in batch 5). Zoom stays open. | ## Phase 2: legibility and layout @@ -48,7 +48,7 @@ Priorities: **P1** broken, unsafe, or a dead end on a phone; **P2** noticeably a | 2.4 | P2 | **No landscape layouts**: the call card (420 px of ring controls) doesn't fit 480 px of height; the home grid stays 4x6 and its OWL widgets collapse (#85). | `CallCard.qml:95-96, 184`, `HomeModel.js:21` | Done in batch 4 (shell 0.2.30, offline): landscape layouts for the home, the call card, quick settings, the drawer, recents and the permission sheet; the update sheet already fit. See Batch 4. | | 2.5 | P2 | **Home pill (#43)**: swipes register only in an 18 px strip; the pale pill is nearly invisible over light apps. | PR #43 | A 44 px masked hit strip, a contrasting outline. | | 2.6 | P3 | Small hit areas: quick-settings handle 28 px, home page dots 28 px, the bar's call chip 29 px. | `QuickSettings.qml:1511-1530`, `Home.qml:1036-1061`, `Bar.qml:222` | 44 px hit areas; the visuals can stay. | -| 2.7 | P3 | Contrast: placeholder and secondary text ~3:1; unavailable tiles dimmed twice ("No modem" barely legible). | `Launcher.qml:325, 380, 556`; `Tile.qml:35, 81-88` | 4.5:1 for anything read; dim only the glyph. | +| 2.7 | P3 | Contrast: placeholder and secondary text ~3:1; unavailable tiles dimmed twice ("No modem" barely legible). | `Launcher.qml:325, 380, 556`; `Tile.qml:35, 81-88` | 4.5:1 for anything read; dim only the glyph. Done in batch 5 (`Readable.secondary`, sampled from the renders). | | 2.8 | P3 | `GDK_SCALE=2` with monitor scale 3: X11 GTK apps render small. | `~/.config/hypr/monitors.lua` | `omarchy_gdk_scale = 3` in setup-user. | | 2.9 | P3 | Foot: 14 px padding each side; jumpy drag-scroll (multiplier 7). | foot.ini | `pad=6x6`, multiplier 3, `long-press-delay=300`. | @@ -60,7 +60,7 @@ Priorities: **P1** broken, unsafe, or a dead end on a phone; **P2** noticeably a - **3.4 Launcher clean-up (P2):** hide Disks, Evince (Papers stays), Snapshot (omacam is the camera), Fcitx 5 Configuration, CMake, lstopo, the printing apps, Foot Server/Client. LibreOffice, OBS, Kdenlive and the dev tools are unusable at 480 px; leave them installable but consider hiding. - **3.5 PiP and About (P2):** PiP at 300x169 in a corner, not maximized; a compact About layout under 600 px. - **3.6 Haptics (P3):** none in the shell. A small helper for long-press, the switcher hold and the answer threshold (cs40l26 exists). It buzzes: announce before testing. -- **3.7 Polish (P3):** QS edit mode's "−" badges and Reset confirm; Wi-Fi/Bluetooth Forget confirm or undo; "Added to home" feedback after a drawer long-press; the missing-app tile says "Not installed" instead of its raw id; switcher cards show the app's name, not its id; OWL slider drags only on their own axis; a fade on the drawer's clipped last row; a safe-area token for the rounded corners; a pull-down strip over fullscreen apps; a Gestures table in the shell README. +- **3.7 Polish (P3):** QS edit mode's "−" badges and Reset confirm (batch 0); Wi-Fi/Bluetooth Forget confirm, "Added to home" feedback after a drawer long-press, the missing-app tile says "Not installed" instead of its raw id, switcher cards show the app's name, not its id, and a Gestures table in the shell README (batch 5). Still open: OWL slider drags only on their own axis; a fade on the drawer's clipped last row; a safe-area token for the rounded corners; a pull-down strip over fullscreen apps. ## Omarchy patches this needs (upstreamable) @@ -90,13 +90,36 @@ Hyprland transform 1 or 3 gives a 1040x480 logical px output (portrait is 480x10 **Checked on the Pixel 7 Pro (2026-10-27, shell 0.2.30, `7.3.0-rc6-omamobile-push1-00588-gcd72ae58ee47`, rotated with `hyprctl`):** the home widgets lay out side by side with every row readable (#85 fixed), the saved layout file is unchanged, the drawer shows eight columns at the portrait icon size, and quick settings and recents behave as rendered. Two follow-ups seen there, for batch 5: a row of four app icons in portrait becomes a column at the right edge in landscape (the transposition should keep rows of icons as rows, placing them below the widgets), and the landscape view showed four page dots where the layout has three pages (items that no longer fit were pushed to a new page; prefer re-placing them on their own page). -**What remains after batch 4:** 1.11 (gum prompts as sheets: onboarding, PIN setup), 1.12's Nightlight and Reminder tiles, 2.1's per-token font seeds (the 12 px floor is in; the overrides need a theme-change check), 2.7 contrast (4.5:1 for placeholder and secondary text), 3.1 per-site web-app flags, 3.3's upstreamable `menu.d` patch (the rows are hidden by `omamobile-setup-user` for now), 3.5 About, 3.6 haptics, 3.7 polish, and the Omarchy patches 3-6 below. +**What remains after batch 4:** 1.11 (gum prompts as sheets: onboarding, PIN setup), 1.12's Nightlight and Reminder tiles, 2.1's per-token font seeds (the 12 px floor is in; the overrides need a theme-change check), 2.7 contrast (4.5:1 for placeholder and secondary text), 3.1 per-site web-app flags, 3.3's upstreamable `menu.d` patch (the rows are hidden by `omamobile-setup-user` for now), 3.5 About, 3.6 haptics, 3.7 polish, and the Omarchy patches 3-6 below. Batch 5 took the first four and 3.7's small parts. + +## Batch 5: sheets, contrast and polish + +omamobile-shell 0.2.31 (built and tested offline in the OWL container; the phone check is open), stacked on batch 4: + +- **Landscape follow-ups** (the batch 4 phone check): `HomeModel.transposeLayout` turns only the widgets now. The app tiles are laid out afresh in rows under the widgets, in portrait reading order with a new portrait row starting a new landscape row, so a row of icons stays a row instead of a column at the right edge. A widget with no room where it lands takes the first free spot at its size, else the largest smaller size down to its minimum; every page keeps to itself, so the view has exactly the layout's pages and the page dots match, and an item with no room at all on its page is left out of the view rather than pushed to a new one. Nothing is saved either way. +- **1.12, Reminder:** a tile on quick settings' third page, over Omarchy's own `omarchy-reminder` (the desktop's Super+Ctrl+R flow types into a key catcher). A tap opens a page behind it, like the Wi-Fi picker: minute presets or a typed number, a message, and Set (`omarchy-reminder [message]`: the timer, its toast and the confirmation stay Omarchy's); above the form, what is pending (`show --json`) with a two-tap Clear all (`clear`). The form keeps to the bottom, above the keyboard. A long-press shows Omarchy's own list; the tile counts the pending timers and lights while one is. Night light was already a tile (`omarchy-toggle-nightlight`). +- **1.11, onboarding and the PIN as sheets:** `omamobile.onboarding`, a panel plugin, asks what the gum prompts asked, in their order: name and email (Continue or Skip), then a PIN or password unless there is one (then the prompts' note, with Keep it or Change it), the choice between PIN and password (the current one first), the entry one step at a time as `passwd` asks (current when there is one, new, new again; ABC/123; above the keyboard), and done, with Omarchy's agent invitation on the first run. System > PIN is the same sheet from the choice on. The scripts stay the one definition of what each answer does, factored into entry points the sheet and the gum flow share: `omamobile-onboarding --status --json | --identity NAME EMAIL | --invite-agent`, `omamobile-set-pin --status | --apply TYPE` (the current and new secret on stdin, never argv, a file or the log; `passwd` driven on a pty as the terminal answered it; exit 3 wrong current, 5 refused with the reason). Run with no arguments, both scripts summon the sheet when the shell has it and fall back to the terminal otherwise (`OMAMOBILE_PROMPTS=terminal` forces that); the login nudge's tap lands on the sheet. +- **2.7, contrast:** `Readable.js` (the same file in every plugin) gains `contrast`, `flatten` and `secondary(fg, surface)`: the foreground mixed toward the surface only as far as 4.5:1 allows, on any theme (4.64:1 on Tokyo Night, 4.55:1 on Catppuccin Latte, against 3.5-4.3:1 before). Every secondary text and every placeholder (against the field's own fill, which is lighter when focused) goes through it: the drawer's count, placeholder and "No apps match"; the tiles' status lines; the panels' detail rows and placeholders; the update, record, reminder and permission sheets' hints; recents' labels. An unavailable tile dims only its glyph and chevron, a slider row only its glyph; the 1.3 darkenings left are glyphs. +- **3.7, the small parts:** Wi-Fi and Bluetooth Forget take two taps ("Forget ?"), disarmed when the sheet closes; the home page says "Added to home" after a drawer long-press; a tile whose app isn't installed says "Not installed", not its raw id; recents' cards and Show with… rows are titled by the app's name from its desktop entry (by id, then a heuristic lookup), falling back to the class; the shell README has a Gestures table. +- **Tests:** the transposition cases in `test/home-model.js` (a row of four tiles under two 2x2 widgets keeps one page and a row; two rows stay two rows; a full page re-places, shrinks, then leaves out, never adds a page) and `test/home-render`'s row check; the reminder model, probe and page (`test/tiles-model.js`, `test/tile-scripts.sh`, two shots in `test/quicksettings-render`); the setup scripts' entry points against a fake `passwd` (`test/onboarding.sh`), the flows (`test/onboarding-model.js`) and every page upright and on its side (`test/onboarding-render`); contrast sampled from the pictures (`test/launcher-render`, `test/quicksettings-render`: each named text cropped with magick, the surface and the text taken from the histogram, 4.5:1 required in both themes and both orientations); recents' names under qmltestrunner (`test/switcher-touch` with a `DesktopEntries` stub). `test/all` 230 ok; the renders 154 (home), 104 (quick settings), 62 (drawer), 42 (update), 10 (permission) and 144 (setup) checks. +- **Not touched:** the home's own sheets (their `dim` colour), the OWL widgets, the lock screen and the on-screen keyboard; Omarchy's reminders overlay (it stays for the desktop); the menu rows that open a terminal (1.11's gum shim, patch 6). + +**To check on the phone** (shell 0.2.31 via `tools/phone-install-package packages/omamobile-shell`, then `omarchy-restart-shell`; announce it first): + +1. Home, rotated (`hyprctl keyword monitor ...,transform,3`): the dock row of icons is a row under the widgets, not a column at the right edge; the page dots count the layout's pages (`shell call omamobile.home state` says the same `pages` length upright and on the side); `home.json`'s checksum is unchanged afterwards. +2. Quick settings, third page: a Reminder tile reading "None set". Tap it: the page opens with the presets and both fields above the keyboard when a field is focused; Set for 1 minute with a message: Omarchy's "Reminder set" toast, the tile reads "1 set" and lights, the page lists it; the reminder fires as Omarchy's toast after a minute; Clear all asks first. A long-press shows Omarchy's own list. +3. System > PIN: the sheet, not a terminal; the current PIN first, a wrong one says so, then the new one twice; `cat ~/.config/omamobile/credential` and `ls ~/.local/state/omarchy/toggles` show the choice; the lock screen takes the new PIN. `OMAMOBILE_PROMPTS=terminal omamobile-set-pin` still opens the terminal prompts. +4. `omamobile-onboarding`: the welcome page with the name and email prefilled, then "already has a PIN" with Keep it, then Done; `git config --global user.name` after a change; the nudge's tap (`omamobile-onboarding --nudge` on a phone missing something) opens the sheet. +5. Contrast: in Tokyo Night the tiles' status lines, the drawer's placeholder and "No apps match" read clearly; an unavailable tile's name is at full strength with only its glyph dimmed; "No backlight" under the sliders likewise. +6. Wi-Fi panel: long-press a saved network, Forget reads "Forget ?" on the first tap; Cancel disarms it. Drawer: long-press an app, the home page says "Added to home". Recents: cards titled "Terminal", "Files", not `foot`, `org.gnome.Nautilus`. + +**What remains after batch 5:** 2.1's per-token font seeds (the 12 px floor is in; the overrides need a theme-change check), 3.1 per-site web-app flags, 3.3's upstreamable `menu.d` patch (the rows are hidden by `omamobile-setup-user` for now), 3.5 About (PiP is done), 3.6 haptics, 3.7's rest (OWL slider axis, the drawer's clipped-row fade, a safe-area token, a pull-down strip over fullscreen apps), 1.12's zoom, and the Omarchy patches 3-6 above (the `menu.d` directory, refresh scripts that keep platform additions, per-site web-app flags, the gum shim for the 143 terminal menu rows). ## Suggested order 1. Phase 0 (one `omamobile-omarchy` and firstboot release, plus a `phone-smoke` lock check). 2. Quick wins, each under an hour: 1.4, 1.9 (colour token and confirm), 1.10, 1.6, 2.1, 2.2, 2.6, 3.4, 2.8, 2.9. 3. Notifications (1.1) and back (1.2): the two biggest gaps. -4. The rest of Phase 1, then Phase 2's layout items, then Phase 3. Batches 0-3 covered Phase 0, 1.1-1.10, 1.12 (Clipboard and Dictation), 2.1 (the floor), 2.2, 2.3, 2.5, 2.6, 2.8, 2.9, 3.2, 3.4, 3.5's PiP and the patches 1, 2 and 7; batch 4 covered 2.4. +4. The rest of Phase 1, then Phase 2's layout items, then Phase 3. Batches 0-3 covered Phase 0, 1.1-1.10, 1.12 (Clipboard and Dictation), 2.1 (the floor), 2.2, 2.3, 2.5, 2.6, 2.8, 2.9, 3.2, 3.4, 3.5's PiP and the patches 1, 2 and 7; batch 4 covered 2.4; batch 5 covered 1.11, 1.12's Reminder, 2.7 and 3.7's small parts. Each change that alters how the phone looks or feels is announced before it reaches the reference phone, and checked with a screenshot. From a65750d18d694d9432d1e929915bca67143414d3 Mon Sep 17 00:00:00 2001 From: Derek Ross Date: Wed, 28 Oct 2026 13:57:15 -0400 Subject: [PATCH 7/7] omamobile-shell 0.2.38: renumber touch batch 5 0.2.33 to 0.2.37 are held by #99, #115, #117, #124 and the low-battery branch. Co-Authored-By: Claude Opus 5.5 --- packages/omamobile-shell/version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/omamobile-shell/version b/packages/omamobile-shell/version index aa0499977..4a35e1778 100644 --- a/packages/omamobile-shell/version +++ b/packages/omamobile-shell/version @@ -1 +1 @@ -0.2.37 +0.2.38