Search in sources :

Example 11 with DialogBuilder

use of de.schildbach.wallet.ui.DialogBuilder in project bitcoin-wallet by bitcoin-wallet.

the class ExtendedPublicKeyFragment method onCreateDialog.

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final String base58 = getArguments().getCharSequence(KEY_EXTENDED_PUBLIC_KEY).toString();
    final View view = LayoutInflater.from(activity).inflate(R.layout.extended_public_key_dialog, null);
    final BitmapDrawable bitmap = new BitmapDrawable(getResources(), Qr.bitmap(base58));
    bitmap.setFilterBitmap(false);
    final ImageView imageView = view.findViewById(R.id.extended_public_key_dialog_image);
    imageView.setImageDrawable(bitmap);
    final DialogBuilder dialog = DialogBuilder.custom(activity, 0, view);
    dialog.setNegativeButton(R.string.button_dismiss, (d, which) -> dismissAllowingStateLoss());
    dialog.setPositiveButton(R.string.button_share, (d, which) -> {
        final ShareCompat.IntentBuilder builder = ShareCompat.IntentBuilder.from(activity);
        builder.setType("text/plain");
        builder.setText(base58);
        builder.setSubject(getString(R.string.extended_public_key_fragment_title));
        builder.setChooserTitle(R.string.extended_public_key_fragment_share);
        builder.startChooser();
        log.info("extended public key shared via intent: {}", base58);
    });
    return dialog.show();
}
Also used : ShareCompat(androidx.core.app.ShareCompat) BitmapDrawable(android.graphics.drawable.BitmapDrawable) ImageView(android.widget.ImageView) DialogBuilder(de.schildbach.wallet.ui.DialogBuilder) ImageView(android.widget.ImageView) View(android.view.View)

Example 12 with DialogBuilder

use of de.schildbach.wallet.ui.DialogBuilder in project bitcoin-wallet by bitcoin-wallet.

the class DiagnosticsFragment method handleInitiateReset.

private void handleInitiateReset() {
    final DialogBuilder dialog = DialogBuilder.dialog(activity, R.string.preferences_initiate_reset_title, R.string.preferences_initiate_reset_dialog_message);
    dialog.setPositiveButton(R.string.preferences_initiate_reset_dialog_positive, (d, which) -> {
        log.info("manually initiated block chain reset");
        BlockchainService.resetBlockchain(activity);
        config.resetBestChainHeightEver();
        config.updateLastBlockchainResetTime();
        // TODO doesn't fully finish prefs on single pane layouts
        activity.finish();
    });
    dialog.setNegativeButton(R.string.button_dismiss, null);
    dialog.show();
}
Also used : DialogBuilder(de.schildbach.wallet.ui.DialogBuilder)

Example 13 with DialogBuilder

use of de.schildbach.wallet.ui.DialogBuilder in project bitcoin-wallet by bitcoin-wallet.

the class RestoreWalletDialogFragment method showPermissionDeniedDialog.

private Dialog showPermissionDeniedDialog() {
    final DialogBuilder dialog = new DialogBuilder(activity);
    dialog.setTitle(R.string.restore_wallet_permission_dialog_title);
    dialog.setMessage(getString(R.string.restore_wallet_permission_dialog_message));
    dialog.singleDismissButton(new OnClickListener() {

        @Override
        public void onClick(final DialogInterface dialog, final int which) {
            RestoreWalletDialogFragment.this.dismiss();
        }
    });
    return dialog.show();
}
Also used : DialogInterface(android.content.DialogInterface) OnClickListener(android.content.DialogInterface.OnClickListener) DialogBuilder(de.schildbach.wallet.ui.DialogBuilder)

Example 14 with DialogBuilder

