mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-08-19 22:00:53 +02:00
Pebble background webview: config page should be shown reliably now.
This commit is contained in:
parent
21b90d1e6e
commit
f84c651c38
@ -99,6 +99,7 @@ function gbPebble() {
|
||||
for (var i = 0; i < l; i++) {
|
||||
evs[i].apply(null, args);
|
||||
}
|
||||
GBjs.eventFinished(name);
|
||||
}
|
||||
|
||||
this.actuallyOpenURL = function() {
|
||||
@ -204,6 +205,14 @@ document.addEventListener('DOMContentLoaded', function(){
|
||||
if (jsConfigFile != null) {
|
||||
loadScript(jsConfigFile, function() {
|
||||
Pebble.evaluate('ready');
|
||||
if(document.hasFocus() && !(getURLVariable('config') == 'true')) {
|
||||
Pebble.evaluate('showConfiguration');
|
||||
} else {
|
||||
window.onfocus = function () {
|
||||
GBjs.gbLog("window focused!!!");
|
||||
Pebble.evaluate('showConfiguration');
|
||||
};
|
||||
}
|
||||
if (getURLVariable('config') == 'true') {
|
||||
showStep("step2");
|
||||
var json_string = getURLVariable('json');
|
||||
|
@ -8,7 +8,6 @@ import android.support.v4.app.NavUtils;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.webkit.JavascriptInterface;
|
||||
import android.webkit.ValueCallback;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.Toast;
|
||||
@ -28,9 +27,7 @@ public class ExternalPebbleJSActivity extends GBActivity {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ExternalPebbleJSActivity.class);
|
||||
|
||||
private UUID appUuid;
|
||||
private Uri confUri;
|
||||
private GBDevice mGBDevice = null;
|
||||
private WebView myWebView;
|
||||
|
||||
@Override
|
||||
@ -39,8 +36,7 @@ public class ExternalPebbleJSActivity extends GBActivity {
|
||||
|
||||
Bundle extras = getIntent().getExtras();
|
||||
if (extras != null) {
|
||||
mGBDevice = extras.getParcelable(GBDevice.EXTRA_DEVICE);
|
||||
appUuid = (UUID) extras.getSerializable(DeviceService.EXTRA_APP_UUID);
|
||||
WebViewSingleton.runJavascriptInterface((GBDevice) extras.getParcelable(GBDevice.EXTRA_DEVICE), (UUID) extras.getSerializable(DeviceService.EXTRA_APP_UUID));
|
||||
} else {
|
||||
throw new IllegalArgumentException("Must provide a device when invoking this activity");
|
||||
}
|
||||
@ -61,13 +57,13 @@ public class ExternalPebbleJSActivity extends GBActivity {
|
||||
public void onViewAttachedToWindow(View v) {
|
||||
|
||||
v.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
||||
//show configuration
|
||||
myWebView.evaluateJavascript("Pebble.evaluate('showConfiguration');", new ValueCallback<String>() {
|
||||
@Override
|
||||
public void onReceiveValue(String s) {
|
||||
LOG.debug("Callback from showConfiguration: " + s);
|
||||
}
|
||||
});
|
||||
//show configuration - moved to JS
|
||||
// myWebView.evaluateJavascript("Pebble.evaluate('showConfiguration');", new ValueCallback<String>() {
|
||||
// @Override
|
||||
// public void onReceiveValue(String s) {
|
||||
// LOG.debug("Callback from showConfiguration: " + s);
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -88,7 +84,6 @@ public class ExternalPebbleJSActivity extends GBActivity {
|
||||
//getting back with configuration data
|
||||
LOG.debug("WEBVIEW returned config: " + confUri.toString());
|
||||
try {
|
||||
appUuid = UUID.fromString(confUri.getHost());
|
||||
queryString = confUri.getEncodedQuery();
|
||||
} catch (IllegalArgumentException e) {
|
||||
GB.toast("returned uri: " + confUri.toString(), Toast.LENGTH_LONG, GB.ERROR);
|
||||
|
@ -60,6 +60,7 @@ public class WebViewSingleton {
|
||||
private static WebView instance = null;
|
||||
private Activity contextWrapper;
|
||||
private static WebViewSingleton webViewSingleton = new WebViewSingleton();
|
||||
private static UUID currentRunningUUID;
|
||||
|
||||
private WebViewSingleton() {
|
||||
}
|
||||
@ -98,6 +99,11 @@ public class WebViewSingleton {
|
||||
|
||||
final JSInterface jsInterface = new JSInterface(device, uuid);
|
||||
|
||||
if (uuid.equals(currentRunningUUID)) {
|
||||
LOG.debug("WEBVIEW uuid not changed keeping the old context");
|
||||
} else {
|
||||
LOG.debug("WEBVIEW uuid changed, restarting");
|
||||
currentRunningUUID = uuid;
|
||||
webViewSingleton.contextWrapper.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -108,6 +114,8 @@ public class WebViewSingleton {
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void appMessage(GBDeviceEventAppMessage message) {
|
||||
|
||||
if (instance == null) {
|
||||
@ -390,7 +398,7 @@ public class WebViewSingleton {
|
||||
|
||||
@JavascriptInterface
|
||||
public void gbLog(String msg) {
|
||||
LOG.debug("WEBVIEW webpage log", msg);
|
||||
LOG.debug("WEBVIEW webpage log: " + msg);
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
@ -562,6 +570,10 @@ public class WebViewSingleton {
|
||||
return geoPosition.toString();
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void eventFinished(String event) {
|
||||
LOG.debug("WEBVIEW event finished: " + event);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user