From 35634b43eea94bfd1b6a0760e10d2336a5e87ff7 Mon Sep 17 00:00:00 2001 From: pokkst Date: Sat, 17 Sep 2022 05:00:20 -0500 Subject: [PATCH] Update node button text when selected node changes --- .../dialog/NodeSelectionBottomSheetDialog.java | 3 +++ .../xmrwallet/fragment/settings/SettingsFragment.java | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/m2049r/xmrwallet/fragment/dialog/NodeSelectionBottomSheetDialog.java b/app/src/main/java/com/m2049r/xmrwallet/fragment/dialog/NodeSelectionBottomSheetDialog.java index 6030b0f..693069e 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/fragment/dialog/NodeSelectionBottomSheetDialog.java +++ b/app/src/main/java/com/m2049r/xmrwallet/fragment/dialog/NodeSelectionBottomSheetDialog.java @@ -2,6 +2,7 @@ package com.m2049r.xmrwallet.fragment.dialog; import android.os.AsyncTask; import android.os.Bundle; +import android.util.Patterns; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -83,9 +84,11 @@ public class NodeSelectionBottomSheetDialog extends BottomSheetDialogFragment im PrefService.getInstance().edit().putString(Constants.PREF_NODE, node.getAddress()).apply(); WalletManager.getInstance().setDaemon(node); adapter.updateSelectedNode(); + listener.onNodeSelected(); } public interface NodeSelectionDialogListener { + void onNodeSelected(); void onClickedAddNode(); } } \ No newline at end of file diff --git a/app/src/main/java/com/m2049r/xmrwallet/fragment/settings/SettingsFragment.java b/app/src/main/java/com/m2049r/xmrwallet/fragment/settings/SettingsFragment.java index 22605b9..7780305 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/fragment/settings/SettingsFragment.java +++ b/app/src/main/java/com/m2049r/xmrwallet/fragment/settings/SettingsFragment.java @@ -60,6 +60,7 @@ public class SettingsFragment extends Fragment implements PasswordBottomSheetDia }; private EditText walletProxyAddressEditText; private EditText walletProxyPortEditText; + private Button selectNodeButton; @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @@ -72,7 +73,7 @@ public class SettingsFragment extends Fragment implements PasswordBottomSheetDia super.onViewCreated(view, savedInstanceState); mViewModel = new ViewModelProvider(this).get(SettingsViewModel.class); 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 torSwitch = view.findViewById(R.id.tor_switch); ConstraintLayout proxySettingsLayout = view.findViewById(R.id.wallet_proxy_settings_layout); @@ -192,6 +193,14 @@ public class SettingsFragment extends Fragment implements PasswordBottomSheetDia 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 public void onClickedAddNode() { AddNodeBottomSheetDialog addNodeDialog = new AddNodeBottomSheetDialog();