Update node button text when selected node changes

This commit is contained in:
pokkst 2022-09-17 05:00:20 -05:00
parent e197cc038d
commit 35634b43ee
No known key found for this signature in database
GPG Key ID: 90C2ED85E67A50FF
2 changed files with 13 additions and 1 deletions

View File

@ -2,6 +2,7 @@ package com.m2049r.xmrwallet.fragment.dialog;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.util.Patterns;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -83,9 +84,11 @@ public class NodeSelectionBottomSheetDialog extends BottomSheetDialogFragment im
PrefService.getInstance().edit().putString(Constants.PREF_NODE, node.getAddress()).apply(); PrefService.getInstance().edit().putString(Constants.PREF_NODE, node.getAddress()).apply();
WalletManager.getInstance().setDaemon(node); WalletManager.getInstance().setDaemon(node);
adapter.updateSelectedNode(); adapter.updateSelectedNode();
listener.onNodeSelected();
} }
public interface NodeSelectionDialogListener { public interface NodeSelectionDialogListener {
void onNodeSelected();
void onClickedAddNode(); void onClickedAddNode();
} }
} }

View File

@ -60,6 +60,7 @@ public class SettingsFragment extends Fragment implements PasswordBottomSheetDia
}; };
private EditText walletProxyAddressEditText; private EditText walletProxyAddressEditText;
private EditText walletProxyPortEditText; private EditText walletProxyPortEditText;
private Button selectNodeButton;
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@ -72,7 +73,7 @@ public class SettingsFragment extends Fragment implements PasswordBottomSheetDia
super.onViewCreated(view, savedInstanceState); super.onViewCreated(view, savedInstanceState);
mViewModel = new ViewModelProvider(this).get(SettingsViewModel.class); mViewModel = new ViewModelProvider(this).get(SettingsViewModel.class);
Button displaySeedButton = view.findViewById(R.id.display_seed_button); Button displaySeedButton = view.findViewById(R.id.display_seed_button);
Button selectNodeButton = view.findViewById(R.id.select_node_button); selectNodeButton = view.findViewById(R.id.select_node_button);
SwitchCompat nightModeSwitch = view.findViewById(R.id.day_night_switch); SwitchCompat nightModeSwitch = view.findViewById(R.id.day_night_switch);
SwitchCompat torSwitch = view.findViewById(R.id.tor_switch); SwitchCompat torSwitch = view.findViewById(R.id.tor_switch);
ConstraintLayout proxySettingsLayout = view.findViewById(R.id.wallet_proxy_settings_layout); ConstraintLayout proxySettingsLayout = view.findViewById(R.id.wallet_proxy_settings_layout);
@ -192,6 +193,14 @@ public class SettingsFragment extends Fragment implements PasswordBottomSheetDia
walletProxyPortEditText.addTextChangedListener(proxyPortListener); walletProxyPortEditText.addTextChangedListener(proxyPortListener);
} }
@Override
public void onNodeSelected() {
Node node = Node.fromString(PrefService.getInstance().getString(Constants.PREF_NODE, DefaultNodes.XMRTW.getAddress()));
selectNodeButton.setText(getString(R.string.node_button_text, node.getAddress()));
mViewModel.updateProxy();
WalletManager.getInstance().getWallet().startRefresh();
}
@Override @Override
public void onClickedAddNode() { public void onClickedAddNode() {
AddNodeBottomSheetDialog addNodeDialog = new AddNodeBottomSheetDialog(); AddNodeBottomSheetDialog addNodeDialog = new AddNodeBottomSheetDialog();