diff --git a/android/app/capacitor.build.gradle b/android/app/capacitor.build.gradle index 93cc75c..458b57d 100644 --- a/android/app/capacitor.build.gradle +++ b/android/app/capacitor.build.gradle @@ -9,6 +9,7 @@ android { apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle" dependencies { + implementation project(':capacitor-community-keep-awake') implementation project(':capacitor-community-native-audio') implementation project(':capacitor-community-sqlite') implementation project(':capacitor-community-text-to-speech') diff --git a/android/capacitor.settings.gradle b/android/capacitor.settings.gradle index 224b553..d616aab 100644 --- a/android/capacitor.settings.gradle +++ b/android/capacitor.settings.gradle @@ -2,6 +2,9 @@ include ':capacitor-android' 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' project(':capacitor-community-native-audio').projectDir = new File('../node_modules/@capacitor-community/native-audio/android') diff --git a/bun.lock b/bun.lock index 25bc995..a9cda75 100644 --- a/bun.lock +++ b/bun.lock @@ -4,6 +4,7 @@ "": { "name": "librenav", "dependencies": { + "@capacitor-community/keep-awake": "^7.1.0", "@capacitor-community/native-audio": "^7.0.0", "@capacitor-community/sqlite": "^7.0.0", "@capacitor-community/text-to-speech": "^6.0.0", @@ -54,6 +55,8 @@ "@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/sqlite": ["@capacitor-community/sqlite@7.0.0", "", { "dependencies": { "jeep-sqlite": "^2.7.2" }, "peerDependencies": { "@capacitor/core": ">=7.0.0" } }, "sha512-GSHxLEiyuhPoWwpMLOwfaOhLpfZglhfI1sqEgA5bSbtIYt1I+iK02b/ymonaghB176NhA5wuGd+spOIaL0kgHw=="], diff --git a/package.json b/package.json index 8fdd36b..a21e66f 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ }, "type": "module", "dependencies": { + "@capacitor-community/keep-awake": "^7.1.0", "@capacitor-community/native-audio": "^7.0.0", "@capacitor-community/sqlite": "^7.0.0", "@capacitor-community/text-to-speech": "^6.0.0", diff --git a/src/lib/services/navigation/routing.svelte.ts b/src/lib/services/navigation/routing.svelte.ts index 5576ee4..1cc61e6 100644 --- a/src/lib/services/navigation/routing.svelte.ts +++ b/src/lib/services/navigation/routing.svelte.ts @@ -4,6 +4,8 @@ import say from "./TTS"; import type { ValhallaRequest } from "./ValhallaRequest"; import type { LngLatBoundsLike } from "maplibre-gl"; import { generateVoiceGuidance } from "./VoiceGuidance"; +import { Capacitor } from "@capacitor/core"; +import { KeepAwake } from "@capacitor-community/keep-awake"; export const routing = $state({ geojson: { @@ -128,6 +130,9 @@ function drawCurrentTrip() { } export async function startRoute(trip: Trip) { + if(Capacitor.isNativePlatform()) { + await KeepAwake.keepAwake(); + } routing.currentTrip = trip; removeAllRoutes(); routing.geojson.route = tripToGeoJSON(trip); @@ -266,6 +271,9 @@ export function stopNavigation() { routing.currentTrip = null; map.updateMapPadding(); // TODO: REMOVE removeAllRoutes(); + if(Capacitor.isNativePlatform()) { + KeepAwake.allowSleep(); + } } // function getUserLocation(): WorldLocation {