forked from Blendman974/faceclaw
Add Timer, Weather apps; build out UI of music app; add wakeword action setting
This commit is contained in:
1 parent
008f2277ca
commit
5c73ba2a4d
27 files changed
+2181
-312
No files matched your search
@@ -3,9 +3,11 @@ import { Application, Utils } from "@nativescript/core";
|
||||
const PERMISSION_REQUEST_CODE = 4242;
|
||||
const VOICE_PERMISSION_REQUEST_CODE = 4243;
|
||||
const CALENDAR_PERMISSION_REQUEST_CODE = 4244;
|
||||
const LOCATION_PERMISSION_REQUEST_CODE = 4245;
|
||||
const POST_NOTIFICATIONS_PERMISSION = "android.permission.POST_NOTIFICATIONS";
|
||||
const RECORD_AUDIO_PERMISSION = "android.permission.RECORD_AUDIO";
|
||||
const READ_CALENDAR_PERMISSION = "android.permission.READ_CALENDAR";
|
||||
const ACCESS_COARSE_LOCATION_PERMISSION = "android.permission.ACCESS_COARSE_LOCATION";
|
||||
|
||||
function getActivity(): androidx.appcompat.app.AppCompatActivity {
|
||||
const activity = Application.android.foregroundActivity ?? Application.android.startActivity;
|
||||
@@ -124,3 +126,26 @@ export async function ensureCalendarPermission(): Promise<boolean> {
|
||||
}
|
||||
}
|
||||
|
||||
/** Whether approximate foreground location access has been granted. */
|
||||
export function hasLocationPermission(): boolean {
|
||||
if (!global.isAndroid) return false;
|
||||
return isPermissionGranted(ACCESS_COARSE_LOCATION_PERMISSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prompt for approximate foreground location access. Weather only needs a
|
||||
* coarse coordinate, which avoids asking for more precise access than needed.
|
||||
*/
|
||||
export async function ensureLocationPermission(): Promise<boolean> {
|
||||
if (!global.isAndroid) return false;
|
||||
try {
|
||||
await ensurePermissions(
|
||||
[ACCESS_COARSE_LOCATION_PERMISSION],
|
||||
LOCATION_PERMISSION_REQUEST_CODE,
|
||||
"Location",
|
||||
);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,11 @@ import {
|
||||
CALENDAR_SURFACE_ID,
|
||||
CALENDAR_WINDOW_ID,
|
||||
} from "../ui/shell/calendar-app";
|
||||
import {
|
||||
createWeatherAppWindow,
|
||||
WEATHER_SURFACE_ID,
|
||||
WEATHER_WINDOW_ID,
|
||||
} from "../ui/shell/weather-app";
|
||||
import {
|
||||
createDebugTestsAppWindow,
|
||||
DEBUG_TESTS_SURFACE_ID,
|
||||
@@ -229,7 +234,7 @@ class DashboardController {
|
||||
requestRender: () => shell.foregroundWindow()?.requestRender(),
|
||||
},
|
||||
apps: [
|
||||
{ appId: "stopwatch", label: "Stopwatch", icon: "timer" },
|
||||
{ appId: "timer", label: "Timer", icon: "timer" },
|
||||
{ appId: "terminal", label: "Terminal", icon: "terminal" },
|
||||
{ appId: "teleprompt", label: "Teleprompt", icon: "file-text" },
|
||||
{ appId: "music", label: "Music", icon: "music" },
|
||||
@@ -237,6 +242,7 @@ class DashboardController {
|
||||
{ appId: "transcribe", label: "Transcribe", icon: "mic" },
|
||||
{ appId: "notifications", label: "Notifications", icon: "bell" },
|
||||
{ appId: "calendar", label: "Calendar", icon: "calendar" },
|
||||
{ appId: "weather", label: "Weather", icon: "cloud-sun" },
|
||||
{ appId: "debug-tests", label: "Debug tests", icon: "flask-conical" },
|
||||
{ appId: "settings", label: "Settings", icon: "settings" },
|
||||
],
|
||||
@@ -854,8 +860,8 @@ class DashboardController {
|
||||
if (existing) return existing;
|
||||
// Worker paths must be string literals for the webpack worker loader.
|
||||
let worker: Worker;
|
||||
if (appId === "stopwatch") {
|
||||
worker = new Worker("../workers/stopwatch-app.worker");
|
||||
if (appId === "timer") {
|
||||
worker = new Worker("../workers/timer-app.worker");
|
||||
} else if (appId === "terminal") {
|
||||
worker = new Worker("../workers/terminal-app.worker");
|
||||
} else {
|
||||
@@ -898,6 +904,10 @@ class DashboardController {
|
||||
await this.launchInProcessApp(CALENDAR_WINDOW_ID, CALENDAR_SURFACE_ID, createCalendarAppWindow);
|
||||
return;
|
||||
}
|
||||
if (appId === "weather") {
|
||||
await this.launchInProcessApp(WEATHER_WINDOW_ID, WEATHER_SURFACE_ID, createWeatherAppWindow);
|
||||
return;
|
||||
}
|
||||
if (appId === "debug-tests") {
|
||||
await this.launchInProcessApp(DEBUG_TESTS_WINDOW_ID, DEBUG_TESTS_SURFACE_ID, createDebugTestsAppWindow);
|
||||
return;
|
||||
@@ -945,10 +955,17 @@ class DashboardController {
|
||||
this.appendLog("launched terminal:hub");
|
||||
return;
|
||||
}
|
||||
const serial = this.nextWindowSerial++;
|
||||
const windowId = `${appId}:${serial}`;
|
||||
host.openWindow({ windowId, title: `Stopwatch ${serial}`, iconLetter: "S", icon: "timer", focus: true });
|
||||
this.appendLog(`launched ${windowId}`);
|
||||
if (appId === "timer") {
|
||||
const existing = shell.getWindows().find((window) => window.appId === "timer");
|
||||
if (existing) {
|
||||
shell.focusWindow(existing.windowId);
|
||||
this.requestShellRender();
|
||||
return;
|
||||
}
|
||||
host.openWindow({ windowId: "timer:main", title: "Timer", iconLetter: "T", icon: "timer", focus: true });
|
||||
this.appendLog("launched timer:main");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/** Create/refresh a window surface on the compositor, if connected. */
|
||||
|
||||
Reference in new issue
Block a user