Improve BangleJS code according to review

This commit is contained in:
Arjan Schrijver
2025-12-25 14:45:08 +01:00
committed by Arjan Schrijver
parent 5757ce7749
commit 3c725b9276
2 changed files with 7 additions and 5 deletions
@@ -207,9 +207,6 @@ public class AppsManagementActivity extends AbstractGBActivity {
webView.addJavascriptInterface(new WebViewInterface(this), "Android");
webView.setWebContentsDebuggingEnabled(true); // FIXME
Prefs devicePrefs = new Prefs(GBApplication.getDeviceSpecificSharedPrefs(mGBDevice.getAddress()));
final String url = devicePrefs.getString(PREF_BANGLEJS_WEBVIEW_URL, "https://banglejs.com/apps/android.html").trim();
webView.setWebViewClient(new GBWebClient(GBWebClient.REQUEST_TYPE_BANGLE_APP_LOADER){
@Override
public void onPageFinished(WebView view, String weburl){
@@ -229,9 +226,14 @@ public class AppsManagementActivity extends AbstractGBActivity {
}
});
Prefs devicePrefs = new Prefs(GBApplication.getDeviceSpecificSharedPrefs(mGBDevice.getAddress()));
String url = devicePrefs.getString(PREF_BANGLEJS_WEBVIEW_URL, "").trim();
if (url.isEmpty()) url = "https://banglejs.com/apps/android.html";
final String finalUrl = url;
final Looper mainLooper = Looper.getMainLooper();
new Handler(mainLooper).postDelayed(() -> {
webView.loadUrl(url);
webView.loadUrl(finalUrl);
}, 1000);
@@ -925,7 +925,7 @@ public class BangleJSDeviceSupport extends AbstractBTLESingleDeviceSupport {
Prefs devicePrefs = new Prefs(GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()));
if (! devicePrefs.getBoolean(PREF_DEVICE_INTERNET_ACCESS, false)) {
uartTxJSONError("http", "Internet access not enabled for this device", id);
uartTxJSONError("http", "Internet access not enabled for this watch", id);
return;
}