parent
de329166d2
commit
cdb7f07368
3 changed files with 20 additions and 9 deletions
|
@ -73,7 +73,7 @@ public class EditProxyFragment extends Fragment {
|
||||||
|
|
||||||
saveButton.setOnClickListener(v -> onSaveClicked());
|
saveButton.setOnClickListener(v -> onSaveClicked());
|
||||||
shareButton.setOnClickListener(v -> onShareClicked());
|
shareButton.setOnClickListener(v -> onShareClicked());
|
||||||
proxySwitch.setOnCheckedChangeListener((buttonView, isChecked) -> viewModel.onToggleProxy(isChecked));
|
proxySwitch.setOnCheckedChangeListener((buttonView, isChecked) -> viewModel.onToggleProxy(isChecked, proxyText.getText().toString()));
|
||||||
|
|
||||||
LearnMoreTextView description = view.findViewById(R.id.edit_proxy_switch_title_description);
|
LearnMoreTextView description = view.findViewById(R.id.edit_proxy_switch_title_description);
|
||||||
description.setLearnMoreVisible(true);
|
description.setLearnMoreVisible(true);
|
||||||
|
@ -103,6 +103,8 @@ public class EditProxyFragment extends Fragment {
|
||||||
case ALL_ENABLED:
|
case ALL_ENABLED:
|
||||||
proxyText.setEnabled(true);
|
proxyText.setEnabled(true);
|
||||||
proxyText.setAlpha(1);
|
proxyText.setAlpha(1);
|
||||||
|
saveButton.setEnabled(true);
|
||||||
|
saveButton.setAlpha(1);
|
||||||
proxyTitle.setAlpha(1);
|
proxyTitle.setAlpha(1);
|
||||||
onProxyTextChanged(proxyText.getText().toString());
|
onProxyTextChanged(proxyText.getText().toString());
|
||||||
break;
|
break;
|
||||||
|
@ -182,7 +184,12 @@ public class EditProxyFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onSaveClicked() {
|
private void onSaveClicked() {
|
||||||
viewModel.onSaveClicked(proxyText.getText().toString());
|
String text = proxyText.getText().toString();
|
||||||
|
if (Util.isEmpty(text)) {
|
||||||
|
proxySwitch.setChecked(false);
|
||||||
|
} else {
|
||||||
|
viewModel.onSaveClicked(text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onShareClicked() {
|
private void onShareClicked() {
|
||||||
|
@ -195,14 +202,10 @@ public class EditProxyFragment extends Fragment {
|
||||||
|
|
||||||
private void onProxyTextChanged(@NonNull String text) {
|
private void onProxyTextChanged(@NonNull String text) {
|
||||||
if (Util.isEmpty(text)) {
|
if (Util.isEmpty(text)) {
|
||||||
saveButton.setEnabled(false);
|
|
||||||
saveButton.setAlpha(0.5f);
|
|
||||||
shareButton.setEnabled(false);
|
shareButton.setEnabled(false);
|
||||||
shareButton.setAlpha(0.5f);
|
shareButton.setAlpha(0.5f);
|
||||||
proxyStatus.setVisibility(View.INVISIBLE);
|
proxyStatus.setVisibility(View.INVISIBLE);
|
||||||
} else {
|
} else {
|
||||||
saveButton.setEnabled(true);
|
|
||||||
saveButton.setAlpha(1);
|
|
||||||
shareButton.setEnabled(true);
|
shareButton.setEnabled(true);
|
||||||
shareButton.setAlpha(1);
|
shareButton.setAlpha(1);
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class EditProxyViewModel extends ViewModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void onToggleProxy(boolean enabled) {
|
void onToggleProxy(boolean enabled, String text) {
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
SignalProxy currentProxy = SignalStore.proxy().getProxy();
|
SignalProxy currentProxy = SignalStore.proxy().getProxy();
|
||||||
|
|
||||||
|
@ -51,6 +51,9 @@ public class EditProxyViewModel extends ViewModel {
|
||||||
SignalProxyUtil.enableProxy(currentProxy);
|
SignalProxyUtil.enableProxy(currentProxy);
|
||||||
}
|
}
|
||||||
uiState.postValue(UiState.ALL_ENABLED);
|
uiState.postValue(UiState.ALL_ENABLED);
|
||||||
|
} else if (Util.isEmpty(text)) {
|
||||||
|
SignalProxyUtil.disableAndClearProxy();
|
||||||
|
uiState.postValue(UiState.ALL_DISABLED);
|
||||||
} else {
|
} else {
|
||||||
SignalProxyUtil.disableProxy();
|
SignalProxyUtil.disableProxy();
|
||||||
uiState.postValue(UiState.ALL_DISABLED);
|
uiState.postValue(UiState.ALL_DISABLED);
|
||||||
|
|
|
@ -67,6 +67,11 @@ public final class SignalProxyUtil {
|
||||||
startListeningToWebsocket();
|
startListeningToWebsocket();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void disableAndClearProxy(){
|
||||||
|
disableProxy();
|
||||||
|
SignalStore.proxy().setProxy(null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A blocking call that will wait until the websocket either successfully connects, or fails.
|
* A blocking call that will wait until the websocket either successfully connects, or fails.
|
||||||
* It is assumed that the app state is already configured how you would like it, e.g. you've
|
* It is assumed that the app state is already configured how you would like it, e.g. you've
|
||||||
|
|
Loading…
Add table
Reference in a new issue