forked from Blendman974/faceclaw
Many bug fixes
This commit is contained in:
1 parent
602520a840
commit
0d0b55c2da
9 files changed
+125
-25
No files matched your search
+25
@@ -1,6 +1,30 @@
|
||||
@import '@nativescript/theme/css/core.css';
|
||||
@import '@nativescript/theme/css/default.css';
|
||||
|
||||
Page {
|
||||
background-color: #ffffff;
|
||||
color: #222222;
|
||||
}
|
||||
|
||||
ActionBar {
|
||||
background-color: #424242;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
ActionItem {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
TextField {
|
||||
background-color: #ffffff;
|
||||
color: #222222;
|
||||
}
|
||||
|
||||
.system-name-modal TextField {
|
||||
background-color: #ffffff;
|
||||
color: #222222;
|
||||
}
|
||||
|
||||
Button.-primary {
|
||||
font-size: 18;
|
||||
}
|
||||
@@ -9,6 +33,7 @@ Button.-primary {
|
||||
margin: 16;
|
||||
padding: 16;
|
||||
background-color: #f6f6f6;
|
||||
color: #222222;
|
||||
border-color: #222222;
|
||||
border-width: 1;
|
||||
border-radius: 8;
|
||||
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
getDashboardNightscoutSettings,
|
||||
getDashboardSystemCardName,
|
||||
isDashboardVoiceControlEnabled,
|
||||
noteDashboardPhoneTextInput,
|
||||
receiveInput,
|
||||
resetDashboardSleepTimerAndWake,
|
||||
setDashboardBatteryLevels,
|
||||
@@ -203,6 +204,7 @@ class DashboardController {
|
||||
}
|
||||
|
||||
setActiveTextSettingValue(value: string): void {
|
||||
noteDashboardPhoneTextInput();
|
||||
switch (this.activeTextSettingEditorKind) {
|
||||
case "dashboard-name":
|
||||
this.setSystemCardName(value);
|
||||
@@ -252,12 +254,12 @@ class DashboardController {
|
||||
this.appendLog(
|
||||
`Using configured arms: R=${addresses.right} L=${addresses.left}${addresses.ring ? ` ring=${addresses.ring}` : ""}`,
|
||||
);
|
||||
startForegroundNotification("Connecting to the glasses");
|
||||
|
||||
let communicator: FaceclawCommunicatorBridge | null = null;
|
||||
|
||||
try {
|
||||
await ensureBlePermissions();
|
||||
startForegroundNotification("Connecting to the glasses");
|
||||
communicator = new FaceclawCommunicatorBridge({
|
||||
right: addresses.right,
|
||||
left: addresses.left,
|
||||
@@ -352,6 +354,7 @@ class DashboardController {
|
||||
this.screenTimeoutTimer = setInterval(() => {
|
||||
if (this.phase !== "connected" || !this.communicator) return;
|
||||
if (!applyDashboardScreenTimeout()) return;
|
||||
this.endTextSettingEdit();
|
||||
void this.requestRender("interval").catch((error) => {
|
||||
const message = this.formatError(error);
|
||||
this.appendLog(`screen timeout render failed: ${message}`);
|
||||
@@ -649,6 +652,9 @@ class DashboardController {
|
||||
private startVoiceControlIfEnabled(): void {
|
||||
if (!this.communicator) return;
|
||||
if (!isDashboardVoiceControlEnabled()) return;
|
||||
if (this.phase === "connected") {
|
||||
updateForegroundNotification("Connected");
|
||||
}
|
||||
voiceControlBridge.start();
|
||||
}
|
||||
|
||||
|
||||
+30
-1
@@ -1,7 +1,11 @@
|
||||
import { EventData, Observable, Page, ScrollView, TextField } from '@nativescript/core'
|
||||
import { Color, EventData, isAndroid, Observable, Page, ScrollView, TextField } from '@nativescript/core'
|
||||
import { MainViewModel } from './main-view-model'
|
||||
import { dashboardController } from './g2/dashboard-controller'
|
||||
|
||||
const SETTINGS_TEXT_COLOR = new Color('#222222')
|
||||
const SETTINGS_BACKGROUND_COLOR = new Color('#ffffff')
|
||||
const SETTINGS_PLACEHOLDER_COLOR = new Color('#666666')
|
||||
|
||||
export function navigatingTo(args: EventData) {
|
||||
const page = <Page>args.object
|
||||
page.bindingContext = new MainViewModel()
|
||||
@@ -44,9 +48,30 @@ function scrollToBottom(scrollView: ScrollView): void {
|
||||
}, 0)
|
||||
}
|
||||
|
||||
function applySettingsTextFieldContrast(textField: TextField): void {
|
||||
textField.color = SETTINGS_TEXT_COLOR
|
||||
textField.backgroundColor = SETTINGS_BACKGROUND_COLOR
|
||||
textField.placeholderColor = SETTINGS_PLACEHOLDER_COLOR
|
||||
|
||||
if (!isAndroid) {
|
||||
return
|
||||
}
|
||||
|
||||
const nativeTextField = (textField as TextField & { nativeView?: android.widget.EditText }).nativeView
|
||||
if (!nativeTextField) {
|
||||
return
|
||||
}
|
||||
|
||||
nativeTextField.setTextColor(android.graphics.Color.rgb(34, 34, 34))
|
||||
nativeTextField.setHintTextColor(android.graphics.Color.rgb(102, 102, 102))
|
||||
}
|
||||
|
||||
function focusSystemNameField(page: Page): void {
|
||||
setTimeout(() => {
|
||||
const textField = page.getViewById<TextField>('settingsTextField')
|
||||
if (textField) {
|
||||
applySettingsTextFieldContrast(textField)
|
||||
}
|
||||
textField?.focus()
|
||||
}, 0)
|
||||
}
|
||||
@@ -58,6 +83,10 @@ export function loaded(args: EventData) {
|
||||
|
||||
const model = page.bindingContext as MainViewModel | null
|
||||
const scrollView = page.getViewById<ScrollView>('logScrollView')
|
||||
const settingsTextField = page.getViewById<TextField>('settingsTextField')
|
||||
if (settingsTextField) {
|
||||
applySettingsTextFieldContrast(settingsTextField)
|
||||
}
|
||||
if (!model || !scrollView) {
|
||||
return
|
||||
}
|
||||
|
||||
+21
-13
@@ -92,7 +92,6 @@ const SYSTEM_CARD_ITEM_HEIGHT = 38;
|
||||
const SYSTEM_CARD_ITEM_GAP = 2;
|
||||
const BATTERY_ITEM_Y_OFFSET = 4;
|
||||
const TOP_LEFT_MENU_LAYOUT = { x: 8, y: 8, width: 272, height: 128 };
|
||||
const TOP_RIGHT_MENU_LAYOUT = { x: 296, y: 8, width: 272, height: 128 };
|
||||
|
||||
function rawInputEventToInputEvent(event: RawInputEvent): DashboardInputEvent {
|
||||
if (event.kind === "sys-event") {
|
||||
@@ -137,6 +136,16 @@ export async function receiveInput(event: RawInputEvent): Promise<void> {
|
||||
const inputEvent = rawInputEventToInputEvent(event);
|
||||
dashboardState.lastInputAtMs = Date.now();
|
||||
dashboardState.logLines.push(eventToString(inputEvent));
|
||||
if (!dashboardState.screenOn) {
|
||||
if (inputEvent.type === "double-click") {
|
||||
dashboardState.screenOn = true;
|
||||
dashboardState.tiledWakePaintPending = dashboardState.wakeMode === "tiled";
|
||||
if (dashboardLayers.isAtBase()) {
|
||||
dashboardLayers.push(createRootMenuLayer());
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
await dashboardLayers.handleInput(inputEvent);
|
||||
}
|
||||
|
||||
@@ -165,6 +174,9 @@ export function setDashboardActions(actions: Partial<LayerActions>): void {
|
||||
}
|
||||
|
||||
export function drawDashboard(): GrayImage {
|
||||
if (!dashboardState.screenOn) {
|
||||
return new GrayImage(G2_LENS_WIDTH, G2_LENS_HEIGHT, 0);
|
||||
}
|
||||
return dashboardLayers.paint();
|
||||
}
|
||||
|
||||
@@ -227,10 +239,13 @@ export function applyDashboardScreenTimeout(nowMs = Date.now()): boolean {
|
||||
if (timeoutMs === null || !dashboardState.screenOn) return false;
|
||||
if (nowMs - dashboardState.lastInputAtMs < timeoutMs) return false;
|
||||
dashboardState.screenOn = false;
|
||||
dashboardLayers.clearToBase();
|
||||
return true;
|
||||
}
|
||||
|
||||
export function noteDashboardPhoneTextInput(nowMs = Date.now()): void {
|
||||
dashboardState.lastInputAtMs = nowMs;
|
||||
}
|
||||
|
||||
export function resetDashboardSleepTimerAndWake(nowMs = Date.now()): boolean {
|
||||
dashboardState.lastInputAtMs = nowMs;
|
||||
if (dashboardState.screenOn) return false;
|
||||
@@ -399,15 +414,6 @@ class DashboardLayer implements Layer {
|
||||
}
|
||||
|
||||
handleInput(event: DashboardInputEvent, ctx: { stack: LayerStack }): void {
|
||||
if (!dashboardState.screenOn) {
|
||||
if (event.type === "double-click") {
|
||||
dashboardState.screenOn = true;
|
||||
dashboardState.tiledWakePaintPending = dashboardState.wakeMode === "tiled";
|
||||
ctx.stack.push(createRootMenuLayer());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.type === "click") {
|
||||
ctx.stack.push(createRootMenuLayer());
|
||||
return;
|
||||
@@ -415,6 +421,8 @@ class DashboardLayer implements Layer {
|
||||
|
||||
if (event.type === "double-click") {
|
||||
dashboardState.screenOn = false;
|
||||
ctx.stack.clearToBase();
|
||||
void dashboardActions.endTextSettingEdit();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -424,6 +432,7 @@ class RootMenuLayer extends MenuLayer {
|
||||
if (event.type === "double-click") {
|
||||
dashboardState.screenOn = false;
|
||||
ctx.stack.clearToBase();
|
||||
void ctx.actions.endTextSettingEdit();
|
||||
return;
|
||||
}
|
||||
await super.handleInput(event, ctx);
|
||||
@@ -637,8 +646,7 @@ function createSystemCardSettingsMenuLayer(): MenuLayer {
|
||||
createSystemCardToggleItem("Show Android Notifications", "showAndroidNotifications"),
|
||||
createSystemCardToggleItem("Show Signal Strength", "showSignalStrength"),
|
||||
],
|
||||
TOP_RIGHT_MENU_LAYOUT,
|
||||
true,
|
||||
TOP_LEFT_MENU_LAYOUT,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,10 @@ export class LayerStack {
|
||||
this.layers.splice(1);
|
||||
}
|
||||
|
||||
isAtBase(): boolean {
|
||||
return this.layers.length === 1;
|
||||
}
|
||||
|
||||
setActions(actions: Partial<LayerActions>): void {
|
||||
Object.assign(this.ctx.actions, actions);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user