List of usage examples for android.content ComponentName flattenToString
public @NonNull String flattenToString()
From source file:com.blu3f1re.reddwallet.ui.SendCoinsFragment.java
private void handleGo() { state = State.PREPARATION;/*from w ww. j a v a 2s . c om*/ updateView(); // final payment intent final PaymentIntent finalPaymentIntent = paymentIntent.mergeWithEditedValues( amountCalculatorLink.getAmount(), validatedAddress != null ? validatedAddress.address : null); final BigInteger finalAmount = finalPaymentIntent.getAmount(); // prepare send request final SendRequest sendRequest = finalPaymentIntent.toSendRequest(); final Address returnAddress = WalletUtils.pickOldestKey(wallet).toAddress(Constants.NETWORK_PARAMETERS); sendRequest.changeAddress = returnAddress; sendRequest.emptyWallet = paymentIntent.mayEditAmount() && finalAmount.equals(wallet.getBalance(BalanceType.AVAILABLE)); //Emptying a wallet with less than 2 RDD can't be possible due to min fee 2 RDD of such a tx. /* if (amount.compareTo(BigInteger.valueOf(200000000)) < 0 && sendRequest.emptyWallet) { AlertDialog.Builder bld = new AlertDialog.Builder(activity); bld.setTitle(R.string.send_coins_error_msg); bld.setMessage(R.string.send_coins_error_desc); bld.setNeutralButton(activity.getResources().getString(android.R.string.ok), null); bld.setCancelable(false); bld.create().show(); state = State.FAILED; updateView(); return; }*/ new SendCoinsOfflineTask(wallet, backgroundHandler) { @Override protected void onSuccess(final Transaction transaction) { sentTransaction = transaction; state = State.SENDING; updateView(); sentTransaction.getConfidence().addEventListener(sentTransactionConfidenceListener); final Payment payment = createPaymentMessage(sentTransaction, returnAddress, finalAmount, null, paymentIntent.payeeData); directPay(payment); application.broadcastTransaction(sentTransaction); final ComponentName callingActivity = activity.getCallingActivity(); if (callingActivity != null) { log.info("returning result to calling activity: {}", callingActivity.flattenToString()); final Intent result = new Intent(); BitcoinIntegration.transactionHashToResult(result, sentTransaction.getHashAsString()); if (paymentIntent.standard == Standard.BIP70) BitcoinIntegration.paymentToResult(result, payment.toByteArray()); activity.setResult(Activity.RESULT_OK, result); } } private void directPay(final Payment payment) { if (directPaymentEnableView.isChecked()) { final DirectPaymentTask.ResultCallback callback = new DirectPaymentTask.ResultCallback() { @Override public void onResult(final boolean ack) { directPaymentAck = ack; if (state == State.SENDING) state = State.SENT; updateView(); } @Override public void onFail(final int messageResId, final Object... messageArgs) { final DialogBuilder dialog = DialogBuilder.warn(activity, R.string.send_coins_fragment_direct_payment_failed_title); dialog.setMessage(paymentIntent.paymentUrl + "\n" + getString(messageResId, messageArgs) + "\n\n" + getString(R.string.send_coins_fragment_direct_payment_failed_msg)); dialog.setPositiveButton(R.string.button_retry, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { directPay(payment); } }); dialog.setNegativeButton(R.string.button_dismiss, null); dialog.show(); } }; if (paymentIntent.isHttpPaymentUrl()) { new DirectPaymentTask.HttpPaymentTask(backgroundHandler, callback, paymentIntent.paymentUrl, application.httpUserAgent()).send(paymentIntent.standard, payment); } else if (paymentIntent.isBluetoothPaymentUrl() && bluetoothAdapter != null && bluetoothAdapter.isEnabled()) { new DirectPaymentTask.BluetoothPaymentTask(backgroundHandler, callback, bluetoothAdapter, paymentIntent.getBluetoothMac()).send(paymentIntent.standard, payment); } } } @Override protected void onInsufficientMoney(@Nullable final BigInteger missing) { state = State.INPUT; updateView(); final BigInteger estimated = wallet.getBalance(BalanceType.ESTIMATED); final BigInteger available = wallet.getBalance(BalanceType.AVAILABLE); final BigInteger pending = estimated.subtract(available); final int btcShift = config.getBtcShift(); final int btcPrecision = config.getBtcMaxPrecision(); final String btcPrefix = config.getBtcPrefix(); final DialogBuilder dialog = DialogBuilder.warn(activity, R.string.send_coins_fragment_insufficient_money_title); final StringBuilder msg = new StringBuilder(); if (missing != null) msg.append(String.format(getString(R.string.send_coins_fragment_insufficient_money_msg1), btcPrefix + ' ' + GenericUtils.formatValue(missing, btcPrecision, btcShift))) .append("\n\n"); if (pending.signum() > 0) msg.append(getString(R.string.send_coins_fragment_pending, GenericUtils.formatValue(pending, btcPrecision, btcShift))).append("\n\n"); msg.append(getString(R.string.send_coins_fragment_insufficient_money_msg2)); dialog.setMessage(msg); dialog.setPositiveButton(R.string.send_coins_options_empty, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { handleEmpty(); } }); dialog.setNegativeButton(R.string.button_cancel, null); dialog.show(); } @Override protected void onFailure() { state = State.FAILED; updateView(); activity.longToast(R.string.send_coins_error_msg); } }.sendCoinsOffline(sendRequest); // send asynchronously }
From source file:com.dopecoin.wallet.ui.SendCoinsFragment.java
private void handleGo() { state = State.PREPARATION;//w w w. ja v a2 s . c o m updateView(); // final payment intent final PaymentIntent finalPaymentIntent = paymentIntent.mergeWithEditedValues( amountCalculatorLink.getAmount(), validatedAddress != null ? validatedAddress.address : null); final BigInteger finalAmount = finalPaymentIntent.getAmount(); // prepare send request final SendRequest sendRequest = finalPaymentIntent.toSendRequest(); final Address returnAddress = WalletUtils.pickOldestKey(wallet).toAddress(Constants.NETWORK_PARAMETERS); sendRequest.changeAddress = returnAddress; sendRequest.emptyWallet = paymentIntent.mayEditAmount() && finalAmount.equals(wallet.getBalance(BalanceType.AVAILABLE)); //Emptying a wallet with less than 2 DOPE can't be possible due to min fee 2 DOPE of such a tx. /* if (amount.compareTo(BigInteger.valueOf(200000000)) < 0 && sendRequest.emptyWallet) { AlertDialog.Builder bld = new AlertDialog.Builder(activity); bld.setTitle(R.string.send_coins_error_msg); bld.setMessage(R.string.send_coins_error_desc); bld.setNeutralButton(activity.getResources().getString(android.R.string.ok), null); bld.setCancelable(false); bld.create().show(); state = State.FAILED; updateView(); return; }*/ new SendCoinsOfflineTask(wallet, backgroundHandler) { @Override protected void onSuccess(final Transaction transaction) { sentTransaction = transaction; state = State.SENDING; updateView(); sentTransaction.getConfidence().addEventListener(sentTransactionConfidenceListener); final Payment payment = createPaymentMessage(sentTransaction, returnAddress, finalAmount, null, paymentIntent.payeeData); directPay(payment); application.broadcastTransaction(sentTransaction); final ComponentName callingActivity = activity.getCallingActivity(); if (callingActivity != null) { log.info("returning result to calling activity: {}", callingActivity.flattenToString()); final Intent result = new Intent(); BitcoinIntegration.transactionHashToResult(result, sentTransaction.getHashAsString()); if (paymentIntent.standard == Standard.BIP70) BitcoinIntegration.paymentToResult(result, payment.toByteArray()); activity.setResult(Activity.RESULT_OK, result); } } private void directPay(final Payment payment) { if (directPaymentEnableView.isChecked()) { final DirectPaymentTask.ResultCallback callback = new DirectPaymentTask.ResultCallback() { @Override public void onResult(final boolean ack) { directPaymentAck = ack; if (state == State.SENDING) state = State.SENT; updateView(); } @Override public void onFail(final int messageResId, final Object... messageArgs) { final DialogBuilder dialog = DialogBuilder.warn(activity, R.string.send_coins_fragment_direct_payment_failed_title); dialog.setMessage(paymentIntent.paymentUrl + "\n" + getString(messageResId, messageArgs) + "\n\n" + getString(R.string.send_coins_fragment_direct_payment_failed_msg)); dialog.setPositiveButton(R.string.button_retry, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { directPay(payment); } }); dialog.setNegativeButton(R.string.button_dismiss, null); dialog.show(); } }; if (paymentIntent.isHttpPaymentUrl()) { new DirectPaymentTask.HttpPaymentTask(backgroundHandler, callback, paymentIntent.paymentUrl, application.httpUserAgent()).send(paymentIntent.standard, payment); } else if (paymentIntent.isBluetoothPaymentUrl() && bluetoothAdapter != null && bluetoothAdapter.isEnabled()) { new DirectPaymentTask.BluetoothPaymentTask(backgroundHandler, callback, bluetoothAdapter, paymentIntent.getBluetoothMac()).send(paymentIntent.standard, payment); } } } @Override protected void onInsufficientMoney(@Nullable final BigInteger missing) { state = State.INPUT; updateView(); final BigInteger estimated = wallet.getBalance(BalanceType.ESTIMATED); final BigInteger available = wallet.getBalance(BalanceType.AVAILABLE); final BigInteger pending = estimated.subtract(available); final int btcShift = config.getBtcShift(); final int btcPrecision = config.getBtcMaxPrecision(); final String btcPrefix = config.getBtcPrefix(); final DialogBuilder dialog = DialogBuilder.warn(activity, R.string.send_coins_fragment_insufficient_money_title); final StringBuilder msg = new StringBuilder(); if (missing != null) msg.append(String.format(getString(R.string.send_coins_fragment_insufficient_money_msg1), btcPrefix + ' ' + GenericUtils.formatValue(missing, btcPrecision, btcShift))) .append("\n\n"); if (pending.signum() > 0) msg.append(getString(R.string.send_coins_fragment_pending, GenericUtils.formatValue(pending, btcPrecision, btcShift))).append("\n\n"); msg.append(getString(R.string.send_coins_fragment_insufficient_money_msg2)); dialog.setMessage(msg); dialog.setPositiveButton(R.string.send_coins_options_empty, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { handleEmpty(); } }); dialog.setNegativeButton(R.string.button_cancel, null); dialog.show(); } @Override protected void onFailure() { state = State.FAILED; updateView(); activity.longToast(R.string.send_coins_error_msg); } }.sendCoinsOffline(sendRequest); // send asynchronously }
From source file:in.leafco.wallet.ui.SendCoinsFragment.java
private void handleGo() { state = State.PREPARATION;//ww w. java 2 s .c o m updateView(); // final payment intent final PaymentIntent finalPaymentIntent = paymentIntent.mergeWithEditedValues( amountCalculatorLink.getAmount(), validatedAddress != null ? validatedAddress.address : null); final BigInteger finalAmount = finalPaymentIntent.getAmount(); // prepare send request final SendRequest sendRequest = finalPaymentIntent.toSendRequest(); final Address returnAddress = WalletUtils.pickOldestKey(wallet).toAddress(Constants.NETWORK_PARAMETERS); sendRequest.changeAddress = returnAddress; sendRequest.emptyWallet = paymentIntent.mayEditAmount() && finalAmount.equals(wallet.getBalance(BalanceType.AVAILABLE)); //Emptying a wallet with less than 2 LEAF can't be possible due to min fee 2 LEAF of such a tx. /* if (amount.compareTo(BigInteger.valueOf(200000000)) < 0 && sendRequest.emptyWallet) { AlertDialog.Builder bld = new AlertDialog.Builder(activity); bld.setTitle(R.string.send_coins_error_msg); bld.setMessage(R.string.send_coins_error_desc); bld.setNeutralButton(activity.getResources().getString(android.R.string.ok), null); bld.setCancelable(false); bld.create().show(); state = State.FAILED; updateView(); return; }*/ new SendCoinsOfflineTask(wallet, backgroundHandler) { @Override protected void onSuccess(final Transaction transaction) { sentTransaction = transaction; state = State.SENDING; updateView(); sentTransaction.getConfidence().addEventListener(sentTransactionConfidenceListener); final Payment payment = createPaymentMessage(sentTransaction, returnAddress, finalAmount, null, paymentIntent.payeeData); directPay(payment); application.broadcastTransaction(sentTransaction); final ComponentName callingActivity = activity.getCallingActivity(); if (callingActivity != null) { log.info("returning result to calling activity: {}", callingActivity.flattenToString()); final Intent result = new Intent(); BitcoinIntegration.transactionHashToResult(result, sentTransaction.getHashAsString()); if (paymentIntent.standard == Standard.BIP70) BitcoinIntegration.paymentToResult(result, payment.toByteArray()); activity.setResult(Activity.RESULT_OK, result); } } private void directPay(final Payment payment) { if (directPaymentEnableView.isChecked()) { final DirectPaymentTask.ResultCallback callback = new DirectPaymentTask.ResultCallback() { @Override public void onResult(final boolean ack) { directPaymentAck = ack; if (state == State.SENDING) state = State.SENT; updateView(); } @Override public void onFail(final int messageResId, final Object... messageArgs) { final DialogBuilder dialog = DialogBuilder.warn(activity, R.string.send_coins_fragment_direct_payment_failed_title); dialog.setMessage(paymentIntent.paymentUrl + "\n" + getString(messageResId, messageArgs) + "\n\n" + getString(R.string.send_coins_fragment_direct_payment_failed_msg)); dialog.setPositiveButton(R.string.button_retry, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { directPay(payment); } }); dialog.setNegativeButton(R.string.button_dismiss, null); dialog.show(); } }; if (paymentIntent.isHttpPaymentUrl()) { new DirectPaymentTask.HttpPaymentTask(backgroundHandler, callback, paymentIntent.paymentUrl, application.httpUserAgent()).send(paymentIntent.standard, payment); } else if (paymentIntent.isBluetoothPaymentUrl() && bluetoothAdapter != null && bluetoothAdapter.isEnabled()) { new DirectPaymentTask.BluetoothPaymentTask(backgroundHandler, callback, bluetoothAdapter, paymentIntent.getBluetoothMac()).send(paymentIntent.standard, payment); } } } @Override protected void onInsufficientMoney(@Nullable final BigInteger missing) { state = State.INPUT; updateView(); final BigInteger estimated = wallet.getBalance(BalanceType.ESTIMATED); final BigInteger available = wallet.getBalance(BalanceType.AVAILABLE); final BigInteger pending = estimated.subtract(available); final int btcShift = config.getBtcShift(); final int btcPrecision = config.getBtcMaxPrecision(); final String btcPrefix = config.getBtcPrefix(); final DialogBuilder dialog = DialogBuilder.warn(activity, R.string.send_coins_fragment_insufficient_money_title); final StringBuilder msg = new StringBuilder(); if (missing != null) msg.append(String.format(getString(R.string.send_coins_fragment_insufficient_money_msg1), btcPrefix + ' ' + GenericUtils.formatValue(missing, btcPrecision, btcShift))) .append("\n\n"); if (pending.signum() > 0) msg.append(getString(R.string.send_coins_fragment_pending, GenericUtils.formatValue(pending, btcPrecision, btcShift))).append("\n\n"); msg.append(getString(R.string.send_coins_fragment_insufficient_money_msg2)); dialog.setMessage(msg); dialog.setPositiveButton(R.string.send_coins_options_empty, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { handleEmpty(); } }); dialog.setNegativeButton(R.string.button_cancel, null); dialog.show(); } @Override protected void onFailure() { state = State.FAILED; updateView(); activity.longToast(R.string.send_coins_error_msg); } }.sendCoinsOffline(sendRequest); // send asynchronously }
From source file:com.hivewallet.androidclient.wallet.ui.send.SendCoinsFragment.java
private void handleGo() { state = State.PREPARATION;// w ww . j a v a2 s .c om updateView(); // final payment intent final PaymentIntent finalPaymentIntent = paymentIntent.mergeWithEditedValues( amountCalculatorLink.getAmount(), validatedAddress != null ? validatedAddress.address : null); final BigInteger finalAmount = finalPaymentIntent.getAmount(); // prepare send request final SendRequest sendRequest = finalPaymentIntent.toSendRequest(); final Address returnAddress = WalletUtils.pickOldestKey(wallet).toAddress(Constants.NETWORK_PARAMETERS); sendRequest.changeAddress = returnAddress; sendRequest.emptyWallet = paymentIntent.mayEditAmount() && finalAmount.equals(wallet.getBalance(BalanceType.AVAILABLE)); new SendCoinsOfflineTask(wallet, backgroundHandler) { @Override protected void onSuccess(final Transaction transaction) { sentTransaction = transaction; state = State.SENDING; updateView(); sentTransaction.getConfidence().addEventListener(sentTransactionConfidenceListener); final Payment payment = PaymentProtocol.createPaymentMessage(sentTransaction, returnAddress, finalAmount, null, paymentIntent.payeeData); directPay(payment); application.broadcastTransaction(sentTransaction); final ComponentName callingActivity = activity.getCallingActivity(); if (callingActivity != null) { log.info("returning result to calling activity: {}", callingActivity.flattenToString()); final Intent result = new Intent(); BitcoinIntegration.transactionHashToResult(result, sentTransaction.getHashAsString()); if (paymentIntent.standard == Standard.BIP70) BitcoinIntegration.paymentToResult(result, payment.toByteArray()); activity.setResult(Activity.RESULT_OK, result); } } private void directPay(final Payment payment) { if (directPaymentEnableView.isChecked()) { final DirectPaymentTask.ResultCallback callback = new DirectPaymentTask.ResultCallback() { @Override public void onResult(final boolean ack) { directPaymentAck = ack; if (state == State.SENDING) state = State.SENT; updateView(); } @Override public void onFail(final int messageResId, final Object... messageArgs) { final DialogBuilder dialog = DialogBuilder.warn(activity, R.string.send_coins_fragment_direct_payment_failed_title); dialog.setMessage(paymentIntent.paymentUrl + "\n" + getString(messageResId, messageArgs) + "\n\n" + getString(R.string.send_coins_fragment_direct_payment_failed_msg)); dialog.setPositiveButton(R.string.button_retry, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { directPay(payment); } }); dialog.setNegativeButton(R.string.button_dismiss, null); dialog.show(); } }; if (paymentIntent.isHttpPaymentUrl()) { new DirectPaymentTask.HttpPaymentTask(backgroundHandler, callback, paymentIntent.paymentUrl, application.httpUserAgent()).send(payment); } else if (paymentIntent.isBluetoothPaymentUrl() && bluetoothAdapter != null && bluetoothAdapter.isEnabled()) { new DirectPaymentTask.BluetoothPaymentTask(backgroundHandler, callback, bluetoothAdapter, Bluetooth.getBluetoothMac(paymentIntent.paymentUrl)).send(payment); } } } @Override protected void onInsufficientMoney(@Nullable final BigInteger missing) { state = State.INPUT; updateView(); final BigInteger estimated = wallet.getBalance(BalanceType.ESTIMATED); final BigInteger available = wallet.getBalance(BalanceType.AVAILABLE); final BigInteger pending = estimated.subtract(available); final int btcShift = config.getBtcShift(); final int btcPrecision = config.getBtcMaxPrecision(); final String btcPrefix = config.getBtcPrefix(); final DialogBuilder dialog = DialogBuilder.warn(activity, R.string.send_coins_fragment_insufficient_money_title); final StringBuilder msg = new StringBuilder(); if (missing != null) msg.append(getString(R.string.send_coins_fragment_insufficient_money_msg1, btcPrefix + ' ' + GenericUtils.formatValue(missing, btcPrecision, btcShift))) .append("\n\n"); if (pending.signum() > 0) msg.append(getString(R.string.send_coins_fragment_pending, btcPrefix + ' ' + GenericUtils.formatValue(pending, btcPrecision, btcShift))) .append("\n\n"); msg.append(getString(R.string.send_coins_fragment_insufficient_money_msg2)); dialog.setMessage(msg); dialog.setPositiveButton(R.string.send_coins_options_empty, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { handleEmpty(); } }); dialog.setNegativeButton(R.string.button_cancel, null); dialog.show(); } @Override protected void onFailure(@Nonnull Exception exception) { state = State.FAILED; updateView(); final DialogBuilder dialog = DialogBuilder.warn(activity, R.string.send_coins_error_msg); dialog.setMessage(exception.toString()); dialog.setNeutralButton(R.string.button_dismiss, null); dialog.show(); } }.sendCoinsOffline(sendRequest); // send asynchronously }
From source file:ja.ohac.wallet.ui.send.SendCoinsFragment.java
private void handleGo() { state = State.PREPARATION;/* w w w. ja va 2 s . co m*/ updateView(); // final payment intent final PaymentIntent finalPaymentIntent = paymentIntent.mergeWithEditedValues( amountCalculatorLink.getAmount(), validatedAddress != null ? validatedAddress.address : null); final BigInteger finalAmount = finalPaymentIntent.getAmount(); // prepare send request final SendRequest sendRequest = finalPaymentIntent.toSendRequest(); final Address returnAddress = WalletUtils.pickOldestKey(wallet).toAddress(Constants.NETWORK_PARAMETERS); sendRequest.changeAddress = returnAddress; sendRequest.emptyWallet = paymentIntent.mayEditAmount() && finalAmount.equals(wallet.getBalance(BalanceType.AVAILABLE)); new SendCoinsOfflineTask(wallet, backgroundHandler) { @Override protected void onSuccess(final Transaction transaction) { sentTransaction = transaction; state = State.SENDING; updateView(); sentTransaction.getConfidence().addEventListener(sentTransactionConfidenceListener); final Payment payment = PaymentProtocol.createPaymentMessage(sentTransaction, returnAddress, finalAmount, null, paymentIntent.payeeData); directPay(payment); application.broadcastTransaction(sentTransaction); final ComponentName callingActivity = activity.getCallingActivity(); if (callingActivity != null) { log.info("returning result to calling activity: {}", callingActivity.flattenToString()); final Intent result = new Intent(); BitcoinIntegration.transactionHashToResult(result, sentTransaction.getHashAsString()); if (paymentIntent.standard == Standard.BIP70) BitcoinIntegration.paymentToResult(result, payment.toByteArray()); activity.setResult(Activity.RESULT_OK, result); } } private void directPay(final Payment payment) { if (directPaymentEnableView.isChecked()) { final DirectPaymentTask.ResultCallback callback = new DirectPaymentTask.ResultCallback() { @Override public void onResult(final boolean ack) { directPaymentAck = ack; if (state == State.SENDING) state = State.SENT; updateView(); } @Override public void onFail(final int messageResId, final Object... messageArgs) { final DialogBuilder dialog = DialogBuilder.warn(activity, R.string.send_coins_fragment_direct_payment_failed_title); dialog.setMessage(paymentIntent.paymentUrl + "\n" + getString(messageResId, messageArgs) + "\n\n" + getString(R.string.send_coins_fragment_direct_payment_failed_msg)); dialog.setPositiveButton(R.string.button_retry, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { directPay(payment); } }); dialog.setNegativeButton(R.string.button_dismiss, null); dialog.show(); } }; if (paymentIntent.isHttpPaymentUrl()) { new DirectPaymentTask.HttpPaymentTask(backgroundHandler, callback, paymentIntent.paymentUrl, application.httpUserAgent()).send(payment); } else if (paymentIntent.isBluetoothPaymentUrl() && bluetoothAdapter != null && bluetoothAdapter.isEnabled()) { new DirectPaymentTask.BluetoothPaymentTask(backgroundHandler, callback, bluetoothAdapter, Bluetooth.getBluetoothMac(paymentIntent.paymentUrl)).send(payment); } } } @Override protected void onInsufficientMoney(@Nullable final BigInteger missing) { state = State.INPUT; updateView(); final Coin estimated = wallet.getBalance(BalanceType.ESTIMATED); final Coin available = wallet.getBalance(BalanceType.AVAILABLE); final Coin pending = estimated.subtract(available); final int btcShift = config.getBtcShift(); final int btcPrecision = config.getBtcMaxPrecision(); final String btcPrefix = config.getBtcPrefix(); final DialogBuilder dialog = DialogBuilder.warn(activity, R.string.send_coins_fragment_insufficient_money_title); final StringBuilder msg = new StringBuilder(); if (missing != null) msg.append(getString(R.string.send_coins_fragment_insufficient_money_msg1, btcPrefix + ' ' + GenericUtils.formatValue(missing, btcPrecision, btcShift))) .append("\n\n"); if (pending.signum() > 0) msg.append( getString(R.string.send_coins_fragment_pending, btcPrefix + ' ' + GenericUtils.formatValue( BigInteger.valueOf(pending.longValue()), btcPrecision, btcShift))) .append("\n\n"); msg.append(getString(R.string.send_coins_fragment_insufficient_money_msg2)); dialog.setMessage(msg); dialog.setPositiveButton(R.string.send_coins_options_empty, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { handleEmpty(); } }); dialog.setNegativeButton(R.string.button_cancel, null); dialog.show(); } @Override protected void onFailure(@Nonnull Exception exception) { state = State.FAILED; updateView(); final DialogBuilder dialog = DialogBuilder.warn(activity, R.string.send_coins_error_msg); dialog.setMessage(exception.toString()); dialog.setNeutralButton(R.string.button_dismiss, null); dialog.show(); } }.sendCoinsOffline(sendRequest); // send asynchronously }
From source file:com.hamradiocoin.wallet.ui.send.SendCoinsFragment.java
private void handleGo() { state = State.PREPARATION;/*w w w. j a va2 s. co m*/ updateView(); // final payment intent final PaymentIntent finalPaymentIntent = paymentIntent.mergeWithEditedValues( amountCalculatorLink.getAmount(), validatedAddress != null ? validatedAddress.address : null); final BigInteger finalAmount = finalPaymentIntent.getAmount(); // prepare send request final SendRequest sendRequest = finalPaymentIntent.toSendRequest(); final Address returnAddress = WalletUtils.pickOldestKey(wallet).toAddress(Constants.NETWORK_PARAMETERS); sendRequest.changeAddress = returnAddress; sendRequest.emptyWallet = paymentIntent.mayEditAmount() && finalAmount.equals(wallet.getBalance(BalanceType.AVAILABLE)); new SendCoinsOfflineTask(wallet, backgroundHandler) { @Override protected void onSuccess(final Transaction transaction) { sentTransaction = transaction; state = State.SENDING; updateView(); sentTransaction.getConfidence().addEventListener(sentTransactionConfidenceListener); final Payment payment = PaymentProtocol.createPaymentMessage(sentTransaction, returnAddress, finalAmount, null, paymentIntent.payeeData); directPay(payment); application.broadcastTransaction(sentTransaction); final ComponentName callingActivity = activity.getCallingActivity(); if (callingActivity != null) { log.info("returning result to calling activity: {}", callingActivity.flattenToString()); final Intent result = new Intent(); BitcoinIntegration.transactionHashToResult(result, sentTransaction.getHashAsString()); if (paymentIntent.standard == PaymentIntent.Standard.BIP70) BitcoinIntegration.paymentToResult(result, payment.toByteArray()); activity.setResult(Activity.RESULT_OK, result); } } private void directPay(final Payment payment) { if (directPaymentEnableView.isChecked()) { final DirectPaymentTask.ResultCallback callback = new DirectPaymentTask.ResultCallback() { @Override public void onResult(final boolean ack) { directPaymentAck = ack; if (state == State.SENDING) state = State.SENT; updateView(); } @Override public void onFail(final int messageResId, final Object... messageArgs) { final DialogBuilder dialog = DialogBuilder.warn(activity, R.string.send_coins_fragment_direct_payment_failed_title); dialog.setMessage(paymentIntent.paymentUrl + "\n" + getString(messageResId, messageArgs) + "\n\n" + getString(R.string.send_coins_fragment_direct_payment_failed_msg)); dialog.setPositiveButton(R.string.button_retry, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { directPay(payment); } }); dialog.setNegativeButton(R.string.button_dismiss, null); dialog.show(); } }; if (paymentIntent.isHttpPaymentUrl()) { new DirectPaymentTask.HttpPaymentTask(backgroundHandler, callback, paymentIntent.paymentUrl, application.httpUserAgent()).send(payment); } else if (paymentIntent.isBluetoothPaymentUrl() && bluetoothAdapter != null && bluetoothAdapter.isEnabled()) { new DirectPaymentTask.BluetoothPaymentTask(backgroundHandler, callback, bluetoothAdapter, Bluetooth.getBluetoothMac(paymentIntent.paymentUrl)).send(payment); } } } @Override protected void onInsufficientMoney(@Nullable final BigInteger missing) { state = State.INPUT; updateView(); final BigInteger estimated = wallet.getBalance(BalanceType.ESTIMATED); final BigInteger available = wallet.getBalance(BalanceType.AVAILABLE); final BigInteger pending = estimated.subtract(available); final int btcShift = config.getBtcShift(); final int btcPrecision = config.getBtcMaxPrecision(); final String btcPrefix = config.getBtcPrefix(); final DialogBuilder dialog = DialogBuilder.warn(activity, R.string.send_coins_fragment_insufficient_money_title); final StringBuilder msg = new StringBuilder(); if (missing != null) msg.append(getString(R.string.send_coins_fragment_insufficient_money_msg1, btcPrefix + ' ' + GenericUtils.formatValue(missing, btcPrecision, btcShift))) .append("\n\n"); if (pending.signum() > 0) msg.append(getString(R.string.send_coins_fragment_pending, btcPrefix + ' ' + GenericUtils.formatValue(pending, btcPrecision, btcShift))) .append("\n\n"); msg.append(getString(R.string.send_coins_fragment_insufficient_money_msg2)); dialog.setMessage(msg); dialog.setPositiveButton(R.string.send_coins_options_empty, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { handleEmpty(); } }); dialog.setNegativeButton(R.string.button_cancel, null); dialog.show(); } @Override protected void onFailure(@Nonnull Exception exception) { state = State.FAILED; updateView(); final DialogBuilder dialog = DialogBuilder.warn(activity, R.string.send_coins_error_msg); dialog.setMessage(exception.toString()); dialog.setNeutralButton(R.string.button_dismiss, null); dialog.show(); } }.sendCoinsOffline(sendRequest); // send asynchronously }
From source file:com.linkbubble.Settings.java
private void addDefaultApp(String host, ComponentName componentName, boolean save) { mDefaultAppsMap.put(host, componentName.flattenToString()); if (save) {//from w ww. j av a2s . co m saveDefaultApps(); } }
From source file:de.langerhans.wallet.ui.SendCoinsFragment.java
private void handleGo() { state = State.PREPARATION;/*w w w. j a va 2 s.c om*/ updateView(); // final payment intent final PaymentIntent finalPaymentIntent = paymentIntent.mergeWithEditedValues( amountCalculatorLink.getAmount(), validatedAddress != null ? validatedAddress.address : null); final BigInteger finalAmount = finalPaymentIntent.getAmount(); // prepare send request final SendRequest sendRequest = finalPaymentIntent.toSendRequest(); final Address returnAddress = WalletUtils.pickOldestKey(wallet).toAddress(Constants.NETWORK_PARAMETERS); sendRequest.changeAddress = returnAddress; sendRequest.emptyWallet = paymentIntent.mayEditAmount() && finalAmount.equals(wallet.getBalance(BalanceType.AVAILABLE)); //Emptying a wallet with less than 2 DOGE can't be possible due to min fee 2 DOGE of such a tx. /* if (amount.compareTo(BigInteger.valueOf(200000000)) < 0 && sendRequest.emptyWallet) { AlertDialog.Builder bld = new AlertDialog.Builder(activity); bld.setTitle(R.string.send_coins_error_msg); bld.setMessage(R.string.send_coins_error_desc); bld.setNeutralButton(activity.getResources().getString(android.R.string.ok), null); bld.setCancelable(false); bld.create().show(); state = State.FAILED; updateView(); return; }*/ new SendCoinsOfflineTask(wallet, backgroundHandler) { @Override protected void onSuccess(final Transaction transaction) { sentTransaction = transaction; state = State.SENDING; updateView(); sentTransaction.getConfidence().addEventListener(sentTransactionConfidenceListener); final Payment payment = PaymentProtocol.createPaymentMessage(sentTransaction, returnAddress, finalAmount, null, paymentIntent.payeeData); directPay(payment); application.broadcastTransaction(sentTransaction); final ComponentName callingActivity = activity.getCallingActivity(); if (callingActivity != null) { log.info("returning result to calling activity: {}", callingActivity.flattenToString()); final Intent result = new Intent(); BitcoinIntegration.transactionHashToResult(result, sentTransaction.getHashAsString()); if (paymentIntent.standard == Standard.BIP70) BitcoinIntegration.paymentToResult(result, payment.toByteArray()); activity.setResult(Activity.RESULT_OK, result); } } private void directPay(final Payment payment) { if (directPaymentEnableView.isChecked()) { final DirectPaymentTask.ResultCallback callback = new DirectPaymentTask.ResultCallback() { @Override public void onResult(final boolean ack) { directPaymentAck = ack; if (state == State.SENDING) state = State.SENT; updateView(); } @Override public void onFail(final int messageResId, final Object... messageArgs) { final DialogBuilder dialog = DialogBuilder.warn(activity, R.string.send_coins_fragment_direct_payment_failed_title); dialog.setMessage(paymentIntent.paymentUrl + "\n" + getString(messageResId, messageArgs) + "\n\n" + getString(R.string.send_coins_fragment_direct_payment_failed_msg)); dialog.setPositiveButton(R.string.button_retry, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { directPay(payment); } }); dialog.setNegativeButton(R.string.button_dismiss, null); dialog.show(); } }; if (paymentIntent.isHttpPaymentUrl()) { new DirectPaymentTask.HttpPaymentTask(backgroundHandler, callback, paymentIntent.paymentUrl, application.httpUserAgent()).send(payment); } else if (paymentIntent.isBluetoothPaymentUrl() && bluetoothAdapter != null && bluetoothAdapter.isEnabled()) { new DirectPaymentTask.BluetoothPaymentTask(backgroundHandler, callback, bluetoothAdapter, Bluetooth.getBluetoothMac(paymentIntent.paymentUrl)).send(payment); } } } @Override protected void onInsufficientMoney(@Nullable final BigInteger missing) { state = State.INPUT; updateView(); final BigInteger estimated = wallet.getBalance(BalanceType.ESTIMATED); final BigInteger available = wallet.getBalance(BalanceType.AVAILABLE); final BigInteger pending = estimated.subtract(available); final int btcShift = config.getBtcShift(); final int btcPrecision = config.getBtcMaxPrecision(); final String btcPrefix = config.getBtcPrefix(); final DialogBuilder dialog = DialogBuilder.warn(activity, R.string.send_coins_fragment_insufficient_money_title); final StringBuilder msg = new StringBuilder(); if (missing != null) msg.append(String.format(getString(R.string.send_coins_fragment_insufficient_money_msg1), btcPrefix + ' ' + GenericUtils.formatValue(missing, btcPrecision, btcShift))) .append("\n\n"); if (pending.signum() > 0) msg.append(getString(R.string.send_coins_fragment_pending, GenericUtils.formatValue(pending, btcPrecision, btcShift))).append("\n\n"); msg.append(getString(R.string.send_coins_fragment_insufficient_money_msg2)); dialog.setMessage(msg); dialog.setPositiveButton(R.string.send_coins_options_empty, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { handleEmpty(); } }); dialog.setNegativeButton(R.string.button_cancel, null); dialog.show(); } @Override protected void onFailure() { state = State.FAILED; updateView(); activity.longToast(R.string.send_coins_error_msg); } }.sendCoinsOffline(sendRequest); // send asynchronously }
From source file:org.hopestarter.wallet.ui.send.SendCoinsFragment.java
private void signAndSendPayment(final KeyParameter encryptionKey) { setState(State.SIGNING);/*from w w w.jav a 2 s. c om*/ // final payment intent final PaymentIntent finalPaymentIntent = paymentIntent.mergeWithEditedValues( amountCalculatorLink.getAmount(), validatedAddress != null ? validatedAddress.address : null); final Coin finalAmount = finalPaymentIntent.getAmount(); // prepare send request final SendRequest sendRequest = finalPaymentIntent.toSendRequest(); sendRequest.emptyWallet = paymentIntent.mayEditAmount() && finalAmount.equals(wallet.getBalance(BalanceType.AVAILABLE)); sendRequest.feePerKb = feeCategory.feePerKb; sendRequest.memo = paymentIntent.memo; sendRequest.exchangeRate = amountCalculatorLink.getExchangeRate(); sendRequest.aesKey = encryptionKey; new SendCoinsOfflineTask(wallet, backgroundHandler) { @Override protected void onSuccess(final Transaction transaction) { sentTransaction = transaction; setState(State.SENDING); sentTransaction.getConfidence().addEventListener(sentTransactionConfidenceListener); final Address refundAddress = paymentIntent.standard == Standard.BIP70 ? wallet.freshAddress(KeyPurpose.REFUND) : null; final Payment payment = PaymentProtocol.createPaymentMessage( Arrays.asList(new Transaction[] { sentTransaction }), finalAmount, refundAddress, null, paymentIntent.payeeData); if (directPaymentEnableView.isChecked()) directPay(payment); application.broadcastTransaction(sentTransaction); final ComponentName callingActivity = activity.getCallingActivity(); if (callingActivity != null) { log.info("returning result to calling activity: {}", callingActivity.flattenToString()); final Intent result = new Intent(); BitcoinIntegration.transactionHashToResult(result, sentTransaction.getHashAsString()); if (paymentIntent.standard == Standard.BIP70) BitcoinIntegration.paymentToResult(result, payment.toByteArray()); activity.setResult(Activity.RESULT_OK, result); } } private void directPay(final Payment payment) { final DirectPaymentTask.ResultCallback callback = new DirectPaymentTask.ResultCallback() { @Override public void onResult(final boolean ack) { directPaymentAck = ack; if (state == State.SENDING) setState(State.SENT); updateView(); } @Override public void onFail(final int messageResId, final Object... messageArgs) { final DialogBuilder dialog = DialogBuilder.warn(activity, R.string.send_coins_fragment_direct_payment_failed_title); dialog.setMessage(paymentIntent.paymentUrl + "\n" + getString(messageResId, messageArgs) + "\n\n" + getString(R.string.send_coins_fragment_direct_payment_failed_msg)); dialog.setPositiveButton(R.string.button_retry, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { directPay(payment); } }); dialog.setNegativeButton(R.string.button_dismiss, null); dialog.show(); } }; if (paymentIntent.isHttpPaymentUrl()) { new DirectPaymentTask.HttpPaymentTask(backgroundHandler, callback, paymentIntent.paymentUrl, application.httpUserAgent()).send(payment); } else if (paymentIntent.isBluetoothPaymentUrl() && bluetoothAdapter != null && bluetoothAdapter.isEnabled()) { new DirectPaymentTask.BluetoothPaymentTask(backgroundHandler, callback, bluetoothAdapter, Bluetooth.getBluetoothMac(paymentIntent.paymentUrl)).send(payment); } } @Override protected void onInsufficientMoney(final Coin missing) { setState(State.INPUT); final Coin estimated = wallet.getBalance(BalanceType.ESTIMATED); final Coin available = wallet.getBalance(BalanceType.AVAILABLE); final Coin pending = estimated.subtract(available); final MonetaryFormat btcFormat = config.getFormat(); final DialogBuilder dialog = DialogBuilder.warn(activity, R.string.send_coins_fragment_insufficient_money_title); final StringBuilder msg = new StringBuilder(); msg.append( getString(R.string.send_coins_fragment_insufficient_money_msg1, btcFormat.format(missing))); if (pending.signum() > 0) msg.append("\n\n") .append(getString(R.string.send_coins_fragment_pending, btcFormat.format(pending))); if (paymentIntent.mayEditAmount()) msg.append("\n\n").append(getString(R.string.send_coins_fragment_insufficient_money_msg2)); dialog.setMessage(msg); if (paymentIntent.mayEditAmount()) { dialog.setPositiveButton(R.string.send_coins_options_empty, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { handleEmpty(); } }); dialog.setNegativeButton(R.string.button_cancel, null); } else { dialog.setNeutralButton(R.string.button_dismiss, null); } dialog.show(); } @Override protected void onInvalidKey() { setState(State.INPUT); privateKeyBadPasswordView.setVisibility(View.VISIBLE); privateKeyPasswordView.requestFocus(); } @Override protected void onEmptyWalletFailed() { setState(State.INPUT); final DialogBuilder dialog = DialogBuilder.warn(activity, R.string.send_coins_fragment_empty_wallet_failed_title); dialog.setMessage(R.string.send_coins_fragment_hint_empty_wallet_failed); dialog.setNeutralButton(R.string.button_dismiss, null); dialog.show(); } @Override protected void onFailure(Exception exception) { setState(State.FAILED); final DialogBuilder dialog = DialogBuilder.warn(activity, R.string.send_coins_error_msg); dialog.setMessage(exception.toString()); dialog.setNeutralButton(R.string.button_dismiss, null); dialog.show(); } }.sendCoinsOffline(sendRequest); // send asynchronously }
From source file:com.cognizant.trumobi.PersonaLauncher.java
private void updateCounters(View view, String packageName, int counter, int color, int updateCounterFor) { Object tag = view.getTag();//from w ww . j a va2s .co m //PersonaLog.d("personalauncher","------- view is ---- "+ view.toString()); if (tag != null) //PersonaLog.d("personalauncher","------- tag is ---- "+ tag.toString()); if (tag instanceof PersonaApplicationInfo) { PersonaApplicationInfo info = (PersonaApplicationInfo) tag; // We need to check for ACTION_MAIN otherwise getComponent() might // return null for some shortcuts (for instance, for shortcuts to // web pages.) final Intent intent = info.intent; final ComponentName name = intent.getComponent(); // PersonaLog.d("Personalauncher","name " + name.flattenToString()); //Badge switch (updateCounterFor) { case UPDATE_COUNTERS_FOR_DIALER: if (name.flattenToString().contains("DialerParentActivity")) { //BADGE - below lines from if loop below added since that if loop fails if (view instanceof PersonaCounterImageView) ((PersonaCounterImageView) view).setCounter(counter, color); // else if view.invalidate(); sModel.updateCounterDesktopItem(info, counter, color); //BADGE ends } break; case UPDATE_COUNTERS_FOR_MESSENGER: if (name.flattenToString().contains("SmsListdisplay")) { //BADGE - below lines from if loop below added since that if loop fails if (view instanceof PersonaCounterImageView) ((PersonaCounterImageView) view).setCounter(counter, color); // else if view.invalidate(); sModel.updateCounterDesktopItem(info, counter, color); //BADGE ends } break; } if ((info.itemType == PersonaLauncherSettings.Favorites.ITEM_TYPE_APPLICATION || info.itemType == PersonaLauncherSettings.Favorites.ITEM_TYPE_SHORTCUT) && Intent.ACTION_MAIN.equals(intent.getAction()) && name != null && packageName.equals(name.getPackageName())) { if (view instanceof PersonaCounterImageView) ((PersonaCounterImageView) view).setCounter(counter, color); // else if view.invalidate(); sModel.updateCounterDesktopItem(info, counter, color); } } else { //PersonaLog.d("personalauncher","------ tag is not an instance of personaApplicationInfo-----"); //if(tag != null) // PersonaLog.d("personalauncher","------- tag not an instance of personaapplicationinfo ---- "+ tag.toString()); } }