mirror of
https://codeberg.org/anoncontributorxmr/mysu.git
synced 2024-11-13 22:53:29 +01:00
handle upgrade better
This commit is contained in:
parent
6d0ddad674
commit
720d88320d
@ -30,6 +30,8 @@ import net.mynero.wallet.service.UTXOService;
|
|||||||
import net.mynero.wallet.util.Constants;
|
import net.mynero.wallet.util.Constants;
|
||||||
import net.mynero.wallet.util.UriData;
|
import net.mynero.wallet.util.UriData;
|
||||||
|
|
||||||
|
import org.json.JSONArray;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity implements MoneroHandlerThread.Listener, PasswordBottomSheetDialog.PasswordListener {
|
public class MainActivity extends AppCompatActivity implements MoneroHandlerThread.Listener, PasswordBottomSheetDialog.PasswordListener {
|
||||||
@ -106,12 +108,42 @@ public class MainActivity extends AppCompatActivity implements MoneroHandlerThre
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void upgradeOldNodePrefs() {
|
private void upgradeOldNodePrefs() {
|
||||||
String oldNodeString = PrefService.getInstance().getString("pref_node", "");
|
try {
|
||||||
if(!oldNodeString.isEmpty()) {
|
String oldNodeString = PrefService.getInstance().getString("pref_node", "");
|
||||||
Node oldNode = Node.fromString(oldNodeString);
|
String nodeString = "";
|
||||||
if(oldNode != null) {
|
if (!oldNodeString.isEmpty()) {
|
||||||
PrefService.getInstance().edit().putString(Constants.PREF_NODE_2, oldNode.toNodeString()).apply();
|
String nodesArray = PrefService.getInstance().getString(Constants.PREF_CUSTOM_NODES, "[]");
|
||||||
|
JSONArray jsonArray = new JSONArray(nodesArray);
|
||||||
|
for (int i = 0; i < jsonArray.length(); i++) {
|
||||||
|
String jsonNodeString = jsonArray.getString(i);
|
||||||
|
Node savedNode = Node.fromString(jsonNodeString);
|
||||||
|
if(savedNode != null) {
|
||||||
|
if (savedNode.getAddress().equals(oldNodeString)) {
|
||||||
|
nodeString = savedNode.toNodeString();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(nodeString.isEmpty()) {
|
||||||
|
for (DefaultNodes defaultNode : DefaultNodes.values()) {
|
||||||
|
Node node = Node.fromString(defaultNode.getUri());
|
||||||
|
if(node != null) {
|
||||||
|
if(node.getAddress().equals(oldNodeString)) {
|
||||||
|
nodeString = node.toNodeString();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!nodeString.isEmpty()) {
|
||||||
|
Node oldNode = Node.fromString(nodeString);
|
||||||
|
if (oldNode != null) {
|
||||||
|
PrefService.getInstance().edit().putString(Constants.PREF_NODE_2, oldNode.toNodeString()).apply();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user