diff --git a/app/graphics/image.ts b/app/graphics/image.ts index c6796a53..fcf1e6bb 100644 --- a/app/graphics/image.ts +++ b/app/graphics/image.ts @@ -251,7 +251,7 @@ export class GrayImage { y: ty, width, height, - bmp: buildEvenHubBmp(width, height, (x, y) => this.getPixel(tx + x, ty + y) >> 4), + bmp: buildEvenHubBmp(width, height, (x, y) => grayToEvenHubNibble(this.getPixel(tx + x, ty + y))), }); } } @@ -327,6 +327,11 @@ function buildEvenHubBmp( return buf; } +function grayToEvenHubNibble(value: number): number { + const clamped = clampByte(value); + return clamped === 0 ? 0 : Math.min(15, (clamped + 15) >> 4); +} + function clampByte(value: number): number { return Math.max(0, Math.min(255, Math.round(value))); } diff --git a/app/images/faceclaw-logo-dashboard.png b/app/images/faceclaw-logo-dashboard.png index c05877ec..925f100d 100644 Binary files a/app/images/faceclaw-logo-dashboard.png and b/app/images/faceclaw-logo-dashboard.png differ diff --git a/app/phone-ui/main-page.ts b/app/phone-ui/main-page.ts index ecbece43..4fd726db 100644 --- a/app/phone-ui/main-page.ts +++ b/app/phone-ui/main-page.ts @@ -1,4 +1,4 @@ -import { Color, EventData, isAndroid, Observable, Page, ScrollView, TextField } from '@nativescript/core' +import { Application, Color, EventData, isAndroid, Observable, Page, ScrollView, TextField } from '@nativescript/core' import { MainViewModel } from './main-view-model' import { dashboardController } from '../g2/dashboard-controller' @@ -12,9 +12,12 @@ export function navigatingTo(args: EventData) { } type MainPageState = { + model: MainViewModel isPinnedToBottom: boolean - scrollHandler: () => void + scrollViews: ScrollView[] + scrollHandler: (args: EventData) => void propertyChangeHandler: (args: EventData & { propertyName?: string }) => void + orientationHandler: () => void } function getPageState(page: Page): MainPageState | undefined { @@ -27,14 +30,15 @@ function setPageState(page: Page, state?: MainPageState): void { function cleanupPage(page: Page): void { const state = getPageState(page) - const model = page.bindingContext as MainViewModel | null - const scrollView = page.getViewById('logScrollView') - if (!state || !model || !scrollView) { + if (!state) { setPageState(page, undefined) return } - scrollView.off(ScrollView.scrollEvent, state.scrollHandler) - model.off(Observable.propertyChangeEvent, state.propertyChangeHandler) + for (const scrollView of state.scrollViews) { + scrollView.off(ScrollView.scrollEvent, state.scrollHandler) + } + state.model.off(Observable.propertyChangeEvent, state.propertyChangeHandler) + Application.off(Application.orientationChangedEvent, state.orientationHandler) setPageState(page, undefined) } @@ -48,6 +52,12 @@ function scrollToBottom(scrollView: ScrollView): void { }, 0) } +function scrollLogsToBottom(scrollViews: ScrollView[]): void { + for (const scrollView of scrollViews) { + scrollToBottom(scrollView) + } +} + function applySettingsTextFieldContrast(textField: TextField): void { textField.color = SETTINGS_TEXT_COLOR textField.backgroundColor = SETTINGS_BACKGROUND_COLOR @@ -82,25 +92,39 @@ export function loaded(args: EventData) { dashboardController.refreshEvenAppStatus() const model = page.bindingContext as MainViewModel | null - const scrollView = page.getViewById('logScrollView') + const scrollViews = [ + page.getViewById('logScrollView'), + page.getViewById('logScrollViewLandscape'), + ].filter((scrollView): scrollView is ScrollView => !!scrollView) const settingsTextField = page.getViewById('settingsTextField') + model?.refreshLayoutMetrics() if (settingsTextField) { applySettingsTextFieldContrast(settingsTextField) } - if (!model || !scrollView) { + if (!model || scrollViews.length === 0) { return } const state: MainPageState = { + model, isPinnedToBottom: true, - scrollHandler: () => { - state.isPinnedToBottom = isAtBottom(scrollView) + scrollViews, + scrollHandler: (scrollArgs) => { + state.isPinnedToBottom = isAtBottom(scrollArgs.object as ScrollView) + }, + orientationHandler: () => { + setTimeout(() => { + model.refreshLayoutMetrics() + if (state.isPinnedToBottom) { + scrollLogsToBottom(scrollViews) + } + }, 0) }, propertyChangeHandler: (propertyArgs) => { if (propertyArgs.propertyName === 'showLog') { if (model.showLog) { state.isPinnedToBottom = true - scrollToBottom(scrollView) + scrollLogsToBottom(scrollViews) } return } @@ -114,15 +138,18 @@ export function loaded(args: EventData) { return } if (state.isPinnedToBottom) { - scrollToBottom(scrollView) + scrollLogsToBottom(scrollViews) } }, } - scrollView.on(ScrollView.scrollEvent, state.scrollHandler) + for (const scrollView of scrollViews) { + scrollView.on(ScrollView.scrollEvent, state.scrollHandler) + } model.on(Observable.propertyChangeEvent, state.propertyChangeHandler) + Application.on(Application.orientationChangedEvent, state.orientationHandler) setPageState(page, state) - scrollToBottom(scrollView) + scrollLogsToBottom(scrollViews) if (model.isTextSettingEditorActive) { focusSystemNameField(page) } diff --git a/app/phone-ui/main-page.xml b/app/phone-ui/main-page.xml index e27c645f..34d83397 100644 --- a/app/phone-ui/main-page.xml +++ b/app/phone-ui/main-page.xml @@ -5,30 +5,57 @@ - - - - - + + + + + + + +