mirror of
https://codeberg.org/anoncontributorxmr/mysu.git
synced 2024-11-25 00:42:32 +00:00
Reset node pref, fix crashing issue in 0.3.0
This commit is contained in:
parent
119ccd67bb
commit
ab51d6cf06
7 changed files with 10 additions and 18 deletions
|
@ -96,7 +96,7 @@ public class NodeSelectionAdapter extends RecyclerView.Adapter<NodeSelectionAdap
|
|||
}
|
||||
|
||||
public void bind(Node node) {
|
||||
String currentNodeString = PrefService.getInstance().getString(Constants.PREF_NODE, "");
|
||||
String currentNodeString = PrefService.getInstance().getString(Constants.PREF_NODE_2, "");
|
||||
Node currentNode = Node.fromString(currentNodeString);
|
||||
boolean match = node.equals(currentNode);
|
||||
if (match) {
|
||||
|
|
|
@ -83,7 +83,7 @@ public class NodeSelectionBottomSheetDialog extends BottomSheetDialogFragment im
|
|||
Toast.makeText(activity, getString(R.string.node_selected), Toast.LENGTH_SHORT).show();
|
||||
});
|
||||
}
|
||||
PrefService.getInstance().edit().putString(Constants.PREF_NODE, node.getAddress()).apply();
|
||||
PrefService.getInstance().edit().putString(Constants.PREF_NODE_2, node.toNodeString()).apply();
|
||||
WalletManager.getInstance().setDaemon(node);
|
||||
adapter.updateSelectedNode();
|
||||
listener.onNodeSelected();
|
||||
|
|
|
@ -30,8 +30,6 @@ import net.mynero.wallet.service.PrefService;
|
|||
import net.mynero.wallet.util.Constants;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
public class OnboardingFragment extends Fragment {
|
||||
|
||||
|
@ -163,7 +161,7 @@ public class OnboardingFragment extends Fragment {
|
|||
private void prepareDefaultNode() {
|
||||
boolean usesTor = PrefService.getInstance().getBoolean(Constants.PREF_USES_TOR, false);
|
||||
DefaultNodes defaultNode = usesTor ? DefaultNodes.SAMOURAI_ONION : DefaultNodes.SAMOURAI;
|
||||
PrefService.getInstance().edit().putString(Constants.PREF_NODE, defaultNode.getAddress()).apply();
|
||||
PrefService.getInstance().edit().putString(Constants.PREF_NODE_2, defaultNode.getUri()).apply();
|
||||
}
|
||||
|
||||
private void createOrImportWallet(String walletPassword, String walletSeed, String restoreHeightText) {
|
||||
|
|
|
@ -174,7 +174,8 @@ public class SettingsFragment extends Fragment implements PasswordBottomSheetDia
|
|||
statusTextView.setText(getResources().getText(R.string.version_mismatch));
|
||||
}
|
||||
});
|
||||
Node node = Node.fromString(PrefService.getInstance().getString(Constants.PREF_NODE, "")); // shouldn't use default value here
|
||||
DefaultNodes defaultNode = usesProxy ? DefaultNodes.SAMOURAI_ONION : DefaultNodes.SAMOURAI;
|
||||
Node node = Node.fromString(PrefService.getInstance().getString(Constants.PREF_NODE_2, defaultNode.getUri())); // shouldn't use default value here
|
||||
selectNodeButton.setText(getString(R.string.node_button_text, node.getAddress()));
|
||||
selectNodeButton.setOnClickListener(view1 -> {
|
||||
NodeSelectionBottomSheetDialog dialog = new NodeSelectionBottomSheetDialog();
|
||||
|
@ -220,7 +221,7 @@ public class SettingsFragment extends Fragment implements PasswordBottomSheetDia
|
|||
|
||||
@Override
|
||||
public void onNodeSelected() {
|
||||
Node node = Node.fromString(PrefService.getInstance().getString(Constants.PREF_NODE, ""));
|
||||
Node node = Node.fromString(PrefService.getInstance().getString(Constants.PREF_NODE_2, ""));
|
||||
selectNodeButton.setText(getString(R.string.node_button_text, node.getAddress()));
|
||||
mViewModel.updateProxy(((MoneroApplication)getActivity().getApplication()));
|
||||
((MoneroApplication)getActivity().getApplication()).getExecutor().execute(() -> {
|
||||
|
|
|
@ -5,14 +5,10 @@ import android.util.Patterns;
|
|||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import net.mynero.wallet.MoneroApplication;
|
||||
import net.mynero.wallet.data.DefaultNodes;
|
||||
import net.mynero.wallet.model.WalletManager;
|
||||
import net.mynero.wallet.service.PrefService;
|
||||
import net.mynero.wallet.util.Constants;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
public class SettingsViewModel extends ViewModel {
|
||||
|
||||
private String proxyAddress = "";
|
||||
|
@ -21,7 +17,7 @@ public class SettingsViewModel extends ViewModel {
|
|||
public void updateProxy(MoneroApplication application) {
|
||||
application.getExecutor().execute(() -> {
|
||||
boolean usesProxy = PrefService.getInstance().getBoolean(Constants.PREF_USES_TOR, false);
|
||||
String currentNodeString = PrefService.getInstance().getString(Constants.PREF_NODE, "");
|
||||
String currentNodeString = PrefService.getInstance().getString(Constants.PREF_NODE_2, "");
|
||||
boolean isNodeLocalIp = currentNodeString.startsWith("10.") || currentNodeString.startsWith("192.168.") || currentNodeString.equals("localhost") || currentNodeString.equals("127.0.0.1");
|
||||
|
||||
if (!usesProxy || isNodeLocalIp) {
|
||||
|
|
|
@ -57,11 +57,8 @@ public class MoneroHandlerThread extends Thread implements WalletListener {
|
|||
@Override
|
||||
public void run() {
|
||||
boolean usesTor = PrefService.getInstance().getBoolean(Constants.PREF_USES_TOR, false);
|
||||
DefaultNodes defaultNode = DefaultNodes.SAMOURAI;
|
||||
if(usesTor) {
|
||||
defaultNode = DefaultNodes.SAMOURAI_ONION;
|
||||
}
|
||||
String currentNodeString = PrefService.getInstance().getString(Constants.PREF_NODE, defaultNode.getAddress());
|
||||
DefaultNodes defaultNode = usesTor ? DefaultNodes.SAMOURAI_ONION : DefaultNodes.SAMOURAI;
|
||||
String currentNodeString = PrefService.getInstance().getString(Constants.PREF_NODE_2, defaultNode.getUri());
|
||||
Node selectedNode = Node.fromString(currentNodeString);
|
||||
boolean isLocalIp = currentNodeString.startsWith("10.") || currentNodeString.startsWith("192.168.") || currentNodeString.equals("localhost") || currentNodeString.equals("127.0.0.1");
|
||||
if (usesTor && !isLocalIp) {
|
||||
|
|
|
@ -7,7 +7,7 @@ public class Constants {
|
|||
public static final String PREF_USES_TOR = "pref_uses_tor";
|
||||
public static final String PREF_NIGHT_MODE = "pref_night_mode";
|
||||
public static final String PREF_PROXY = "pref_proxy";
|
||||
public static final String PREF_NODE = "pref_node";
|
||||
public static final String PREF_NODE_2 = "pref_node_2";
|
||||
public static final String PREF_CUSTOM_NODES = "pref_custom_nodes";
|
||||
|
||||
public static final String URI_PREFIX = "monero:";
|
||||
|
|
Loading…
Reference in a new issue