mirror of https://github.com/m2049r/xmrwallet.git
Merge pull request #9 from m2049r/feature_walletinfo
Wallet Details on long press in wallet list
This commit is contained in:
commit
d61198b47f
|
@ -579,6 +579,9 @@ Java_com_m2049r_xmrwallet_model_Wallet_store(JNIEnv *env, jobject instance,
|
||||||
const char *_path = env->GetStringUTFChars(path, JNI_FALSE);
|
const char *_path = env->GetStringUTFChars(path, JNI_FALSE);
|
||||||
Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance);
|
Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance);
|
||||||
bool success = wallet->store(std::string(_path));
|
bool success = wallet->store(std::string(_path));
|
||||||
|
if (!success) {
|
||||||
|
LOGE("store() %s", wallet->errorString().c_str());
|
||||||
|
}
|
||||||
env->ReleaseStringUTFChars(path, _path);
|
env->ReleaseStringUTFChars(path, _path);
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,10 +25,14 @@ import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.m2049r.xmrwallet.model.Wallet;
|
||||||
import com.m2049r.xmrwallet.model.WalletManager;
|
import com.m2049r.xmrwallet.model.WalletManager;
|
||||||
|
import com.m2049r.xmrwallet.service.MoneroHandlerThread;
|
||||||
|
|
||||||
public class GenerateReviewFragment extends Fragment {
|
public class GenerateReviewFragment extends Fragment {
|
||||||
static final String TAG = "GenerateReviewFragment";
|
static final String TAG = "GenerateReviewFragment";
|
||||||
|
static final public String VIEW_DETAILS = "details";
|
||||||
|
static final public String VIEW_ACCEPT = "accept";
|
||||||
|
|
||||||
TextView tvWalletName;
|
TextView tvWalletName;
|
||||||
TextView tvWalletPassword;
|
TextView tvWalletPassword;
|
||||||
|
@ -63,7 +67,12 @@ public class GenerateReviewFragment extends Fragment {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
showDetails();
|
Bundle b = getArguments();
|
||||||
|
String name = b.getString("name");
|
||||||
|
String password = b.getString("password");
|
||||||
|
String type = b.getString("type");
|
||||||
|
show(name, password, type);
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,26 +83,41 @@ public class GenerateReviewFragment extends Fragment {
|
||||||
activityCallback.onAccept(name, password);
|
activityCallback.onAccept(name, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showDetails() {
|
private void show(final String walletPath, final String password, final String type) {
|
||||||
Bundle b = getArguments();
|
new Thread(null,
|
||||||
String name = b.getString("name");
|
new Runnable() {
|
||||||
String password = b.getString("password");
|
@Override
|
||||||
String address = b.getString("address");
|
public void run() {
|
||||||
String seed = b.getString("seed");
|
Wallet wallet = WalletManager.getInstance().openWallet(walletPath, password);
|
||||||
String view = b.getString("viewkey");
|
final String name = wallet.getName();
|
||||||
String spend = b.getString("spendkey");
|
final String seed = wallet.getSeed();
|
||||||
|
final String address = wallet.getAddress();
|
||||||
|
final String view = wallet.getSecretViewKey();
|
||||||
|
final String spend = wallet.isWatchOnly() ? "" : "not available - use seed for recovery";
|
||||||
|
wallet.close();
|
||||||
|
|
||||||
tvWalletName.setText(name);
|
getActivity().runOnUiThread(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
if (type.equals(GenerateReviewFragment.VIEW_ACCEPT)) {
|
||||||
tvWalletPassword.setText(password);
|
tvWalletPassword.setText(password);
|
||||||
|
bAccept.setVisibility(View.VISIBLE);
|
||||||
|
bAccept.setEnabled(true);
|
||||||
|
}
|
||||||
|
tvWalletName.setText(name);
|
||||||
tvWalletAddress.setText(address);
|
tvWalletAddress.setText(address);
|
||||||
tvWalletMnemonic.setText(seed);
|
tvWalletMnemonic.setText(seed);
|
||||||
tvWalletViewKey.setText(view);
|
tvWalletViewKey.setText(view);
|
||||||
if (spend.length() > 0) { // should be == 64, but spendkey is not in the API yet
|
if (spend.length() > 0) { //TODO should be == 64, but spendkey is not in the API yet
|
||||||
tvWalletSpendKey.setText(spend);
|
tvWalletSpendKey.setText(spend);
|
||||||
} else {
|
} else {
|
||||||
tvWalletSpendKey.setText(getString(R.string.generate_wallet_watchonly));
|
tvWalletSpendKey.setText(getString(R.string.generate_wallet_watchonly));
|
||||||
}
|
}
|
||||||
bAccept.setEnabled(true);
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
, "DetailsReview", MoneroHandlerThread.THREAD_STACK_SIZE).start();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GenerateReviewFragment.Listener activityCallback;
|
GenerateReviewFragment.Listener activityCallback;
|
||||||
|
|
|
@ -79,16 +79,37 @@ public class LoginActivity extends AppCompatActivity
|
||||||
// now it's getting real, check if wallet exists
|
// now it's getting real, check if wallet exists
|
||||||
String walletPath = Helper.getWalletPath(this, walletName);
|
String walletPath = Helper.getWalletPath(this, walletName);
|
||||||
if (WalletManager.getInstance().walletExists(walletPath)) {
|
if (WalletManager.getInstance().walletExists(walletPath)) {
|
||||||
promptPassword(walletName);
|
promptPassword(walletName, new PasswordAction() {
|
||||||
|
@Override
|
||||||
|
public void action(String walletName, String password) {
|
||||||
|
startWallet(walletName, password);
|
||||||
|
}
|
||||||
|
});
|
||||||
} else { // this cannot really happen as we prefilter choices
|
} else { // this cannot really happen as we prefilter choices
|
||||||
Toast.makeText(this, getString(R.string.bad_wallet), Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, getString(R.string.bad_wallet), Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onWalletDetails(final String walletName) {
|
||||||
|
Log.d(TAG, "details for wallet ." + walletName + ".");
|
||||||
|
final String walletPath = Helper.getWalletPath(this, walletName);
|
||||||
|
if (WalletManager.getInstance().walletExists(walletPath)) {
|
||||||
|
promptPassword(walletName, new PasswordAction() {
|
||||||
|
@Override
|
||||||
|
public void action(String walletName, String password) {
|
||||||
|
startDetails(walletPath, password, GenerateReviewFragment.VIEW_DETAILS);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else { // this cannot really happen as we prefilter choices
|
||||||
|
Toast.makeText(this, getString(R.string.bad_wallet), Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
AlertDialog passwordDialog = null; // for preventing multiple clicks in wallet list
|
AlertDialog passwordDialog = null; // for preventing multiple clicks in wallet list
|
||||||
|
|
||||||
void promptPassword(final String wallet) {
|
void promptPassword(final String wallet, final PasswordAction action) {
|
||||||
if (passwordDialog != null) return; // we are already asking for password
|
if (passwordDialog != null) return; // we are already asking for password
|
||||||
Context context = LoginActivity.this;
|
Context context = LoginActivity.this;
|
||||||
LayoutInflater li = LayoutInflater.from(context);
|
LayoutInflater li = LayoutInflater.from(context);
|
||||||
|
@ -110,7 +131,7 @@ public class LoginActivity extends AppCompatActivity
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
Helper.hideKeyboardAlways(LoginActivity.this);
|
Helper.hideKeyboardAlways(LoginActivity.this);
|
||||||
String pass = etPassword.getText().toString();
|
String pass = etPassword.getText().toString();
|
||||||
processPasswordEntry(wallet, pass);
|
processPasswordEntry(wallet, pass, action);
|
||||||
passwordDialog = null;
|
passwordDialog = null;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -133,7 +154,7 @@ public class LoginActivity extends AppCompatActivity
|
||||||
Helper.hideKeyboardAlways(LoginActivity.this);
|
Helper.hideKeyboardAlways(LoginActivity.this);
|
||||||
String pass = etPassword.getText().toString();
|
String pass = etPassword.getText().toString();
|
||||||
passwordDialog.cancel();
|
passwordDialog.cancel();
|
||||||
processPasswordEntry(wallet, pass);
|
processPasswordEntry(wallet, pass, action);
|
||||||
passwordDialog = null;
|
passwordDialog = null;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -151,9 +172,13 @@ public class LoginActivity extends AppCompatActivity
|
||||||
return WalletManager.getInstance().verifyWalletPassword(walletPath, password, true);
|
return WalletManager.getInstance().verifyWalletPassword(walletPath, password, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processPasswordEntry(String walletName, String pass) {
|
interface PasswordAction {
|
||||||
|
void action(String walletName, String password);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void processPasswordEntry(String walletName, String pass, PasswordAction action) {
|
||||||
if (checkWalletPassword(walletName, pass)) {
|
if (checkWalletPassword(walletName, pass)) {
|
||||||
startWallet(walletName, pass);
|
action.action(walletName, pass);
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(this, getString(R.string.bad_password), Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, getString(R.string.bad_password), Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
@ -201,6 +226,16 @@ public class LoginActivity extends AppCompatActivity
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void startDetails(final String walletPath, final String password, String type) {
|
||||||
|
Log.d(TAG, "startDetails()");
|
||||||
|
Bundle b = new Bundle();
|
||||||
|
b.putString("name", walletPath);
|
||||||
|
b.putString("password", password);
|
||||||
|
b.putString("type", type);
|
||||||
|
startReviewFragment(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
|
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
|
||||||
Log.d(TAG, "onRequestPermissionsResult()");
|
Log.d(TAG, "onRequestPermissionsResult()");
|
||||||
|
@ -279,51 +314,36 @@ public class LoginActivity extends AppCompatActivity
|
||||||
if (cacheFile.exists() || keysFile.exists() || addressFile.exists()) {
|
if (cacheFile.exists() || keysFile.exists() || addressFile.exists()) {
|
||||||
Log.e(TAG, "Cannot remove all old wallet files: " + cacheFile.getAbsolutePath());
|
Log.e(TAG, "Cannot remove all old wallet files: " + cacheFile.getAbsolutePath());
|
||||||
genFragment.walletGenerateError();
|
genFragment.walletGenerateError();
|
||||||
;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String newWalletPath = new File(newWalletFolder, name).getAbsolutePath();
|
String newWalletPath = new File(newWalletFolder, name).getAbsolutePath();
|
||||||
new Thread(null,
|
boolean success = walletCreator.createWallet(newWalletPath, password);
|
||||||
new Runnable() {
|
if (success) {
|
||||||
@Override
|
startDetails(newWalletPath, password, GenerateReviewFragment.VIEW_ACCEPT);
|
||||||
public void run() {
|
} else {
|
||||||
Log.d(TAG, "creating wallet " + newWalletPath);
|
Toast.makeText(LoginActivity.this,
|
||||||
Wallet newWallet = walletCreator.createWallet(newWalletPath, password);
|
getString(R.string.generate_wallet_create_failed), Toast.LENGTH_LONG).show();
|
||||||
final String seed = newWallet.getSeed();
|
Log.e(TAG, "Could not create new wallet in " + newWalletPath);
|
||||||
final String address = newWallet.getAddress();
|
|
||||||
final String view = newWallet.getSecretViewKey();
|
|
||||||
final String spend = newWallet.isWatchOnly() ? "" : "not available - use seed for recovery";
|
|
||||||
newWallet.close();
|
|
||||||
Log.d(TAG, "Created " + address);
|
|
||||||
runOnUiThread(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
Bundle b = new Bundle();
|
|
||||||
b.putString("name", name);
|
|
||||||
b.putString("password", password);
|
|
||||||
b.putString("seed", seed);
|
|
||||||
b.putString("address", address);
|
|
||||||
b.putString("viewkey", view);
|
|
||||||
b.putString("spendkey", spend);
|
|
||||||
startReviewFragment(b);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
, "CreateWallet", MoneroHandlerThread.THREAD_STACK_SIZE).start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface WalletCreator {
|
interface WalletCreator {
|
||||||
Wallet createWallet(String path, String password);
|
boolean createWallet(String path, String password);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGenerate(String name, String password) {
|
public void onGenerate(String name, String password) {
|
||||||
createWallet(name, password,
|
createWallet(name, password,
|
||||||
new WalletCreator() {
|
new WalletCreator() {
|
||||||
public Wallet createWallet(String path, String password) {
|
public boolean createWallet(String path, String password) {
|
||||||
return WalletManager.getInstance()
|
Wallet newWallet = WalletManager.getInstance()
|
||||||
.createWallet(path, password, MNEMONIC_LANGUAGE);
|
.createWallet(path, password, MNEMONIC_LANGUAGE);
|
||||||
|
boolean success = (newWallet.getStatus() == Wallet.Status.Status_Ok);
|
||||||
|
if (!success) Log.e(TAG, newWallet.getErrorString());
|
||||||
|
newWallet.close();
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -332,11 +352,14 @@ public class LoginActivity extends AppCompatActivity
|
||||||
public void onGenerate(String name, String password, final String seed, final long restoreHeight) {
|
public void onGenerate(String name, String password, final String seed, final long restoreHeight) {
|
||||||
createWallet(name, password,
|
createWallet(name, password,
|
||||||
new WalletCreator() {
|
new WalletCreator() {
|
||||||
public Wallet createWallet(String path, String password) {
|
public boolean createWallet(String path, String password) {
|
||||||
Wallet newWallet = WalletManager.getInstance().recoveryWallet(path, seed, restoreHeight);
|
Wallet newWallet = WalletManager.getInstance().recoveryWallet(path, seed, restoreHeight);
|
||||||
|
boolean success = (newWallet.getStatus() == Wallet.Status.Status_Ok);
|
||||||
|
if (!success) Log.e(TAG, newWallet.getErrorString());
|
||||||
newWallet.setPassword(password);
|
newWallet.setPassword(password);
|
||||||
newWallet.store();
|
success = success && newWallet.store();
|
||||||
return newWallet;
|
newWallet.close();
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -346,13 +369,16 @@ public class LoginActivity extends AppCompatActivity
|
||||||
final String address, final String viewKey, final String spendKey, final long restoreHeight) {
|
final String address, final String viewKey, final String spendKey, final long restoreHeight) {
|
||||||
createWallet(name, password,
|
createWallet(name, password,
|
||||||
new WalletCreator() {
|
new WalletCreator() {
|
||||||
public Wallet createWallet(String path, String password) {
|
public boolean createWallet(String path, String password) {
|
||||||
Wallet newWallet = WalletManager.getInstance()
|
Wallet newWallet = WalletManager.getInstance()
|
||||||
.createWalletFromKeys(path, MNEMONIC_LANGUAGE, restoreHeight,
|
.createWalletFromKeys(path, MNEMONIC_LANGUAGE, restoreHeight,
|
||||||
address, viewKey, spendKey);
|
address, viewKey, spendKey);
|
||||||
|
boolean success = (newWallet.getStatus() == Wallet.Status.Status_Ok);
|
||||||
|
if (!success) Log.e(TAG, newWallet.getErrorString());
|
||||||
newWallet.setPassword(password);
|
newWallet.setPassword(password);
|
||||||
newWallet.store();
|
success = success && newWallet.store();
|
||||||
return newWallet;
|
newWallet.close();
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -362,16 +388,10 @@ public class LoginActivity extends AppCompatActivity
|
||||||
public void onAccept(final String name, final String password) {
|
public void onAccept(final String name, final String password) {
|
||||||
final File newWalletFolder = new File(getStorageRoot(), ".new");
|
final File newWalletFolder = new File(getStorageRoot(), ".new");
|
||||||
final File walletFolder = getStorageRoot();
|
final File walletFolder = getStorageRoot();
|
||||||
new Thread(null,
|
|
||||||
new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
final String walletPath = new File(walletFolder, name).getAbsolutePath();
|
final String walletPath = new File(walletFolder, name).getAbsolutePath();
|
||||||
final boolean rc = copyWallet(walletFolder, newWalletFolder, name)
|
final boolean rc = copyWallet(walletFolder, newWalletFolder, name)
|
||||||
&&
|
&&
|
||||||
(testWallet(walletPath, password) == Wallet.Status.Status_Ok);
|
(testWallet(walletPath, password) == Wallet.Status.Status_Ok);
|
||||||
runOnUiThread(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
if (rc) {
|
if (rc) {
|
||||||
getFragmentManager().popBackStack("gen",
|
getFragmentManager().popBackStack("gen",
|
||||||
FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
||||||
|
@ -383,11 +403,6 @@ public class LoginActivity extends AppCompatActivity
|
||||||
getString(R.string.generate_wallet_create_failed_2), Toast.LENGTH_LONG).show();
|
getString(R.string.generate_wallet_create_failed_2), Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
, "AcceptWallet", MoneroHandlerThread.THREAD_STACK_SIZE).start();
|
|
||||||
}
|
|
||||||
|
|
||||||
Wallet.Status testWallet(String path, String password) {
|
Wallet.Status testWallet(String path, String password) {
|
||||||
Log.d(TAG, "testing wallet " + path);
|
Log.d(TAG, "testing wallet " + path);
|
||||||
|
@ -403,6 +418,7 @@ public class LoginActivity extends AppCompatActivity
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
try {
|
try {
|
||||||
// TODO: the cache is corrupt if we recover (!!)
|
// TODO: the cache is corrupt if we recover (!!)
|
||||||
|
// TODO: the cache is ok if we immediately to a full refresh()
|
||||||
// TODO recoveryheight is ignored but not on watchonly wallet ?! - find out why
|
// TODO recoveryheight is ignored but not on watchonly wallet ?! - find out why
|
||||||
//copyFile(dstDir, srcDir, name);
|
//copyFile(dstDir, srcDir, name);
|
||||||
copyFile(dstDir, srcDir, name + ".keys");
|
copyFile(dstDir, srcDir, name + ".keys");
|
||||||
|
|
|
@ -79,6 +79,8 @@ public class LoginFragment extends Fragment {
|
||||||
|
|
||||||
void onWalletSelected(final String wallet);
|
void onWalletSelected(final String wallet);
|
||||||
|
|
||||||
|
void onWalletDetails(final String wallet);
|
||||||
|
|
||||||
void setTitle(String title);
|
void setTitle(String title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,6 +192,44 @@ public class LoginFragment extends Fragment {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
|
EditText tvDaemonAddress = (EditText) getView().findViewById(R.id.etDaemonAddress);
|
||||||
|
if (tvDaemonAddress.getText().toString().length() == 0) {
|
||||||
|
Toast.makeText(getActivity(), getString(R.string.prompt_daemon_missing), Toast.LENGTH_SHORT).show();
|
||||||
|
tvDaemonAddress.requestFocus();
|
||||||
|
Helper.showKeyboard(getActivity());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
String itemValue = (String) listView.getItemAtPosition(position);
|
||||||
|
|
||||||
|
if (itemValue.length() <= (WALLETNAME_PREAMBLE_LENGTH)) {
|
||||||
|
Toast.makeText(getActivity(), getString(R.string.panic), Toast.LENGTH_LONG).show();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
String x = isMainNet() ? "4-" : "9A-";
|
||||||
|
if (x.indexOf(itemValue.charAt(1)) < 0) {
|
||||||
|
Toast.makeText(getActivity(), getString(R.string.prompt_wrong_net), Toast.LENGTH_LONG).show();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!checkAndSetWalletDaemon(getDaemon(), !isMainNet())) {
|
||||||
|
Toast.makeText(getActivity(), getString(R.string.warn_daemon_unavailable), Toast.LENGTH_SHORT).show();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// looking good
|
||||||
|
savePrefs(false);
|
||||||
|
|
||||||
|
String wallet = itemValue.substring(WALLETNAME_PREAMBLE_LENGTH);
|
||||||
|
if (itemValue.charAt(1) == '-') wallet = ':' + wallet;
|
||||||
|
activityCallback.onWalletDetails(wallet);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
activityCallback.setTitle(getString(R.string.app_name) + " " +
|
activityCallback.setTitle(getString(R.string.app_name) + " " +
|
||||||
getString(isMainNet() ? R.string.connect_mainnet : R.string.connect_testnet));
|
getString(isMainNet() ? R.string.connect_mainnet : R.string.connect_testnet));
|
||||||
|
|
||||||
|
|
|
@ -256,10 +256,14 @@ public class WalletActivity extends AppCompatActivity implements WalletFragment.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onWalletStored() {
|
public void onWalletStored(final boolean success) {
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
|
if (success) {
|
||||||
Toast.makeText(WalletActivity.this, getString(R.string.status_wallet_unloaded), Toast.LENGTH_SHORT).show();
|
Toast.makeText(WalletActivity.this, getString(R.string.status_wallet_unloaded), Toast.LENGTH_SHORT).show();
|
||||||
|
} else {
|
||||||
|
Toast.makeText(WalletActivity.this, getString(R.string.status_wallet_unload_failed), Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,8 +28,7 @@ public class Wallet {
|
||||||
static final String TAG = "Wallet";
|
static final String TAG = "Wallet";
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
String p = getPath();
|
return new File(getPath()).getName();
|
||||||
return new File(p).getName();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private long handle = 0;
|
private long handle = 0;
|
||||||
|
@ -83,7 +82,7 @@ public class Wallet {
|
||||||
public native String getSecretViewKey();
|
public native String getSecretViewKey();
|
||||||
|
|
||||||
public boolean store() {
|
public boolean store() {
|
||||||
return store(this.getPath());
|
return store("");
|
||||||
}
|
}
|
||||||
|
|
||||||
public native boolean store(String path);
|
public native boolean store(String path);
|
||||||
|
|
|
@ -131,7 +131,7 @@ public class WalletService extends Service {
|
||||||
updateDaemonState(wallet, 0);
|
updateDaemonState(wallet, 0);
|
||||||
TransactionHistory history = wallet.getHistory();
|
TransactionHistory history = wallet.getHistory();
|
||||||
history.refresh();
|
history.refresh();
|
||||||
observer.onRefreshed(wallet, true);
|
if (observer != null) observer.onRefreshed(wallet, true);
|
||||||
updated = false;
|
updated = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -193,7 +193,7 @@ public class WalletService extends Service {
|
||||||
|
|
||||||
void onProgress(int n);
|
void onProgress(int n);
|
||||||
|
|
||||||
void onWalletStored();
|
void onWalletStored(boolean success);
|
||||||
}
|
}
|
||||||
|
|
||||||
String progressText = null;
|
String progressText = null;
|
||||||
|
@ -258,9 +258,12 @@ public class WalletService extends Service {
|
||||||
} else if (cmd.equals(REQUEST_CMD_STORE)) {
|
} else if (cmd.equals(REQUEST_CMD_STORE)) {
|
||||||
Wallet myWallet = getWallet();
|
Wallet myWallet = getWallet();
|
||||||
Log.d(TAG, "storing wallet: " + myWallet.getName());
|
Log.d(TAG, "storing wallet: " + myWallet.getName());
|
||||||
getWallet().store();
|
boolean rc = myWallet.store();
|
||||||
Log.d(TAG, "wallet stored: " + myWallet.getName());
|
Log.d(TAG, "wallet stored: " + myWallet.getName() + " with rc=" + rc);
|
||||||
if (observer != null) observer.onWalletStored();
|
if (!rc) {
|
||||||
|
Log.d(TAG, "Wallet store failed: " + myWallet.getErrorString());
|
||||||
|
}
|
||||||
|
if (observer != null) observer.onWalletStored(rc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -387,7 +390,7 @@ public class WalletService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Wallet loadWallet(String walletName, String walletPassword) {
|
private Wallet loadWallet(String walletName, String walletPassword) {
|
||||||
String path = Helper.getWalletPath(getApplicationContext(), walletName);
|
//String path = Helper.getWalletPath(getApplicationContext(), walletName);
|
||||||
//Log.d(TAG, "open wallet " + path);
|
//Log.d(TAG, "open wallet " + path);
|
||||||
Wallet wallet = openWallet(walletName, walletPassword);
|
Wallet wallet = openWallet(walletName, walletPassword);
|
||||||
//Log.d(TAG, "wallet opened: " + wallet);
|
//Log.d(TAG, "wallet opened: " + wallet);
|
||||||
|
|
|
@ -34,8 +34,8 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
|
||||||
android:layout_marginBottom="8dp"
|
android:layout_marginBottom="8dp"
|
||||||
|
android:orientation="horizontal"
|
||||||
android:weightSum="2">
|
android:weightSum="2">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -43,7 +43,6 @@
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="@string/generate_name_hint"
|
|
||||||
android:textAlignment="center"
|
android:textAlignment="center"
|
||||||
android:textColor="@color/colorPrimaryDark"
|
android:textColor="@color/colorPrimaryDark"
|
||||||
android:textSize="16sp" />
|
android:textSize="16sp" />
|
||||||
|
@ -53,7 +52,7 @@
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="@string/generate_password_hint"
|
android:text="***"
|
||||||
android:textAlignment="center"
|
android:textAlignment="center"
|
||||||
android:textColor="@color/colorPrimaryDark"
|
android:textColor="@color/colorPrimaryDark"
|
||||||
android:textSize="16sp" />
|
android:textSize="16sp" />
|
||||||
|
@ -72,7 +71,6 @@
|
||||||
android:id="@+id/tvWalletMnemonic"
|
android:id="@+id/tvWalletMnemonic"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/generate_mnemonic_placeholder"
|
|
||||||
android:textAlignment="center"
|
android:textAlignment="center"
|
||||||
android:textColor="@color/colorPrimaryDark"
|
android:textColor="@color/colorPrimaryDark"
|
||||||
android:textSize="16sp" />
|
android:textSize="16sp" />
|
||||||
|
@ -92,7 +90,6 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:selectAllOnFocus="true"
|
android:selectAllOnFocus="true"
|
||||||
android:text="@string/generate_address_placeholder"
|
|
||||||
android:textAlignment="center"
|
android:textAlignment="center"
|
||||||
android:textColor="@color/colorPrimaryDark"
|
android:textColor="@color/colorPrimaryDark"
|
||||||
android:textIsSelectable="true"
|
android:textIsSelectable="true"
|
||||||
|
@ -113,7 +110,6 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:selectAllOnFocus="true"
|
android:selectAllOnFocus="true"
|
||||||
android:text="@string/generate_viewkey_placeholder"
|
|
||||||
android:textAlignment="center"
|
android:textAlignment="center"
|
||||||
android:textColor="@color/colorPrimaryDark"
|
android:textColor="@color/colorPrimaryDark"
|
||||||
android:textIsSelectable="true"
|
android:textIsSelectable="true"
|
||||||
|
@ -134,7 +130,6 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:selectAllOnFocus="true"
|
android:selectAllOnFocus="true"
|
||||||
android:text="@string/generate_spendkey_placeholder"
|
|
||||||
android:textAlignment="center"
|
android:textAlignment="center"
|
||||||
android:textColor="@color/colorPrimaryDark"
|
android:textColor="@color/colorPrimaryDark"
|
||||||
android:textIsSelectable="true"
|
android:textIsSelectable="true"
|
||||||
|
@ -146,6 +141,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="16dp"
|
||||||
android:background="@color/colorPrimary"
|
android:background="@color/colorPrimary"
|
||||||
android:text="@string/generate_button_accept" />
|
android:text="@string/generate_button_accept"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -12,12 +12,14 @@
|
||||||
<string name="status_wallet_loading">Loading Wallet …</string>
|
<string name="status_wallet_loading">Loading Wallet …</string>
|
||||||
<string name="status_wallet_unloading">Saving Wallet</string>
|
<string name="status_wallet_unloading">Saving Wallet</string>
|
||||||
<string name="status_wallet_unloaded">Wallet saved</string>
|
<string name="status_wallet_unloaded">Wallet saved</string>
|
||||||
|
<string name="status_wallet_unload_failed">Wallet save failed!</string>
|
||||||
<string name="status_wallet_connecting">Connecting …</string>
|
<string name="status_wallet_connecting">Connecting …</string>
|
||||||
<string name="status_working">Working on it …</string>
|
<string name="status_working">Working on it …</string>
|
||||||
|
|
||||||
<string name="prompt_password">Password for</string>
|
<string name="prompt_password">Password for</string>
|
||||||
<string name="bad_password">Bad password!</string>
|
<string name="bad_password">Bad password!</string>
|
||||||
<string name="bad_wallet">Wallet does not exists!</string>
|
<string name="bad_wallet">Wallet does not exists!</string>
|
||||||
|
<string name="error_not_wallet">This is not a wallet!</string>
|
||||||
<string name="prompt_daemon_missing">Daemon address must be set!</string>
|
<string name="prompt_daemon_missing">Daemon address must be set!</string>
|
||||||
<string name="prompt_wrong_net">Wallet does not match selected net</string>
|
<string name="prompt_wrong_net">Wallet does not match selected net</string>
|
||||||
<string name="warn_daemon_unavailable">Cannot connect to daemon! Try again.</string>
|
<string name="warn_daemon_unavailable">Cannot connect to daemon! Try again.</string>
|
||||||
|
@ -57,6 +59,7 @@
|
||||||
|
|
||||||
<string name="generate_wallet_exists">Wallet exists! Choose another name</string>
|
<string name="generate_wallet_exists">Wallet exists! Choose another name</string>
|
||||||
<string name="generate_wallet_created">Wallet created</string>
|
<string name="generate_wallet_created">Wallet created</string>
|
||||||
|
<string name="generate_wallet_create_failed">Wallet create failed</string>
|
||||||
<string name="generate_wallet_create_failed_1">Wallet create failed (1/2)</string>
|
<string name="generate_wallet_create_failed_1">Wallet create failed (1/2)</string>
|
||||||
<string name="generate_wallet_create_failed_2">Wallet create failed (2/2)</string>
|
<string name="generate_wallet_create_failed_2">Wallet create failed (2/2)</string>
|
||||||
<string name="generate_address_placeholder">9tDC52GsMjTNt4dpnRCwAF7ekVBkbkgkXGaMKTcSTpBhGpqkPX56jCNRydLq9oGjbbAQBsZhLfgmTKsntmxRd3TaJFYM2f8</string>
|
<string name="generate_address_placeholder">9tDC52GsMjTNt4dpnRCwAF7ekVBkbkgkXGaMKTcSTpBhGpqkPX56jCNRydLq9oGjbbAQBsZhLfgmTKsntmxRd3TaJFYM2f8</string>
|
||||||
|
|
Loading…
Reference in New Issue