Skip to content

Commit d0e3c9d

Browse files
committed
(android) Relax rule for showing tipping button
Tipping should be available when the invoice specifies an amount, even if overpayment is disabled. Overpayment applies to manual editing of the amount input.
1 parent 36da8c7 commit d0e3c9d

10 files changed

Lines changed: 28 additions & 16 deletions

File tree

phoenix-android/src/main/kotlin/fr/acinq/phoenix/android/components/buttons/FilledButton.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ fun TransparentFilledButton(
106106
space: Dp = 12.dp,
107107
shape: Shape = RoundedCornerShape(12.dp),
108108
padding: PaddingValues = PaddingValues(12.dp),
109+
horizontalArrangement: Arrangement.Horizontal = Arrangement.Center,
109110
onClick: () -> Unit,
110111
) {
111112
FilledButton(
@@ -115,6 +116,7 @@ fun TransparentFilledButton(
115116
iconTint = iconTint,
116117
modifier = modifier, text = text, icon = icon, maxLines = maxLines, enabled = enabled,
117118
enabledEffect = enabledEffect, space = space, padding = padding, onClick = onClick,
119+
horizontalArrangement = horizontalArrangement,
118120
)
119121
}
120122

phoenix-android/src/main/kotlin/fr/acinq/phoenix/android/components/inputs/AmountHeroInput.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ import fr.acinq.phoenix.android.LocalBusiness
7676
import fr.acinq.phoenix.android.LocalExchangeRatesMap
7777
import fr.acinq.phoenix.android.LocalFiatCurrencies
7878
import fr.acinq.phoenix.android.R
79+
import fr.acinq.phoenix.android.components.HSeparator
7980
import fr.acinq.phoenix.android.components.buttons.BorderButton
8081
import fr.acinq.phoenix.android.components.buttons.Button
8182
import fr.acinq.phoenix.android.utils.borderColor
@@ -107,9 +108,9 @@ fun AmountHeroInput(
107108
inputModifier: Modifier = Modifier,
108109
dropdownModifier: Modifier = Modifier,
109110
inputTextSize: TextUnit = 16.sp,
110-
enabled: Boolean = true,
111-
canTip: Boolean = false,
112-
canSendLNBalance: Boolean = false,
111+
canEditAmount: Boolean,
112+
canTip: Boolean,
113+
canSendLNBalance: Boolean,
113114
) {
114115
val context = LocalContext.current
115116
val focusManager = LocalFocusManager.current
@@ -192,7 +193,6 @@ fun AmountHeroInput(
192193
is AmountConversionResult.Error.AmountNegative -> context.getString(R.string.send_error_amount_negative)
193194
}
194195
}
195-
196196
null -> {
197197
inputValueInMsat = null
198198
inputValueConvertedToAlt = ""
@@ -227,7 +227,7 @@ fun AmountHeroInput(
227227
),
228228
keyboardActions = KeyboardActions(onDone = { focusManager.clearFocus(); keyboardController?.hide() }),
229229
singleLine = true,
230-
enabled = enabled,
230+
enabled = canEditAmount,
231231
cursorBrush = SolidColor(MaterialTheme.colors.primary.copy(alpha = 0.7f))
232232
)
233233
}
@@ -256,15 +256,17 @@ fun AmountHeroInput(
256256
canAddMoreUnits = true,
257257
onDismiss = { },
258258
modifier = dropdownModifier,
259-
enabled = enabled,
259+
enabled = true,
260260
otherItems = if (canSendLNBalance) {
261261
{
262262
val peerManager = LocalBusiness.current?.peerManager
263263
val scope = rememberCoroutineScope()
264264
Spacer(Modifier.height(8.dp))
265+
HSeparator()
266+
Spacer(Modifier.height(8.dp))
265267
Box(modifier = Modifier.padding(horizontal = 8.dp)) {
266268
BorderButton(
267-
text = "Use all balance",
269+
text = stringResource(R.string.send_balance_use_all),
268270
icon = R.drawable.ic_arrow_to_end,
269271
onClick = {
270272
scope.launch {

phoenix-android/src/main/kotlin/fr/acinq/phoenix/android/components/inputs/UnitDropdown.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ fun UnitDropdown(
130130
Box(modifier = Modifier.padding(horizontal = 8.dp)) {
131131
BorderButton(
132132
text = stringResource(R.string.unitdropdown_more),
133-
icon = R.drawable.ic_plus_circle,
133+
icon = R.drawable.ic_settings,
134134
onClick = { showAddCurrencyDialog = true ; expanded = false },
135135
modifier = Modifier.fillMaxSize(),
136136
borderColor = borderColor,

phoenix-android/src/main/kotlin/fr/acinq/phoenix/android/payments/send/bolt11/SendToBolt11.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,14 @@ fun SendToBolt11View(
9595
topContent = {
9696
AmountHeroInput(
9797
initialAmount = requestedAmount,
98-
enabled = requestedAmount == null || isOverpaymentEnabled,
98+
canEditAmount = requestedAmount == null || isOverpaymentEnabled,
9999
onAmountChange = {
100100
amount = it?.amount
101101
},
102102
validationErrorMessage = amountErrorMessage,
103103
inputTextSize = 42.sp,
104-
canTip = requestedAmount != null && isOverpaymentEnabled,
105104
canSendLNBalance = requestedAmount == null,
105+
canTip = requestedAmount != null,
106106
)
107107
}
108108
) {

phoenix-android/src/main/kotlin/fr/acinq/phoenix/android/payments/send/lnurl/LnurlPayView.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ fun LnurlPayView(
110110
},
111111
validationErrorMessage = amountErrorMessage,
112112
inputTextSize = 42.sp,
113-
enabled = payIntent.minSendable != payIntent.maxSendable
113+
canEditAmount = payIntent.minSendable != payIntent.maxSendable,
114+
canTip = false,
115+
canSendLNBalance = false,
114116
)
115117
}
116118
) {

phoenix-android/src/main/kotlin/fr/acinq/phoenix/android/payments/send/lnurl/LnurlWithdrawView.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ fun LnurlWithdrawView(
9191
},
9292
validationErrorMessage = amountErrorMessage,
9393
inputTextSize = 42.sp,
94-
enabled = !isAmountDisabled,
94+
canEditAmount = !isAmountDisabled,
95+
canTip = false,
96+
canSendLNBalance = false,
9597
)
9698
}
9799
) {

phoenix-android/src/main/kotlin/fr/acinq/phoenix/android/payments/send/offer/SendOfferView.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,14 @@ fun SendToOfferView(
106106
topContent = {
107107
AmountHeroInput(
108108
initialAmount = requestedAmount,
109-
enabled = vm.state !is OfferState.FetchingInvoice,
109+
canEditAmount = vm.state !is OfferState.FetchingInvoice,
110110
onAmountChange = { newAmount ->
111111
if (newAmount?.amount != amount) vm.state = OfferState.Init
112112
amount = newAmount?.amount
113113
},
114114
validationErrorMessage = amountErrorMessage,
115115
inputTextSize = 42.sp,
116-
canTip = requestedAmount != null && isOverpaymentEnabled,
116+
canTip = requestedAmount != null,
117117
canSendLNBalance = requestedAmount == null,
118118
)
119119
}

phoenix-android/src/main/kotlin/fr/acinq/phoenix/android/payments/send/spliceout/SpliceOutView.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,10 @@ fun SendSpliceOutView(
125125
amount = newAmount
126126
},
127127
validationErrorMessage = amountErrorMessage,
128-
inputTextSize = 42.sp
128+
inputTextSize = 42.sp,
129+
canEditAmount = true,
130+
canTip = false,
131+
canSendLNBalance = false,
129132
)
130133
}
131134
) {

phoenix-android/src/main/kotlin/fr/acinq/phoenix/android/utils/images/QRCodeAnalyser.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class ZxingQrCodeAnalyzer(
7777
} catch (e: ChecksumException) {
7878
log.debug("QR code detected but checksum failed: ", e)
7979
} catch (e: FormatException) {
80-
log.warn("QR code detected but content does not match expectations: ", e)
80+
log.debug("QR code detected but content does not match expectations: ", e)
8181
} catch (e: Exception) {
8282
log.debug("error when decoding: ", e)
8383
}

phoenix-android/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@
154154
<!-- send -->
155155

156156
<string name="send_balance_prefix">Balance</string>
157+
<string name="send_balance_use_all">Use all balance</string>
157158
<string name="send_error_amount_too_large">Amount is too large.</string>
158159
<string name="send_error_amount_negative">Amount cannot be negative.</string>
159160
<string name="send_error_amount_invalid">This is not a valid amount.</string>

0 commit comments

Comments
 (0)