Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/src/main/java/com/bitcoin/merchant/app/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ open class MainActivity : AppCompatActivity(), WebSocketListener {
if (!payment.isUnderpayment && !payment.isOverpayment) {
Log.d(TAG, "${payment.txHash} has been received.")
val i = Intent(Action.ACKNOWLEDGE_BIP21_PAYMENT)
payment.toIntent(i)
LocalBroadcastManager.getInstance(this).sendBroadcast(i)
} else {
if (payment.isUnderpayment) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import com.bitcoin.merchant.app.currency.CurrencyExchange
import com.bitcoin.merchant.app.model.Analytics
import com.bitcoin.merchant.app.model.PaymentTarget
import com.bitcoin.merchant.app.network.ExpectedPayments
import com.bitcoin.merchant.app.network.PaymentReceived
import com.bitcoin.merchant.app.screens.dialogs.DialogHelper
import com.bitcoin.merchant.app.screens.dialogs.SnackHelper
import com.bitcoin.merchant.app.screens.features.ToolbarAwareFragment
Expand Down Expand Up @@ -65,6 +66,7 @@ class PaymentRequestFragment : ToolbarAwareFragment() {
private lateinit var ivReceivingQr: ImageView
private lateinit var progressLayout: LinearLayout
private lateinit var ivCancel: ImageView
private lateinit var ivReceipt: Button
private lateinit var ivDone: Button
private lateinit var bip70Manager: Bip70Manager
private lateinit var bip70PayService: Bip70PayService
Expand All @@ -89,7 +91,9 @@ class PaymentRequestFragment : ToolbarAwareFragment() {
bip70Manager.reconnectIfNecessary()
}
if (Action.ACKNOWLEDGE_BIP21_PAYMENT == intent.action) {
showCheckMark()
val paymentReceived = PaymentReceived(intent)
val receiptHtml = PrintUtil.createReceiptHtml(activity, paymentReceived)
showCheckMark(receiptHtml)
soundAlert()
}
}
Expand Down Expand Up @@ -126,7 +130,8 @@ class PaymentRequestFragment : ToolbarAwareFragment() {
Log.i(TAG, "record new Tx:$i")
val fiatFormatted = AmountUtil(activity).formatFiat(i.fiatTotal)
app.paymentProcessor.recordInDatabase(i, fiatFormatted)
showCheckMark()
val receiptHtml = PrintUtil.createReceiptHtml(activity, i)
showCheckMark(receiptHtml)
soundAlert()
}

Expand Down Expand Up @@ -299,6 +304,7 @@ class PaymentRequestFragment : ToolbarAwareFragment() {
waitingLayout = v.findViewById(R.id.layout_waiting)
receivedLayout = v.findViewById(R.id.layout_complete)
ivCancel = v.findViewById(R.id.iv_cancel)
ivReceipt = v.findViewById(R.id.iv_receipt)
ivDone = v.findViewById(R.id.iv_done)
fabShare = v.findViewById(R.id.fab_share)
ivCancel.setOnClickListener { deleteActiveInvoiceAndExitScreen() }
Expand Down Expand Up @@ -495,7 +501,7 @@ class PaymentRequestFragment : ToolbarAwareFragment() {
}.start()
}

private fun showCheckMark() {
private fun showCheckMark(receiptHtml: String) {
tvConnectionStatus.visibility = View.GONE // hide it white top bar on green background
waitingLayout.visibility = View.GONE
receivedLayout.visibility = View.VISIBLE
Expand All @@ -505,12 +511,16 @@ class PaymentRequestFragment : ToolbarAwareFragment() {
if(bip21Address != null) {
ExpectedPayments.getInstance().removePayment(bip21Address)
}
ivReceipt.setOnClickListener {
PrintUtil.printHtml(activity, receiptHtml)
}
ivDone.setOnClickListener {
AppUtil.setStatusBarColor(activity, R.color.gray)
exitScreen()
}
}


private fun setInvoiceReadyToShare(ready: Boolean) {
if (ready) {
fabShare.backgroundTintList = ColorStateList.valueOf(ContextCompat.getColor(app, R.color.bitcoindotcom_green))
Expand Down
Loading