forked from Blendman974/faceclaw
Main-form "Disconnect" option is available if in a reconnection-attempt loop. Remove broken/unused "Show Logs" button.
This commit is contained in:
1 parent
fa241161e4
commit
1a1416c8f0
4 files changed
+28
-122
No files matched your search
@@ -49,7 +49,6 @@ type ConnectionPhase = "disconnected" | "connecting" | "connected" | "charging"
|
|||||||
export type DashboardSnapshot = {
|
export type DashboardSnapshot = {
|
||||||
phase: ConnectionPhase;
|
phase: ConnectionPhase;
|
||||||
status: string;
|
status: string;
|
||||||
log: string;
|
|
||||||
displayPreview: ImageSource | null;
|
displayPreview: ImageSource | null;
|
||||||
/**
|
/**
|
||||||
* When non-empty, the phone UI shows this instead of the display preview:
|
* When non-empty, the phone UI shows this instead of the display preview:
|
||||||
@@ -148,7 +147,6 @@ function sourceName(eventSource: number): string {
|
|||||||
class DashboardController {
|
class DashboardController {
|
||||||
private phase: ConnectionPhase = "disconnected";
|
private phase: ConnectionPhase = "disconnected";
|
||||||
private status = "Disconnected.";
|
private status = "Disconnected.";
|
||||||
private log = "";
|
|
||||||
private activeTextSettings: ConfigSettingString[] = [];
|
private activeTextSettings: ConfigSettingString[] = [];
|
||||||
private activeTextEditorTitle = "";
|
private activeTextEditorTitle = "";
|
||||||
private activeTextEditorOnFinish: (() => void) | null = null;
|
private activeTextEditorOnFinish: (() => void) | null = null;
|
||||||
@@ -720,7 +718,6 @@ class DashboardController {
|
|||||||
return {
|
return {
|
||||||
phase: this.phase,
|
phase: this.phase,
|
||||||
status: this.status,
|
status: this.status,
|
||||||
log: this.log,
|
|
||||||
displayPreview: this.displayPreview,
|
displayPreview: this.displayPreview,
|
||||||
displayPreviewMessage: this.displayPreviewMessage(),
|
displayPreviewMessage: this.displayPreviewMessage(),
|
||||||
activeTextSettingId: primaryTextSetting?.id ?? null,
|
activeTextSettingId: primaryTextSetting?.id ?? null,
|
||||||
@@ -839,7 +836,6 @@ class DashboardController {
|
|||||||
this.appendLog(`error: ${message}`);
|
this.appendLog(`error: ${message}`);
|
||||||
throw new Error(message);
|
throw new Error(message);
|
||||||
}
|
}
|
||||||
this.log = "";
|
|
||||||
this.lastInput = "waiting...";
|
this.lastInput = "waiting...";
|
||||||
this.lastSys = "none yet";
|
this.lastSys = "none yet";
|
||||||
this.welcomeSoundArmed = isWelcomeSoundPending();
|
this.welcomeSoundArmed = isWelcomeSoundPending();
|
||||||
@@ -1147,6 +1143,14 @@ class DashboardController {
|
|||||||
*/
|
*/
|
||||||
async disconnect(options?: { skipFirmwareCleanup?: boolean }): Promise<void> {
|
async disconnect(options?: { skipFirmwareCleanup?: boolean }): Promise<void> {
|
||||||
suppressAutoReconnect();
|
suppressAutoReconnect();
|
||||||
|
// The phone menu offers Disconnect during the connecting phase (it is the
|
||||||
|
// only way out of a reconnection-attempt loop), so a call can land while
|
||||||
|
// connect() is still mid-flight; let it finish so the teardown doesn't
|
||||||
|
// race its surface setup. connect() returns once the Java worker thread
|
||||||
|
// owns the retry loop, so this wait is short.
|
||||||
|
while (this.connectRunning) {
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 200));
|
||||||
|
}
|
||||||
if (this.phase === "disconnected" || this.phase === "disconnecting") return;
|
if (this.phase === "disconnected" || this.phase === "disconnecting") return;
|
||||||
|
|
||||||
this.setPhase("disconnecting");
|
this.setPhase("disconnecting");
|
||||||
@@ -1886,10 +1890,7 @@ class DashboardController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private appendLog(line: string): void {
|
private appendLog(line: string): void {
|
||||||
const stamped = `[${formatTimestamp(new Date())}] ${line}`;
|
console.log(`[${formatTimestamp(new Date())}] ${line}`);
|
||||||
//this.log = this.log ? `${this.log}\n${stamped}` : stamped;
|
|
||||||
console.log(stamped);
|
|
||||||
//this.emit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private setDisplayPreview(preview: ImageSource | null): void {
|
private setDisplayPreview(preview: ImageSource | null): void {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Application, Color, EventData, isAndroid, Observable, Page, ScrollView, TextField } from '@nativescript/core'
|
import { Application, Color, EventData, isAndroid, Observable, Page, TextField } from '@nativescript/core'
|
||||||
import { MainViewModel } from './main-view-model'
|
import { MainViewModel } from './main-view-model'
|
||||||
import { dashboardController } from '../g2/dashboard-controller'
|
import { dashboardController } from '../g2/dashboard-controller'
|
||||||
|
|
||||||
@@ -13,9 +13,6 @@ export function navigatingTo(args: EventData) {
|
|||||||
|
|
||||||
type MainPageState = {
|
type MainPageState = {
|
||||||
model: MainViewModel
|
model: MainViewModel
|
||||||
isPinnedToBottom: boolean
|
|
||||||
scrollViews: ScrollView[]
|
|
||||||
scrollHandler: (args: EventData) => void
|
|
||||||
propertyChangeHandler: (args: EventData & { propertyName?: string }) => void
|
propertyChangeHandler: (args: EventData & { propertyName?: string }) => void
|
||||||
orientationHandler: () => void
|
orientationHandler: () => void
|
||||||
}
|
}
|
||||||
@@ -34,30 +31,11 @@ function cleanupPage(page: Page): void {
|
|||||||
setPageState(page, undefined)
|
setPageState(page, undefined)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for (const scrollView of state.scrollViews) {
|
|
||||||
scrollView.off(ScrollView.scrollEvent, state.scrollHandler)
|
|
||||||
}
|
|
||||||
state.model.off(Observable.propertyChangeEvent, state.propertyChangeHandler)
|
state.model.off(Observable.propertyChangeEvent, state.propertyChangeHandler)
|
||||||
Application.off(Application.orientationChangedEvent, state.orientationHandler)
|
Application.off(Application.orientationChangedEvent, state.orientationHandler)
|
||||||
setPageState(page, undefined)
|
setPageState(page, undefined)
|
||||||
}
|
}
|
||||||
|
|
||||||
function isAtBottom(scrollView: ScrollView): boolean {
|
|
||||||
return scrollView.scrollableHeight <= 0 || scrollView.verticalOffset >= scrollView.scrollableHeight - 8
|
|
||||||
}
|
|
||||||
|
|
||||||
function scrollToBottom(scrollView: ScrollView): void {
|
|
||||||
setTimeout(() => {
|
|
||||||
scrollView.scrollToVerticalOffset(scrollView.scrollableHeight, false)
|
|
||||||
}, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
function scrollLogsToBottom(scrollViews: ScrollView[]): void {
|
|
||||||
for (const scrollView of scrollViews) {
|
|
||||||
scrollToBottom(scrollView)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function applySettingsTextFieldContrast(textField: TextField): void {
|
function applySettingsTextFieldContrast(textField: TextField): void {
|
||||||
textField.color = SETTINGS_TEXT_COLOR
|
textField.color = SETTINGS_TEXT_COLOR
|
||||||
textField.backgroundColor = SETTINGS_BACKGROUND_COLOR
|
textField.backgroundColor = SETTINGS_BACKGROUND_COLOR
|
||||||
@@ -105,64 +83,34 @@ export function loaded(args: EventData) {
|
|||||||
// Reopen the apps that were open before the last restart (no-op after the
|
// Reopen the apps that were open before the last restart (no-op after the
|
||||||
// first load).
|
// first load).
|
||||||
void dashboardController.restoreOpenApps()
|
void dashboardController.restoreOpenApps()
|
||||||
const scrollViews = [
|
|
||||||
page.getViewById<ScrollView>('logScrollView'),
|
|
||||||
page.getViewById<ScrollView>('logScrollViewLandscape'),
|
|
||||||
].filter((scrollView): scrollView is ScrollView => !!scrollView)
|
|
||||||
const settingsTextField = page.getViewById<TextField>('settingsTextField')
|
const settingsTextField = page.getViewById<TextField>('settingsTextField')
|
||||||
model?.refreshLayoutMetrics()
|
model?.refreshLayoutMetrics()
|
||||||
if (settingsTextField) {
|
if (settingsTextField) {
|
||||||
applySettingsTextFieldContrast(settingsTextField)
|
applySettingsTextFieldContrast(settingsTextField)
|
||||||
}
|
}
|
||||||
if (!model || scrollViews.length === 0) {
|
if (!model) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const state: MainPageState = {
|
const state: MainPageState = {
|
||||||
model,
|
model,
|
||||||
isPinnedToBottom: true,
|
|
||||||
scrollViews,
|
|
||||||
scrollHandler: (scrollArgs) => {
|
|
||||||
state.isPinnedToBottom = isAtBottom(scrollArgs.object as ScrollView)
|
|
||||||
},
|
|
||||||
orientationHandler: () => {
|
orientationHandler: () => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
model.refreshLayoutMetrics()
|
model.refreshLayoutMetrics()
|
||||||
if (state.isPinnedToBottom) {
|
|
||||||
scrollLogsToBottom(scrollViews)
|
|
||||||
}
|
|
||||||
}, 0)
|
}, 0)
|
||||||
},
|
},
|
||||||
propertyChangeHandler: (propertyArgs) => {
|
propertyChangeHandler: (propertyArgs) => {
|
||||||
if (propertyArgs.propertyName === 'showLog') {
|
|
||||||
if (model.showLog) {
|
|
||||||
state.isPinnedToBottom = true
|
|
||||||
scrollLogsToBottom(scrollViews)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (propertyArgs.propertyName === 'activeTextSettingId') {
|
if (propertyArgs.propertyName === 'activeTextSettingId') {
|
||||||
if (model.isTextSettingEditorActive) {
|
if (model.isTextSettingEditorActive) {
|
||||||
focusTextEditor(page)
|
focusTextEditor(page)
|
||||||
}
|
}
|
||||||
return
|
|
||||||
}
|
|
||||||
if (propertyArgs.propertyName !== 'log') {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (state.isPinnedToBottom) {
|
|
||||||
scrollLogsToBottom(scrollViews)
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const scrollView of scrollViews) {
|
|
||||||
scrollView.on(ScrollView.scrollEvent, state.scrollHandler)
|
|
||||||
}
|
|
||||||
model.on(Observable.propertyChangeEvent, state.propertyChangeHandler)
|
model.on(Observable.propertyChangeEvent, state.propertyChangeHandler)
|
||||||
Application.on(Application.orientationChangedEvent, state.orientationHandler)
|
Application.on(Application.orientationChangedEvent, state.orientationHandler)
|
||||||
setPageState(page, state)
|
setPageState(page, state)
|
||||||
scrollLogsToBottom(scrollViews)
|
|
||||||
if (model.isTextSettingEditorActive) {
|
if (model.isTextSettingEditorActive) {
|
||||||
focusTextEditor(page)
|
focusTextEditor(page)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo" loaded="loaded" unloaded="unloaded">
|
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo" loaded="loaded" unloaded="unloaded">
|
||||||
<ActionBar title="Faceclaw">
|
<ActionBar title="Faceclaw">
|
||||||
<ActionItem text="{{ buttonLabel }}" tap="{{ onTap }}" isEnabled="{{ canRun }}" android.position="popup" />
|
<ActionItem text="{{ buttonLabel }}" tap="{{ onTap }}" isEnabled="{{ connectItemEnabled }}" android.position="popup" />
|
||||||
<ActionItem text="Pair glasses" tap="{{ onPairGlassesTap }}" isEnabled="{{ canRun }}" android.position="popup" />
|
<ActionItem text="Pair glasses" tap="{{ onPairGlassesTap }}" isEnabled="{{ canRun }}" android.position="popup" />
|
||||||
<ActionItem text="Configure devices" tap="{{ onConfigureTap }}" isEnabled="{{ canRun }}" android.position="popup" />
|
<ActionItem text="Configure devices" tap="{{ onConfigureTap }}" isEnabled="{{ canRun }}" android.position="popup" />
|
||||||
<ActionItem text="Take screenshot" tap="{{ onTakeScreenshotTap }}" android.position="popup" />
|
<ActionItem text="Take screenshot" tap="{{ onTakeScreenshotTap }}" android.position="popup" />
|
||||||
<ActionItem text="Record screen" tap="{{ onRecordScreenTap }}" android.position="popup" />
|
<ActionItem text="Record screen" tap="{{ onRecordScreenTap }}" android.position="popup" />
|
||||||
<ActionItem text="Uninstall custom firmware" tap="{{ onUninstallFirmwareTap }}" isEnabled="{{ canRun }}" android.position="popup" />
|
<ActionItem text="Uninstall custom firmware" tap="{{ onUninstallFirmwareTap }}" isEnabled="{{ canRun }}" android.position="popup" />
|
||||||
<ActionItem text="{{ showLogMenuLabel }}" tap="{{ onToggleLogTap }}" android.position="popup" />
|
|
||||||
</ActionBar>
|
</ActionBar>
|
||||||
|
|
||||||
<GridLayout>
|
<GridLayout>
|
||||||
@@ -21,7 +20,7 @@
|
|||||||
visibility="{{ displayPreviewMessageVisibility }}">
|
visibility="{{ displayPreviewMessageVisibility }}">
|
||||||
<Label text="{{ displayPreviewMessage }}" textWrap="true" horizontalAlignment="center" verticalAlignment="center" />
|
<Label text="{{ displayPreviewMessage }}" textWrap="true" horizontalAlignment="center" verticalAlignment="center" />
|
||||||
</GridLayout>
|
</GridLayout>
|
||||||
<GridLayout row="1" rows="auto,auto,auto,*" class="p-20">
|
<GridLayout row="1" rows="auto,auto,auto" class="p-20">
|
||||||
<StackLayout row="0" class="m-b-8">
|
<StackLayout row="0" class="m-b-8">
|
||||||
<StackLayout visibility="{{ evenAppConflictWarningVisibility }}">
|
<StackLayout visibility="{{ evenAppConflictWarningVisibility }}">
|
||||||
<Label text="{{ evenAppConflictMessage }}" textWrap="true" />
|
<Label text="{{ evenAppConflictMessage }}" textWrap="true" />
|
||||||
@@ -48,9 +47,6 @@
|
|||||||
<Button text="Stop recording" tap="{{ onStopRecordingTap }}" visibility="{{ stopRecordingButtonVisibility }}" />
|
<Button text="Stop recording" tap="{{ onStopRecordingTap }}" visibility="{{ stopRecordingButtonVisibility }}" />
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
<Label row="2" text="{{ status }}" class="m-t-16" textWrap="true" />
|
<Label row="2" text="{{ status }}" class="m-t-16" textWrap="true" />
|
||||||
<ScrollView id="logScrollView" row="3" class="m-t-16" visibility="{{ showLogVisibility }}">
|
|
||||||
<Label text="{{ log }}" textWrap="true" verticalAlignment="top" />
|
|
||||||
</ScrollView>
|
|
||||||
</GridLayout>
|
</GridLayout>
|
||||||
</GridLayout>
|
</GridLayout>
|
||||||
|
|
||||||
@@ -66,7 +62,7 @@
|
|||||||
<Button text="Allow unrestricted background usage" tap="{{ onAllowBackgroundUsageTap }}" class="-primary" />
|
<Button text="Allow unrestricted background usage" tap="{{ onAllowBackgroundUsageTap }}" class="-primary" />
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
<GridLayout row="1" rows="auto,auto,*" columns="*,260">
|
<GridLayout row="1" rows="auto,auto" columns="*,260">
|
||||||
<StackLayout row="0" col="0" visibility="{{ displayPreviewVisibility }}" horizontalAlignment="left">
|
<StackLayout row="0" col="0" visibility="{{ displayPreviewVisibility }}" horizontalAlignment="left">
|
||||||
<Image
|
<Image
|
||||||
src="{{ displayPreview }}"
|
src="{{ displayPreview }}"
|
||||||
@@ -96,9 +92,6 @@
|
|||||||
<Button text="Stop recording" tap="{{ onStopRecordingTap }}" visibility="{{ stopRecordingButtonVisibility }}" />
|
<Button text="Stop recording" tap="{{ onStopRecordingTap }}" visibility="{{ stopRecordingButtonVisibility }}" />
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
<Label row="1" col="0" colSpan="2" text="{{ status }}" class="m-t-16" textWrap="true" />
|
<Label row="1" col="0" colSpan="2" text="{{ status }}" class="m-t-16" textWrap="true" />
|
||||||
<ScrollView id="logScrollViewLandscape" row="2" col="0" colSpan="2" class="m-t-16" visibility="{{ showLogVisibility }}">
|
|
||||||
<Label text="{{ log }}" textWrap="true" verticalAlignment="top" />
|
|
||||||
</ScrollView>
|
|
||||||
</GridLayout>
|
</GridLayout>
|
||||||
</GridLayout>
|
</GridLayout>
|
||||||
<StackLayout
|
<StackLayout
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ type LayoutOrientation = "portrait" | "landscape";
|
|||||||
|
|
||||||
export class MainViewModel extends Observable {
|
export class MainViewModel extends Observable {
|
||||||
private _status = "Disconnected.";
|
private _status = "Disconnected.";
|
||||||
private _log = "";
|
|
||||||
private _displayPreview: ImageSource | null = null;
|
private _displayPreview: ImageSource | null = null;
|
||||||
private _displayPreviewMessage = "";
|
private _displayPreviewMessage = "";
|
||||||
private _layoutOrientation: LayoutOrientation = this.readLayoutOrientation();
|
private _layoutOrientation: LayoutOrientation = this.readLayoutOrientation();
|
||||||
@@ -29,14 +28,12 @@ export class MainViewModel extends Observable {
|
|||||||
private _firmwareWarningVisible = false;
|
private _firmwareWarningVisible = false;
|
||||||
private _screenRecordingActive = false;
|
private _screenRecordingActive = false;
|
||||||
private _batteryOptimizationWarningVisible = false;
|
private _batteryOptimizationWarningVisible = false;
|
||||||
private _showLog = false;
|
|
||||||
private _phase: "disconnected" | "connecting" | "connected" | "charging" | "disconnecting" = "disconnected";
|
private _phase: "disconnected" | "connecting" | "connected" | "charging" | "disconnecting" = "disconnected";
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
dashboardController.subscribe((snapshot) => {
|
dashboardController.subscribe((snapshot) => {
|
||||||
this.status = snapshot.status;
|
this.status = snapshot.status;
|
||||||
this.log = snapshot.log;
|
|
||||||
this.displayPreview = snapshot.displayPreview;
|
this.displayPreview = snapshot.displayPreview;
|
||||||
this.displayPreviewMessage = snapshot.displayPreviewMessage;
|
this.displayPreviewMessage = snapshot.displayPreviewMessage;
|
||||||
this.phase = snapshot.phase;
|
this.phase = snapshot.phase;
|
||||||
@@ -69,17 +66,6 @@ export class MainViewModel extends Observable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get log(): string {
|
|
||||||
return this._log;
|
|
||||||
}
|
|
||||||
|
|
||||||
set log(value: string) {
|
|
||||||
if (this._log !== value) {
|
|
||||||
this._log = value;
|
|
||||||
this.notifyPropertyChange("log", value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
get displayPreview(): ImageSource | null {
|
get displayPreview(): ImageSource | null {
|
||||||
return this._displayPreview;
|
return this._displayPreview;
|
||||||
}
|
}
|
||||||
@@ -160,27 +146,6 @@ export class MainViewModel extends Observable {
|
|||||||
this.notifyPropertyChange("landscapeDisplayPreviewHeight", this.landscapeDisplayPreviewHeight);
|
this.notifyPropertyChange("landscapeDisplayPreviewHeight", this.landscapeDisplayPreviewHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
get showLog(): boolean {
|
|
||||||
return this._showLog;
|
|
||||||
}
|
|
||||||
|
|
||||||
set showLog(value: boolean) {
|
|
||||||
if (this._showLog !== value) {
|
|
||||||
this._showLog = value;
|
|
||||||
this.notifyPropertyChange("showLog", value);
|
|
||||||
this.notifyPropertyChange("showLogVisibility", this.showLogVisibility);
|
|
||||||
this.notifyPropertyChange("showLogMenuLabel", this.showLogMenuLabel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
get showLogVisibility(): "visible" | "collapse" {
|
|
||||||
return this._showLog ? "visible" : "collapse";
|
|
||||||
}
|
|
||||||
|
|
||||||
get showLogMenuLabel(): string {
|
|
||||||
return this._showLog ? "Hide Log" : "Show Log";
|
|
||||||
}
|
|
||||||
|
|
||||||
get activeTextSettingId(): string | null {
|
get activeTextSettingId(): string | null {
|
||||||
return this._activeTextSettingId;
|
return this._activeTextSettingId;
|
||||||
}
|
}
|
||||||
@@ -447,13 +412,13 @@ export class MainViewModel extends Observable {
|
|||||||
this.notifyPropertyChange("phase", value);
|
this.notifyPropertyChange("phase", value);
|
||||||
this.notifyPropertyChange("buttonLabel", this.buttonLabel);
|
this.notifyPropertyChange("buttonLabel", this.buttonLabel);
|
||||||
this.notifyPropertyChange("canRun", this.canRun);
|
this.notifyPropertyChange("canRun", this.canRun);
|
||||||
|
this.notifyPropertyChange("connectItemEnabled", this.connectItemEnabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get buttonLabel(): string {
|
get buttonLabel(): string {
|
||||||
switch (this.phase) {
|
switch (this.phase) {
|
||||||
case "connecting":
|
case "connecting":
|
||||||
return "Connecting...";
|
|
||||||
case "connected":
|
case "connected":
|
||||||
case "charging":
|
case "charging":
|
||||||
return "Disconnect";
|
return "Disconnect";
|
||||||
@@ -468,20 +433,28 @@ export class MainViewModel extends Observable {
|
|||||||
return this.phase !== "connecting" && this.phase !== "disconnecting";
|
return this.phase !== "connecting" && this.phase !== "disconnecting";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unlike the other canRun-gated menu items, Connect/Disconnect stays live
|
||||||
|
* while connecting: Disconnect is the only way out of a reconnection-attempt
|
||||||
|
* loop short of force-stopping the app.
|
||||||
|
*/
|
||||||
|
get connectItemEnabled(): boolean {
|
||||||
|
return this.phase !== "disconnecting";
|
||||||
|
}
|
||||||
|
|
||||||
async onTap(): Promise<void> {
|
async onTap(): Promise<void> {
|
||||||
if (!this.canRun) return;
|
if (!this.connectItemEnabled) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (this.phase === "connected" || this.phase === "charging") {
|
if (this.phase === "disconnected") {
|
||||||
await dashboardController.disconnect();
|
|
||||||
} else {
|
|
||||||
await dashboardController.connect();
|
await dashboardController.connect();
|
||||||
|
} else {
|
||||||
|
await dashboardController.disconnect();
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const message = this.formatError(error);
|
const message = this.formatError(error);
|
||||||
if (!this.status.startsWith("Failed:")) {
|
if (!this.status.startsWith("Failed:")) {
|
||||||
this.status = `Failed: ${message}`;
|
this.status = `Failed: ${message}`;
|
||||||
this.appendLog(`error: ${message}`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -550,10 +523,6 @@ export class MainViewModel extends Observable {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onToggleLogTap(): void {
|
|
||||||
this.showLog = !this.showLog;
|
|
||||||
}
|
|
||||||
|
|
||||||
onTextSettingTextChange(args: { value?: string; object?: { text?: string } }): void {
|
onTextSettingTextChange(args: { value?: string; object?: { text?: string } }): void {
|
||||||
dashboardController.setActiveTextSettingValue(
|
dashboardController.setActiveTextSettingValue(
|
||||||
args.object?.text ?? args.value ?? "",
|
args.object?.text ?? args.value ?? "",
|
||||||
@@ -618,11 +587,6 @@ export class MainViewModel extends Observable {
|
|||||||
await dashboardController.injectSyntheticRingInput("wakeword");
|
await dashboardController.injectSyntheticRingInput("wakeword");
|
||||||
}
|
}
|
||||||
|
|
||||||
private appendLog(line: string): void {
|
|
||||||
const stamp = new Date().toISOString().slice(11, 19);
|
|
||||||
this.log = this.log ? `${this.log}\n[${stamp}] ${line}` : `[${stamp}] ${line}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
private readLayoutOrientation(): LayoutOrientation {
|
private readLayoutOrientation(): LayoutOrientation {
|
||||||
const applicationOrientation = Application.orientation();
|
const applicationOrientation = Application.orientation();
|
||||||
if (applicationOrientation === "landscape" || applicationOrientation === "portrait") {
|
if (applicationOrientation === "landscape" || applicationOrientation === "portrait") {
|
||||||
|
|||||||
Reference in new issue
Block a user