Search in sources :

Example 1 with SignalProxy

use of org.whispersystems.signalservice.internal.configuration.SignalProxy in project Signal-Android by WhisperSystems.

the class EditProxyFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    this.proxySwitch = view.findViewById(R.id.edit_proxy_switch);
    this.proxyTitle = view.findViewById(R.id.edit_proxy_address_title);
    this.proxyText = view.findViewById(R.id.edit_proxy_host);
    this.proxyStatus = view.findViewById(R.id.edit_proxy_status);
    this.saveButton = view.findViewById(R.id.edit_proxy_save);
    this.shareButton = view.findViewById(R.id.edit_proxy_share);
    proxyText.addTextChangedListener(new SimpleTextWatcher() {

        @Override
        public void onTextChanged(String text) {
            onProxyTextChanged(text);
        }
    });
    this.proxyText.setText(Optional.fromNullable(SignalStore.proxy().getProxy()).transform(SignalProxy::getHost).or(""));
    this.proxySwitch.setChecked(SignalStore.proxy().isProxyEnabled());
    initViewModel();
    saveButton.setOnClickListener(v -> onSaveClicked());
    shareButton.setOnClickListener(v -> onShareClicked());
    proxySwitch.setOnCheckedChangeListener((buttonView, isChecked) -> viewModel.onToggleProxy(isChecked));
    LearnMoreTextView description = view.findViewById(R.id.edit_proxy_switch_title_description);
    description.setLearnMoreVisible(true);
    description.setOnLinkClickListener(v -> CommunicationActions.openBrowserLink(requireContext(), "https://support.signal.org/hc/articles/360056052052"));
    requireActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
}
Also used : SimpleTextWatcher(org.thoughtcrime.securesms.contactshare.SimpleTextWatcher) SignalProxy(org.whispersystems.signalservice.internal.configuration.SignalProxy) LearnMoreTextView(org.thoughtcrime.securesms.util.views.LearnMoreTextView)

Example 2 with SignalProxy

use of org.whispersystems.signalservice.internal.configuration.SignalProxy in project Signal-Android by WhisperSystems.

the class EditProxyViewModel method onToggleProxy.

void onToggleProxy(boolean enabled) {
    if (enabled) {
        SignalProxy currentProxy = SignalStore.proxy().getProxy();
        if (currentProxy != null && !Util.isEmpty(currentProxy.getHost())) {
            SignalProxyUtil.enableProxy(currentProxy);
        }
        uiState.postValue(UiState.ALL_ENABLED);
    } else {
        SignalProxyUtil.disableProxy();
        uiState.postValue(UiState.ALL_DISABLED);
    }
}
Also used : SignalProxy(org.whispersystems.signalservice.internal.configuration.SignalProxy)

Example 3 with SignalProxy

use of org.whispersystems.signalservice.internal.configuration.SignalProxy in project Signal-Android by WhisperSystems.

the class EditProxyViewModel method onSaveClicked.

public void onSaveClicked(@NonNull String host) {
    String trueHost = SignalProxyUtil.convertUserEnteredAddressToHost(host);
    saveState.postValue(SaveState.IN_PROGRESS);
    SignalExecutors.BOUNDED.execute(() -> {
        SignalProxyUtil.enableProxy(new SignalProxy(trueHost, 443));
        boolean success = SignalProxyUtil.testWebsocketConnection(TimeUnit.SECONDS.toMillis(10));
        if (success) {
            events.postValue(Event.PROXY_SUCCESS);
        } else {
            SignalProxyUtil.disableProxy();
            events.postValue(Event.PROXY_FAILURE);
        }
        saveState.postValue(SaveState.IDLE);
    });
}
Also used : SignalProxy(org.whispersystems.signalservice.internal.configuration.SignalProxy)

Aggregations

SignalProxy (org.whispersystems.signalservice.internal.configuration.SignalProxy)3 SimpleTextWatcher (org.thoughtcrime.securesms.contactshare.SimpleTextWatcher)1 LearnMoreTextView (org.thoughtcrime.securesms.util.views.LearnMoreTextView)1