@iternio/react-native-auto-play 0.1.10 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/VirtualRenderer.kt +1 -1
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/template/MapTemplate.kt +19 -4
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/template/TripPreviewTemplate.kt +7 -4
- package/ios/scenes/HeadUnitSceneDelegate.swift +12 -0
- package/lib/specs/VoiceInput.nitro.d.ts +8 -0
- package/lib/specs/VoiceInput.nitro.js +1 -0
- package/package.json +1 -1
- package/lib/hooks/useIsAutoPlayFocused.d.ts +0 -7
- package/lib/hooks/useIsAutoPlayFocused.js +0 -20
- package/lib/hybrid.d.ts +0 -2
- package/lib/hybrid.js +0 -2
package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/VirtualRenderer.kt
CHANGED
|
@@ -250,7 +250,7 @@ class VirtualRenderer(
|
|
|
250
250
|
private fun getMapTemplateConfig(): MapTemplateConfig? {
|
|
251
251
|
val screenManager = AndroidAutoScreen.getScreen(moduleName)?.screenManager ?: return null
|
|
252
252
|
val marker = screenManager.top.marker ?: return null
|
|
253
|
-
return AndroidAutoTemplate.
|
|
253
|
+
return AndroidAutoTemplate.getTypedConfig<MapTemplateConfig>(marker)
|
|
254
254
|
}
|
|
255
255
|
|
|
256
256
|
private fun initRenderer() {
|
|
@@ -239,11 +239,19 @@ class MapTemplate(
|
|
|
239
239
|
fun updateTripDestinations() {
|
|
240
240
|
val tripDestinations = getTripDestinations()
|
|
241
241
|
UiThreadUtil.runOnUiThread {
|
|
242
|
-
|
|
242
|
+
val trip = Trip.Builder().apply {
|
|
243
243
|
tripDestinations.forEach {
|
|
244
244
|
addDestination(it.key, it.value)
|
|
245
245
|
}
|
|
246
|
-
}.build()
|
|
246
|
+
}.build()
|
|
247
|
+
try {
|
|
248
|
+
navigationManager.updateTrip(trip)
|
|
249
|
+
} catch(e: IllegalStateException) {
|
|
250
|
+
// Sometimes we get a "java.lang.IllegalStateException: Navigation is not started" here, although the navigation
|
|
251
|
+
// is started already (we check for isNavigating at the top). So i guess this is a race condition, that we start navigation
|
|
252
|
+
// and the AA app is not ready yet. Unfortunately we can not ask the AA app for it's state, so we just catch the error.
|
|
253
|
+
}
|
|
254
|
+
|
|
247
255
|
}
|
|
248
256
|
}
|
|
249
257
|
|
|
@@ -380,7 +388,7 @@ class MapTemplate(
|
|
|
380
388
|
AndroidAutoScreen.invalidateSurfaceScreens()
|
|
381
389
|
|
|
382
390
|
UiThreadUtil.runOnUiThread {
|
|
383
|
-
|
|
391
|
+
val trip = Trip.Builder().apply {
|
|
384
392
|
addStep(
|
|
385
393
|
currentStep, Parser.parseTravelEstimates(current.travelEstimates)
|
|
386
394
|
)
|
|
@@ -390,7 +398,14 @@ class MapTemplate(
|
|
|
390
398
|
getTripDestinations().forEach {
|
|
391
399
|
addDestination(it.key, it.value)
|
|
392
400
|
}
|
|
393
|
-
}.build()
|
|
401
|
+
}.build()
|
|
402
|
+
try {
|
|
403
|
+
navigationManager.updateTrip(trip)
|
|
404
|
+
} catch(exception: IllegalStateException) {
|
|
405
|
+
// Sometimes we get a "java.lang.IllegalStateException: Navigation is not started" here, although the navigation
|
|
406
|
+
// is started already (we check for isNavigating at the top). So i guess this is a race condition, that we start navigation
|
|
407
|
+
// and the AA app is not ready yet. Unfortunately we can not ask the AA app for it's state, so we just catch the error.
|
|
408
|
+
}
|
|
394
409
|
}
|
|
395
410
|
}
|
|
396
411
|
}
|
|
@@ -63,10 +63,13 @@ class TripPreviewTemplate(
|
|
|
63
63
|
|
|
64
64
|
return MapWithContentTemplate.Builder().apply {
|
|
65
65
|
val pane = Pane.Builder().apply {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
selectedRoute.additionalInformationVariants.firstOrNull()
|
|
67
|
+
?.takeIf { it.isNotEmpty() }?.let {
|
|
68
|
+
addRow(Row.Builder().apply {
|
|
69
|
+
setTitle(Parser.parseText(selectedRoute.additionalInformationVariants))
|
|
70
|
+
addText(Parser.parseText(selectedRoute.selectionSummaryVariants))
|
|
71
|
+
}.build())
|
|
72
|
+
}
|
|
70
73
|
addRow(Row.Builder().apply {
|
|
71
74
|
setTitle(
|
|
72
75
|
"${textConfig.travelEstimatesTitle} ${
|
|
@@ -37,6 +37,18 @@ class HeadUnitSceneDelegate: AutoPlayScene, CPTemplateApplicationSceneDelegate {
|
|
|
37
37
|
HybridAutoPlay.emit(event: .didconnect)
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
func templateApplicationScene(
|
|
41
|
+
_ templateApplicationScene: CPTemplateApplicationScene,
|
|
42
|
+
didConnect interfaceController: CPInterfaceController
|
|
43
|
+
) {
|
|
44
|
+
self.interfaceController = AutoPlayInterfaceController(
|
|
45
|
+
interfaceController: interfaceController
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
connect(props: [:])
|
|
49
|
+
HybridAutoPlay.emit(event: .didconnect)
|
|
50
|
+
}
|
|
51
|
+
|
|
40
52
|
func templateApplicationScene(
|
|
41
53
|
_ templateApplicationScene: CPTemplateApplicationScene,
|
|
42
54
|
didDisconnectInterfaceController interfaceController:
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { HybridObject } from 'react-native-nitro-modules';
|
|
2
|
+
import type { CleanupCallback } from '../types/Event';
|
|
3
|
+
export interface VoiceInput extends HybridObject<{
|
|
4
|
+
android: 'kotlin';
|
|
5
|
+
ios: 'swift';
|
|
6
|
+
}> {
|
|
7
|
+
registerVoiceInputListener(callback: (voiceInputResult?: string, error?: string) => void): CleanupCallback;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A hook to determine if the CarPlay/Android Auto screen is currently focused (visible).
|
|
3
|
-
*
|
|
4
|
-
* @param moduleName The name of the module to listen to.
|
|
5
|
-
* @returns `true` if the screen is focused, `false` otherwise.
|
|
6
|
-
*/
|
|
7
|
-
export declare function useIsAutoPlayFocused(moduleName: string): boolean;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
2
|
-
import { HybridAutoPlay } from '..';
|
|
3
|
-
/**
|
|
4
|
-
* A hook to determine if the CarPlay/Android Auto screen is currently focused (visible).
|
|
5
|
-
*
|
|
6
|
-
* @param moduleName The name of the module to listen to.
|
|
7
|
-
* @returns `true` if the screen is focused, `false` otherwise.
|
|
8
|
-
*/
|
|
9
|
-
export function useIsAutoPlayFocused(moduleName) {
|
|
10
|
-
const [isFocused, setIsFocused] = useState(false);
|
|
11
|
-
useEffect(() => {
|
|
12
|
-
const remove = HybridAutoPlay.addListenerRenderState(moduleName, (state) => {
|
|
13
|
-
setIsFocused(state === 'didAppear');
|
|
14
|
-
});
|
|
15
|
-
return () => {
|
|
16
|
-
remove();
|
|
17
|
-
};
|
|
18
|
-
}, [moduleName]);
|
|
19
|
-
return isFocused;
|
|
20
|
-
}
|
package/lib/hybrid.d.ts
DELETED
package/lib/hybrid.js
DELETED