Adapt complete Android phone UI and fix idle audio and microphone test gates
android-ci / android-arm64 (push) Successful in 17m35s

This commit is contained in:
bit9992 committed 2026-11-12 18:33:57 +03:00
1 parent cec86d8e3d
commit 5e2a82b1bb
20 files changed
+976 -201

No files matched your search

+184 -50
View File
@@ -19,6 +19,7 @@ export global DialogBridge {
in-out property <string> submit-label;
in-out property <string> cancel-label;
in-out property <string> advanced-label;
in-out property <bool> has-advanced;
in-out property <string> loading-label;
callback edit(string, string);
callback choose(string, int);
@@ -27,54 +28,197 @@ export global DialogBridge {
callback cancel();
}
// Android first-run is a page, not a small modal with its required fields hidden in a scroller.
component AndroidOnboarding inherits Rectangle {
background: Theme.shaded;
// Android forms share a bounded viewport: context and decisions stay on screen while
// every field, auxiliary action and confirmation remains scrollable above the IME.
component AndroidDialog inherits Rectangle {
background: Theme.contrast;
accessible-role: form;
accessible-label: DialogBridge.title;
// A resized Android surface can exclude the IME entirely, leaving a zero overlap inset.
property <bool> typing: Theme.ime-inset > 0px || root.height < 480px;
property <bool> advanced: false;
property <length> focused-y: -1px;
property <string> focused-field;
property <bool> short: root.height < 400px;
property <bool> stack-actions: root.width < 480px && !root.short;
VerticalLayout {
padding: root.typing ? 12px : 24px;
padding-top: root.typing ? 16px : 28px;
padding-bottom: 8px;
spacing: root.typing ? 6px : 16px;
Text { text: DialogBridge.title; color: Theme.fg; font-size: Theme.font-size * (root.typing ? 1.25 : 1.8); font-weight: 700; wrap: word-wrap; }
if !root.typing: Text { text: DialogBridge.description; color: Theme.fg; font-size: Theme.font-size; wrap: word-wrap; }
for field in DialogBridge.fields: VerticalLayout {
spacing: 4px;
vertical-stretch: 0;
Text { text: field.label; color: Theme.fg; font-size: Theme.font-size; }
if field.kind == 0: TextField {
height: Theme.touch-target; vertical-stretch: 0;
text: field.value; placeholder: field.label; enabled: field.enabled && !DialogBridge.busy;
edited(value) => { DialogBridge.edit(field.id,value); }
accepted => { DialogBridge.submit(); }
padding: 12px; spacing: 8px;
Text {
text: DialogBridge.title; color: Theme.fg;
font-family: Theme.font-family; font-size: Theme.font-size * 1.25; font-weight: 700;
wrap: word-wrap; vertical-stretch: 0;
accessible-role: text; accessible-label: self.text;
}
body := ScrollView {
min-height: 0px; min-width: 0px; vertical-stretch: 1;
changed visible-height => {
if root.focused-y >= 0px { self.content-y = clamp(-root.focused-y, min(0px, self.visible-height - self.content-height), 0px); }
}
if field.kind == 6: HorizontalLayout {
spacing: 8px; height: Theme.touch-target; vertical-stretch: 0;
for label[index] in field.choices: ActionButton {
text: label; primary: field.choice-index == index; enabled: field.enabled && !DialogBridge.busy;
horizontal-stretch: 1; clicked => { DialogBridge.choose(field.id,index); }
VerticalLayout {
spacing: 12px; alignment: start;
if DialogBridge.description != "": Text {
text: DialogBridge.description; color: Theme.muted; wrap: word-wrap;
font-family: Theme.font-family; font-size: Theme.font-size;
}
for field in DialogBridge.fields: field-row := Rectangle {
visible: !field.advanced || root.advanced;
height: self.visible ? row.preferred-height : 0px;
vertical-stretch: 0; min-width: 0px;
changed y => {
if root.focused-field == field.id {
root.focused-y = self.y;
body.content-y = clamp(-self.y, min(0px, body.visible-height - body.content-height), 0px);
}
}
row := VerticalLayout {
spacing: 4px;
if field.kind != 5: Text {
text: field.label; color: Theme.fg; wrap: word-wrap;
font-family: Theme.font-family; font-size: Theme.font-size;
}
if field.kind == 0 || field.kind == 1 || field.kind == 3 || field.kind == 4: TextField {
text: field.value; placeholder: field.label; secret: field.kind == 1;
enabled: field.enabled && !DialogBridge.busy; min-width: 0px;
edited(value) => { DialogBridge.edit(field.id, value); }
accepted => { if DialogBridge.onboarding { DialogBridge.submit(); } }
changed has-focus => {
if self.has-focus {
root.focused-field = field.id;
root.focused-y = field-row.y;
body.content-y = clamp(-field-row.y, min(0px, body.visible-height - body.content-height), 0px);
} else if root.focused-field == field.id {
root.focused-field = "";
root.focused-y = -1px;
}
}
}
if field.kind == 2: TextEdit {
text: field.value; enabled: field.enabled && !DialogBridge.busy; wrap: word-wrap;
height: max(96px, Theme.font-size * 4); min-width: 0px;
font-family: Theme.font-family; font-size: Theme.font-size;
accessible-label: field.label;
edited => { DialogBridge.edit(field.id, self.text); }
changed has-focus => {
if self.has-focus {
root.focused-field = field.id;
root.focused-y = field-row.y;
body.content-y = clamp(-field-row.y, min(0px, body.visible-height - body.content-height), 0px);
} else if root.focused-field == field.id {
root.focused-field = "";
root.focused-y = -1px;
}
}
}
if field.kind == 5: HorizontalLayout {
spacing: 8px;
Text {
text: field.label; color: Theme.fg; wrap: word-wrap; vertical-alignment: center;
font-family: Theme.font-family; font-size: Theme.font-size;
horizontal-stretch: 1; min-width: 0px;
}
Toggle {
width: max(48px, Theme.touch-target); horizontal-stretch: 0;
checked: field.checked; label: field.label; enabled: field.enabled && !DialogBridge.busy;
toggled(value) => { DialogBridge.edit(field.id, value ? "true" : "false"); }
}
}
if field.kind == 6: Choice {
values: field.choices; current-index: field.choice-index; label: field.label;
enabled: field.enabled && !DialogBridge.busy; min-width: 0px;
selected(index) => { DialogBridge.choose(field.id, index); }
}
if field.hint != "": Text {
text: field.hint; color: Theme.muted; wrap: word-wrap;
font-family: Theme.font-family; font-size: Theme.font-size;
}
if field.error != "": Text {
text: field.error; color: Theme.error; wrap: word-wrap;
font-family: Theme.font-family; font-size: Theme.font-size;
accessible-role: text; accessible-live-region: assertive;
}
}
}
for action in DialogBridge.actions: ActionButton {
text: action.label; enabled: action.enabled && !DialogBridge.busy;
destructive: action.destructive; min-width: 0px;
clicked => { ShellBridge.invoke(action.id); }
}
if !DialogBridge.onboarding && DialogBridge.has-advanced: ActionButton {
text: DialogBridge.advanced-label; min-width: 0px;
clicked => { root.advanced = !root.advanced; }
}
if DialogBridge.confirmation-label != "": confirmation-row := VerticalLayout {
spacing: 4px; vertical-stretch: 0;
changed y => {
if root.focused-field == "__confirmation" {
root.focused-y = self.y;
body.content-y = clamp(-self.y, min(0px, body.visible-height - body.content-height), 0px);
}
}
Text {
text: DialogBridge.confirmation-label; color: Theme.warning; wrap: word-wrap;
font-family: Theme.font-family; font-size: Theme.font-size;
}
TextField {
text: DialogBridge.confirmation; placeholder: DialogBridge.confirmation-label;
enabled: !DialogBridge.busy; min-width: 0px;
edited(value) => { DialogBridge.confirm(value); }
changed has-focus => {
if self.has-focus {
root.focused-field = "__confirmation";
root.focused-y = confirmation-row.y;
body.content-y = clamp(-confirmation-row.y, min(0px, body.visible-height - body.content-height), 0px);
} else if root.focused-field == "__confirmation" {
root.focused-field = "";
root.focused-y = -1px;
}
}
}
}
if DialogBridge.error != "": Text {
text: DialogBridge.error; color: Theme.error; wrap: word-wrap;
font-family: Theme.font-family; font-size: Theme.font-size;
accessible-live-region: assertive;
}
if DialogBridge.busy: Text {
text: DialogBridge.loading-label; color: Theme.muted; wrap: word-wrap;
font-family: Theme.font-family; font-size: Theme.font-size;
}
}
if field.error != "": Text { text: field.error; color: Theme.error; wrap: word-wrap; accessible-live-region: assertive; }
}
if DialogBridge.error != "": Text { text: DialogBridge.error; color: Theme.error; wrap: word-wrap; accessible-live-region: assertive; }
if DialogBridge.busy: Text { text: DialogBridge.loading-label; color: Theme.fg; }
Rectangle { vertical-stretch: 1; min-height: 0px; }
ActionButton { height: Theme.touch-target; vertical-stretch: 0; text: DialogBridge.submit-label; primary: true; enabled: !DialogBridge.busy; clicked => { DialogBridge.submit(); } }
ActionButton { height: Theme.touch-target; vertical-stretch: 0; text: DialogBridge.cancel-label; enabled: !DialogBridge.busy; clicked => { DialogBridge.cancel(); } }
if root.stack-actions: VerticalLayout {
spacing: 8px; vertical-stretch: 0;
ActionButton {
text: DialogBridge.submit-label; primary: true; destructive: DialogBridge.destructive;
enabled: !DialogBridge.busy; min-width: 0px;
clicked => { DialogBridge.submit(); }
}
ActionButton {
text: DialogBridge.cancel-label; enabled: !DialogBridge.onboarding || !DialogBridge.busy; min-width: 0px;
clicked => { DialogBridge.cancel(); }
}
}
if !root.stack-actions: HorizontalLayout {
spacing: 8px; vertical-stretch: 0;
ActionButton {
text: DialogBridge.cancel-label; enabled: !DialogBridge.onboarding || !DialogBridge.busy;
min-width: 0px; horizontal-stretch: 1;
clicked => { DialogBridge.cancel(); }
}
ActionButton {
text: DialogBridge.submit-label; primary: true; destructive: DialogBridge.destructive;
enabled: !DialogBridge.busy; min-width: 0px; horizontal-stretch: 1;
clicked => { DialogBridge.submit(); }
}
}
}
}
export component ShellDialog inherits Rectangle {
background: Theme.contrast.with-alpha(0.75);
property <bool> fullscreen-onboarding: Theme.android && DialogBridge.onboarding;
property <bool> phone: Theme.android;
// An overlay blocks background pointer input without turning Cancel into a submit.
TouchArea { }
if root.fullscreen-onboarding: AndroidOnboarding { width: root.width; height: root.height; }
if !root.fullscreen-onboarding: dialog := Rectangle {
if root.phone: AndroidDialog { width: root.width; height: root.height; }
if !root.phone: dialog := Rectangle {
width: min(parent.width - 24px, 640px);
height: min(parent.height - 24px, layout.preferred-height);
x: (parent.width - self.width)/2;
@@ -89,15 +233,12 @@ export component ShellDialog inherits Rectangle {
property <length> focused-y: 0px;
layout := VerticalLayout {
padding: 20px; spacing: 12px;
if !Theme.android: Text { text: DialogBridge.title; font-size: Theme.font-size * 1.6; font-weight: 700; color: Theme.fg; wrap: word-wrap; }
if !Theme.android && DialogBridge.description != "": Text { text: DialogBridge.description; color: Theme.muted; wrap: word-wrap; }
Text { text: DialogBridge.title; font-size: Theme.font-size * 1.6; font-weight: 700; color: Theme.fg; wrap: word-wrap; }
if DialogBridge.description != "": Text { text: DialogBridge.description; color: Theme.muted; wrap: word-wrap; }
form-scroll := ScrollView {
min-height: Theme.android ? min(80px, max(0px, root.height - 112px)) : 80px; max-height: 600px;
changed visible-height => { if Theme.android { self.content-y = clamp(-dialog.focused-y, min(0px, self.visible-height - self.content-height), 0px); } }
min-height: 80px; max-height: 600px;
VerticalLayout {
spacing: 12px;
if Theme.android: Text { text: DialogBridge.title; font-size: Theme.font-size * 1.6; font-weight: 700; color: Theme.fg; wrap: word-wrap; }
if Theme.android && DialogBridge.description != "": Text { text: DialogBridge.description; color: Theme.muted; wrap: word-wrap; }
for field in DialogBridge.fields: field-row := Rectangle {
visible: !field.advanced || dialog.advanced;
height: self.visible ? row.preferred-height : 0px;
@@ -125,22 +266,15 @@ export component ShellDialog inherits Rectangle {
ActionButton { text: DialogBridge.advanced-label; clicked => { dialog.advanced = !dialog.advanced; } }
if DialogBridge.confirmation-label != "": Text { text: DialogBridge.confirmation-label; color: Theme.warning; wrap: word-wrap; }
if DialogBridge.confirmation-label != "": TextField { text: DialogBridge.confirmation; placeholder: DialogBridge.confirmation-label; enabled: !DialogBridge.busy; edited(value) => { DialogBridge.confirm(value); } }
if Theme.android && DialogBridge.error != "": Text { text: DialogBridge.error; color: Theme.error; wrap: word-wrap; accessible-live-region: assertive; }
if Theme.android && DialogBridge.busy: Text { text: DialogBridge.loading-label; color: Theme.muted; }
}
}
if !Theme.android && DialogBridge.error != "": Text { text: DialogBridge.error; color: Theme.error; wrap: word-wrap; accessible-live-region: assertive; }
if !Theme.android && DialogBridge.busy: Text { text: DialogBridge.loading-label; color: Theme.muted; }
if !Theme.android: HorizontalLayout {
if DialogBridge.error != "": Text { text: DialogBridge.error; color: Theme.error; wrap: word-wrap; accessible-live-region: assertive; }
if DialogBridge.busy: Text { text: DialogBridge.loading-label; color: Theme.muted; }
HorizontalLayout {
alignment: end; spacing: 8px;
ActionButton { text: DialogBridge.cancel-label; clicked => { DialogBridge.cancel(); } }
ActionButton { text: DialogBridge.submit-label; primary: true; destructive: DialogBridge.destructive; enabled: !DialogBridge.busy; clicked => { DialogBridge.submit(); } }
}
if Theme.android: HorizontalLayout {
spacing: 8px;
ActionButton { min-width: 48px; horizontal-stretch: 1; text: DialogBridge.cancel-label; clicked => { DialogBridge.cancel(); } }
ActionButton { min-width: 48px; horizontal-stretch: 1; text: DialogBridge.submit-label; primary: true; destructive: DialogBridge.destructive; enabled: !DialogBridge.busy; clicked => { DialogBridge.submit(); } }
}
}
}
}