use of de.schildbach.wallet.ui.DialogBuilder 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 = view.findViewById(R.id.backup_wallet_dialog_password);
    passwordView.setText(null);
    passwordAgainView = view.findViewById(R.id.backup_wallet_dialog_password_again);
    passwordAgainView.setText(null);
    passwordStrengthView = view.findViewById(R.id.backup_wallet_dialog_password_strength);
    passwordMismatchView = view.findViewById(R.id.backup_wallet_dialog_password_mismatch);
    showView = view.findViewById(R.id.backup_wallet_dialog_show);
    warningView = view.findViewById(R.id.backup_wallet_dialog_warning_encrypted);
    final DialogBuilder builder = DialogBuilder.custom(activity, R.string.export_keys_dialog_title, view);
    // dummies, just to make buttons show
    builder.setPositiveButton(R.string.export_keys_dialog_button_export, null);
    builder.setNegativeButton(R.string.button_cancel, null);
    final AlertDialog dialog = builder.create();
    dialog.setCanceledOnTouchOutside(false);
    dialog.setOnShowListener(d -> {
        positiveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
        positiveButton.setEnabled(false);
        positiveButton.setTypeface(Typeface.DEFAULT_BOLD);
        positiveButton.setOnClickListener(v -> handleGo());
        negativeButton = dialog.getButton(DialogInterface.BUTTON_NEGATIVE);
        negativeButton.setOnClickListener(v -> {
            dismissAllowingStateLoss();
            activity.finish();
        });
        passwordView.addTextChangedListener(textWatcher);
        passwordAgainView.addTextChangedListener(textWatcher);
        showView.setOnCheckedChangeListener(new ShowPasswordCheckListener(passwordView, passwordAgainView));
        walletActivityViewModel.wallet.observe(BackupWalletDialogFragment.this, wallet -> warningView.setVisibility(wallet.isEncrypted() ? View.VISIBLE : View.GONE));
        viewModel.password.observe(BackupWalletDialogFragment.this, password -> {
            passwordMismatchView.setVisibility(View.INVISIBLE);
            final int passwordLength = password.length();
            passwordStrengthView.setVisibility(passwordLength > 0 ? View.VISIBLE : View.INVISIBLE);
            if (passwordLength < 6) {
                passwordStrengthView.setText(R.string.encrypt_keys_dialog_password_strength_weak);
                passwordStrengthView.setTextColor(activity.getColor(R.color.fg_password_strength_weak));
            } else if (passwordLength < 8) {
                passwordStrengthView.setText(R.string.encrypt_keys_dialog_password_strength_fair);
                passwordStrengthView.setTextColor(activity.getColor(R.color.fg_password_strength_fair));
            } else if (passwordLength < 10) {
                passwordStrengthView.setText(R.string.encrypt_keys_dialog_password_strength_good);
                passwordStrengthView.setTextColor(activity.getColor(R.color.fg_password_strength_good));
            } else {
                passwordStrengthView.setText(R.string.encrypt_keys_dialog_password_strength_strong);
                passwordStrengthView.setTextColor(activity.getColor(R.color.fg_password_strength_strong));
            }
            if (positiveButton != null) {
                final Wallet wallet = walletActivityViewModel.wallet.getValue();
                final boolean hasPassword = !password.isEmpty();
                final boolean hasPasswordAgain = !passwordAgainView.getText().toString().trim().isEmpty();
                positiveButton.setEnabled(wallet != null && hasPassword && hasPasswordAgain);
            }
        });
    });
    return dialog;
}
Also used : AlertDialog(android.app.AlertDialog) Wallet(org.bitcoinj.wallet.Wallet) ShowPasswordCheckListener(de.schildbach.wallet.ui.ShowPasswordCheckListener) DialogBuilder(de.schildbach.wallet.ui.DialogBuilder) View(android.view.View) TextView(android.widget.TextView)

Example 15 with DialogBuilder

use of de.schildbach.wallet.ui.DialogBuilder in project bitcoin-wallet by bitcoin-wallet.

the class SendCoinsFragment method initStateFromIntentUri.

private void initStateFromIntentUri(final String mimeType, final Uri bitcoinUri) {
    try {
        final InputStream is = contentResolver.openInputStream(bitcoinUri);
        new StreamInputParser(mimeType, is) {

            @Override
            protected void handlePaymentIntent(final PaymentIntent paymentIntent) {
                updateStateFrom(paymentIntent);
            }

            @Override
            protected void error(final int messageResId, final Object... messageArgs) {
                final DialogBuilder dialog = DialogBuilder.dialog(activity, 0, messageResId, messageArgs);
                dialog.singleDismissButton(activityDismissListener);
                dialog.show();
            }
        }.parse();
    } catch (final FileNotFoundException x) {
        throw new RuntimeException(x);
    }
}
Also used : StreamInputParser(de.schildbach.wallet.ui.InputParser.StreamInputParser) InputStream(java.io.InputStream) FileNotFoundException(java.io.FileNotFoundException) PaymentIntent(de.schildbach.wallet.data.PaymentIntent) DialogBuilder(de.schildbach.wallet.ui.DialogBuilder)

Aggregations

DialogBuilder (de.schildbach.wallet.ui.DialogBuilder)20 DialogInterface (android.content.DialogInterface)8 View (android.view.View)8 OnClickListener (android.content.DialogInterface.OnClickListener)7 PaymentIntent (de.schildbach.wallet.data.PaymentIntent)7 TextView (android.widget.TextView)6 AlertDialog (android.app.AlertDialog)5 Transaction (org.bitcoinj.core.Transaction)5 StringInputParser (de.schildbach.wallet.ui.InputParser.StringInputParser)4 IOException (java.io.IOException)4 InputStream (java.io.InputStream)4 Coin (org.bitcoinj.core.Coin)4 VerificationException (org.bitcoinj.core.VerificationException)4 MonetaryFormat (org.bitcoinj.utils.MonetaryFormat)4 Wallet (org.bitcoinj.wallet.Wallet)4 FileInputStream (java.io.FileInputStream)3 Activity (android.app.Activity)2 Context (android.content.Context)2 Intent (android.content.Intent)2 PackageManager (android.content.pm.PackageManager)2