mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 00:59:49 +01:00
Improve WebSocket health monitoring.
This commit is contained in:
@@ -21,13 +21,13 @@ import com.dd.CircularProgressButton;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.contactshare.SimpleTextWatcher;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
import org.thoughtcrime.securesms.net.PipeConnectivityListener;
|
||||
import org.thoughtcrime.securesms.util.CommunicationActions;
|
||||
import org.thoughtcrime.securesms.util.SignalProxyUtil;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||
import org.thoughtcrime.securesms.util.views.LearnMoreTextView;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
import org.whispersystems.signalservice.api.websocket.WebSocketConnectionState;
|
||||
import org.whispersystems.signalservice.internal.configuration.SignalProxy;
|
||||
|
||||
public class EditProxyFragment extends Fragment {
|
||||
@@ -118,10 +118,11 @@ public class EditProxyFragment extends Fragment {
|
||||
}
|
||||
}
|
||||
|
||||
private void presentProxyState(@NonNull PipeConnectivityListener.State proxyState) {
|
||||
private void presentProxyState(@NonNull WebSocketConnectionState proxyState) {
|
||||
if (SignalStore.proxy().getProxy() != null) {
|
||||
switch (proxyState) {
|
||||
case DISCONNECTED:
|
||||
case DISCONNECTING:
|
||||
case CONNECTING:
|
||||
proxyStatus.setText(R.string.preferences_connecting_to_proxy);
|
||||
proxyStatus.setTextColor(getResources().getColor(R.color.signal_text_secondary));
|
||||
@@ -130,7 +131,8 @@ public class EditProxyFragment extends Fragment {
|
||||
proxyStatus.setText(R.string.preferences_connected_to_proxy);
|
||||
proxyStatus.setTextColor(getResources().getColor(R.color.signal_accent_green));
|
||||
break;
|
||||
case FAILURE:
|
||||
case AUTHENTICATION_FAILED:
|
||||
case FAILED:
|
||||
proxyStatus.setText(R.string.preferences_connection_failed);
|
||||
proxyStatus.setTextColor(getResources().getColor(R.color.signal_alert_primary));
|
||||
break;
|
||||
|
||||
@@ -8,28 +8,34 @@ import androidx.lifecycle.ViewModel;
|
||||
import org.signal.core.util.concurrent.SignalExecutors;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
import org.thoughtcrime.securesms.net.PipeConnectivityListener;
|
||||
import org.thoughtcrime.securesms.util.SignalProxyUtil;
|
||||
import org.thoughtcrime.securesms.util.SingleLiveEvent;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.whispersystems.signalservice.api.websocket.WebSocketConnectionState;
|
||||
import org.whispersystems.signalservice.internal.configuration.SignalProxy;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.rxjava3.core.BackpressureStrategy;
|
||||
|
||||
import static androidx.lifecycle.LiveDataReactiveStreams.fromPublisher;
|
||||
|
||||
public class EditProxyViewModel extends ViewModel {
|
||||
|
||||
private final SingleLiveEvent<Event> events;
|
||||
private final MutableLiveData<UiState> uiState;
|
||||
private final MutableLiveData<SaveState> saveState;
|
||||
private final LiveData<PipeConnectivityListener.State> pipeState;
|
||||
private final SingleLiveEvent<Event> events;
|
||||
private final MutableLiveData<UiState> uiState;
|
||||
private final MutableLiveData<SaveState> saveState;
|
||||
private final LiveData<WebSocketConnectionState> pipeState;
|
||||
|
||||
public EditProxyViewModel() {
|
||||
this.events = new SingleLiveEvent<>();
|
||||
this.uiState = new MutableLiveData<>();
|
||||
this.saveState = new MutableLiveData<>(SaveState.IDLE);
|
||||
this.pipeState = TextSecurePreferences.getLocalNumber(ApplicationDependencies.getApplication()) == null ? new MutableLiveData<>()
|
||||
: ApplicationDependencies.getPipeListener().getState();
|
||||
: fromPublisher(ApplicationDependencies.getSignalWebSocket()
|
||||
.getWebSocketState()
|
||||
.toFlowable(BackpressureStrategy.LATEST));
|
||||
|
||||
if (SignalStore.proxy().isProxyEnabled()) {
|
||||
uiState.setValue(UiState.ALL_ENABLED);
|
||||
@@ -81,7 +87,7 @@ public class EditProxyViewModel extends ViewModel {
|
||||
return events;
|
||||
}
|
||||
|
||||
@NonNull LiveData<PipeConnectivityListener.State> getProxyState() {
|
||||
@NonNull LiveData<WebSocketConnectionState> getProxyState() {
|
||||
return pipeState;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user