Skip to content

Commit

Permalink
### 0.2.0 (2016-05-10)
Browse files Browse the repository at this point in the history
- (bluefox) make it run on 4.0.x and 4.1.x
  • Loading branch information
GermanBluefox committed May 10, 2016
1 parent 32156a7 commit b633f41
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 56 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ With command in javascript adapter you can activate text to speech engine of And

## Changelog

### 0.2.0 (2016-05-10)
- (bluefox) make it run on 4.0.x and 4.1.x

### 0.1.2 (2016-05-03)
- (bluefox) fix error with SVG files
- (bluefox) try to fix error with start
Expand Down
119 changes: 68 additions & 51 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ $.extend(systemDictionary, {

var app = {
settings: {
socketUrl: 'http://localhost:8082',
socketUrl: 'http://localhost:8082',//10.0.2.2. for emulator
systemLang: navigator.language || navigator.userLanguage || 'en',
noSleep: false,
project: '',
Expand Down Expand Up @@ -211,48 +211,60 @@ var app = {
dirHandler.getFile(fileN, {create: true}, function (fileHandler) {
console.log('Store:' + fileN);
var length = data.byteLength || data.length || 0;
fileHandler.createWriter(function (fileWriter) {
// workaround. Sometimes onWrite do not return.
var writeTimer = setTimeout(function () {
cb && cb('Timeout by write of "' + fileN + '"');
cb = null;
}, 1000);

try {
fileWriter.truncate(0);
fileWriter.onwrite = function(evt) {
if (writeTimer) {
clearTimeout(writeTimer);
writeTimer = null;
}

if (length && evt.target.position < length) {
writeTimer = setTimeout(function () {
cb && cb('Timeout by _write of "' + fileN + '"');
cb = null;
}, 1000);
return;
try {
fileHandler.createWriter(function (fileWriter) {
// workaround. Sometimes onWrite do not return.
var writeTimer = setTimeout(function () {
cb && cb('Timeout by write of "' + fileN + '"');
cb = null;
}, 1000);

try {
fileWriter.truncate(0);
fileWriter.onwrite = function(evt) {
if (writeTimer) {
clearTimeout(writeTimer);
writeTimer = null;
}

if (length && evt.target.position < length) {
writeTimer = setTimeout(function () {
cb && cb('Timeout by _write of "' + fileN + '"');
cb = null;
}, 1000);
return;
}
console.log('write "' + fileN + '" success:' + JSON.stringify(evt));
cb && cb();
cb = null;
};

if (window.MozBlobBuilder || window.WebKitBlobBuilder || window.BlobBuilder) {
var bb = new (window.MozBlobBuilder || window.WebKitBlobBuilder || window.BlobBuilder)();
bb.append(data);
fileWriter.write(bb.getBlob());
} else {
fileWriter.write(new Blob([data]));
}
console.log('write "' + fileN + '" success:' + JSON.stringify(evt));
cb && cb();
} catch (error) {
console.error(fileWriter.nativeURL + ': ' + error);
cb && cb(error);
cb = null;
};

fileWriter.write(new Blob([data]));
} catch (e) {
console.error(fileWriter.nativeURL + ': ' + e);
cb && cb(e);
}
}, function (error) {
cb && cb(error);
cb = null;
}
}, function (error) {
console.error('Cannot write file: ' + JSON.stringify(error));
});
} catch (err) {
cb && cb(error);
cb = null;
console.error('Cannot write file: ' + JSON.stringify(error));
});
console.error('Cannot create file:' + err);
}
}, function (error) {
cb && cb(error);
cb = null;
console.error('Cannot create file')
console.error('Cannot create file: ' + error);
});
} else {
console.error('Directory "' + fileName + '" not found');
Expand Down Expand Up @@ -424,24 +436,29 @@ var app = {
if (this.settings.socketUrlGSM && navigator.network && navigator.network.connection.type != 'wifi') {
socketUrl = this.settings.socketUrlGSM + (this.settings.userGSM ? '/?user=' + this.settings.userGSM + '&pass=' + this.settings.passwordGSM : '');
} else {
// If WIFI and SSID is set
if (navigator.wifi) {
// read SSID info
delayed = true;
navigator.wifi.getWifiInfo(function (data) {
this.ssid = data.connection.SSID;
if (this.settings.socketUrlGSM && this.settings.ssid && data.connection.SSID != this.settings.ssid) {
// other wifi network
socketUrl = this.settings.socketUrlGSM + (this.settings.userGSM ? '/?user=' + this.settings.userGSM + '&pass=' + this.settings.passwordGSM : '');
} else {
try {
// If WIFI and SSID is set
if (this.settings.socketUrlGSM && this.settings.ssid && navigator.wifi) {
// read SSID info
delayed = true;
navigator.wifi.getWifiInfo(function (data) {
this.ssid = data.connection.SSID;
if (this.settings.socketUrlGSM && this.settings.ssid && data.connection.SSID != this.settings.ssid) {
// other wifi network
socketUrl = this.settings.socketUrlGSM + (this.settings.userGSM ? '/?user=' + this.settings.userGSM + '&pass=' + this.settings.passwordGSM : '');
} else {
socketUrl = this.settings.socketUrl + (this.settings.user ? '/?user=' + this.settings.user + '&pass=' + this.settings.password : '');
}
cb && cb();
}.bind(this), function (error) {
socketUrl = this.settings.socketUrl + (this.settings.user ? '/?user=' + this.settings.user + '&pass=' + this.settings.password : '');
}
cb && cb();
}.bind(this), function (error) {
console.error(error);
}.bind(this));
} else {
socketUrl = this.settings.socketUrl + (this.settings.user ? '/?user=' + this.settings.user + '&pass=' + this.settings.password : '');
console.error(error);
}.bind(this));
} else {
}
} catch (err) {
delayed = false;
socketUrl = this.settings.socketUrl + (this.settings.user ? '/?user=' + this.settings.user + '&pass=' + this.settings.password : '');
}
}
Expand Down
2 changes: 1 addition & 1 deletion config.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<widget id="net.iobroker.vis" version="0.1.2" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<widget id="net.iobroker.vis" version="0.2.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>ioBroker.vis</name>
<description>
ioBroker.vis runtime for ioBroker.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "iobroker.vis.cordova",
"description": "Cordova APP for ioBroker.",
"version": "0.1.2",
"version": "0.2.0",
"author": {
"name": "bluefox",
"email": "[email protected]"
Expand Down
4 changes: 2 additions & 2 deletions platforms/android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="102" android:versionName="0.1.2" package="net.iobroker.vis" xmlns:android="http://schemas.android.com/apk/res/android">
<manifest android:hardwareAccelerated="true" android:versionCode="200" android:versionName="0.2.0" package="net.iobroker.vis" xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Expand All @@ -16,7 +16,7 @@
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19" />
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="16" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
</manifest>
2 changes: 1 addition & 1 deletion platforms/android/res/xml/config.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<widget id="net.iobroker.vis" version="0.1.2" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<widget id="net.iobroker.vis" version="0.2.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<feature name="Whitelist">
<param name="android-package" value="org.apache.cordova.whitelist.WhitelistPlugin" />
<param name="onload" value="true" />
Expand Down

0 comments on commit b633f41

Please sign in to comment.