mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 18:00:02 +01:00
Add UI for when the user's grace period expires or while they are in the grace period.
This commit is contained in:
committed by
Cody Henthorne
parent
5e9824a180
commit
a6bfeebb24
@@ -165,7 +165,7 @@ class RemoteBackupsSettingsFragment : ComposeFragment() {
|
||||
@Stable
|
||||
private inner class Callbacks : ContentCallbacks {
|
||||
override fun onNavigationClick() {
|
||||
findNavController().popBackStack()
|
||||
requireActivity().onBackPressedDispatcher.onBackPressed()
|
||||
}
|
||||
|
||||
override fun onBackupTypeActionClick(tier: MessageBackupTier) {
|
||||
@@ -433,6 +433,14 @@ private fun RemoteBackupsSettingsContent(
|
||||
onBackupTypeActionButtonClicked = contentCallbacks::onBackupTypeActionClick
|
||||
)
|
||||
}
|
||||
|
||||
RemoteBackupsSettingsState.BackupState.NotFound -> {
|
||||
SubscriptionNotFoundCard(
|
||||
title = stringResource(R.string.RemoteBackupsSettingsFragment__your_subscription_was_not_found),
|
||||
onRenewClick = contentCallbacks::onRenewLostSubscription,
|
||||
onLearnMoreClick = contentCallbacks::onLearnMoreAboutLostSubscription
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -849,7 +857,9 @@ private fun RedemptionErrorAlert(
|
||||
|
||||
Text(
|
||||
text = stringResource(R.string.AppSettingsFragment__couldnt_redeem_your_backups_subscription),
|
||||
modifier = Modifier.padding(start = 16.dp, end = 4.dp).weight(1f)
|
||||
modifier = Modifier
|
||||
.padding(start = 16.dp, end = 4.dp)
|
||||
.weight(1f)
|
||||
)
|
||||
|
||||
Buttons.Small(onClick = onDetailsClick) {
|
||||
@@ -939,8 +949,8 @@ private fun PendingCard(
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun SubscriptionMismatchMissingGooglePlayCard(
|
||||
state: RemoteBackupsSettingsState.BackupState.SubscriptionMismatchMissingGooglePlay,
|
||||
private fun SubscriptionNotFoundCard(
|
||||
title: String,
|
||||
onRenewClick: () -> Unit = {},
|
||||
onLearnMoreClick: () -> Unit = {}
|
||||
) {
|
||||
@@ -951,11 +961,9 @@ private fun SubscriptionMismatchMissingGooglePlayCard(
|
||||
.background(color = SignalTheme.colors.colorSurface2, shape = RoundedCornerShape(12.dp))
|
||||
.padding(24.dp)
|
||||
) {
|
||||
val days by rememberUpdatedState((state.renewalTime - System.currentTimeMillis().milliseconds).inWholeDays)
|
||||
|
||||
Row {
|
||||
Text(
|
||||
text = pluralStringResource(R.plurals.RemoteBackupsSettingsFragment__your_subscription_on_this_device_is_valid, days.toInt(), days),
|
||||
text = title,
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.padding(end = 13.dp)
|
||||
@@ -1017,6 +1025,21 @@ private fun SubscriptionMismatchMissingGooglePlayCard(
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun SubscriptionMismatchMissingGooglePlayCard(
|
||||
state: RemoteBackupsSettingsState.BackupState.SubscriptionMismatchMissingGooglePlay,
|
||||
onRenewClick: () -> Unit = {},
|
||||
onLearnMoreClick: () -> Unit = {}
|
||||
) {
|
||||
val days by rememberUpdatedState((state.renewalTime - System.currentTimeMillis().milliseconds).inWholeDays)
|
||||
|
||||
SubscriptionNotFoundCard(
|
||||
title = pluralStringResource(R.plurals.RemoteBackupsSettingsFragment__your_subscription_on_this_device_is_valid, days.toInt(), days),
|
||||
onRenewClick = onRenewClick,
|
||||
onLearnMoreClick = onLearnMoreClick
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun InProgressBackupRow(
|
||||
archiveUploadProgressState: ArchiveUploadProgressState
|
||||
@@ -1430,6 +1453,16 @@ private fun PendingCardPreview() {
|
||||
}
|
||||
}
|
||||
|
||||
@SignalPreview
|
||||
@Composable
|
||||
private fun SubscriptionNotFoundCardPreview() {
|
||||
Previews.Preview {
|
||||
SubscriptionNotFoundCard(
|
||||
title = stringResource(R.string.RemoteBackupsSettingsFragment__your_subscription_was_not_found)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@SignalPreview
|
||||
@Composable
|
||||
private fun SubscriptionMismatchMissingGooglePlayCardPreview() {
|
||||
|
||||
@@ -85,6 +85,11 @@ data class RemoteBackupsSettingsState(
|
||||
override val renewalTime: Duration = 0.seconds
|
||||
) : WithTypeAndRenewalTime
|
||||
|
||||
/**
|
||||
* User has an active backup but no active subscription
|
||||
*/
|
||||
data object NotFound : BackupState
|
||||
|
||||
/**
|
||||
* User has a canceled paid tier backup
|
||||
*/
|
||||
|
||||
@@ -345,11 +345,19 @@ class RemoteBackupsSettingsViewModel : ViewModel() {
|
||||
)
|
||||
}
|
||||
} else {
|
||||
Log.d(TAG, "ActiveSubscription had null subscription object. Updating UI state with INACTIVE subscription.")
|
||||
_state.update {
|
||||
it.copy(
|
||||
backupState = RemoteBackupsSettingsState.BackupState.Inactive(type)
|
||||
)
|
||||
Log.d(TAG, "ActiveSubscription had null subscription object.")
|
||||
if (SignalStore.backup.areBackupsEnabled) {
|
||||
_state.update {
|
||||
it.copy(
|
||||
backupState = RemoteBackupsSettingsState.BackupState.NotFound
|
||||
)
|
||||
}
|
||||
} else {
|
||||
_state.update {
|
||||
it.copy(
|
||||
backupState = RemoteBackupsSettingsState.BackupState.Inactive(type)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -522,6 +522,22 @@ fun Screen(
|
||||
|
||||
Dividers.Default()
|
||||
|
||||
Rows.TextRow(
|
||||
text = "Mark backup failure",
|
||||
label = "This will display the error sheet when returning to the chats list.",
|
||||
onClick = {
|
||||
SignalStore.backup.internalSetBackupFailedErrorState()
|
||||
}
|
||||
)
|
||||
|
||||
Rows.TextRow(
|
||||
text = "Mark backup expired and downgraded",
|
||||
label = "This will not actually downgrade the user.",
|
||||
onClick = {
|
||||
SignalStore.backup.backupExpiredAndDowngraded = true
|
||||
}
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user