forked from Blendman974/faceclaw
Add calendar app and accelerometer demo
This commit is contained in:
1 parent
3cdc5ba262
commit
ff447d5161
18 files changed
+911
-5
No files matched your search
@@ -2,8 +2,10 @@ import { Application, Utils } from "@nativescript/core";
|
||||
|
||||
const PERMISSION_REQUEST_CODE = 4242;
|
||||
const VOICE_PERMISSION_REQUEST_CODE = 4243;
|
||||
const CALENDAR_PERMISSION_REQUEST_CODE = 4244;
|
||||
const POST_NOTIFICATIONS_PERMISSION = "android.permission.POST_NOTIFICATIONS";
|
||||
const RECORD_AUDIO_PERMISSION = "android.permission.RECORD_AUDIO";
|
||||
const READ_CALENDAR_PERMISSION = "android.permission.READ_CALENDAR";
|
||||
|
||||
function getActivity(): androidx.appcompat.app.AppCompatActivity {
|
||||
const activity = Application.android.foregroundActivity ?? Application.android.startActivity;
|
||||
@@ -101,3 +103,24 @@ export async function ensureVoicePermissions(): Promise<void> {
|
||||
await ensurePermissions([RECORD_AUDIO_PERMISSION], VOICE_PERMISSION_REQUEST_CODE, "Voice control");
|
||||
}
|
||||
|
||||
/** Whether READ_CALENDAR has been granted (false off-Android). */
|
||||
export function hasCalendarPermission(): boolean {
|
||||
if (!global.isAndroid) return false;
|
||||
return isPermissionGranted(READ_CALENDAR_PERMISSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prompt for READ_CALENDAR if not already granted. Resolves true when the
|
||||
* permission is held afterward, false if the user denied it (or no activity
|
||||
* was available to show the prompt).
|
||||
*/
|
||||
export async function ensureCalendarPermission(): Promise<boolean> {
|
||||
if (!global.isAndroid) return false;
|
||||
try {
|
||||
await ensurePermissions([READ_CALENDAR_PERMISSION], CALENDAR_PERMISSION_REQUEST_CODE, "Calendar");
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,11 @@ import {
|
||||
NOTIFICATIONS_SURFACE_ID,
|
||||
NOTIFICATIONS_WINDOW_ID,
|
||||
} from "../ui/shell/notifications-app";
|
||||
import {
|
||||
createCalendarAppWindow,
|
||||
CALENDAR_SURFACE_ID,
|
||||
CALENDAR_WINDOW_ID,
|
||||
} from "../ui/shell/calendar-app";
|
||||
import {
|
||||
createDebugTestsAppWindow,
|
||||
DEBUG_TESTS_SURFACE_ID,
|
||||
@@ -218,6 +223,7 @@ class DashboardController {
|
||||
{ appId: "nightscout", label: "Nightscout", icon: "nightscout" },
|
||||
{ appId: "transcribe", label: "Transcribe", icon: "mic" },
|
||||
{ appId: "notifications", label: "Notifications", icon: "bell" },
|
||||
{ appId: "calendar", label: "Calendar", icon: "calendar" },
|
||||
{ appId: "debug-tests", label: "Debug tests", icon: "flask-conical" },
|
||||
{ appId: "settings", label: "Settings", icon: "settings" },
|
||||
],
|
||||
@@ -873,6 +879,10 @@ class DashboardController {
|
||||
await this.launchInProcessApp(NOTIFICATIONS_WINDOW_ID, NOTIFICATIONS_SURFACE_ID, createNotificationsAppWindow);
|
||||
return;
|
||||
}
|
||||
if (appId === "calendar") {
|
||||
await this.launchInProcessApp(CALENDAR_WINDOW_ID, CALENDAR_SURFACE_ID, createCalendarAppWindow);
|
||||
return;
|
||||
}
|
||||
if (appId === "debug-tests") {
|
||||
await this.launchInProcessApp(DEBUG_TESTS_WINDOW_ID, DEBUG_TESTS_SURFACE_ID, createDebugTestsAppWindow);
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user