more fixes

This commit is contained in:
pokkst 2022-10-14 23:55:10 -05:00
parent ab51d6cf06
commit c0e6465943
No known key found for this signature in database
GPG Key ID: 90C2ED85E67A50FF
3 changed files with 9 additions and 3 deletions

View File

@ -96,7 +96,9 @@ public class NodeSelectionAdapter extends RecyclerView.Adapter<NodeSelectionAdap
} }
public void bind(Node node) { public void bind(Node node) {
String currentNodeString = PrefService.getInstance().getString(Constants.PREF_NODE_2, ""); boolean usesProxy = PrefService.getInstance().getBoolean(Constants.PREF_USES_TOR, false);
DefaultNodes defaultNode = usesProxy ? DefaultNodes.SAMOURAI_ONION : DefaultNodes.SAMOURAI;
String currentNodeString = PrefService.getInstance().getString(Constants.PREF_NODE_2, defaultNode.getUri());
Node currentNode = Node.fromString(currentNodeString); Node currentNode = Node.fromString(currentNodeString);
boolean match = node.equals(currentNode); boolean match = node.equals(currentNode);
if (match) { if (match) {

View File

@ -221,7 +221,9 @@ public class SettingsFragment extends Fragment implements PasswordBottomSheetDia
@Override @Override
public void onNodeSelected() { public void onNodeSelected() {
Node node = Node.fromString(PrefService.getInstance().getString(Constants.PREF_NODE_2, "")); boolean usesProxy = PrefService.getInstance().getBoolean(Constants.PREF_USES_TOR, false);
DefaultNodes defaultNode = usesProxy ? DefaultNodes.SAMOURAI_ONION : DefaultNodes.SAMOURAI;
Node node = Node.fromString(PrefService.getInstance().getString(Constants.PREF_NODE_2, defaultNode.getUri()));
selectNodeButton.setText(getString(R.string.node_button_text, node.getAddress())); selectNodeButton.setText(getString(R.string.node_button_text, node.getAddress()));
mViewModel.updateProxy(((MoneroApplication)getActivity().getApplication())); mViewModel.updateProxy(((MoneroApplication)getActivity().getApplication()));
((MoneroApplication)getActivity().getApplication()).getExecutor().execute(() -> { ((MoneroApplication)getActivity().getApplication()).getExecutor().execute(() -> {

View File

@ -5,6 +5,7 @@ import android.util.Patterns;
import androidx.lifecycle.ViewModel; import androidx.lifecycle.ViewModel;
import net.mynero.wallet.MoneroApplication; import net.mynero.wallet.MoneroApplication;
import net.mynero.wallet.data.DefaultNodes;
import net.mynero.wallet.model.WalletManager; import net.mynero.wallet.model.WalletManager;
import net.mynero.wallet.service.PrefService; import net.mynero.wallet.service.PrefService;
import net.mynero.wallet.util.Constants; import net.mynero.wallet.util.Constants;
@ -17,7 +18,8 @@ public class SettingsViewModel extends ViewModel {
public void updateProxy(MoneroApplication application) { public void updateProxy(MoneroApplication application) {
application.getExecutor().execute(() -> { application.getExecutor().execute(() -> {
boolean usesProxy = PrefService.getInstance().getBoolean(Constants.PREF_USES_TOR, false); boolean usesProxy = PrefService.getInstance().getBoolean(Constants.PREF_USES_TOR, false);
String currentNodeString = PrefService.getInstance().getString(Constants.PREF_NODE_2, ""); DefaultNodes defaultNode = usesProxy ? DefaultNodes.SAMOURAI_ONION : DefaultNodes.SAMOURAI;
String currentNodeString = PrefService.getInstance().getString(Constants.PREF_NODE_2, defaultNode.getUri());
boolean isNodeLocalIp = currentNodeString.startsWith("10.") || currentNodeString.startsWith("192.168.") || currentNodeString.equals("localhost") || currentNodeString.equals("127.0.0.1"); boolean isNodeLocalIp = currentNodeString.startsWith("10.") || currentNodeString.startsWith("192.168.") || currentNodeString.equals("localhost") || currentNodeString.equals("127.0.0.1");
if (!usesProxy || isNodeLocalIp) { if (!usesProxy || isNodeLocalIp) {