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