From e270b277a575e578c8c662319790589376395b09 Mon Sep 17 00:00:00 2001
From: m2049r <30435443+m2049r@users.noreply.github.com>
Date: Wed, 27 Sep 2017 23:01:37 +0200
Subject: [PATCH] Fixup wallet locations (#89)
* create wallets directly in wallet dir, renamed backup dir
* new version + notes
---
README.md | 6 ++--
app/build.gradle | 4 +--
.../com/m2049r/xmrwallet/LoginActivity.java | 32 +++++++------------
app/src/main/res/values/strings.xml | 2 --
4 files changed, 17 insertions(+), 27 deletions(-)
diff --git a/README.md b/README.md
index 84ae6757..66d3c675 100644
--- a/README.md
+++ b/README.md
@@ -25,11 +25,13 @@ You may lose all your Moneroj if you use this App. Be cautious when spending on
- more sensible error dialogs
### Issues / Pitfalls
+- The backups folder is now called "backups" and not ".backups" - which in most file explorers was a hidden folder
+- Wallets are now created directly in the "monerujo" folder, and not in the ".new" folder as before
+- You may want to check the old folders with a file browsing app and delete the ".new" and ".backups" folders AFTER moving neccessary wallet files to the new locations. Or simply make new backups from within Monerujo.
+- Also note, that on some devices the backups will only be visible on a PC over USB after a reboot of the device (it's an Android bug/feature)
- Created wallets on a private testnet are unusable because the restore height is set to that
of the "real" testnet. After creating a new wallet, make a **new** one by recovering from the seed.
The official monero client shows the same behaviour.
-- In rare occasions the monero core code returns a wallet address with corrupted characters -
-in these cases Monerujo crashes on purpose to make sure nothing bad happens
### HOW TO BUILD
No need to build. Binaries are included:
diff --git a/app/build.gradle b/app/build.gradle
index 798a3f07..c687233c 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -8,8 +8,8 @@ android {
applicationId "com.m2049r.xmrwallet"
minSdkVersion 21
targetSdkVersion 25
- versionCode 20
- versionName "0.8.0.7"
+ versionCode 21
+ versionName "0.8.0.8"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
diff --git a/app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java b/app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java
index 1310b7c3..e3d740ef 100644
--- a/app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java
+++ b/app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java
@@ -24,6 +24,7 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
+import android.media.MediaScannerConnection;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.StrictMode;
@@ -308,12 +309,14 @@ public class LoginActivity extends AppCompatActivity
}
private boolean backupWallet(String walletName) {
- File backupFolder = new File(getStorageRoot(), ".backups");
+ File backupFolder = new File(getStorageRoot(), "backups");
if (!backupFolder.exists()) {
if (!backupFolder.mkdir()) {
Log.e(TAG, "Cannot create backup dir " + backupFolder.getAbsolutePath());
return false;
}
+ // make folder visible over USB/MTP
+ MediaScannerConnection.scanFile(this, new String[]{backupFolder.toString()}, null, null);
}
File walletFile = Helper.getWalletFile(LoginActivity.this, walletName);
File backupFile = new File(backupFolder, walletName);
@@ -726,26 +729,17 @@ public class LoginActivity extends AppCompatActivity
@Override
protected Boolean doInBackground(Void... params) {
- File newWalletFolder = new File(getStorageRoot(), ".new");
- if (!newWalletFolder.exists()) {
- if (!newWalletFolder.mkdir()) {
- Log.e(TAG, "Cannot create new wallet dir " + newWalletFolder.getAbsolutePath());
- return false;
- }
- }
+ File newWalletFolder = getStorageRoot();
if (!newWalletFolder.isDirectory()) {
- Log.e(TAG, "New wallet dir " + newWalletFolder.getAbsolutePath() + "is not a directory");
+ Log.e(TAG, "Wallet dir " + newWalletFolder.getAbsolutePath() + "is not a directory");
return false;
}
File cacheFile = new File(newWalletFolder, walletName);
- cacheFile.delete();
File keysFile = new File(newWalletFolder, walletName + ".keys");
- keysFile.delete();
File addressFile = new File(newWalletFolder, walletName + ".address.txt");
- addressFile.delete();
if (cacheFile.exists() || keysFile.exists() || addressFile.exists()) {
- Log.e(TAG, "Cannot remove all old wallet files: " + cacheFile.getAbsolutePath());
+ Log.e(TAG, "Some wallet files already exist for " + cacheFile.getAbsolutePath());
return false;
}
@@ -854,15 +848,11 @@ public class LoginActivity extends AppCompatActivity
@Override
public void onAccept(final String name, final String password) {
- File newWalletFile = new File(new File(getStorageRoot(), ".new"), name);
File walletFolder = getStorageRoot();
File walletFile = new File(walletFolder, name);
- boolean rc = copyWallet(newWalletFile, walletFile, false);
- if (rc) {
- walletFile.delete(); // when recovering wallets, the cache seems corrupt
- // TODO: figure out why this is so? Only for a private testnet?
- rc = testWallet(walletFile.getAbsolutePath(), password) == Wallet.Status.Status_Ok;
- }
+ walletFile.delete(); // when recovering wallets, the cache seems corrupt
+ // TODO: figure out why this is so? Only for a private testnet?
+ boolean rc = testWallet(walletFile.getAbsolutePath(), password) == Wallet.Status.Status_Ok;
if (rc) {
popFragmentStack(GENERATE_STACK);
@@ -871,7 +861,7 @@ public class LoginActivity extends AppCompatActivity
} else {
Log.e(TAG, "Wallet store failed to " + walletFile.getAbsolutePath());
Toast.makeText(LoginActivity.this,
- getString(R.string.generate_wallet_create_failed_2), Toast.LENGTH_LONG).show();
+ getString(R.string.generate_wallet_create_failed), Toast.LENGTH_LONG).show();
}
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 98130bff..78b3038e 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -100,8 +100,6 @@
Creating wallet
Wallet created
Wallet create failed
- Wallet create failed (1/2)
- Wallet create failed (2/2)
9tDC52GsMjTNt4dpnRCwAF7ekVBkbkgkXGaMKTcSTpBhGpqkPX56jCNRydLq9oGjbbAQBsZhLfgmTKsntmxRd3TaJFYM2f8
e2b99f4cc3d644774c4b118db05f8aa9967583a01ca4d47058c3860af10bd306
300a54208ab0a638a8407a12e3de946da76f5a9ded303338452332ec7755210d