From 6d0ddad6742c786343f873595bc47838a15231a7 Mon Sep 17 00:00:00 2001 From: pokkst Date: Sat, 15 Oct 2022 00:00:54 -0500 Subject: [PATCH] upgrade old node prefs if valid node --- .../main/java/net/mynero/wallet/MainActivity.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/src/main/java/net/mynero/wallet/MainActivity.java b/app/src/main/java/net/mynero/wallet/MainActivity.java index 6735568..86ca72f 100644 --- a/app/src/main/java/net/mynero/wallet/MainActivity.java +++ b/app/src/main/java/net/mynero/wallet/MainActivity.java @@ -13,6 +13,7 @@ import androidx.fragment.app.FragmentManager; import androidx.navigation.fragment.NavHostFragment; import net.mynero.wallet.data.DefaultNodes; +import net.mynero.wallet.data.Node; import net.mynero.wallet.fragment.dialog.PasswordBottomSheetDialog; import net.mynero.wallet.fragment.dialog.SendBottomSheetDialog; import net.mynero.wallet.livedata.SingleLiveEvent; @@ -92,6 +93,7 @@ public class MainActivity extends AppCompatActivity implements MoneroHandlerThre } public void init(File walletFile, String password) { + upgradeOldNodePrefs(); Wallet wallet = WalletManager.getInstance().openWallet(walletFile.getAbsolutePath(), password); thread = new MoneroHandlerThread("WalletService", this, wallet); new TxService(thread); @@ -103,6 +105,16 @@ public class MainActivity extends AppCompatActivity implements MoneroHandlerThre thread.start(); } + private void upgradeOldNodePrefs() { + String oldNodeString = PrefService.getInstance().getString("pref_node", ""); + if(!oldNodeString.isEmpty()) { + Node oldNode = Node.fromString(oldNodeString); + if(oldNode != null) { + PrefService.getInstance().edit().putString(Constants.PREF_NODE_2, oldNode.toNodeString()).apply(); + } + } + } + @Override public void onRefresh() { this.historyService.refreshHistory();