Skip to content

Commit

Permalink
Android: if a URI doesn't contain a field, leave existing values in t…
Browse files Browse the repository at this point in the history
…hat field unchanged
  • Loading branch information
mhsmith committed Jan 6, 2021
1 parent 0b3fb89 commit 8c4af1e
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions android/app/src/main/java/org/electroncash/electroncash3/Send.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ val MIN_FEE = 1 // sat/byte
class SendDialog : TaskLauncherDialog<Unit>() {
val wallet = daemonModel.wallet!!

init {
// The SendDialog shouldn't be dismissed until the SendPasswordDialog succeeds.
dismissAfterExecute = false
}

class Model : ViewModel() {
var paymentRequest: PyObject? = null
val tx = BackgroundLiveData<TxArgs, TxResult>().apply {
Expand All @@ -47,6 +42,9 @@ class SendDialog : TaskLauncherDialog<Unit>() {
var settingAmount = false // Prevent infinite recursion.

init {
// The SendDialog shouldn't be dismissed until the SendPasswordDialog succeeds.
dismissAfterExecute = false

if (daemonModel.wallet!!.callAttr("is_watching_only").toBoolean()) {
throw ToastException(R.string.this_wallet_is)
} else if (daemonModel.wallet!!.callAttr("get_receiving_addresses")
Expand Down Expand Up @@ -240,9 +238,9 @@ class SendDialog : TaskLauncherDialog<Unit>() {
showDialog(this, GetPaymentRequestDialog(r.toString()))
} else {
setPaymentRequest(null)
etAddress.setText(parsed.callAttr("get", "address")?.toString() ?: "")
etDescription.setText(parsed.callAttr("get", "message")?.toString() ?: "")
amountBox.amount = parsed.callAttr("get", "amount")?.toLong()
parsed.callAttr("get", "address")?.let { etAddress.setText(it.toString()) }
parsed.callAttr("get", "message")?.let { etDescription.setText(it.toString()) }
parsed.callAttr("get", "amount")?.let { amountBox.amount = it.toLong() }
amountBox.requestFocus()
btnMax.isChecked = false
}
Expand Down

0 comments on commit 8c4af1e

Please sign in to comment.