Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Android console improvment

Mica Hallinea92fb1c48a6
diff --git a/console/android/src/main/java/org/openremote/android/MainActivity.java b/console/android/src/main/java/org/openremote/android/MainActivity.java
index 00e4be405..fdff87fd2 100644
--- a/console/android/src/main/java/org/openremote/android/MainActivity.java
+++ b/console/android/src/main/java/org/openremote/android/MainActivity.java
@@ -166,15 +166,9 @@ public class MainActivity extends Activity {
webView.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) {
- Log.i("WEBVIEW", "request url :" + request.getUrl().toString());
- Log.i("WEBVIEW", "error :" + errorResponse.getStatusCode());
- if (request.getUrl().toString().startsWith(getString(R.string.OR_BASE_SERVER) + getString(R.string.OR_CONSOLE_URL))) {
- errorViewHolder.show(R.string.httpError,R.string.httpErrorExplain,true,true);
- }
-
-
- //
- //todo: translate common error into user friendly dialog msg ex 400-500 => try again later service not avaible (app clean exit with confirm button)
+ LOG.warning("request url :" + request.getUrl().toString());
+ LOG.warning("error :" + errorResponse.getStatusCode());
+ errorViewHolder.show(R.string.httpError,R.string.httpErrorExplain,true,true);
}
@Override
@@ -182,7 +176,8 @@ public class MainActivity extends Activity {
if (Boolean.parseBoolean(getString(R.string.SSL_IGNORE))) {
handler.proceed(); // Ignore SSL certificate errors
} else {
- super.onReceivedSslError(view, handler, error);
+ LOG.severe("error : something wrong with SSL configuration");
+ errorViewHolder.show(R.string.httpError,R.string.httpErrorExplain,true,true);
}
}
@@ -190,17 +185,14 @@ public class MainActivity extends Activity {
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- LOG.info("request url :" + request.getUrl().toString());
- LOG.info( "error :" + error.getErrorCode());
- LOG.info( "error :" + error.getDescription());
+ LOG.warning("request url :" + request.getUrl().toString());
+ LOG.warning("error :" + error.getErrorCode());
+ LOG.warning("error :" + error.getDescription());
// Remote debugging sessions from Chrome trigger "ERR_CACHE_MISS" that don't hurt, but we should not redirect the view
if (isRemoteDebuggingEnabled() && error.getErrorCode() == ERROR_UNKNOWN) {
return;
}
}
-
- //TODO => try again later service not avaible (app clean exit with confirm button) // good message
- //webView.loadUrl("about:blank");
errorViewHolder.show(R.string.fatalError,R.string.fatalErrorExplain,false,true);
}
});
@@ -221,6 +213,7 @@ public class MainActivity extends Activity {
public void exitOnClick(View view) {
finish();
+ System.exit(0);
}
private class WebAppInterface {
@@ -236,15 +229,6 @@ public class MainActivity extends Activity {
tokenService.clearToken();
}
- @JavascriptInterface
- public String getMobileToken() {
- return tokenService.getJsonToken();
- }
-
- @JavascriptInterface
- public void setMobileToken(String token, String refreshToken, String idToken) {
- tokenService.saveToken(token, refreshToken, idToken);
- }
@JavascriptInterface
public void postMessage(String jsonMessage) throws JSONException {
@@ -255,8 +239,14 @@ public class MainActivity extends Activity {
case "token" :
tokenService.saveToken(data.getString("token"), data.getString("refreshToken") , data.getString("idToken"));
break;
- case "error" :
- //
+ case "logout":
+ tokenService.clearToken();
+ break;
+ case "status" :
+ // TODO: status that we want to receive from webview | waiting to know if it's relevant to show error if bad connectivity meybe a conter or timmout retry should be consider
+ // currently
+ // websocket drop with error
+ // websocket connect back (success)
default:
}
}
@@ -270,14 +260,13 @@ public class MainActivity extends Activity {
return "{}";
}
}
- //TODO receive error with severity
+
}
private void onConnectivityChanged(boolean connectivity) {
this.hasNetwork = connectivity;
if (connectivity) {
- //TODO : pass conectivity information to wwebapp
reloadPage(getCurrentFocus());
} else {
errorViewHolder.show(R.string.noConnectivity,R.string.noConnectivityExplain,false,true);
diff --git a/console/android/src/main/java/org/openremote/android/ORFirebaseMessagingService.java b/console/android/src/main/java/org/openremote/android/ORFirebaseMessagingService.java
index f4bd93fe4..d6c5ba485 100644
--- a/console/android/src/main/java/org/openremote/android/ORFirebaseMessagingService.java
+++ b/console/android/src/main/java/org/openremote/android/ORFirebaseMessagingService.java
@@ -1,5 +1,6 @@
package org.openremote.android;
+import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
@@ -130,6 +131,7 @@ public class ORFirebaseMessagingService extends com.google.firebase.messaging.Fi
.setDeleteIntent(pendingIntent)
.setSmallIcon(R.drawable.app_icon)
.setWhen(0)
+ .setPriority(Notification.PRIORITY_MAX)
.setSound(defaultSoundUri);
for (AlertAction alertAction : alertNotification.getActions()) {
diff --git a/console/android/src/main/res/values/strings.xml b/console/android/src/main/res/values/strings.xml
index ba97f7b36..f87a57ffb 100644
--- a/console/android/src/main/res/values/strings.xml
+++ b/console/android/src/main/res/values/strings.xml
@@ -11,13 +11,13 @@
<string name="SHARED_PREF_DEVICE_ID">FCM_DEVICE_ID_KEY</string>
<string name="reload">reload</string>
<string name="noConnectivity">No connectivity Detected</string>
- <string name="noConnectivityExplain">This application can not work without internet connectivity, you can wait to have it back or exit app</string>
+ <string name="noConnectivityExplain">This application can not work without internet connectivity, you can wait to have it back or exit app.</string>
<string name="SHARED_PREF_OPENED_ALERT">OPENED_ALERT</string>
<string name="AUTH_URL">/auth</string>
<string name="SSL_IGNORE">false</string>
<string name="exit">exit</string>
- <string name="fatalErrorExplain">Blok61 console is avaible, please try again later</string>
+ <string name="fatalErrorExplain">Service unavaible, please try again later</string>
<string name="fatalError">Something go wrong</string>
- <string name="httpError">Failled to contact Blok61 server</string>
- <string name="httpErrorExplain">Something went wrong when communicating with blok61.</string>
+ <string name="httpError">Failled to contact service</string>
+ <string name="httpErrorExplain">Something went wrong when communicating with server.</string>
</resources>