Resize widgets by dragging handles on their edges

Holding a widget and letting go without moving now shows handles on its
right edge, bottom edge and corner (plus a Remove / Done bar). Dragging
them snaps the widget to whole grid columns and half rows, within the
provider's min/max resize size and resize mode, which the shell reports
through widgetLimits. Widgets keep their width in columns (0 = full row),
saved with the rest of the home screen.

The shell keeps the system's edge-swipe gestures off the handles and only
calls updateAppWidgetSize when a widget's size actually changes (with the
sizes list on Android 12+), not on every scroll.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PuFQh1zV94TcKboMuS7t35
This commit is contained in:
Claude committed 2026-10-21 23:46:31 +00:00
1 parent d8b51496ae
commit d7bd24b817
7 files changed
+267 -15

No files matched your search

+22 -1
View File
@@ -94,8 +94,29 @@ const BASE = process.env.BASE || "http://localhost:8000";
assert.equal(await p.$$eval(".slots > li", (ls) => ls.length), 5);
await p.click(".slots .tile:first-child"); await settle();
assert.equal(await p.textContent("#toast"), "Open com.example.gmail/.MainActivity");
// hold a widget without moving: resize handles; drag them to snap it to the grid
await longpress(".widget-slot");
await p.click(".sheet-item >> text=Remove widget"); await settle();
assert.ok(!(await p.$(".sheet")), "a widget gets handles, not the menu");
assert.ok(await p.$(".widget-slot.resizing .resize-handle[data-edge=rb]"));
const size = () => p.$eval(".widget-slot", (w) => [Math.round(w.getBoundingClientRect().width), Math.round(w.getBoundingClientRect().height)]);
const [w0] = await size();
const tile = await p.locator(".slots .tile").first().boundingBox();
const hd = await p.locator(".resize-handle[data-edge=rb]").boundingBox();
await p.mouse.move(hd.x + hd.width / 2, hd.y + hd.height / 2);
await p.mouse.down();
const ws = await p.locator(".widget-slot").boundingBox();
await p.mouse.move(ws.x + tile.width * 2.1, ws.y + 230, { steps: 8 }); await settle();
await p.mouse.up(); await settle();
const [w1, h1] = await size();
assert.ok(w1 < w0 && Math.abs(w1 - (2 * tile.width + 8)) < 3, `two columns wide: ${w1} (tile ${tile.width})`);
assert.equal(h1, 250, "snapped to half rows");
assert.ok(await p.$(".widget-slot.resizing"), "letting go of a handle keeps the handles");
await p.click(".resize-bar >> text=Done"); await settle();
assert.ok(!(await p.$(".resize-handle")));
await p.reload(); await p.waitForSelector(".widget-slot");
assert.deepEqual(await size(), [w1, h1], "the size is saved");
await longpress(".widget-slot");
await p.click(".resize-bar >> text=Remove"); await settle();
assert.ok(!(await p.$(".widget-slot")));
await p.evaluate(() => { window.ultraHome.reload(); }); await settle();
assert.equal(await p.$$eval(".slots > li", (ls) => ls.length), 4);