feat: keep device awake during navigation

This commit is contained in:
Cfp
2025-07-03 18:07:05 +02:00
parent 94b8b8559c
commit 0b7ba06e9e
5 changed files with 16 additions and 0 deletions

View File

@ -9,6 +9,7 @@ android {
apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle" apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
dependencies { dependencies {
implementation project(':capacitor-community-keep-awake')
implementation project(':capacitor-community-native-audio') implementation project(':capacitor-community-native-audio')
implementation project(':capacitor-community-sqlite') implementation project(':capacitor-community-sqlite')
implementation project(':capacitor-community-text-to-speech') implementation project(':capacitor-community-text-to-speech')

View File

@ -2,6 +2,9 @@
include ':capacitor-android' include ':capacitor-android'
project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/android/capacitor') project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/android/capacitor')
include ':capacitor-community-keep-awake'
project(':capacitor-community-keep-awake').projectDir = new File('../node_modules/@capacitor-community/keep-awake/android')
include ':capacitor-community-native-audio' include ':capacitor-community-native-audio'
project(':capacitor-community-native-audio').projectDir = new File('../node_modules/@capacitor-community/native-audio/android') project(':capacitor-community-native-audio').projectDir = new File('../node_modules/@capacitor-community/native-audio/android')

View File

@ -4,6 +4,7 @@
"": { "": {
"name": "librenav", "name": "librenav",
"dependencies": { "dependencies": {
"@capacitor-community/keep-awake": "^7.1.0",
"@capacitor-community/native-audio": "^7.0.0", "@capacitor-community/native-audio": "^7.0.0",
"@capacitor-community/sqlite": "^7.0.0", "@capacitor-community/sqlite": "^7.0.0",
"@capacitor-community/text-to-speech": "^6.0.0", "@capacitor-community/text-to-speech": "^6.0.0",
@ -54,6 +55,8 @@
"@babel/runtime": ["@babel/runtime@7.27.3", "", {}, "sha512-7EYtGezsdiDMyY80+65EzwiGmcJqpmcZCojSXaRgdrBaGtWTgDZKq69cPIVped6MkIM78cTQ2GOiEYjwOlG4xw=="], "@babel/runtime": ["@babel/runtime@7.27.3", "", {}, "sha512-7EYtGezsdiDMyY80+65EzwiGmcJqpmcZCojSXaRgdrBaGtWTgDZKq69cPIVped6MkIM78cTQ2GOiEYjwOlG4xw=="],
"@capacitor-community/keep-awake": ["@capacitor-community/keep-awake@7.1.0", "", { "peerDependencies": { "@capacitor/core": ">=7.0.0" } }, "sha512-4Hj6OKnBd/DAOeiMnqBy74tg1rwC+qLYWQbWJmysMZm2e2nptz43hxaKu22Xlyyw5O71CwwskLCM0skDFMPpQQ=="],
"@capacitor-community/native-audio": ["@capacitor-community/native-audio@7.0.0", "", { "peerDependencies": { "@capacitor/core": ">=7.0.0" } }, "sha512-wi2l68tU6KDLJWKL6I0lPUKOdB+hNxlvF7RMe/jfkKOMZnd1eUq7kszmbMqyGFZFIxdNG/GMiZrEztZHDypf8A=="], "@capacitor-community/native-audio": ["@capacitor-community/native-audio@7.0.0", "", { "peerDependencies": { "@capacitor/core": ">=7.0.0" } }, "sha512-wi2l68tU6KDLJWKL6I0lPUKOdB+hNxlvF7RMe/jfkKOMZnd1eUq7kszmbMqyGFZFIxdNG/GMiZrEztZHDypf8A=="],
"@capacitor-community/sqlite": ["@capacitor-community/sqlite@7.0.0", "", { "dependencies": { "jeep-sqlite": "^2.7.2" }, "peerDependencies": { "@capacitor/core": ">=7.0.0" } }, "sha512-GSHxLEiyuhPoWwpMLOwfaOhLpfZglhfI1sqEgA5bSbtIYt1I+iK02b/ymonaghB176NhA5wuGd+spOIaL0kgHw=="], "@capacitor-community/sqlite": ["@capacitor-community/sqlite@7.0.0", "", { "dependencies": { "jeep-sqlite": "^2.7.2" }, "peerDependencies": { "@capacitor/core": ">=7.0.0" } }, "sha512-GSHxLEiyuhPoWwpMLOwfaOhLpfZglhfI1sqEgA5bSbtIYt1I+iK02b/ymonaghB176NhA5wuGd+spOIaL0kgHw=="],

View File

@ -33,6 +33,7 @@
}, },
"type": "module", "type": "module",
"dependencies": { "dependencies": {
"@capacitor-community/keep-awake": "^7.1.0",
"@capacitor-community/native-audio": "^7.0.0", "@capacitor-community/native-audio": "^7.0.0",
"@capacitor-community/sqlite": "^7.0.0", "@capacitor-community/sqlite": "^7.0.0",
"@capacitor-community/text-to-speech": "^6.0.0", "@capacitor-community/text-to-speech": "^6.0.0",

View File

@ -4,6 +4,8 @@ import say from "./TTS";
import type { ValhallaRequest } from "./ValhallaRequest"; import type { ValhallaRequest } from "./ValhallaRequest";
import type { LngLatBoundsLike } from "maplibre-gl"; import type { LngLatBoundsLike } from "maplibre-gl";
import { generateVoiceGuidance } from "./VoiceGuidance"; import { generateVoiceGuidance } from "./VoiceGuidance";
import { Capacitor } from "@capacitor/core";
import { KeepAwake } from "@capacitor-community/keep-awake";
export const routing = $state({ export const routing = $state({
geojson: { geojson: {
@ -128,6 +130,9 @@ function drawCurrentTrip() {
} }
export async function startRoute(trip: Trip) { export async function startRoute(trip: Trip) {
if(Capacitor.isNativePlatform()) {
await KeepAwake.keepAwake();
}
routing.currentTrip = trip; routing.currentTrip = trip;
removeAllRoutes(); removeAllRoutes();
routing.geojson.route = tripToGeoJSON(trip); routing.geojson.route = tripToGeoJSON(trip);
@ -266,6 +271,9 @@ export function stopNavigation() {
routing.currentTrip = null; routing.currentTrip = null;
map.updateMapPadding(); // TODO: REMOVE map.updateMapPadding(); // TODO: REMOVE
removeAllRoutes(); removeAllRoutes();
if(Capacitor.isNativePlatform()) {
KeepAwake.allowSleep();
}
} }
// function getUserLocation(): WorldLocation { // function getUserLocation(): WorldLocation {