Skip to content

Commit

Permalink
Merge pull request #82 from freeflyk/ws_fix
Browse files Browse the repository at this point in the history
Ws fix
  • Loading branch information
0xf104a committed May 16, 2024
2 parents 8eb7dde + 8c1a611 commit 4e78bc8
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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
Expand Down

0 comments on commit 4e78bc8

Please sign in to comment.