Search in sources :

Example 1 with ShowPasswordCheckListener

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);
}
Also used : ShowPasswordCheckListener(de.schildbach.wallet.ui.ShowPasswordCheckListener) File(java.io.File) LinkedList(java.util.LinkedList)

Example 2 with ShowPasswordCheckListener

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;
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) OnClickListener(android.view.View.OnClickListener) ShowPasswordCheckListener(de.schildbach.wallet.ui.ShowPasswordCheckListener) TextView(android.widget.TextView) DialogBuilder(de.schildbach.wallet.ui.DialogBuilder) View(android.view.View) TextView(android.widget.TextView) OnShowListener(android.content.DialogInterface.OnShowListener)

Example 3 with ShowPasswordCheckListener

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));
}
Also used : ShowPasswordCheckListener(de.schildbach.wallet.ui.ShowPasswordCheckListener)

Aggregations

ShowPasswordCheckListener (de.schildbach.wallet.ui.ShowPasswordCheckListener)3 AlertDialog (android.app.AlertDialog)1 DialogInterface (android.content.DialogInterface)1 OnShowListener (android.content.DialogInterface.OnShowListener)1 View (android.view.View)1 OnClickListener (android.view.View.OnClickListener)1 TextView (android.widget.TextView)1 DialogBuilder (de.schildbach.wallet.ui.DialogBuilder)1 File (java.io.File)1 LinkedList (java.util.LinkedList)1