diff --git a/app/src/main/assets/app_config/js/gadgetbridge_boilerplate.js b/app/src/main/assets/app_config/js/gadgetbridge_boilerplate.js index d3021c31..24de66f5 100644 --- a/app/src/main/assets/app_config/js/gadgetbridge_boilerplate.js +++ b/app/src/main/assets/app_config/js/gadgetbridge_boilerplate.js @@ -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 diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/ExternalPebbleJSActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/ExternalPebbleJSActivity.java index 44d5d93a..d26691b7 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/ExternalPebbleJSActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/ExternalPebbleJSActivity.java @@ -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");