use of de.schildbach.wallet.ui.ShowPasswordCheckListener in project bitcoin-wallet by bitcoin-wallet.
the class RestoreWalletDialogFragment method updateView.
private void updateView() {
if (dialog == null)
return;
final String path;
final String backupPath = Constants.Files.EXTERNAL_WALLET_BACKUP_DIR.getAbsolutePath();
final String storagePath = Constants.Files.EXTERNAL_STORAGE_DIR.getAbsolutePath();
if (backupPath.startsWith(storagePath))
path = backupPath.substring(storagePath.length());
else
path = backupPath;
final List<File> files = new LinkedList<File>();
// external storage
log.info("looking for backup files in '{}'", Constants.Files.EXTERNAL_WALLET_BACKUP_DIR);
final File[] externalFiles = Constants.Files.EXTERNAL_WALLET_BACKUP_DIR.listFiles();
if (externalFiles != null) {
for (final File file : externalFiles) {
final boolean looksLikeBackup = Crypto.OPENSSL_FILE_FILTER.accept(file);
log.info(" {}{}", file.getName(), looksLikeBackup ? " -- looks like backup file" : "");
if (looksLikeBackup)
files.add(file);
}
}
// app-private storage
log.info("adding backup files from app-private storage");
for (final String filename : activity.fileList()) {
if (filename.startsWith(Constants.Files.WALLET_KEY_BACKUP_PROTOBUF + '.')) {
log.info(" {}", filename);
files.add(new File(activity.getFilesDir(), filename));
}
}
// sort
Collections.sort(files, new Comparator<File>() {
@Override
public int compare(final File lhs, final File rhs) {
return lhs.getName().compareToIgnoreCase(rhs.getName());
}
});
messageView.setText(getString(!files.isEmpty() ? R.string.import_keys_dialog_message : R.string.restore_wallet_dialog_message_empty, path));
fileView.setVisibility(!files.isEmpty() ? View.VISIBLE : View.GONE);
final FileAdapter adapter = (FileAdapter) fileView.getAdapter();
adapter.setFiles(files);
passwordView.setVisibility(!files.isEmpty() ? View.VISIBLE : View.GONE);
passwordView.setText(null);
showView.setVisibility(!files.isEmpty() ? View.VISIBLE : View.GONE);
showView.setOnCheckedChangeListener(new ShowPasswordCheckListener(passwordView));
final boolean hasCoins = wallet.getBalance(BalanceType.ESTIMATED).signum() > 0;
replaceWarningView.setVisibility(hasCoins ? View.VISIBLE : View.GONE);
}
use of de.schildbach.wallet.ui.ShowPasswordCheckListener in project bitcoin-wallet by bitcoin-wallet.
the class BackupWalletDialogFragment method onCreateDialog.
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
final View view = LayoutInflater.from(activity).inflate(R.layout.backup_wallet_dialog, null);
passwordView = (EditText) view.findViewById(R.id.backup_wallet_dialog_password);
passwordView.setText(null);
passwordAgainView = (EditText) view.findViewById(R.id.backup_wallet_dialog_password_again);
passwordAgainView.setText(null);
passwordStrengthView = (TextView) view.findViewById(R.id.backup_wallet_dialog_password_strength);
passwordMismatchView = view.findViewById(R.id.backup_wallet_dialog_password_mismatch);
showView = (CheckBox) view.findViewById(R.id.backup_wallet_dialog_show);
final TextView warningView = (TextView) view.findViewById(R.id.backup_wallet_dialog_warning_encrypted);
warningView.setVisibility(wallet.isEncrypted() ? View.VISIBLE : View.GONE);
final DialogBuilder builder = new DialogBuilder(activity);
builder.setTitle(R.string.export_keys_dialog_title);
builder.setView(view);
// dummies, just to make buttons show
builder.setPositiveButton(R.string.button_ok, null);
builder.setNegativeButton(R.string.button_cancel, null);
builder.setCancelable(false);
final AlertDialog dialog = builder.create();
dialog.setOnShowListener(new OnShowListener() {
@Override
public void onShow(final DialogInterface d) {
positiveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
positiveButton.setTypeface(Typeface.DEFAULT_BOLD);
positiveButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(final View v) {
handleGo();
}
});
negativeButton = dialog.getButton(DialogInterface.BUTTON_NEGATIVE);
negativeButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(final View v) {
dismissAllowingStateLoss();
}
});
passwordView.addTextChangedListener(textWatcher);
passwordAgainView.addTextChangedListener(textWatcher);
showView.setOnCheckedChangeListener(new ShowPasswordCheckListener(passwordView, passwordAgainView));
BackupWalletDialogFragment.this.dialog = dialog;
updateView();
}
});
return dialog;
}
use of de.schildbach.wallet.ui.ShowPasswordCheckListener in project bitcoin-wallet by bitcoin-wallet.
the class RestoreWalletFromExternalDialogFragment method updateView.
private void updateView() {
if (dialog == null)
return;
final boolean hasCoins = wallet.getBalance(BalanceType.ESTIMATED).signum() > 0;
replaceWarningView.setVisibility(hasCoins ? View.VISIBLE : View.GONE);
showView.setOnCheckedChangeListener(new ShowPasswordCheckListener(passwordView));
}
Aggregations