Search in sources :

Example 6 with PaymentIntent

use of de.schildbach.wallet.data.PaymentIntent in project bitcoin-wallet by bitcoin-wallet.

the class SendCoinsQrActivity method onActivityResult.

@Override
public void onActivityResult(final int requestCode, final int resultCode, final Intent intent) {
    if (requestCode == REQUEST_CODE_SCAN && resultCode == Activity.RESULT_OK) {
        final String input = intent.getStringExtra(ScanActivity.INTENT_EXTRA_RESULT);
        new StringInputParser(input) {

            @Override
            protected void handlePaymentIntent(final PaymentIntent paymentIntent) {
                SendCoinsActivity.start(SendCoinsQrActivity.this, paymentIntent);
                SendCoinsQrActivity.this.finish();
            }

            @Override
            protected void handlePrivateKey(final VersionedChecksummedBytes key) {
                if (Constants.ENABLE_SWEEP_WALLET) {
                    SweepWalletActivity.start(SendCoinsQrActivity.this, key);
                    SendCoinsQrActivity.this.finish();
                } else {
                    super.handlePrivateKey(key);
                }
            }

            @Override
            protected void handleDirectTransaction(final Transaction transaction) throws VerificationException {
                final WalletApplication application = (WalletApplication) getApplication();
                application.processDirectTransaction(transaction);
                SendCoinsQrActivity.this.finish();
            }

            @Override
            protected void error(final int messageResId, final Object... messageArgs) {
                dialog(SendCoinsQrActivity.this, dismissListener, 0, messageResId, messageArgs);
            }

            private final OnClickListener dismissListener = new OnClickListener() {

                @Override
                public void onClick(final DialogInterface dialog, final int which) {
                    SendCoinsQrActivity.this.finish();
                }
            };
        }.parse();
    } else {
        finish();
    }
}
Also used : VersionedChecksummedBytes(org.bitcoinj.core.VersionedChecksummedBytes) Transaction(org.bitcoinj.core.Transaction) DialogInterface(android.content.DialogInterface) WalletApplication(de.schildbach.wallet.WalletApplication) StringInputParser(de.schildbach.wallet.ui.InputParser.StringInputParser) VerificationException(org.bitcoinj.core.VerificationException) OnClickListener(android.content.DialogInterface.OnClickListener) PaymentIntent(de.schildbach.wallet.data.PaymentIntent)

Example 7 with PaymentIntent

use of de.schildbach.wallet.data.PaymentIntent in project bitcoin-wallet by bitcoin-wallet.

the class WalletActivity method onActivityResult.

@Override
public void onActivityResult(final int requestCode, final int resultCode, final Intent intent) {
    if (requestCode == REQUEST_CODE_SCAN) {
        if (resultCode == Activity.RESULT_OK) {
            final String input = intent.getStringExtra(ScanActivity.INTENT_EXTRA_RESULT);
            new StringInputParser(input) {

                @Override
                protected void handlePaymentIntent(final PaymentIntent paymentIntent) {
                    SendCoinsActivity.start(WalletActivity.this, paymentIntent);
                }

                @Override
                protected void handlePrivateKey(final VersionedChecksummedBytes key) {
                    if (Constants.ENABLE_SWEEP_WALLET)
                        SweepWalletActivity.start(WalletActivity.this, key);
                    else
                        super.handlePrivateKey(key);
                }

                @Override
                protected void handleDirectTransaction(final Transaction tx) throws VerificationException {
                    application.processDirectTransaction(tx);
                }

                @Override
                protected void error(final int messageResId, final Object... messageArgs) {
                    dialog(WalletActivity.this, null, R.string.button_scan, messageResId, messageArgs);
                }
            }.parse();
        }
    } else {
        super.onActivityResult(requestCode, resultCode, intent);
    }
}
Also used : VersionedChecksummedBytes(org.bitcoinj.core.VersionedChecksummedBytes) Transaction(org.bitcoinj.core.Transaction) StringInputParser(de.schildbach.wallet.ui.InputParser.StringInputParser) VerificationException(org.bitcoinj.core.VerificationException) PaymentIntent(de.schildbach.wallet.data.PaymentIntent)

Example 8 with PaymentIntent

use of de.schildbach.wallet.data.PaymentIntent in project bitcoin-wallet by bitcoin-wallet.

the class SendCoinsFragment method initStateFromIntentExtras.

private void initStateFromIntentExtras(final Bundle extras) {
    final PaymentIntent paymentIntent = extras.getParcelable(SendCoinsActivity.INTENT_EXTRA_PAYMENT_INTENT);
    final FeeCategory feeCategory = (FeeCategory) extras.getSerializable(SendCoinsActivity.INTENT_EXTRA_FEE_CATEGORY);
    if (feeCategory != null) {
        log.info("got fee category {}", feeCategory);
        this.feeCategory = feeCategory;
    }
    updateStateFrom(paymentIntent);
}
Also used : PaymentIntent(de.schildbach.wallet.data.PaymentIntent)

Example 9 with PaymentIntent

use of de.schildbach.wallet.data.PaymentIntent 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) {
                dialog(activity, activityDismissListener, 0, messageResId, messageArgs);
            }
        }.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)

Example 10 with PaymentIntent

use of de.schildbach.wallet.data.PaymentIntent in project bitcoin-wallet by bitcoin-wallet.

the class SendCoinsFragment method initStateFromBitcoinUri.

private void initStateFromBitcoinUri(final Uri bitcoinUri) {
    final String input = bitcoinUri.toString();
    new StringInputParser(input) {

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

        @Override
        protected void handlePrivateKey(final VersionedChecksummedBytes key) {
            throw new UnsupportedOperationException();
        }

        @Override
        protected void handleDirectTransaction(final Transaction transaction) throws VerificationException {
            throw new UnsupportedOperationException();
        }

        @Override
        protected void error(final int messageResId, final Object... messageArgs) {
            dialog(activity, activityDismissListener, 0, messageResId, messageArgs);
        }
    }.parse();
}
Also used : VersionedChecksummedBytes(org.bitcoinj.core.VersionedChecksummedBytes) Transaction(org.bitcoinj.core.Transaction) StringInputParser(de.schildbach.wallet.ui.InputParser.StringInputParser) VerificationException(org.bitcoinj.core.VerificationException) PaymentIntent(de.schildbach.wallet.data.PaymentIntent)

Aggregations

PaymentIntent (de.schildbach.wallet.data.PaymentIntent)15 StringInputParser (de.schildbach.wallet.ui.InputParser.StringInputParser)6 Transaction (org.bitcoinj.core.Transaction)6 VerificationException (org.bitcoinj.core.VerificationException)6 VersionedChecksummedBytes (org.bitcoinj.core.VersionedChecksummedBytes)4 DialogInterface (android.content.DialogInterface)3 Intent (android.content.Intent)2 DialogBuilder (de.schildbach.wallet.ui.DialogBuilder)2 FileNotFoundException (java.io.FileNotFoundException)2 OnClickListener (android.content.DialogInterface.OnClickListener)1 NdefMessage (android.nfc.NdefMessage)1 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 UninitializedMessageException (com.google.protobuf.UninitializedMessageException)1 WalletApplication (de.schildbach.wallet.WalletApplication)1 BinaryInputParser (de.schildbach.wallet.ui.InputParser.BinaryInputParser)1 StreamInputParser (de.schildbach.wallet.ui.InputParser.StreamInputParser)1 InputStream (java.io.InputStream)1 KeyStore (java.security.KeyStore)1 KeyStoreException (java.security.KeyStoreException)1 ArrayList (java.util.ArrayList)1