Skip to content

Commit dbb0ab9

Browse files
authored
Merge pull request #341 from smartdevicelink/release/1.2.0
1.2.0 Release
2 parents fed7eb3 + 1f2001b commit dbb0ab9

File tree

475 files changed

+10888
-218010
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

475 files changed

+10888
-218010
lines changed

.eslintrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@
111111
"jsdoc/check-param-names": 1,
112112
"jsdoc/check-property-names": 1,
113113
"jsdoc/check-tag-names": 1,
114-
"jsdoc/check-values": 1,
115114
"jsdoc/empty-tags": 1,
116115
"jsdoc/implements-on-classes": 1,
117116
"jsdoc/require-description": 1,

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@
99
*.pytest_cache
1010
hello-sdl*.zip
1111
app-directory.json
12+
**/dist/
13+
**/SDL.min.js

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,13 @@ The JavaScript library will be open source and stored in a new smartdevicelink r
5555
The development should be done in JavaScript (not TypeScript) following ECMA-Script 2017. All the base source code should be developed using [JavaScript standard built-in objects](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects).
5656

5757
The transport related source code for Node.js can use Node specific libraries needed (like socket.io). This code should be stored in a separate folder from the base source code in the repository.
58+
59+
### Building the Project
60+
NodeJS, npm, and Python3 are required:
61+
62+
```js
63+
npm install
64+
npm run build
65+
```
66+
67+
The output will be in the `dist` folder. There is a vanilla JS and a NodeJS build, which can be placed into the corresponding example apps in the `examples` folder to test out the library.

examples/js/hello-sdl/SDL.min.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

examples/js/hello-sdl/index.html

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
.setLanguageDesired(SDL.rpc.enums.Language.EN_US)
5454
.setHmiDisplayLanguageDesired(SDL.rpc.enums.Language.EN_US)
5555
.setAppTypes([
56-
SDL.rpc.enums.AppHMIType.DEFAULT,
56+
SDL.rpc.enums.AppHMIType.MEDIA,
5757
])
5858
.setTransportConfig(new SDL.transport.WebSocketClientConfig('ws://localhost', 5050))
5959
.setAppIcon(file)
@@ -98,6 +98,7 @@
9898

9999
this._sdlManager = new SDL.manager.SdlManager(this._appConfig, managerListener);
100100
this._sdlManager.start();
101+
this._isButtonSubscriptionRequested = false;
101102
}
102103

103104
async _onConnected () {
@@ -123,6 +124,8 @@
123124
screenManager.setTextAlignment(SDL.rpc.enums.TextAlignment.RIGHT_ALIGNED);
124125
screenManager.setPrimaryGraphic(new SDL.manager.file.filetypes.SdlArtwork('sdl-logo', SDL.rpc.enums.FileType.GRAPHIC_PNG)
125126
.setFilePath(this._filePath));
127+
screenManager.changeLayout(new SDL.rpc.structs.TemplateConfiguration()
128+
.setTemplate(SDL.rpc.enums.PredefinedLayout.NON_MEDIA));
126129
}
127130

128131
async _onHmiStatusListener (onHmiStatus) {
@@ -131,6 +134,39 @@
131134

132135
// wait for the FULL state for more functionality
133136
if (hmiLevel === SDL.rpc.enums.HMILevel.HMI_FULL) {
137+
const screenManager = this._sdlManager.getScreenManager();
138+
const isRpcAllowed = (rpc) => {
139+
return this._permissionManager &&
140+
this._permissionManager.isRpcAllowed(rpc);
141+
};
142+
143+
if (!this._isButtonSubscriptionRequested && isRpcAllowed(SDL.rpc.enums.FunctionID.SubscribeButton)) {
144+
const availableButtons = this._sdlManager.getRegisterAppInterfaceResponse().getButtonCapabilities().map(function (capability) {
145+
return capability.getNameParam();
146+
});
147+
148+
// add button listeners
149+
const ButtonName = SDL.rpc.enums.ButtonName;
150+
const buttonNames = [ButtonName.PRESET_0, ButtonName.PRESET_1, ButtonName.PRESET_2, ButtonName.PRESET_3,
151+
ButtonName.PRESET_4, ButtonName.PRESET_5, ButtonName.PRESET_6, ButtonName.PRESET_7, ButtonName.PRESET_8,
152+
ButtonName.PRESET_9, ButtonName.PLAY_PAUSE, ButtonName.OK, ButtonName.SEEKLEFT, ButtonName.SEEKRIGHT,
153+
ButtonName.TUNEUP, ButtonName.TUNEDOWN];
154+
155+
156+
for (const buttonName of buttonNames) {
157+
if (availableButtons.indexOf(buttonName) !== -1) {
158+
console.log('Subscribing to', buttonName);
159+
await screenManager.addButtonListener(buttonName, this._onButtonListener.bind(this)).catch(function (err) {
160+
console.error(err);
161+
});
162+
} else {
163+
console.log('No capability found for button', buttonName);
164+
}
165+
}
166+
167+
this._isButtonSubscriptionRequested = true;
168+
}
169+
134170
const art1 = new SDL.manager.file.filetypes.SdlArtwork('logo', SDL.rpc.enums.FileType.GRAPHIC_PNG)
135171
.setFilePath(this._filePath);
136172

@@ -153,7 +189,6 @@
153189
];
154190

155191
// set the softbuttons now and rotate through the states of the first softbutton
156-
const screenManager = this._sdlManager.getScreenManager();
157192
await screenManager.setSoftButtonObjects(softButtonObjects);
158193

159194
await this._sleep(2000);
@@ -164,12 +199,9 @@
164199

165200
const count = 3;
166201
for (let i = 0; i < count; i++) {
167-
const showCountdown = new SDL.rpc.messages.Show();
168-
showCountdown.setMainField1(`Exiting in ${(count - i).toString()}`)
169-
.setMainField2('')
170-
.setMainField3('');
171-
172-
this._sdlManager.sendRpcResolve(showCountdown); // don't wait for a response
202+
screenManager.setTextField1(`Exiting in ${(count - i).toString()}`)
203+
.setTextField2('')
204+
.setTextField3('');
173205

174206
await this._sleep();
175207
}
@@ -187,6 +219,14 @@
187219
});
188220
}
189221

222+
_onButtonListener (buttonName, onButton) {
223+
if (onButton instanceof SDL.rpc.messages.OnButtonPress) {
224+
this._sdlManager.getScreenManager().setTextField1(`${buttonName} pressed`);
225+
} else if (onButton instanceof SDL.rpc.messages.OnButtonEvent) {
226+
this._sdlManager.getScreenManager().setTextField2(`${buttonName} ${onButton.getButtonEventMode()}`);
227+
}
228+
}
229+
190230
_logPermissions () {
191231
if (this._permissionManager) {
192232
console.log(`Show RPC allowed: ${this._permissionManager.isRpcAllowed(SDL.rpc.enums.FunctionID.Show)}`);

examples/js/hello-sdl/readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
## SDL JavaScript App Startup Instructions
2+
1) Place the vanilla JS SDL.min.js file into this directory
23
1) Request a [Manticore instance](https://smartdevicelink.com/resources/manticore/)
34
1) Open two terminal sessions and `cd` both of them into `./examples/js/hello-sdl`
45
1) In one terminal session, run `java -jar proxy.jar m.sdl.tools [PORT]`, where `[PORT]` is the one given to you by Manticore

0 commit comments

Comments
 (0)