mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-04 01:09:47 +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:
parent
d8145a52f9
commit
1a22752b98
@ -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
|
||||
|
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user