This is a workaround for bugs in the javascript code of the configured watchfaces, that could fail to handle a returned failure properly and crash the webview / fill its stack.
remove the pre-KITKAT checks as the minsupportedversion is KITKAT
fix the currentPosition override
move the returned configuration parsing to onResume method (where it was previously) as it seems more reliable
pass the whole GBDeviceEventAppMessage object, this way the jsInterface in the webview doesn't need to be static anymore
change the way the webview is initialized, this way the context doesn't need to be static anymore
use runOnUiThread instead of the Handler .. MainLooper to post the commands to the webview instance
comment a couple of custom message handler for weather as the watchapp seem to work well with JS alone
add a couple of log messages for debugging
known issue: legacy app configuration pasting does not work.
Progress so far:
- webview is created upon watchapp launch
- webview is destroyed after disconnect
- ready event is fired in the background
- showConfiguration is fired upon webview display
This is not needed as long as one GB instance is used to manage a single pebble device, if multiple devices are managed the stored watchapp configuration could be messed up.
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.
- localstorage is now cleared at every launch: this prevents some clay configuration pages to send back to the watch a number of keys that were set by other configuration pages
- only execute JS on document ready: this prevents some race conditions
- added dummy getTimelineToken function to Pebble JS object
- corrected (hopefully!) a few logic errors in the JS code (this referenced where it wasn't)
- refactored the steps visualization in JS
- lifecycle changes to the java activity: now the configuration page gets closed as soon as the settings have been sent, and there is only one instance of it
* no more ByteBuffer, but a fixed size byte array that gets flushed everytime it's needed
* log of activity data to a separate file (no DB integration yet)
* the size of the buffer must be a multiple of 3 (1 minute of data = 3 bytes) and 20 (the normal size of the chunks we get from the device)
* better logging and more comments in code