mirror of https://github.com/m2049r/xmrwallet.git
Random fixes (#275)
* reduce label length * api fix * show correct password after change
This commit is contained in:
parent
63e0c265cb
commit
857cf8d6d8
|
@ -62,27 +62,26 @@ public class GenerateReviewFragment extends Fragment {
|
||||||
static final public String VIEW_TYPE_ACCEPT = "accept";
|
static final public String VIEW_TYPE_ACCEPT = "accept";
|
||||||
static final public String VIEW_TYPE_WALLET = "wallet";
|
static final public String VIEW_TYPE_WALLET = "wallet";
|
||||||
|
|
||||||
ScrollView scrollview;
|
public static final String REQUEST_TYPE = "type";
|
||||||
|
public static final String REQUEST_PATH = "path";
|
||||||
|
public static final String REQUEST_PASSWORD = "password";
|
||||||
|
|
||||||
ProgressBar pbProgress;
|
private ScrollView scrollview;
|
||||||
TextView tvWalletPassword;
|
|
||||||
TextView tvWalletAddress;
|
|
||||||
TextView tvWalletMnemonic;
|
|
||||||
TextView tvWalletViewKey;
|
|
||||||
TextView tvWalletSpendKey;
|
|
||||||
ImageButton bCopyAddress;
|
|
||||||
LinearLayout llAdvancedInfo;
|
|
||||||
LinearLayout llPassword;
|
|
||||||
Button bAdvancedInfo;
|
|
||||||
Button bAccept;
|
|
||||||
|
|
||||||
// TODO fix visibility of variables
|
private ProgressBar pbProgress;
|
||||||
String walletPath;
|
private TextView tvWalletPassword;
|
||||||
String walletName;
|
private TextView tvWalletAddress;
|
||||||
// we need to keep the password so the user is not asked again if they want to change it
|
private TextView tvWalletMnemonic;
|
||||||
// note they can only enter this fragment immediately after entering the password
|
private TextView tvWalletViewKey;
|
||||||
// so asking them to enter it a couple of seconds later seems silly
|
private TextView tvWalletSpendKey;
|
||||||
String walletPassword = null;
|
private ImageButton bCopyAddress;
|
||||||
|
private LinearLayout llAdvancedInfo;
|
||||||
|
private LinearLayout llPassword;
|
||||||
|
private Button bAdvancedInfo;
|
||||||
|
private Button bAccept;
|
||||||
|
|
||||||
|
private String walletPath;
|
||||||
|
private String walletName;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
@ -136,14 +135,14 @@ public class GenerateReviewFragment extends Fragment {
|
||||||
});
|
});
|
||||||
|
|
||||||
Bundle args = getArguments();
|
Bundle args = getArguments();
|
||||||
type = args.getString("type");
|
type = args.getString(REQUEST_TYPE);
|
||||||
walletPath = args.getString("path");
|
walletPath = args.getString(REQUEST_PATH);
|
||||||
showDetails(args.getString("password"));
|
localPassword = args.getString(REQUEST_PASSWORD);
|
||||||
|
showDetails();
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
void showDetails(String password) {
|
void showDetails() {
|
||||||
walletPassword = password;
|
|
||||||
showProgress();
|
showProgress();
|
||||||
tvWalletPassword.setText(null);
|
tvWalletPassword.setText(null);
|
||||||
new AsyncShow().executeOnExecutor(MoneroThreadPoolExecutor.MONERO_THREAD_POOL_EXECUTOR, walletPath);
|
new AsyncShow().executeOnExecutor(MoneroThreadPoolExecutor.MONERO_THREAD_POOL_EXECUTOR, walletPath);
|
||||||
|
@ -178,7 +177,7 @@ public class GenerateReviewFragment extends Fragment {
|
||||||
|
|
||||||
private void acceptWallet() {
|
private void acceptWallet() {
|
||||||
bAccept.setEnabled(false);
|
bAccept.setEnabled(false);
|
||||||
acceptCallback.onAccept(walletName, walletPassword);
|
acceptCallback.onAccept(walletName, getPassword());
|
||||||
}
|
}
|
||||||
|
|
||||||
private class AsyncShow extends AsyncTask<String, Void, Boolean> {
|
private class AsyncShow extends AsyncTask<String, Void, Boolean> {
|
||||||
|
@ -201,7 +200,7 @@ public class GenerateReviewFragment extends Fragment {
|
||||||
wallet = GenerateReviewFragment.this.walletCallback.getWallet();
|
wallet = GenerateReviewFragment.this.walletCallback.getWallet();
|
||||||
closeWallet = false;
|
closeWallet = false;
|
||||||
} else {
|
} else {
|
||||||
wallet = WalletManager.getInstance().openWallet(walletPath, walletPassword);
|
wallet = WalletManager.getInstance().openWallet(walletPath, getPassword());
|
||||||
closeWallet = true;
|
closeWallet = true;
|
||||||
}
|
}
|
||||||
name = wallet.getName();
|
name = wallet.getName();
|
||||||
|
@ -231,10 +230,8 @@ public class GenerateReviewFragment extends Fragment {
|
||||||
bAccept.setVisibility(View.VISIBLE);
|
bAccept.setVisibility(View.VISIBLE);
|
||||||
bAccept.setEnabled(true);
|
bAccept.setEnabled(true);
|
||||||
}
|
}
|
||||||
if (walletPassword != null) {
|
|
||||||
llPassword.setVisibility(View.VISIBLE);
|
llPassword.setVisibility(View.VISIBLE);
|
||||||
tvWalletPassword.setText(walletPassword);
|
tvWalletPassword.setText(getPassword());
|
||||||
}
|
|
||||||
tvWalletAddress.setText(address);
|
tvWalletAddress.setText(address);
|
||||||
tvWalletMnemonic.setText(seed);
|
tvWalletMnemonic.setText(seed);
|
||||||
tvWalletViewKey.setText(viewKey);
|
tvWalletViewKey.setText(viewKey);
|
||||||
|
@ -260,6 +257,7 @@ public class GenerateReviewFragment extends Fragment {
|
||||||
ProgressListener progressCallback = null;
|
ProgressListener progressCallback = null;
|
||||||
AcceptListener acceptCallback = null;
|
AcceptListener acceptCallback = null;
|
||||||
ListenerWithWallet walletCallback = null;
|
ListenerWithWallet walletCallback = null;
|
||||||
|
PasswordChangedListener passwordCallback = null;
|
||||||
|
|
||||||
public interface Listener {
|
public interface Listener {
|
||||||
void setTitle(String title, String subtitle);
|
void setTitle(String title, String subtitle);
|
||||||
|
@ -282,6 +280,24 @@ public class GenerateReviewFragment extends Fragment {
|
||||||
Wallet getWallet();
|
Wallet getWallet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface PasswordChangedListener {
|
||||||
|
void onPasswordChanged(String newPassword);
|
||||||
|
|
||||||
|
String getPassword();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String localPassword = null;
|
||||||
|
|
||||||
|
private String getPassword() {
|
||||||
|
if (passwordCallback != null) return passwordCallback.getPassword();
|
||||||
|
return localPassword;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setPassword(String password) {
|
||||||
|
if (passwordCallback != null) passwordCallback.onPasswordChanged(password);
|
||||||
|
else localPassword = password;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(Context context) {
|
public void onAttach(Context context) {
|
||||||
super.onAttach(context);
|
super.onAttach(context);
|
||||||
|
@ -297,6 +313,9 @@ public class GenerateReviewFragment extends Fragment {
|
||||||
if (context instanceof ListenerWithWallet) {
|
if (context instanceof ListenerWithWallet) {
|
||||||
this.walletCallback = (ListenerWithWallet) context;
|
this.walletCallback = (ListenerWithWallet) context;
|
||||||
}
|
}
|
||||||
|
if (context instanceof PasswordChangedListener) {
|
||||||
|
this.passwordCallback = (PasswordChangedListener) context;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -328,7 +347,7 @@ public class GenerateReviewFragment extends Fragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
String type = getArguments().getString("type");
|
String type = getArguments().getString(REQUEST_TYPE); // intance variable <type> not set yet
|
||||||
if (GenerateReviewFragment.VIEW_TYPE_ACCEPT.equals(type)) {
|
if (GenerateReviewFragment.VIEW_TYPE_ACCEPT.equals(type)) {
|
||||||
inflater.inflate(R.menu.wallet_details_help_menu, menu);
|
inflater.inflate(R.menu.wallet_details_help_menu, menu);
|
||||||
super.onCreateOptionsMenu(menu, inflater);
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
|
@ -345,7 +364,7 @@ public class GenerateReviewFragment extends Fragment {
|
||||||
wallet = GenerateReviewFragment.this.walletCallback.getWallet();
|
wallet = GenerateReviewFragment.this.walletCallback.getWallet();
|
||||||
closeWallet = false;
|
closeWallet = false;
|
||||||
} else {
|
} else {
|
||||||
wallet = WalletManager.getInstance().openWallet(walletPath, walletPassword);
|
wallet = WalletManager.getInstance().openWallet(walletPath, getPassword());
|
||||||
closeWallet = true;
|
closeWallet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,7 +419,8 @@ public class GenerateReviewFragment extends Fragment {
|
||||||
progressCallback.dismissProgressDialog();
|
progressCallback.dismissProgressDialog();
|
||||||
if (result) {
|
if (result) {
|
||||||
Toast.makeText(getActivity(), getString(R.string.changepw_success), Toast.LENGTH_SHORT).show();
|
Toast.makeText(getActivity(), getString(R.string.changepw_success), Toast.LENGTH_SHORT).show();
|
||||||
showDetails(newPassword);
|
setPassword(newPassword);
|
||||||
|
showDetails();
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(getActivity(), getString(R.string.changepw_failed), Toast.LENGTH_LONG).show();
|
Toast.makeText(getActivity(), getString(R.string.changepw_failed), Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
|
@ -527,7 +547,7 @@ public class GenerateReviewFragment extends Fragment {
|
||||||
} else if (!newPasswordA.equals(newPasswordB)) {
|
} else if (!newPasswordA.equals(newPasswordB)) {
|
||||||
etPasswordB.setError(getString(R.string.generate_bad_passwordB));
|
etPasswordB.setError(getString(R.string.generate_bad_passwordB));
|
||||||
} else if (newPasswordA.equals(newPasswordB)) {
|
} else if (newPasswordA.equals(newPasswordB)) {
|
||||||
new AsyncChangePassword().execute(walletName, walletPassword, newPasswordA, Boolean.toString(swFingerprintAllowed.isChecked()));
|
new AsyncChangePassword().execute(walletName, getPassword(), newPasswordA, Boolean.toString(swFingerprintAllowed.isChecked()));
|
||||||
Helper.hideKeyboardAlways(getActivity());
|
Helper.hideKeyboardAlways(getActivity());
|
||||||
openDialog.dismiss();
|
openDialog.dismiss();
|
||||||
openDialog = null;
|
openDialog = null;
|
||||||
|
@ -549,7 +569,7 @@ public class GenerateReviewFragment extends Fragment {
|
||||||
} else if (!newPasswordA.equals(newPasswordB)) {
|
} else if (!newPasswordA.equals(newPasswordB)) {
|
||||||
etPasswordB.setError(getString(R.string.generate_bad_passwordB));
|
etPasswordB.setError(getString(R.string.generate_bad_passwordB));
|
||||||
} else if (newPasswordA.equals(newPasswordB)) {
|
} else if (newPasswordA.equals(newPasswordB)) {
|
||||||
new AsyncChangePassword().execute(walletName, walletPassword, newPasswordA, Boolean.toString(swFingerprintAllowed.isChecked()));
|
new AsyncChangePassword().execute(walletName, getPassword(), newPasswordA, Boolean.toString(swFingerprintAllowed.isChecked()));
|
||||||
Helper.hideKeyboardAlways(getActivity());
|
Helper.hideKeyboardAlways(getActivity());
|
||||||
openDialog.dismiss();
|
openDialog.dismiss();
|
||||||
openDialog = null;
|
openDialog = null;
|
||||||
|
|
|
@ -55,6 +55,7 @@ public class WalletActivity extends SecureActivity implements WalletFragment.Lis
|
||||||
WalletService.Observer, SendFragment.Listener, TxFragment.Listener,
|
WalletService.Observer, SendFragment.Listener, TxFragment.Listener,
|
||||||
GenerateReviewFragment.ListenerWithWallet,
|
GenerateReviewFragment.ListenerWithWallet,
|
||||||
GenerateReviewFragment.Listener,
|
GenerateReviewFragment.Listener,
|
||||||
|
GenerateReviewFragment.PasswordChangedListener,
|
||||||
ScannerFragment.OnScannedListener, ReceiveFragment.Listener,
|
ScannerFragment.OnScannedListener, ReceiveFragment.Listener,
|
||||||
SendAddressWizardFragment.OnScanListener {
|
SendAddressWizardFragment.OnScanListener {
|
||||||
|
|
||||||
|
@ -65,6 +66,18 @@ public class WalletActivity extends SecureActivity implements WalletFragment.Lis
|
||||||
private Toolbar toolbar;
|
private Toolbar toolbar;
|
||||||
private boolean needVerifyIdentity;
|
private boolean needVerifyIdentity;
|
||||||
|
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPasswordChanged(String newPassword) {
|
||||||
|
password = newPassword;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setToolbarButton(int type) {
|
public void setToolbarButton(int type) {
|
||||||
toolbar.setButton(type);
|
toolbar.setButton(type);
|
||||||
|
@ -119,9 +132,8 @@ public class WalletActivity extends SecureActivity implements WalletFragment.Lis
|
||||||
if (extras != null) {
|
if (extras != null) {
|
||||||
acquireWakeLock();
|
acquireWakeLock();
|
||||||
String walletId = extras.getString(REQUEST_ID);
|
String walletId = extras.getString(REQUEST_ID);
|
||||||
String walletPassword = extras.getString(REQUEST_PW);
|
|
||||||
needVerifyIdentity = extras.getBoolean(REQUEST_FINGERPRINT_USED);
|
needVerifyIdentity = extras.getBoolean(REQUEST_FINGERPRINT_USED);
|
||||||
connectWalletService(walletId, walletPassword);
|
connectWalletService(walletId, password);
|
||||||
} else {
|
} else {
|
||||||
finish();
|
finish();
|
||||||
//throw new IllegalStateException("No extras passed! Panic!");
|
//throw new IllegalStateException("No extras passed! Panic!");
|
||||||
|
@ -186,7 +198,7 @@ public class WalletActivity extends SecureActivity implements WalletFragment.Lis
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onWalletChangePassword() {//final String walletName, final String walletPassword) {
|
public void onWalletChangePassword() {
|
||||||
try {
|
try {
|
||||||
GenerateReviewFragment detailsFragment = (GenerateReviewFragment)
|
GenerateReviewFragment detailsFragment = (GenerateReviewFragment)
|
||||||
getSupportFragmentManager().findFragmentById(R.id.fragment_container);
|
getSupportFragmentManager().findFragmentById(R.id.fragment_container);
|
||||||
|
@ -247,6 +259,8 @@ public class WalletActivity extends SecureActivity implements WalletFragment.Lis
|
||||||
.add(R.id.fragment_container, walletFragment, WalletFragment.class.getName()).commit();
|
.add(R.id.fragment_container, walletFragment, WalletFragment.class.getName()).commit();
|
||||||
Timber.d("fragment added");
|
Timber.d("fragment added");
|
||||||
|
|
||||||
|
password = getIntent().getExtras().getString(REQUEST_PW);
|
||||||
|
|
||||||
startWalletService();
|
startWalletService();
|
||||||
Timber.d("onCreate() done.");
|
Timber.d("onCreate() done.");
|
||||||
}
|
}
|
||||||
|
@ -709,8 +723,7 @@ public class WalletActivity extends SecureActivity implements WalletFragment.Lis
|
||||||
switch (which) {
|
switch (which) {
|
||||||
case DialogInterface.BUTTON_POSITIVE:
|
case DialogInterface.BUTTON_POSITIVE:
|
||||||
final Bundle extras = new Bundle();
|
final Bundle extras = new Bundle();
|
||||||
extras.putString("type", GenerateReviewFragment.VIEW_TYPE_WALLET);
|
extras.putString(GenerateReviewFragment.REQUEST_TYPE, GenerateReviewFragment.VIEW_TYPE_WALLET);
|
||||||
extras.putString("password", getIntent().getExtras().getString(REQUEST_PW));
|
|
||||||
|
|
||||||
if (needVerifyIdentity) {
|
if (needVerifyIdentity) {
|
||||||
Helper.promptPassword(WalletActivity.this, getWallet().getName(), true, new Helper.PasswordAction() {
|
Helper.promptPassword(WalletActivity.this, getWallet().getName(), true, new Helper.PasswordAction() {
|
||||||
|
|
|
@ -166,7 +166,7 @@ public class Wallet {
|
||||||
|
|
||||||
//TODO static static bool keyValid(const std::string &secret_key_string, const std::string &address_string, bool isViewKey, bool testnet, std::string &error);
|
//TODO static static bool keyValid(const std::string &secret_key_string, const std::string &address_string, bool isViewKey, bool testnet, std::string &error);
|
||||||
|
|
||||||
public static native String getPaymentIdFromAddress(String address, boolean isTestNet);
|
public static native String getPaymentIdFromAddress(String address, int networkType);
|
||||||
|
|
||||||
public static native long getMaximumAllowedAmount();
|
public static native long getMaximumAllowedAmount();
|
||||||
|
|
||||||
|
|
|
@ -224,7 +224,7 @@
|
||||||
<string name="send_paymentid_hint">Zahlungs-ID (optional)</string>
|
<string name="send_paymentid_hint">Zahlungs-ID (optional)</string>
|
||||||
<string name="send_amount_hint">0.00</string>
|
<string name="send_amount_hint">0.00</string>
|
||||||
<string name="send_notes_hint">Private Notizen (optional)</string>
|
<string name="send_notes_hint">Private Notizen (optional)</string>
|
||||||
<string name="send_generate_paymentid_hint">Generieren</string>
|
<string name="send_generate_paymentid_hint">Erzeuge</string>
|
||||||
<string name="send_qr_hint">Scannen</string>
|
<string name="send_qr_hint">Scannen</string>
|
||||||
<string name="send_send_label">Gib meine wertvollen Moneroj aus</string>
|
<string name="send_send_label">Gib meine wertvollen Moneroj aus</string>
|
||||||
<string name="send_send_timed_label">Gib meine wertvollen Moneroj aus (%1$s)</string>
|
<string name="send_send_timed_label">Gib meine wertvollen Moneroj aus (%1$s)</string>
|
||||||
|
|
Loading…
Reference in New Issue