1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-28 21:06:50 +01:00

Pebble: enable localStorage

LocalStorage native functions are overridden to keep each watchface's settings separated. It's possible the bind method do not work on older versions of android.
This commit is contained in:
Daniele Gobbetti 2016-11-14 17:51:33 +01:00
parent d8145a52f9
commit 1a22752b98
2 changed files with 15 additions and 2 deletions

View File

@ -1,5 +1,16 @@
//clay stores the values in the localStorage
localStorage.clear();
if (window.Storage){
var prefix = GBjs.getAppUUID();
GBjs.gbLog("redefining local storage with prefix: " + prefix);
Storage.prototype.setItem = (function(key, value) {
this.call(localStorage,prefix + key, value);
}).bind(Storage.prototype.setItem);
Storage.prototype.getItem = (function(key) {
//GBjs.gbLog("I am about to return " + prefix + key);
return this.call(localStorage,prefix + key);
}).bind(Storage.prototype.getItem);
}
function loadScript(url, callback) {
// Adding the script tag to the head as suggested before

View File

@ -69,6 +69,8 @@ public class ExternalPebbleJSActivity extends GBActivity {
webSettings.setJavaScriptEnabled(true);
//needed to access the DOM
webSettings.setDomStorageEnabled(true);
//needed for localstorage
webSettings.setDatabaseEnabled(true);
JSInterface gbJSInterface = new JSInterface(this);
myWebView.addJavascriptInterface(gbJSInterface, "GBjs");