diff --git a/app/src/main/java/com/polar/nextcloudservices/Services/NotificationWebsocketService.java b/app/src/main/java/com/polar/nextcloudservices/Services/NotificationWebsocketService.java index b3ab081..b88e1de 100644 --- a/app/src/main/java/com/polar/nextcloudservices/Services/NotificationWebsocketService.java +++ b/app/src/main/java/com/polar/nextcloudservices/Services/NotificationWebsocketService.java @@ -1,7 +1,6 @@ package com.polar.nextcloudservices.Services; import android.app.Notification; -import android.app.NotificationManager; import android.app.Service; import android.content.Intent; import android.os.IBinder; @@ -134,7 +133,9 @@ public void onWebsocketConnected() { @Override public String getStatus() { - if(mNotificationWebsocket == null){ + if(!mConnectionController.checkConnection(this)){ + return "Disconnected: no suitable network found"; + }else if(mNotificationWebsocket == null){ return "Disconnected: can not connect to websocket. Are login details correct? Is notify_push installed on server?"; } return mStatusController.getStatusString(); @@ -148,15 +149,14 @@ private void safeCloseWebsocket(){ @Override public void onPreferencesChanged() { + safeCloseWebsocket(); if(!mServiceSettings.isWebsocketEnabled()){ Log.i(TAG, "Websocket is no more enabled. Disconnecting websocket and stopping service"); - safeCloseWebsocket(); stopForeground(true); + }else{ + Log.i(TAG, "Preferences changed. Re-connecting to websocket."); + mAPI = mServiceSettings.getAPIFromSettings(); } - Log.i(TAG, "Preferences changed. Re-connecting to websocket."); - safeCloseWebsocket(); - mAPI = mServiceSettings.getAPIFromSettings(); - startListening(); } @Override