upgrade old node prefs if valid node

This commit is contained in:
pokkst 2022-10-15 00:00:54 -05:00
parent c1b4f8400d
commit 6d0ddad674
No known key found for this signature in database
GPG key ID: 90C2ED85E67A50FF

View file

@ -13,6 +13,7 @@ import androidx.fragment.app.FragmentManager;
import androidx.navigation.fragment.NavHostFragment; import androidx.navigation.fragment.NavHostFragment;
import net.mynero.wallet.data.DefaultNodes; 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.PasswordBottomSheetDialog;
import net.mynero.wallet.fragment.dialog.SendBottomSheetDialog; import net.mynero.wallet.fragment.dialog.SendBottomSheetDialog;
import net.mynero.wallet.livedata.SingleLiveEvent; import net.mynero.wallet.livedata.SingleLiveEvent;
@ -92,6 +93,7 @@ public class MainActivity extends AppCompatActivity implements MoneroHandlerThre
} }
public void init(File walletFile, String password) { public void init(File walletFile, String password) {
upgradeOldNodePrefs();
Wallet wallet = WalletManager.getInstance().openWallet(walletFile.getAbsolutePath(), password); Wallet wallet = WalletManager.getInstance().openWallet(walletFile.getAbsolutePath(), password);
thread = new MoneroHandlerThread("WalletService", this, wallet); thread = new MoneroHandlerThread("WalletService", this, wallet);
new TxService(thread); new TxService(thread);
@ -103,6 +105,16 @@ public class MainActivity extends AppCompatActivity implements MoneroHandlerThre
thread.start(); 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 @Override
public void onRefresh() { public void onRefresh() {
this.historyService.refreshHistory(); this.historyService.refreshHistory();