@javascriptcommon/react-native-carplay 2.3.11
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/README.md +633 -0
- package/ios/RCTConvert+RNCarPlay.h +19 -0
- package/ios/RCTConvert+RNCarPlay.m +95 -0
- package/ios/RNCPStore.h +22 -0
- package/ios/RNCPStore.m +68 -0
- package/ios/RNCarPlay.h +32 -0
- package/ios/RNCarPlay.m +1755 -0
- package/ios/RNCarPlay.xcodeproj/project.pbxproj +300 -0
- package/lib/CarPlay.js +146 -0
- package/lib/index.js +63 -0
- package/lib/interfaces/Action.js +2 -0
- package/lib/interfaces/AlertAction.js +2 -0
- package/lib/interfaces/BarButton.js +2 -0
- package/lib/interfaces/CarColor.js +2 -0
- package/lib/interfaces/GridButton.js +2 -0
- package/lib/interfaces/Header.js +2 -0
- package/lib/interfaces/ListItem.js +2 -0
- package/lib/interfaces/ListItemUpdate.js +2 -0
- package/lib/interfaces/ListSection.js +2 -0
- package/lib/interfaces/Maneuver.js +2 -0
- package/lib/interfaces/MapButton.js +2 -0
- package/lib/interfaces/NavigationAlert.js +9 -0
- package/lib/interfaces/NavigationInfo.js +2 -0
- package/lib/interfaces/NavigationStep.js +2 -0
- package/lib/interfaces/Pane.js +2 -0
- package/lib/interfaces/PauseReason.js +11 -0
- package/lib/interfaces/Place.js +2 -0
- package/lib/interfaces/TextConfiguration.js +2 -0
- package/lib/interfaces/TimeRemainingColor.js +2 -0
- package/lib/interfaces/TravelEstimates.js +2 -0
- package/lib/interfaces/VoiceControlState.js +2 -0
- package/lib/navigation/NavigationSession.js +53 -0
- package/lib/navigation/Trip.js +19 -0
- package/lib/templates/ActionSheetTemplate.js +15 -0
- package/lib/templates/AlertTemplate.js +15 -0
- package/lib/templates/ContactTemplate.js +15 -0
- package/lib/templates/GridTemplate.js +16 -0
- package/lib/templates/InformationTemplate.js +24 -0
- package/lib/templates/ListTemplate.js +67 -0
- package/lib/templates/MapTemplate.js +115 -0
- package/lib/templates/NowPlayingTemplate.js +17 -0
- package/lib/templates/PointOfInterestTemplate.js +16 -0
- package/lib/templates/SearchTemplate.js +41 -0
- package/lib/templates/TabBarTemplate.js +26 -0
- package/lib/templates/Template.js +74 -0
- package/lib/templates/VoiceControlTemplate.js +19 -0
- package/lib/templates/android/AndroidNavigationBaseTemplate.js +29 -0
- package/lib/templates/android/MessageTemplate.js +10 -0
- package/lib/templates/android/NavigationTemplate.js +16 -0
- package/lib/templates/android/PaneTemplate.js +10 -0
- package/lib/templates/android/PlaceListMapTemplate.js +18 -0
- package/lib/templates/android/PlaceListNavigationTemplate.js +19 -0
- package/lib/templates/android/RoutePreviewNavigationTemplate.js +22 -0
- package/package.json +71 -0
- package/react-native-carplay.podspec +21 -0
- package/src/CarPlay.ts +286 -0
- package/src/index.ts +50 -0
- package/src/interfaces/Action.ts +15 -0
- package/src/interfaces/AlertAction.ts +5 -0
- package/src/interfaces/BarButton.ts +41 -0
- package/src/interfaces/CarColor.ts +1 -0
- package/src/interfaces/GridButton.ts +25 -0
- package/src/interfaces/Header.ts +16 -0
- package/src/interfaces/ListItem.ts +84 -0
- package/src/interfaces/ListItemUpdate.ts +14 -0
- package/src/interfaces/ListSection.ts +21 -0
- package/src/interfaces/Maneuver.ts +30 -0
- package/src/interfaces/MapButton.ts +27 -0
- package/src/interfaces/NavigationAlert.ts +46 -0
- package/src/interfaces/NavigationInfo.ts +19 -0
- package/src/interfaces/NavigationStep.ts +17 -0
- package/src/interfaces/Pane.ts +29 -0
- package/src/interfaces/PauseReason.ts +7 -0
- package/src/interfaces/Place.ts +12 -0
- package/src/interfaces/TextConfiguration.ts +5 -0
- package/src/interfaces/TimeRemainingColor.ts +1 -0
- package/src/interfaces/TravelEstimates.ts +39 -0
- package/src/interfaces/VoiceControlState.ts +8 -0
- package/src/navigation/NavigationSession.ts +57 -0
- package/src/navigation/Trip.ts +36 -0
- package/src/templates/ActionSheetTemplate.ts +21 -0
- package/src/templates/AlertTemplate.ts +20 -0
- package/src/templates/ContactTemplate.ts +45 -0
- package/src/templates/GridTemplate.ts +45 -0
- package/src/templates/InformationTemplate.ts +42 -0
- package/src/templates/ListTemplate.ts +167 -0
- package/src/templates/MapTemplate.ts +231 -0
- package/src/templates/NowPlayingTemplate.ts +31 -0
- package/src/templates/PointOfInterestTemplate.ts +40 -0
- package/src/templates/SearchTemplate.ts +70 -0
- package/src/templates/TabBarTemplate.ts +56 -0
- package/src/templates/Template.ts +164 -0
- package/src/templates/VoiceControlTemplate.ts +25 -0
- package/src/templates/android/AndroidNavigationBaseTemplate.ts +46 -0
- package/src/templates/android/MessageTemplate.ts +19 -0
- package/src/templates/android/NavigationTemplate.ts +50 -0
- package/src/templates/android/PaneTemplate.ts +16 -0
- package/src/templates/android/PlaceListMapTemplate.ts +64 -0
- package/src/templates/android/PlaceListNavigationTemplate.ts +57 -0
- package/src/templates/android/RoutePreviewNavigationTemplate.ts +66 -0
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { ImageSourcePropType, Platform } from 'react-native';
|
|
2
|
+
import { CarPlay } from '../CarPlay';
|
|
3
|
+
import { BarButton } from '../interfaces/BarButton';
|
|
4
|
+
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
6
|
+
const resolveAssetSource = require('react-native/Libraries/Image/resolveAssetSource');
|
|
7
|
+
|
|
8
|
+
export interface BaseEvent {
|
|
9
|
+
/**
|
|
10
|
+
* Template id that fired the event
|
|
11
|
+
*/
|
|
12
|
+
templateId: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface BarButtonEvent extends BaseEvent {
|
|
16
|
+
id: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface TemplateConfig {
|
|
20
|
+
/**
|
|
21
|
+
* Give the template your own ID. Must be unique.
|
|
22
|
+
*/
|
|
23
|
+
id?: string;
|
|
24
|
+
/**
|
|
25
|
+
* An array of bar buttons to display on the leading side of the navigation bar.
|
|
26
|
+
*
|
|
27
|
+
* The navigation bar displays up to two buttons in the leading space. When including more than two buttons in the array, the system displays only the first two buttons.
|
|
28
|
+
* @namespace iOS
|
|
29
|
+
*/
|
|
30
|
+
leadingNavigationBarButtons?: BarButton[];
|
|
31
|
+
/**
|
|
32
|
+
* An array of bar buttons to display on the trailing side of the navigation bar.
|
|
33
|
+
*
|
|
34
|
+
* The navigation bar displays up to two buttons in the trailing space. When including more than two buttons in the array, the system displays only the first two buttons.
|
|
35
|
+
* @namespace iOS
|
|
36
|
+
*/
|
|
37
|
+
trailingNavigationBarButtons?: BarButton[];
|
|
38
|
+
/**
|
|
39
|
+
* UITabBarSystemItem
|
|
40
|
+
*/
|
|
41
|
+
tabSystemItem?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Name of system image for tab
|
|
44
|
+
*/
|
|
45
|
+
tabSystemImageName?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Image source for tab
|
|
48
|
+
*/
|
|
49
|
+
tabImage?: ImageSourcePropType;
|
|
50
|
+
/**
|
|
51
|
+
* Set tab title
|
|
52
|
+
*/
|
|
53
|
+
tabTitle?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Fired before template appears
|
|
56
|
+
* @param e Event
|
|
57
|
+
*/
|
|
58
|
+
onWillAppear?(e: BaseEvent): void;
|
|
59
|
+
/**
|
|
60
|
+
* Fired before template disappears
|
|
61
|
+
* @param e Event
|
|
62
|
+
*/
|
|
63
|
+
onWillDisappear?(e: BaseEvent): void;
|
|
64
|
+
/**
|
|
65
|
+
* Fired after template appears
|
|
66
|
+
* @param e Event
|
|
67
|
+
*/
|
|
68
|
+
onDidAppear?(e: BaseEvent): void;
|
|
69
|
+
/**
|
|
70
|
+
* Fired after template disappears
|
|
71
|
+
* @param e Event
|
|
72
|
+
*/
|
|
73
|
+
onDidDisappear?(e: BaseEvent): void;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Fired when bar button is pressed
|
|
77
|
+
* @param e Event
|
|
78
|
+
*/
|
|
79
|
+
onBarButtonPressed?(e: BarButtonEvent): void;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export class Template<P> {
|
|
83
|
+
public get type(): string {
|
|
84
|
+
return 'unset';
|
|
85
|
+
}
|
|
86
|
+
public id!: string;
|
|
87
|
+
|
|
88
|
+
public get eventMap() {
|
|
89
|
+
return {};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
constructor(public config: TemplateConfig & P) {
|
|
93
|
+
if (config.id) {
|
|
94
|
+
this.id = config.id;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (!this.id) {
|
|
98
|
+
this.id = `${this.type}-${Date.now()}-${Math.round(Math.random() * Number.MAX_SAFE_INTEGER)}`;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const eventMap = {
|
|
102
|
+
barButtonPressed: 'onBarButtonPressed',
|
|
103
|
+
didAppear: 'onDidAppear',
|
|
104
|
+
didDisappear: 'onDidDisappear',
|
|
105
|
+
willAppear: 'onWillAppear',
|
|
106
|
+
willDisappear: 'onWillDisappear',
|
|
107
|
+
...(this.eventMap || {}),
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
111
|
+
Object.entries(eventMap).forEach(([eventName, callbackName]: [string, any]) => {
|
|
112
|
+
CarPlay.emitter.addListener(eventName, (e: { id: string; templateId: string }) => {
|
|
113
|
+
const configEventName = callbackName as keyof Pick<
|
|
114
|
+
TemplateConfig,
|
|
115
|
+
| 'onWillAppear'
|
|
116
|
+
| 'onWillDisappear'
|
|
117
|
+
| 'onDidAppear'
|
|
118
|
+
| 'onDidDisappear'
|
|
119
|
+
| 'onBarButtonPressed'
|
|
120
|
+
>;
|
|
121
|
+
if (config[configEventName] && e.templateId === this.id) {
|
|
122
|
+
config[configEventName]?.(e);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
if (this.type !== 'map') {
|
|
128
|
+
const callbackFn = Platform.select({
|
|
129
|
+
android: ({ error }: { error?: string } = {}) => {
|
|
130
|
+
error && console.error(error);
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
CarPlay.bridge.createTemplate(
|
|
134
|
+
this.id,
|
|
135
|
+
this.parseConfig({ type: this.type, ...config }),
|
|
136
|
+
callbackFn,
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
updateTemplate = (config: P) => {
|
|
142
|
+
console.log('LETSGO!', config, this.type);
|
|
143
|
+
CarPlay.bridge.updateTemplate(this.id, this.parseConfig({ type: this.type, ...config }));
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
147
|
+
public parseConfig(config: any) {
|
|
148
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
149
|
+
function traverse(obj: any) {
|
|
150
|
+
for (const i in obj) {
|
|
151
|
+
if (obj[i] !== null && typeof obj[i] === 'object') {
|
|
152
|
+
traverse(obj[i]);
|
|
153
|
+
}
|
|
154
|
+
if (String(i).match(/[Ii]mage$/)) {
|
|
155
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
156
|
+
obj[i] = resolveAssetSource(obj[i]);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
const result = JSON.parse(JSON.stringify(config));
|
|
161
|
+
traverse(result);
|
|
162
|
+
return result;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CarPlay } from '../CarPlay';
|
|
2
|
+
import { VoiceControlState } from '../interfaces/VoiceControlState';
|
|
3
|
+
import { Template } from './Template';
|
|
4
|
+
|
|
5
|
+
export interface VoiceControlTemplateConfig {
|
|
6
|
+
/**
|
|
7
|
+
* The array of voice control states that can be used by your voice control template.
|
|
8
|
+
*/
|
|
9
|
+
voiceControlStates: VoiceControlState[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Displays a voice control indicator on the CarPlay screen.
|
|
14
|
+
*
|
|
15
|
+
* CarPlay navigation apps must show the voice control template during audio input.
|
|
16
|
+
*/
|
|
17
|
+
export class VoiceControlTemplate extends Template<VoiceControlTemplateConfig> {
|
|
18
|
+
public get type(): string {
|
|
19
|
+
return 'voicecontrol';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public activateVoiceControlState(identifier: string) {
|
|
23
|
+
CarPlay.bridge.activateVoiceControlState(this.id, identifier);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { AppRegistry, Platform } from 'react-native';
|
|
2
|
+
import { Template, TemplateConfig } from '../Template';
|
|
3
|
+
import { CarPlay } from '../../CarPlay';
|
|
4
|
+
|
|
5
|
+
export interface AndroidNavigationBaseTemplateConfig extends TemplateConfig {
|
|
6
|
+
/**
|
|
7
|
+
* Your component to render inside Android Auto Map view
|
|
8
|
+
* Example `component: MyComponent`
|
|
9
|
+
*/
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
|
+
component: React.ComponentType<any>;
|
|
12
|
+
|
|
13
|
+
onDidShowPanningInterface?(): void;
|
|
14
|
+
onDidDismissPanningInterface?(): void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export class AndroidNavigationBaseTemplate<
|
|
18
|
+
T extends AndroidNavigationBaseTemplateConfig,
|
|
19
|
+
> extends Template<T> {
|
|
20
|
+
get eventMap() {
|
|
21
|
+
return {
|
|
22
|
+
didShowPanningInterface: 'onDidShowPanningInterface',
|
|
23
|
+
didDismissPanningInterface: 'onDidDismissPanningInterface',
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
constructor(public config: T) {
|
|
28
|
+
super(config);
|
|
29
|
+
|
|
30
|
+
if (config.component) {
|
|
31
|
+
AppRegistry.registerComponent(this.id, () => config.component);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const callbackFn = Platform.select({
|
|
35
|
+
android: ({ error }: { error?: string } = {}) => {
|
|
36
|
+
error && console.error(error);
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
CarPlay.bridge.createTemplate(
|
|
41
|
+
this.id,
|
|
42
|
+
this.parseConfig({ type: this.type, ...config, render: true }),
|
|
43
|
+
callbackFn,
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Action, HeaderAction } from '../../interfaces/Action';
|
|
2
|
+
import { Template, TemplateConfig } from '../Template';
|
|
3
|
+
import { ImageSourcePropType } from 'react-native';
|
|
4
|
+
|
|
5
|
+
export interface MessageTemplateConfig extends TemplateConfig {
|
|
6
|
+
message?: string;
|
|
7
|
+
loading?: boolean;
|
|
8
|
+
headerAction?: HeaderAction;
|
|
9
|
+
actions?: Action[];
|
|
10
|
+
icon?: ImageSourcePropType;
|
|
11
|
+
title?: string;
|
|
12
|
+
debugMessage?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class MessageTemplate extends Template<MessageTemplateConfig> {
|
|
16
|
+
public get type(): string {
|
|
17
|
+
return 'message';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Action } from '../../interfaces/Action';
|
|
2
|
+
import { CarColor } from '../../interfaces/CarColor';
|
|
3
|
+
import { NavigationInfo } from '../../interfaces/NavigationInfo';
|
|
4
|
+
import { TravelEstimates } from '../../interfaces/TravelEstimates';
|
|
5
|
+
import {
|
|
6
|
+
AndroidNavigationBaseTemplate,
|
|
7
|
+
AndroidNavigationBaseTemplateConfig,
|
|
8
|
+
} from './AndroidNavigationBaseTemplate';
|
|
9
|
+
|
|
10
|
+
export interface NavigationTemplateConfig extends AndroidNavigationBaseTemplateConfig {
|
|
11
|
+
/**
|
|
12
|
+
* Sets an ActionStrip with a list of template-scoped actions for this template.
|
|
13
|
+
* The Action buttons in Map Based Template are automatically adjusted based on the screen size. On narrow width screen, icon Actions show by default. If no icon specify, showing title Actions instead. On wider width screen, title Actions show by default. If no title specify, showing icon Actions instead.
|
|
14
|
+
* Requirements This template allows up to 4 Actions in its ActionStrip. Of the 4 allowed Actions, it can either be a title Action as set via setTitle, or a icon Action as set via setIcon.
|
|
15
|
+
*/
|
|
16
|
+
actions: Action[];
|
|
17
|
+
/**
|
|
18
|
+
* Sets the background color to use for the navigation information.
|
|
19
|
+
* Depending on contrast requirements, capabilities of the vehicle screens, or other factors, the color may be ignored by the host or overridden by the vehicle system.
|
|
20
|
+
*/
|
|
21
|
+
backgroundColor?: CarColor;
|
|
22
|
+
/**
|
|
23
|
+
* Sets the TravelEstimate to the final destination.
|
|
24
|
+
*/
|
|
25
|
+
travelEstimate?: TravelEstimates;
|
|
26
|
+
/**
|
|
27
|
+
* Sets an ActionStrip with a list of map-control related actions for this template, such as pan or zoom.
|
|
28
|
+
* The host will draw the buttons in an area that is associated with map controls.
|
|
29
|
+
* If the app does not include the PAN button in this ActionStrip, the app will not receive the user input for panning gestures from SurfaceCallback methods, and the host will exit any previously activated pan mode.
|
|
30
|
+
* Requirements This template allows up to 4 Actions in its map ActionStrip. Only Actions with icons set via setIcon are allowed.
|
|
31
|
+
*/
|
|
32
|
+
mapButtons?: Action[];
|
|
33
|
+
/**
|
|
34
|
+
* Sets the navigation information to display on the template.
|
|
35
|
+
* Unless set with this method, navigation info won't be displayed on the template.
|
|
36
|
+
*/
|
|
37
|
+
navigationInfo?: NavigationInfo;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* A template for showing navigation information.
|
|
42
|
+
* This template has two independent sections which can be updated:
|
|
43
|
+
* - Navigation information such as routing instructions or navigation-related messages.
|
|
44
|
+
* - Travel estimates to the destination.
|
|
45
|
+
*/
|
|
46
|
+
export class NavigationTemplate extends AndroidNavigationBaseTemplate<NavigationTemplateConfig> {
|
|
47
|
+
public get type(): string {
|
|
48
|
+
return 'navigation';
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Action, HeaderAction } from '../../interfaces/Action';
|
|
2
|
+
import { Template, TemplateConfig } from '../Template';
|
|
3
|
+
import { Pane } from '../../interfaces/Pane';
|
|
4
|
+
|
|
5
|
+
export interface PaneTemplateConfig extends TemplateConfig {
|
|
6
|
+
pane: Pane;
|
|
7
|
+
headerAction?: HeaderAction;
|
|
8
|
+
actions?: Action[];
|
|
9
|
+
title?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class PaneTemplate extends Template<PaneTemplateConfig> {
|
|
13
|
+
public get type(): string {
|
|
14
|
+
return 'pane';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Action, HeaderAction } from '../../interfaces/Action';
|
|
2
|
+
import {
|
|
3
|
+
AndroidNavigationBaseTemplate,
|
|
4
|
+
AndroidNavigationBaseTemplateConfig,
|
|
5
|
+
} from './AndroidNavigationBaseTemplate';
|
|
6
|
+
import { Place } from '../../interfaces/Place';
|
|
7
|
+
import { ListItem } from '../../interfaces/ListItem';
|
|
8
|
+
|
|
9
|
+
export interface PlaceListMapTemplateConfig extends AndroidNavigationBaseTemplateConfig {
|
|
10
|
+
/**
|
|
11
|
+
* Sets an ActionStrip with a list of template-scoped actions for this template.
|
|
12
|
+
* The Action buttons in Map Based Template are automatically adjusted based on the screen size. On narrow width screen, icon Actions show by default. If no icon specify, showing title Actions instead. On wider width screen, title Actions show by default. If no title specify, showing icon Actions instead.
|
|
13
|
+
* @limit This template allows up to 4 Actions in its ActionStrip. Of the 4 allowed Actions, it can either be a title Action as set via setTitle, or a icon Action as set via setIcon.
|
|
14
|
+
*/
|
|
15
|
+
actions?: Action[];
|
|
16
|
+
/**
|
|
17
|
+
* Sets the anchor maker on the map.
|
|
18
|
+
* An anchor marker will not be displayed unless set with this method.
|
|
19
|
+
* The anchor marker is displayed differently from other markers by the host.
|
|
20
|
+
* If not null, an anchor marker will be shown at the specified CarLocation on the map. The camera will adapt to always have the anchor marker visible within its viewport, along with other places' markers from Row that are currently visible in the Pane. This can be used to provide a reference point on the map (e.g. the center of a search region) as the user pages through the Pane's markers, for example.
|
|
21
|
+
*/
|
|
22
|
+
anchor?: Place;
|
|
23
|
+
/**
|
|
24
|
+
* Sets whether to show the current location in the map.
|
|
25
|
+
* The map template will show the user's current location on the map.
|
|
26
|
+
* This functionality requires the app to have either the ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION permission. When isEnabled is true, the host may receive location updates from the app in order to show the user's current location.
|
|
27
|
+
*/
|
|
28
|
+
currentLocationEnabled?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Sets the Action that will be displayed in the header of the template.
|
|
31
|
+
* Unless set with this method, the template will not have a header action.
|
|
32
|
+
* @limit This template only supports either one of APP_ICON and BACK as a header Action.
|
|
33
|
+
*/
|
|
34
|
+
headerAction?: HeaderAction;
|
|
35
|
+
/**
|
|
36
|
+
* Sets an ItemList to show in a list view along with the map.
|
|
37
|
+
* Unless set with this method, the template will not show an item list.
|
|
38
|
+
* To show a marker corresponding to a point of interest represented by a row, set the Place instance via setMetadata. The host will display the PlaceMarker in both the map and the list view as the row becomes visible.
|
|
39
|
+
* @limit The number of items in the ItemList should be smaller or equal than the limit provided by CONTENT_LIMIT_TYPE_PLACE_LIST. The host will ignore any items over that limit. The list itself cannot be selectable as set via setOnSelectedListener. Each Row can add up to 2 lines of texts via addText and cannot contain a Toggle.
|
|
40
|
+
*/
|
|
41
|
+
itemList?: ListItem[];
|
|
42
|
+
/**
|
|
43
|
+
* Sets whether the template is in a loading state.
|
|
44
|
+
*/
|
|
45
|
+
loading?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Title for the map
|
|
48
|
+
*/
|
|
49
|
+
title?: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* A template that displays a map along with a list of places.
|
|
54
|
+
* The map can display markers corresponding to the places in the list. See setItemList for details.
|
|
55
|
+
* Template Restrictions In regards to template refreshes, as described in onGetTemplate, this template is considered a refresh of a previous one if:
|
|
56
|
+
* - The previous template is in a loading state (see setLoading, or
|
|
57
|
+
* - The template title has not changed, and the number of rows and the title (not counting spans) of each row between the previous and new ItemLists have not changed.
|
|
58
|
+
* - The template is sent in response to a user-initiated content refresh request. (see setOnContentRefreshListener.
|
|
59
|
+
*/
|
|
60
|
+
export class PlaceListMapTemplate extends AndroidNavigationBaseTemplate<PlaceListMapTemplateConfig> {
|
|
61
|
+
public get type(): string {
|
|
62
|
+
return 'place-list-map';
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Action } from '../../interfaces/Action';
|
|
2
|
+
import { Header } from '../../interfaces/Header';
|
|
3
|
+
import { ListItem } from '../../interfaces/ListItem';
|
|
4
|
+
import {
|
|
5
|
+
AndroidNavigationBaseTemplate,
|
|
6
|
+
AndroidNavigationBaseTemplateConfig,
|
|
7
|
+
} from './AndroidNavigationBaseTemplate';
|
|
8
|
+
|
|
9
|
+
export interface PlaceListNavigationTemplateConfig extends AndroidNavigationBaseTemplateConfig {
|
|
10
|
+
/**
|
|
11
|
+
* Sets an ActionStrip with a list of template-scoped actions for this template.
|
|
12
|
+
* The Action buttons in Map Based Template are automatically adjusted based on the screen size. On narrow width screen, icon Actions show by default. If no icon specify, showing title Actions instead. On wider width screen, title Actions show by default. If no title specify, showing icon Actions instead.
|
|
13
|
+
* @limit This template allows up to 4 Actions in its ActionStrip. Of the 4 allowed Actions, it can either be a title Action as set via setTitle, or a icon Action as set via setIcon.
|
|
14
|
+
*/
|
|
15
|
+
actions?: Action[];
|
|
16
|
+
/**
|
|
17
|
+
* Sets the Header for this template.
|
|
18
|
+
*/
|
|
19
|
+
header?: Header;
|
|
20
|
+
/**
|
|
21
|
+
* Sets an ItemList to show in a list view along with the map.
|
|
22
|
+
* Unless set with this method, the template will not show an item list.
|
|
23
|
+
* To show a marker corresponding to a point of interest represented by a row, set the Place instance via setMetadata. The host will display the PlaceMarker in both the map and the list view as the row becomes visible.
|
|
24
|
+
* @limit The number of items in the ItemList should be smaller or equal than the limit provided by CONTENT_LIMIT_TYPE_PLACE_LIST. The host will ignore any items over that limit. The list itself cannot be selectable as set via setOnSelectedListener. Each Row can add up to 2 lines of texts via addText and cannot contain a Toggle.
|
|
25
|
+
*/
|
|
26
|
+
itemList?: ListItem[];
|
|
27
|
+
/**
|
|
28
|
+
* Sets whether the template is in a loading state.
|
|
29
|
+
*/
|
|
30
|
+
loading?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Sets an ActionStrip with a list of map-control related actions for this template, such as pan or zoom.
|
|
33
|
+
* The host will draw the buttons in an area that is associated with map controls.
|
|
34
|
+
* If the app does not include the PAN button in this ActionStrip, the app will not receive the user input for panning gestures from SurfaceCallback methods, and the host will exit any previously activated pan mode.
|
|
35
|
+
* @limit This template allows up to 4 Actions in its map ActionStrip. Only Actions with icons set via setIcon are allowed.
|
|
36
|
+
*/
|
|
37
|
+
mapButtons?: Action[];
|
|
38
|
+
/**
|
|
39
|
+
* Title for the map
|
|
40
|
+
*/
|
|
41
|
+
title?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* A template that supports showing a list of places alongside a custom drawn map.
|
|
46
|
+
* The template itself does not expose a drawing surface. In order to draw on the canvas, use setSurfaceCallback.
|
|
47
|
+
* Template Restrictions In regards to template refreshes, as described in onGetTemplate, this template is considered a refresh of a previous one if:
|
|
48
|
+
* - The previous template is in a loading state (see setLoading, or
|
|
49
|
+
* - The template title has not changed, and the number of rows and the title (not counting spans) of each row between the previous and new ItemLists have not changed.
|
|
50
|
+
* - The template is sent in response to a user-initiated content refresh request. (see setOnContentRefreshListener.
|
|
51
|
+
* In order to use this template your car app MUST declare that it uses the **androidx.car.app.NAVIGATION_TEMPLATES** permission in the manifest.
|
|
52
|
+
*/
|
|
53
|
+
export class PlaceListNavigationTemplate extends AndroidNavigationBaseTemplate<PlaceListNavigationTemplateConfig> {
|
|
54
|
+
public get type(): string {
|
|
55
|
+
return 'place-navigation-map';
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Action } from '../../interfaces/Action';
|
|
2
|
+
import { Header } from '../../interfaces/Header';
|
|
3
|
+
import { ListItem } from '../../interfaces/ListItem';
|
|
4
|
+
import {
|
|
5
|
+
AndroidNavigationBaseTemplate,
|
|
6
|
+
AndroidNavigationBaseTemplateConfig,
|
|
7
|
+
} from './AndroidNavigationBaseTemplate';
|
|
8
|
+
|
|
9
|
+
export interface RoutePreviewNavigationTemplateConfig extends AndroidNavigationBaseTemplateConfig {
|
|
10
|
+
/**
|
|
11
|
+
* Sets an ActionStrip with a list of template-scoped actions for this template.
|
|
12
|
+
* The Action buttons in Map Based Template are automatically adjusted based on the screen size. On narrow width screen, icon Actions show by default. If no icon specify, showing title Actions instead. On wider width screen, title Actions show by default. If no title specify, showing icon Actions instead.
|
|
13
|
+
* @limit This template allows up to 4 Actions in its ActionStrip. Of the 4 allowed Actions, it can either be a title Action as set via setTitle, or a icon Action as set via setIcon.
|
|
14
|
+
*/
|
|
15
|
+
actions?: Action[];
|
|
16
|
+
/**
|
|
17
|
+
* Sets the Header for this template.
|
|
18
|
+
*/
|
|
19
|
+
header?: Header;
|
|
20
|
+
/**
|
|
21
|
+
* Sets an ItemList to show in a list view along with the map.
|
|
22
|
+
* Unless set with this method, the template will not show an item list.
|
|
23
|
+
* To show a marker corresponding to a point of interest represented by a row, set the Place instance via setMetadata. The host will display the PlaceMarker in both the map and the list view as the row becomes visible.
|
|
24
|
+
* @limit The number of items in the ItemList should be smaller or equal than the limit provided by CONTENT_LIMIT_TYPE_PLACE_LIST. The host will ignore any items over that limit. The list itself cannot be selectable as set via setOnSelectedListener. Each Row can add up to 2 lines of texts via addText and cannot contain a Toggle.
|
|
25
|
+
*/
|
|
26
|
+
itemList?: ListItem[];
|
|
27
|
+
/**
|
|
28
|
+
* Sets whether the template is in a loading state.
|
|
29
|
+
*/
|
|
30
|
+
loading?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Sets an ActionStrip with a list of map-control related actions for this template, such as pan or zoom.
|
|
33
|
+
* The host will draw the buttons in an area that is associated with map controls.
|
|
34
|
+
* If the app does not include the PAN button in this ActionStrip, the app will not receive the user input for panning gestures from SurfaceCallback methods, and the host will exit any previously activated pan mode.
|
|
35
|
+
* @limit This template allows up to 4 Actions in its map ActionStrip. Only Actions with icons set via setIcon are allowed.
|
|
36
|
+
*/
|
|
37
|
+
mapButtons?: Action[];
|
|
38
|
+
/**
|
|
39
|
+
* Sets the Action to allow users to request navigation using the currently selected route.
|
|
40
|
+
* This should not be null if the template is not in a loading state (see #setIsLoading}), and the Action's title must be set.
|
|
41
|
+
* Spans are not supported in the navigate action and will be ignored.
|
|
42
|
+
*/
|
|
43
|
+
navigateAction?: Action;
|
|
44
|
+
/**
|
|
45
|
+
* Title for the map
|
|
46
|
+
*/
|
|
47
|
+
title?: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* A template that supports showing a list of routes alongside a custom drawn map.
|
|
52
|
+
* The list must have its ItemList.OnSelectedListener set, and the template must have its navigate action set (see setNavigateAction). These are used in conjunction to inform the app that:
|
|
53
|
+
* - A route has been selected. The app should also highlight the route on the map surface.
|
|
54
|
+
* - A navigate action has been triggered. The app should begin navigation using the selected route.
|
|
55
|
+
* The template itself does not expose a drawing surface. In order to draw on the canvas, use setSurfaceCallback.
|
|
56
|
+
* Template Restrictions In regards to template refreshes, as described in onGetTemplate, this template is considered a refresh of a previous one if:
|
|
57
|
+
* - The previous template is in a loading state (see setLoading, or
|
|
58
|
+
* - The template title has not changed, and the number of rows and the title (not counting spans) of each row between the previous and new ItemLists have not changed.
|
|
59
|
+
* Note that specifically, this means the app should not use this template to continuously refresh the routes as the car moves.
|
|
60
|
+
* In order to use this template your car app MUST declare that it uses the **androidx.car.app.NAVIGATION_TEMPLATES** permission in the manifest.
|
|
61
|
+
*/
|
|
62
|
+
export class RoutePreviewNavigationTemplate extends AndroidNavigationBaseTemplate<RoutePreviewNavigationTemplateConfig> {
|
|
63
|
+
public get type(): string {
|
|
64
|
+
return 'route-preview-navigation';
|
|
65
|
+
}
|
|
66
|
+
}
|