mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 18:00:02 +01:00
Add cancellation support and renew support for canceled subscriptions.
This commit is contained in:
committed by
Cody Henthorne
parent
1aa2c85edd
commit
fc5aae34f3
@@ -810,28 +810,44 @@ private fun BackupCard(
|
||||
)
|
||||
}
|
||||
|
||||
val buttonText = when (messageBackupsType) {
|
||||
is MessageBackupsType.Paid -> stringResource(R.string.RemoteBackupsSettingsFragment__manage_or_cancel)
|
||||
is MessageBackupsType.Free -> stringResource(R.string.RemoteBackupsSettingsFragment__upgrade)
|
||||
}
|
||||
|
||||
if (backupState.isActive()) {
|
||||
Buttons.LargeTonal(
|
||||
onClick = { onBackupTypeActionButtonClicked(messageBackupsType.tier) },
|
||||
colors = ButtonDefaults.filledTonalButtonColors().copy(
|
||||
containerColor = SignalTheme.colors.colorTransparent5,
|
||||
contentColor = colorResource(R.color.signal_light_colorOnSurface)
|
||||
),
|
||||
modifier = Modifier.padding(top = 12.dp)
|
||||
) {
|
||||
Text(
|
||||
text = buttonText
|
||||
)
|
||||
val buttonText = when (messageBackupsType) {
|
||||
is MessageBackupsType.Paid -> stringResource(R.string.RemoteBackupsSettingsFragment__manage_or_cancel)
|
||||
is MessageBackupsType.Free -> stringResource(R.string.RemoteBackupsSettingsFragment__upgrade)
|
||||
}
|
||||
|
||||
CallToActionButton(
|
||||
text = buttonText,
|
||||
onClick = { onBackupTypeActionButtonClicked(messageBackupsType.tier) }
|
||||
)
|
||||
} else if (backupState is RemoteBackupsSettingsState.BackupState.Canceled) {
|
||||
CallToActionButton(
|
||||
text = stringResource(R.string.RemoteBackupsSettingsFragment__renew),
|
||||
onClick = { onBackupTypeActionButtonClicked(MessageBackupTier.FREE) }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun CallToActionButton(
|
||||
text: String,
|
||||
onClick: () -> Unit
|
||||
) {
|
||||
Buttons.LargeTonal(
|
||||
onClick = onClick,
|
||||
colors = ButtonDefaults.filledTonalButtonColors().copy(
|
||||
containerColor = SignalTheme.colors.colorTransparent5,
|
||||
contentColor = colorResource(R.color.signal_light_colorOnSurface)
|
||||
),
|
||||
modifier = Modifier.padding(top = 12.dp)
|
||||
) {
|
||||
Text(
|
||||
text = text
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun RedemptionErrorAlert(
|
||||
onDetailsClick: () -> Unit
|
||||
|
||||
@@ -321,19 +321,19 @@ class RemoteBackupsSettingsViewModel : ViewModel() {
|
||||
|
||||
val subscription = activeSubscription.getOrThrow().activeSubscription
|
||||
if (subscription != null) {
|
||||
Log.d(TAG, "Subscription found. Updating UI state with subscription details.")
|
||||
Log.d(TAG, "Subscription found. Updating UI state with subscription details. Status: ${subscription.status}")
|
||||
_state.update {
|
||||
it.copy(
|
||||
hasRedemptionError = lastPurchase?.data?.error?.data_ == "409",
|
||||
backupState = when {
|
||||
subscription.isActive -> RemoteBackupsSettingsState.BackupState.ActivePaid(
|
||||
subscription.isCanceled && subscription.isActive -> RemoteBackupsSettingsState.BackupState.Canceled(
|
||||
messageBackupsType = type,
|
||||
price = FiatMoney.fromSignalNetworkAmount(subscription.amount, Currency.getInstance(subscription.currency)),
|
||||
renewalTime = subscription.endOfCurrentPeriod.seconds
|
||||
)
|
||||
|
||||
subscription.isCanceled -> RemoteBackupsSettingsState.BackupState.Canceled(
|
||||
subscription.isActive -> RemoteBackupsSettingsState.BackupState.ActivePaid(
|
||||
messageBackupsType = type,
|
||||
price = FiatMoney.fromSignalNetworkAmount(subscription.amount, Currency.getInstance(subscription.currency)),
|
||||
renewalTime = subscription.endOfCurrentPeriod.seconds
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user