call fail() if password cancelled (#726)

This commit is contained in:
m2049r 2021-03-12 19:57:13 +01:00 committed by GitHub
parent 3329636d32
commit 1b680344b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 43 additions and 54 deletions

View File

@ -376,7 +376,7 @@ public class LoginActivity extends BaseActivity
}
@Override
public void fail(String walletName1, String password, boolean fingerprintUsed) {
public void fail(String walletName) {
}
});
} else { // this cannot really happen as we prefilter choices
@ -412,7 +412,7 @@ public class LoginActivity extends BaseActivity
}
@Override
public void fail(String walletName, String password, boolean fingerprintUsed) {
public void fail(String walletName) {
}
});
} else { // this cannot really happen as we prefilter choices
@ -1400,7 +1400,7 @@ public class LoginActivity extends BaseActivity
}
@Override
public void fail(String walletName, String password, boolean fingerprintUsed) {
public void fail(String walletName) {
}
});

View File

@ -337,7 +337,7 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
}
@Override
public void fail(String walletName, String password, boolean fingerprintUsed) {
public void fail(String walletName) {
}
});
}
@ -854,7 +854,7 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
}
@Override
public void fail(String walletName, String password, boolean fingerprintUsed) {
public void fail(String walletName) {
}
});

View File

@ -332,7 +332,7 @@ public class SendBtcConfirmWizardFragment extends SendWizardFragment implements
send();
}
public void fail(String walletName, String password, boolean fingerprintUsed) {
public void fail(String walletName) {
getActivity().runOnUiThread(() -> {
bSend.setEnabled(sendCountdown > 0); // allow to try again
});

View File

@ -227,7 +227,7 @@ public class SendConfirmWizardFragment extends SendWizardFragment implements Sen
send();
}
public void fail(String walletName, String password, boolean fingerprintUsed) {
public void fail(String walletName) {
getActivity().runOnUiThread(() -> {
bSend.setEnabled(true); // allow to try again
});

View File

@ -23,7 +23,6 @@ import android.content.ClipData;
import android.content.ClipDescription;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
@ -484,7 +483,6 @@ public class Helper {
}
etPassword.getEditText().addTextChangedListener(new TextWatcher() {
@Override
public void afterTextChanged(Editable s) {
if (etPassword.getError() != null) {
@ -508,8 +506,8 @@ public class Helper {
.setCancelable(false)
.setPositiveButton(context.getString(R.string.label_ok), null)
.setNegativeButton(context.getString(R.string.label_cancel),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
(dialog, id) -> {
action.fail(wallet);
Helper.hideKeyboardAlways((Activity) context);
cancelSignal.cancel();
if (passwordTask != null) {
@ -518,7 +516,6 @@ public class Helper {
}
dialog.cancel();
openDialog = null;
}
});
openDialog = alertDialogBuilder.create();
@ -561,9 +558,7 @@ public class Helper {
};
}
openDialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
openDialog.setOnShowListener(dialog -> {
if (fingerprintAuthAllowed && fingerprintAuthCallback != null) {
tvOpenPrompt.setCompoundDrawablesRelativeWithIntrinsicBounds(icFingerprint, null, null, null);
tvOpenPrompt.setText(context.getText(R.string.prompt_fingerprint_auth));
@ -573,22 +568,17 @@ public class Helper {
etPassword.requestFocus();
}
Button button = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
button.setOnClickListener(view -> {
String pass = etPassword.getEditText().getText().toString();
if (passwordTask == null) {
passwordTask = new PasswordTask(pass, false);
passwordTask.execute();
}
}
});
}
});
// accept keyboard "ok"
etPassword.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() {
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
etPassword.getEditText().setOnEditorActionListener((v, actionId, event) -> {
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN))
|| (actionId == EditorInfo.IME_ACTION_DONE)) {
String pass = etPassword.getEditText().getText().toString();
@ -599,7 +589,6 @@ public class Helper {
return true;
}
return false;
}
});
if (Helper.preventScreenshot()) {
@ -613,7 +602,7 @@ public class Helper {
public interface PasswordAction {
void act(String walletName, String password, boolean fingerprintUsed);
void fail(String walletName, String password, boolean fingerprintUsed);
void fail(String walletName);
}
static private boolean processPasswordEntry(Context context, String walletName, String pass, boolean fingerprintUsed, PasswordAction action) {
@ -622,7 +611,7 @@ public class Helper {
action.act(walletName, walletPassword, fingerprintUsed);
return true;
} else {
action.fail(walletName, walletPassword, fingerprintUsed);
action.fail(walletName);
return false;
}
}