Search in sources :

Example 1 with WalletApplication

use of de.schildbach.wallet.WalletApplication in project bitcoin-wallet by bitcoin-wallet.

the class BootstrapReceiver method onReceive.

@Override
public void onReceive(final Context context, final Intent intent) {
    log.info("got broadcast: " + intent);
    final WalletApplication application = (WalletApplication) context.getApplicationContext();
    final boolean bootCompleted = Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction());
    final boolean packageReplaced = Intent.ACTION_MY_PACKAGE_REPLACED.equals(intent.getAction());
    if (packageReplaced || bootCompleted) {
        // make sure wallet is upgraded to HD
        if (packageReplaced)
            UpgradeWalletService.startUpgrade(context);
        // make sure there is always an alarm scheduled
        BlockchainService.scheduleStart(application);
        // if the app hasn't been used for a while and contains coins, maybe show reminder
        final Configuration config = application.getConfiguration();
        if (config.remindBalance() && config.hasBeenUsed() && config.getLastUsedAgo() > Constants.LAST_USAGE_THRESHOLD_INACTIVE_MS)
            InactivityNotificationService.startMaybeShowNotification(context);
    }
}
Also used : Configuration(de.schildbach.wallet.Configuration) WalletApplication(de.schildbach.wallet.WalletApplication)

Example 2 with WalletApplication

use of de.schildbach.wallet.WalletApplication in project bitcoin-wallet by bitcoin-wallet.

the class MaybeMaintenanceFragment method onAttach.

@Override
public void onAttach(final Context context) {
    super.onAttach(context);
    final AbstractWalletActivity activity = (AbstractWalletActivity) context;
    final WalletApplication application = activity.getWalletApplication();
    this.wallet = application.getWallet();
    this.broadcastManager = LocalBroadcastManager.getInstance(context);
}
Also used : WalletApplication(de.schildbach.wallet.WalletApplication)

Example 3 with WalletApplication

use of de.schildbach.wallet.WalletApplication 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 4 with WalletApplication

use of de.schildbach.wallet.WalletApplication in project bitcoin-wallet by bitcoin-wallet.

the class WalletDisclaimerFragment method onAttach.

@Override
public void onAttach(final Context context) {
    super.onAttach(context);
    this.activity = (AbstractBindServiceActivity) context;
    final WalletApplication application = activity.getWalletApplication();
    this.config = application.getConfiguration();
    this.loaderManager = getLoaderManager();
}
Also used : WalletApplication(de.schildbach.wallet.WalletApplication)

Example 5 with WalletApplication

use of de.schildbach.wallet.WalletApplication in project bitcoin-wallet by bitcoin-wallet.

the class ExchangeRatesProvider method onCreate.

@Override
public boolean onCreate() {
    if (!Constants.ENABLE_EXCHANGE_RATES)
        return false;
    final Stopwatch watch = Stopwatch.createStarted();
    final Context context = getContext();
    Logging.init(context.getFilesDir());
    final WalletApplication application = (WalletApplication) context.getApplicationContext();
    this.config = application.getConfiguration();
    this.userAgent = WalletApplication.httpUserAgent(application.packageInfo().versionName);
    final ExchangeRate cachedExchangeRate = config.getCachedExchangeRate();
    if (cachedExchangeRate != null) {
        exchangeRates = new TreeMap<String, ExchangeRate>();
        exchangeRates.put(cachedExchangeRate.getCurrencyCode(), cachedExchangeRate);
    }
    watch.stop();
    log.info("{}.onCreate() took {}", getClass().getSimpleName(), watch);
    return true;
}
Also used : Context(android.content.Context) Stopwatch(com.google.common.base.Stopwatch) WalletApplication(de.schildbach.wallet.WalletApplication)

Aggregations

WalletApplication (de.schildbach.wallet.WalletApplication)7 Context (android.content.Context)1 DialogInterface (android.content.DialogInterface)1 OnClickListener (android.content.DialogInterface.OnClickListener)1 Stopwatch (com.google.common.base.Stopwatch)1 Configuration (de.schildbach.wallet.Configuration)1 PaymentIntent (de.schildbach.wallet.data.PaymentIntent)1 StringInputParser (de.schildbach.wallet.ui.InputParser.StringInputParser)1 Transaction (org.bitcoinj.core.Transaction)1 VerificationException (org.bitcoinj.core.VerificationException)1 VersionedChecksummedBytes (org.bitcoinj.core.VersionedChecksummedBytes)1