mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 13:08:46 +00:00
Fix checkout flow activity close on error.
This commit is contained in:
@@ -273,4 +273,8 @@ class MessageBackupsFlowFragment : ComposeFragment(), InAppPaymentCheckoutDelega
|
||||
override fun navigateToDonationPending(inAppPayment: InAppPaymentTable.InAppPayment) {
|
||||
// TODO [message-backups] What do? Are we even supporting bank transfers?
|
||||
}
|
||||
|
||||
override fun exitCheckoutFlow() {
|
||||
requireActivity().finishAfterTransition()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,4 +313,8 @@ class GiftFlowConfirmationFragment :
|
||||
override fun onUserLaunchedAnExternalApplication() = error("Not supported for gifts.")
|
||||
|
||||
override fun navigateToDonationPending(inAppPayment: InAppPaymentTable.InAppPayment) = error("Not supported for gifts")
|
||||
|
||||
override fun exitCheckoutFlow() {
|
||||
requireActivity().finishAfterTransition()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -528,4 +528,8 @@ class DonateToSignalFragment :
|
||||
override fun navigateToDonationPending(inAppPayment: InAppPaymentTable.InAppPayment) {
|
||||
findNavController().safeNavigate(DonateToSignalFragmentDirections.actionDonateToSignalFragmentToDonationPendingBottomSheet(inAppPayment))
|
||||
}
|
||||
|
||||
override fun exitCheckoutFlow() {
|
||||
requireActivity().finishAffinity()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import androidx.fragment.app.setFragmentResultListener
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.lifecycle.DefaultLifecycleObserver
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.navigation.navGraphViewModels
|
||||
import com.google.android.gms.wallet.PaymentData
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
@@ -139,7 +138,7 @@ class InAppPaymentCheckoutDelegate(
|
||||
.setTitle(R.string.DonationsErrors__failed_to_cancel_subscription)
|
||||
.setMessage(R.string.DonationsErrors__subscription_cancellation_requires_an_internet_connection)
|
||||
.setPositiveButton(android.R.string.ok) { _, _ ->
|
||||
fragment.findNavController().popBackStack(R.id.checkout_flow, true)
|
||||
callback.exitCheckoutFlow()
|
||||
}
|
||||
.show()
|
||||
} else {
|
||||
@@ -285,14 +284,17 @@ class InAppPaymentCheckoutDelegate(
|
||||
is DonationError.UserCancelledPaymentError -> {
|
||||
Log.d(TAG, "User cancelled out of payment flow.", true)
|
||||
}
|
||||
|
||||
is DonationError.BadgeRedemptionError.DonationPending -> {
|
||||
Log.d(TAG, "User launched an external application.", true)
|
||||
errorHandlerCallback?.onUserLaunchedAnExternalApplication()
|
||||
}
|
||||
|
||||
is DonationError.UserLaunchedExternalApplication -> {
|
||||
Log.d(TAG, "Long-running donation is still pending.", true)
|
||||
errorHandlerCallback?.navigateToDonationPending(inAppPayment)
|
||||
}
|
||||
|
||||
else -> {
|
||||
Log.d(TAG, "Displaying donation error dialog.", true)
|
||||
errorDialog = DonationErrorDialogs.show(
|
||||
@@ -353,7 +355,7 @@ class InAppPaymentCheckoutDelegate(
|
||||
errorDialog = null
|
||||
if (!tryAgain) {
|
||||
tryAgain = false
|
||||
fragment?.findNavController()?.popBackStack(R.id.checkout_flow, true)
|
||||
errorHandlerCallback?.exitCheckoutFlow()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -362,6 +364,7 @@ class InAppPaymentCheckoutDelegate(
|
||||
interface ErrorHandlerCallback {
|
||||
fun onUserLaunchedAnExternalApplication()
|
||||
fun navigateToDonationPending(inAppPayment: InAppPaymentTable.InAppPayment)
|
||||
fun exitCheckoutFlow()
|
||||
}
|
||||
|
||||
interface Callback : ErrorHandlerCallback {
|
||||
|
||||
@@ -163,6 +163,10 @@ class BankTransferDetailsFragment : ComposeFragment(), InAppPaymentCheckoutDeleg
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun exitCheckoutFlow() {
|
||||
requireActivity().finishAfterTransition()
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
|
||||
@@ -194,6 +194,10 @@ class IdealTransferDetailsFragment : ComposeFragment(), InAppPaymentCheckoutDele
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun exitCheckoutFlow() {
|
||||
requireActivity().finishAfterTransition()
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
|
||||
Reference in New Issue
Block a user