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 apps/flipcash/core/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@
<string name="title_insufficientBalance">Insufficient Balance</string>
<string name="description_insufficientBalanceToCreate">Add more money to create a currency</string>
<string name="description_insufficientBalanceToUse">Add more money, or enter a smaller amount</string>
<string name="description_insufficientBalanceToPayRequest">Add more money, or select a different Community Currency</string>
<string name="description_noBalanceYetToGive">Add money to give cash</string>
<string name="description_noBalanceYetToBuy">Add money to buy currencies</string>
<string name="description_noBalanceYetToSend">Add money to send cash</string>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.flipcash.app.messenger.internal.payment

import androidx.annotation.StringRes
import com.flipcash.analytics.AddMoneySource
import com.flipcash.analytics.State as AnalyticsState
import com.flipcash.analytics.events.AddMoneyEvents
Expand Down Expand Up @@ -53,7 +54,10 @@ internal interface StartChattingPayer {
suspend fun mayProceed(onAddMoney: () -> Unit, onDiscoverCurrencies: () -> Unit): Boolean

/** Over balance, with something in the account. [onAddMoney] is the alert's action. */
fun presentInsufficientBalance(onAddMoney: () -> Unit)
fun presentInsufficientBalance(
onAddMoney: () -> Unit,
@StringRes message: Int = R.string.description_insufficientBalanceToUse,
)

/** The deposit screen to open for an "Add Money" action, or null when there is none to open. */
suspend fun depositRoute(): AppRoute?
Expand Down Expand Up @@ -113,10 +117,10 @@ internal class DefaultStartChattingPayer @Inject constructor(
return false
}

override fun presentInsufficientBalance(onAddMoney: () -> Unit) {
override fun presentInsufficientBalance(onAddMoney: () -> Unit, @StringRes message: Int) {
BottomBarManager.showInfo(
title = resources.getString(R.string.title_insufficientBalance),
message = resources.getString(R.string.description_insufficientBalanceToUse),
message = resources.getString(message),
actions = listOf(
BottomBarAction(text = resources.getString(R.string.action_addMoney)) { onAddMoney() },
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,11 @@ internal class RequestPayFlow(
}

private fun present(block: PayBlock) = when (block) {
PayBlock.OverBalance -> payer.presentInsufficientBalance(onAddMoney = ::presentDeposit)
PayBlock.OverBalance -> payer.presentInsufficientBalance(
onAddMoney = ::presentDeposit,
// A share is a fixed amount, so the way out is another currency, not a smaller amount.
message = R.string.description_insufficientBalanceToPayRequest,
)
PayBlock.OverSendLimit -> BottomBarManager.showAlert(
resources.getString(R.string.error_title_sendLimitReached),
resources.getString(R.string.error_description_sendLimitReached),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class RequestDetailsInsufficientFundsTest {
vm.payTapped()

assertEquals(true, vm.pay.value.open)
verify(exactly = 0) { payer.presentInsufficientBalance(any()) }
verify(exactly = 0) { payer.presentInsufficientBalance(any(), any()) }
}

@Test
Expand All @@ -123,7 +123,7 @@ class RequestDetailsInsufficientFundsTest {
vm.payTapped()

assertEquals(true, vm.pay.value.open)
verify(exactly = 0) { payer.presentInsufficientBalance(any()) }
verify(exactly = 0) { payer.presentInsufficientBalance(any(), any()) }
}

@Test
Expand All @@ -137,7 +137,7 @@ class RequestDetailsInsufficientFundsTest {
vm.confirmPay()

assertEquals(true, vm.pay.value.open)
verify(exactly = 1) { payer.presentInsufficientBalance(any()) }
verify(exactly = 1) { payer.presentInsufficientBalance(any(), any()) }
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class RequestPayFlowTest {
f.start(listOf<Byte>(2))

assertEquals(true, f.state.value.open)
verify(exactly = 0) { payer.presentInsufficientBalance(any()) }
verify(exactly = 0) { payer.presentInsufficientBalance(any(), any()) }
}

@Test
Expand All @@ -114,7 +114,7 @@ class RequestPayFlowTest {
f.confirm()

assertEquals(true, f.state.value.open)
verify(exactly = 1) { payer.presentInsufficientBalance(any()) }
verify(exactly = 1) { payer.presentInsufficientBalance(any(), any()) }
coVerify(exactly = 0) { payments.pay(any(), any(), any()) }
}

Expand Down
Loading