Skip to content

Commit 039e96c

Browse files
committed
Added check if the device could be automatic detected or if the user needs to pair the device first.
Added navigator translations. Fixes open issues for the 5.6.28 release.
1 parent 0c92f6f commit 039e96c

File tree

21 files changed

+305
-131
lines changed

21 files changed

+305
-131
lines changed

app/chrome_app/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"short_name": "Coding with Chrome",
1010
"description": "Learn, improve, or teach coding skills within a Chrome browser.",
1111
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAgSWdCJSwkgFTY9d993Quot277oCS2PCM2H/F6U28NE8D3Z21GXS/7qW8XCGShB054Wboq62pP679f9tB9F+GRHzOh/an4zIu+Uhb3ZKVzZLJbHsP8N+E5wk3wgwOBgE+UXCy9I8i1RpfzutJ4aha+YEzvCsVpo6UwsuWiXORB9yRU5NuooYX+fhVpWZmrZJo4vqzQhuoJ/uWiQujABXXo4qdrclwSw8+JlpWLMqHHQ6HE8Sf7VWDdGvRdYP6LRZobWqovb659qEumJ0bxhwXtHkWgPHQWtW35T/r/oH8uuke35pH+YtBtaOqN5U3bYGPinP0bYrI33OSLUJx/DrC1wIDAQAB",
12-
"version": "5.6.24",
12+
"version": "5.6.28",
1313
"oauth2": {
1414
"client_id": "418162477970-2qmsb2sp3m522hf292154favsjgpsj9n.apps.googleusercontent.com",
1515
"scopes": [
@@ -58,7 +58,7 @@
5858
}
5959
]
6060
},
61-
"minimum_chrome_version": "38",
61+
"minimum_chrome_version": "42",
6262
"offline_enabled": true,
6363
"bluetooth": {
6464
"uuids": [

app/nw_app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "binary",
3-
"version": "5.6.24",
3+
"version": "5.6.28",
44
"main": "js/background.js",
55
"window": {
66
"title": "Coding with Chrome",

locales/deu/navigation.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* @fileoverview Translation file for the navigation (german).
3+
*
4+
* @license Copyright 2018 The Coding with Chrome Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* @author [email protected] (Markus Bordihn)
19+
*/
20+
/* eslint-disable max-len */
21+
Locales['deu']['NAVIGATION'] = {
22+
'ABOUT': 'Über',
23+
'ABOUT_TEXT': 'Weitere Informationen zur Codierung mit Chrome',
24+
'DEBUG': 'Debuggen',
25+
'DEBUG_TEXT': 'Open Debug',
26+
'HELP': 'Hilfe',
27+
'HELP_TEXT': 'Dokumentation öffnen',
28+
'HOME': 'Home',
29+
'HOME_TEXT': 'Nach Hause gehen',
30+
'NEW_FILE': 'Neue Datei',
31+
'NEW_FILE_TEXT': 'Eine Datei starten',
32+
'OPEN_FILE': 'Datei öffnen',
33+
'OPEN_FILE_TEXT': 'Öffne eine lokale Datei',
34+
'OPEN_GDRIVE_FILE': 'Open Google Drive-Datei',
35+
'OPEN_GDRIVE_FILE_TEXT': 'Öffnen Sie eine Google Drive-Datei ...',
36+
'OVERVIEW': 'Überblick',
37+
'OVERVIEW_TEXT': 'Überblick',
38+
'SAVE_AS': 'Als neue Datei speichern',
39+
'SAVE_AS_TEXT': 'Als neue Datei speichern ...',
40+
'SAVE_GDRIVE_FILE': 'Als Google Drive-Datei speichern',
41+
'SAVE_GDRIVE_FILE_TEXT': 'Als Google Drive-Datei speichern ...',
42+
'SETTINGS': 'Einstellungen',
43+
'SETTINGS_TEXT': 'Einstellungen öffnen',
44+
};

locales/eng/navigation.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* @fileoverview Translation file for the navigation (english).
3+
*
4+
* @license Copyright 2018 The Coding with Chrome Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* @author [email protected] (Markus Bordihn)
19+
*/
20+
/* eslint-disable max-len */
21+
Locales['eng']['NAVIGATION'] = {
22+
'ABOUT': 'About',
23+
'ABOUT_TEXT': 'Learn more about Coding with Chrome',
24+
'DEBUG': 'Debug',
25+
'DEBUG_TEXT': 'Open Debug',
26+
'HELP': 'Help',
27+
'HELP_TEXT': 'Open documentation',
28+
'HOME': 'Home',
29+
'HOME_TEXT': 'Go Home',
30+
'NEW_FILE': 'New file',
31+
'NEW_FILE_TEXT': 'Start a file',
32+
'OPEN_FILE': 'Open file',
33+
'OPEN_FILE_TEXT': 'Open a local file',
34+
'OPEN_GDRIVE_FILE': 'Open Google Drive file',
35+
'OPEN_GDRIVE_FILE_TEXT': 'Open a Google Drive file...',
36+
'OVERVIEW': 'Overview',
37+
'OVERVIEW_TEXT': 'Go Overview',
38+
'SAVE_AS': 'Save as new file',
39+
'SAVE_AS_TEXT': 'Save as new file...',
40+
'SAVE_GDRIVE_FILE': 'Save as Google Drive file',
41+
'SAVE_GDRIVE_FILE_TEXT': 'Save as Google Drive file...',
42+
'SETTINGS': 'Settings',
43+
'SETTINGS_TEXT': 'Open settings',
44+
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "coding-with-chrome",
33
"description": "Coding with Chrome",
4-
"version": "5.6.24",
4+
"version": "5.6.28",
55
"author": "Markus Bordihn ([email protected])",
66
"license": "Apache-2.0",
77
"private": true,

src/mode/lego/ev3/connection.js

Lines changed: 47 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,17 @@
1919
*/
2020
goog.provide('cwc.mode.lego.ev3.Connection');
2121

22+
goog.require('cwc.lib.protocol.bluetoothChrome.profile.Device');
2223
goog.require('cwc.protocol.lego.ev3.Api');
2324
goog.require('cwc.ui.PreviewState');
2425
goog.require('cwc.utils.Events');
25-
goog.require('cwc.utils.Logger');
2626

2727
goog.require('goog.Timer');
2828

2929

30+
goog.scope(function() {
31+
const BluetoothProfile =
32+
goog.module.get('cwc.lib.protocol.bluetoothChrome.profile.Device');
3033
/**
3134
* @constructor
3235
* @param {!cwc.utils.Helper} helper
@@ -35,9 +38,6 @@ cwc.mode.lego.ev3.Connection = function(helper) {
3538
/** @type {string} */
3639
this.name = 'EV3 Connection';
3740

38-
/** @type {string} */
39-
this.autoConnectName = 'EV3';
40-
4141
/** @type {!cwc.utils.Helper} */
4242
this.helper = helper;
4343

@@ -56,22 +56,18 @@ cwc.mode.lego.ev3.Connection = function(helper) {
5656
/** @private {!cwc.utils.Events} */
5757
this.events_ = new cwc.utils.Events(this.name);
5858

59-
/** @private {!cwc.utils.Logger|null} */
60-
this.log_ = new cwc.utils.Logger(this.name);
59+
/** @private {!cwc.lib.protocol.bluetoothChrome.profile.Device} */
60+
this.device_ = BluetoothProfile.LEGO_EV3;
6161
};
6262

6363

6464
/**
6565
* Connects the EV3 unit.
6666
*/
6767
cwc.mode.lego.ev3.Connection.prototype.init = function() {
68-
this.handleConnecting_({
69-
'data': 'Connecting EV3',
70-
'source': 1,
71-
});
7268
if (this.apiEvents_) {
7369
this.events_.listen(this.apiEvents_,
74-
cwc.protocol.sphero.v1.Events.Type.CONNECT,
70+
cwc.protocol.lego.ev3.Events.Type.CONNECT,
7571
this.handleConnecting_.bind(this));
7672

7773
// Monitor device data
@@ -93,6 +89,21 @@ cwc.mode.lego.ev3.Connection.prototype.init = function() {
9389
false, this);
9490
}
9591

92+
let bluetoothInstance = this.helper.getInstance('bluetoothChrome');
93+
if (bluetoothInstance) {
94+
if (bluetoothInstance.getDeviceByName(this.device_.namePrefix)) {
95+
this.handleConnecting_({
96+
'data': 'Searching for ' + this.device_.name,
97+
'source': 1,
98+
});
99+
} else {
100+
this.handleConnecting_({
101+
'data': 'Unable to find any valid ' + this.device_.name + ' device!',
102+
'source': -1,
103+
});
104+
}
105+
}
106+
96107
if (!this.connectMonitor) {
97108
this.connectMonitor = new goog.Timer(this.connectMonitorInterval);
98109
this.events_.listen(this.connectMonitor, goog.Timer.TICK,
@@ -113,7 +124,7 @@ cwc.mode.lego.ev3.Connection.prototype.connect = function() {
113124
return;
114125
}
115126
if (!this.isConnected()) {
116-
bluetoothInstance.autoConnectDevice(this.autoConnectName,
127+
bluetoothInstance.autoConnectDevice(this.device_.namePrefix,
117128
this.api_.connect.bind(this.api_));
118129
}
119130
this.api_.monitor(true);
@@ -124,7 +135,6 @@ cwc.mode.lego.ev3.Connection.prototype.connect = function() {
124135
* Connects the EV3 unit.
125136
*/
126137
cwc.mode.lego.ev3.Connection.prototype.disconnect = function() {
127-
this.log_.info('Disconnect the EV3 unit...');
128138
this.api_.disconnect();
129139
};
130140

@@ -191,47 +201,47 @@ cwc.mode.lego.ev3.Connection.prototype.stop = function() {
191201
* @param {Event|Object} e
192202
* @private
193203
*/
194-
cwc.mode.lego.ev3.Connection.prototype.handleConnecting_ = function(e) {
195-
let message = e.data;
196-
let step = e.source;
197-
let title = 'Connecting EV3';
198-
let connectScreenInstance = this.helper.getInstance('connectScreen');
199-
connectScreenInstance.showConnectingStep(title, message, step);
204+
cwc.mode.lego.ev3.Connection.prototype.handleUpdateDevices_ = function(e) {
205+
let rendererInstance = this.helper.getInstance('renderer');
206+
if (rendererInstance && e.data) {
207+
rendererInstance.setDevices(e.data);
208+
}
200209
};
201210

202211

203212
/**
204-
* @param {Event|Object} e
205-
* @private
213+
* Cleans up the event listener and any other modification.
206214
*/
207-
cwc.mode.lego.ev3.Connection.prototype.handlePreviewStatus_ = function(e) {
208-
if (e.data === cwc.ui.PreviewState.STOPPED) {
209-
this.stop();
215+
cwc.mode.lego.ev3.Connection.prototype.cleanUp = function() {
216+
if (this.connectMonitor) {
217+
this.connectMonitor.stop();
210218
}
219+
this.api_.cleanUp();
220+
this.stop();
221+
this.events_.clear();
211222
};
212223

213224

214225
/**
215226
* @param {Event|Object} e
216227
* @private
217228
*/
218-
cwc.mode.lego.ev3.Connection.prototype.handleUpdateDevices_ = function(e) {
219-
let rendererInstance = this.helper.getInstance('renderer');
220-
if (rendererInstance && e.data) {
221-
rendererInstance.setDevices(e.data);
222-
}
229+
cwc.mode.lego.ev3.Connection.prototype.handleConnecting_ = function(e) {
230+
let message = e.data;
231+
let step = e.source;
232+
let title = 'Connecting EV3';
233+
let connectScreenInstance = this.helper.getInstance('connectScreen');
234+
connectScreenInstance.showConnectingStep(title, message, step);
223235
};
224236

225237

226238
/**
227-
* Cleans up the event listener and any other modification.
239+
* @param {Event|Object} e
240+
* @private
228241
*/
229-
cwc.mode.lego.ev3.Connection.prototype.cleanUp = function() {
230-
this.log_.info('Clean up ...');
231-
if (this.connectMonitor) {
232-
this.connectMonitor.stop();
242+
cwc.mode.lego.ev3.Connection.prototype.handlePreviewStatus_ = function(e) {
243+
if (e.data === cwc.ui.PreviewState.STOPPED) {
244+
this.stop();
233245
}
234-
this.api_.cleanUp();
235-
this.stop();
236-
this.events_.clear();
237246
};
247+
});

src/mode/makeblock/mbot/connection.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ cwc.mode.makeblock.mBot.Connection = function(helper) {
4141
/** @type {string} */
4242
this.name = 'mBot Connection';
4343

44-
/** @type {string} */
45-
this.autoConnectName = 'Makeblock';
46-
4744
/** @type {!cwc.utils.Helper} */
4845
this.helper = helper;
4946

@@ -72,11 +69,6 @@ cwc.mode.makeblock.mBot.Connection = function(helper) {
7269
* @export
7370
*/
7471
cwc.mode.makeblock.mBot.Connection.prototype.init = function() {
75-
this.handleConnecting_({
76-
'data': 'Searching for ' + this.device_.name,
77-
'source': 1,
78-
});
79-
8072
if (this.apiEvents_) {
8173
this.events_.listen(this.apiEvents_,
8274
Events.Type.CONNECT, this.handleConnecting_.bind(this));
@@ -95,6 +87,21 @@ cwc.mode.makeblock.mBot.Connection.prototype.init = function() {
9587
false, this);
9688
}
9789

90+
let bluetoothInstance = this.helper.getInstance('bluetoothChrome');
91+
if (bluetoothInstance) {
92+
if (bluetoothInstance.getDeviceByName(this.device_.namePrefix)) {
93+
this.handleConnecting_({
94+
'data': 'Searching for ' + this.device_.name,
95+
'source': 1,
96+
});
97+
} else {
98+
this.handleConnecting_({
99+
'data': 'Unable to find any valid ' + this.device_.name + ' device!',
100+
'source': -1,
101+
});
102+
}
103+
}
104+
98105
if (!this.connectMonitor) {
99106
this.connectMonitor = new goog.Timer(this.connectMonitorInterval);
100107
this.events_.listen(this.connectMonitor, goog.Timer.TICK,
@@ -117,7 +124,7 @@ cwc.mode.makeblock.mBot.Connection.prototype.connect = function(opt_event) {
117124
return;
118125
}
119126
if (!this.isConnected()) {
120-
bluetoothInstance.autoConnectDevice(this.autoConnectName,
127+
bluetoothInstance.autoConnectDevice(this.device_.namePrefix,
121128
this.api_.connect.bind(this.api_));
122129
}
123130
this.api_.monitor(true);

src/mode/makeblock/mbot_ranger/connection.js

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ cwc.mode.makeblock.mBotRanger.Connection = function(helper) {
4141
/** @type {string} */
4242
this.name = 'mBot Ranger Connection';
4343

44-
/** @type {string} */
45-
this.autoConnectName = 'Makeblock';
46-
4744
/** @type {!cwc.utils.Helper} */
4845
this.helper = helper;
4946

@@ -72,11 +69,6 @@ cwc.mode.makeblock.mBotRanger.Connection = function(helper) {
7269
* @export
7370
*/
7471
cwc.mode.makeblock.mBotRanger.Connection.prototype.init = function() {
75-
this.handleConnecting_({
76-
'data': 'Searching for ' + this.device_.name,
77-
'source': 1,
78-
});
79-
8072
if (this.apiEvents_) {
8173
this.events_.listen(this.apiEvents_,
8274
Events.Type.CONNECT, this.handleConnecting_.bind(this));
@@ -95,6 +87,21 @@ cwc.mode.makeblock.mBotRanger.Connection.prototype.init = function() {
9587
false, this);
9688
}
9789

90+
let bluetoothInstance = this.helper.getInstance('bluetoothChrome');
91+
if (bluetoothInstance) {
92+
if (bluetoothInstance.getDeviceByName(this.device_.namePrefix)) {
93+
this.handleConnecting_({
94+
'data': 'Searching for ' + this.device_.name,
95+
'source': 1,
96+
});
97+
} else {
98+
this.handleConnecting_({
99+
'data': 'Unable to find any valid ' + this.device_.name + ' device!',
100+
'source': -1,
101+
});
102+
}
103+
}
104+
98105
if (!this.connectMonitor) {
99106
this.connectMonitor = new goog.Timer(this.connectMonitorInterval);
100107
this.events_.listen(this.connectMonitor, goog.Timer.TICK,
@@ -118,8 +125,8 @@ cwc.mode.makeblock.mBotRanger.Connection.prototype.connect = function(
118125
return;
119126
}
120127
if (!this.isConnected()) {
121-
bluetoothInstance.autoConnectDevice(this.autoConnectName,
122-
this.api_.connect.bind(this.api_));
128+
bluetoothInstance.autoConnectDevice(
129+
this.device_.namePrefix, this.api_.connect.bind(this.api_));
123130
}
124131
this.api_.monitor(true);
125132
};

0 commit comments

Comments
 (0)