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();
}
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();
}
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();
}
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;
}
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);
}
}
Aggregations