mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 00:59:49 +01:00
Always display paid tier but stick a dialog in front of it for non-GPS devices.
This commit is contained in:
@@ -495,6 +495,7 @@ private fun RemoteBackupsSettingsContent(
|
||||
BackupCard(
|
||||
backupState = state.backupState,
|
||||
onBackupTypeActionButtonClicked = contentCallbacks::onBackupTypeActionClick,
|
||||
isPaidTierPricingAvailable = state.isPaidTierPricingAvailable,
|
||||
buttonsEnabled = backupDeleteState.isIdle()
|
||||
)
|
||||
}
|
||||
@@ -983,6 +984,7 @@ private fun LazyListScope.appendBackupDetailsItems(
|
||||
@Composable
|
||||
private fun BackupCard(
|
||||
backupState: BackupState.WithTypeAndRenewalTime,
|
||||
isPaidTierPricingAvailable: Boolean,
|
||||
buttonsEnabled: Boolean,
|
||||
onBackupTypeActionButtonClicked: (MessageBackupTier) -> Unit = {}
|
||||
) {
|
||||
@@ -1074,7 +1076,7 @@ private fun BackupCard(
|
||||
)
|
||||
}
|
||||
|
||||
if (backupState.isActive()) {
|
||||
if (backupState.isActive() && isPaidTierPricingAvailable) {
|
||||
val buttonText = when (messageBackupsType) {
|
||||
is MessageBackupsType.Paid -> stringResource(R.string.RemoteBackupsSettingsFragment__manage_or_cancel)
|
||||
is MessageBackupsType.Free -> stringResource(R.string.RemoteBackupsSettingsFragment__upgrade)
|
||||
@@ -1464,6 +1466,7 @@ private fun getBackupExportPhaseProgressString(state: ArchiveUploadProgressState
|
||||
stringResource(R.string.RemoteBackupsSettingsFragment__Waiting_for_Wifi)
|
||||
}
|
||||
}
|
||||
|
||||
ArchiveUploadProgressState.BackupPhase.Message -> {
|
||||
pluralStringResource(
|
||||
R.plurals.RemoteBackupsSettingsFragment__processing_messages_progress_text,
|
||||
@@ -1835,65 +1838,92 @@ private fun SubscriptionMismatchMissingGooglePlayCardPreview() {
|
||||
@Composable
|
||||
private fun BackupCardPreview() {
|
||||
Previews.Preview {
|
||||
Column {
|
||||
BackupCard(
|
||||
backupState = BackupState.ActivePaid(
|
||||
messageBackupsType = MessageBackupsType.Paid(
|
||||
pricePerMonth = FiatMoney(BigDecimal.valueOf(3), Currency.getInstance("CAD")),
|
||||
storageAllowanceBytes = 100_000_000,
|
||||
mediaTtl = 30.days
|
||||
LazyColumn {
|
||||
item {
|
||||
BackupCard(
|
||||
backupState = BackupState.ActivePaid(
|
||||
messageBackupsType = MessageBackupsType.Paid(
|
||||
pricePerMonth = FiatMoney(BigDecimal.valueOf(3), Currency.getInstance("CAD")),
|
||||
storageAllowanceBytes = 100_000_000,
|
||||
mediaTtl = 30.days
|
||||
),
|
||||
renewalTime = 1727193018.seconds,
|
||||
price = FiatMoney(BigDecimal.valueOf(3), Currency.getInstance("CAD"))
|
||||
),
|
||||
renewalTime = 1727193018.seconds,
|
||||
price = FiatMoney(BigDecimal.valueOf(3), Currency.getInstance("CAD"))
|
||||
),
|
||||
buttonsEnabled = true
|
||||
)
|
||||
isPaidTierPricingAvailable = true,
|
||||
buttonsEnabled = true
|
||||
)
|
||||
}
|
||||
|
||||
BackupCard(
|
||||
backupState = BackupState.Canceled(
|
||||
messageBackupsType = MessageBackupsType.Paid(
|
||||
pricePerMonth = FiatMoney(BigDecimal.valueOf(3), Currency.getInstance("CAD")),
|
||||
storageAllowanceBytes = 100_000_000,
|
||||
mediaTtl = 30.days
|
||||
item {
|
||||
BackupCard(
|
||||
backupState = BackupState.Canceled(
|
||||
messageBackupsType = MessageBackupsType.Paid(
|
||||
pricePerMonth = FiatMoney(BigDecimal.valueOf(3), Currency.getInstance("CAD")),
|
||||
storageAllowanceBytes = 100_000_000,
|
||||
mediaTtl = 30.days
|
||||
),
|
||||
renewalTime = 1727193018.seconds
|
||||
),
|
||||
renewalTime = 1727193018.seconds
|
||||
),
|
||||
buttonsEnabled = true
|
||||
)
|
||||
isPaidTierPricingAvailable = true,
|
||||
buttonsEnabled = true
|
||||
)
|
||||
}
|
||||
|
||||
BackupCard(
|
||||
backupState = BackupState.Inactive(
|
||||
messageBackupsType = MessageBackupsType.Paid(
|
||||
pricePerMonth = FiatMoney(BigDecimal.valueOf(3), Currency.getInstance("CAD")),
|
||||
storageAllowanceBytes = 100_000_000,
|
||||
mediaTtl = 30.days
|
||||
item {
|
||||
BackupCard(
|
||||
backupState = BackupState.Inactive(
|
||||
messageBackupsType = MessageBackupsType.Paid(
|
||||
pricePerMonth = FiatMoney(BigDecimal.valueOf(3), Currency.getInstance("CAD")),
|
||||
storageAllowanceBytes = 100_000_000,
|
||||
mediaTtl = 30.days
|
||||
),
|
||||
renewalTime = 1727193018.seconds
|
||||
),
|
||||
renewalTime = 1727193018.seconds
|
||||
),
|
||||
buttonsEnabled = true
|
||||
)
|
||||
isPaidTierPricingAvailable = true,
|
||||
buttonsEnabled = true
|
||||
)
|
||||
}
|
||||
|
||||
BackupCard(
|
||||
backupState = BackupState.ActivePaid(
|
||||
messageBackupsType = MessageBackupsType.Paid(
|
||||
pricePerMonth = FiatMoney(BigDecimal.valueOf(3), Currency.getInstance("CAD")),
|
||||
storageAllowanceBytes = 100_000_000,
|
||||
mediaTtl = 30.days
|
||||
item {
|
||||
BackupCard(
|
||||
backupState = BackupState.ActivePaid(
|
||||
messageBackupsType = MessageBackupsType.Paid(
|
||||
pricePerMonth = FiatMoney(BigDecimal.valueOf(3), Currency.getInstance("CAD")),
|
||||
storageAllowanceBytes = 100_000_000,
|
||||
mediaTtl = 30.days
|
||||
),
|
||||
renewalTime = 1727193018.seconds,
|
||||
price = FiatMoney(BigDecimal.valueOf(3), Currency.getInstance("CAD"))
|
||||
),
|
||||
renewalTime = 1727193018.seconds,
|
||||
price = FiatMoney(BigDecimal.valueOf(3), Currency.getInstance("CAD"))
|
||||
),
|
||||
buttonsEnabled = true
|
||||
)
|
||||
isPaidTierPricingAvailable = true,
|
||||
buttonsEnabled = true
|
||||
)
|
||||
}
|
||||
|
||||
BackupCard(
|
||||
backupState = BackupState.ActiveFree(
|
||||
messageBackupsType = MessageBackupsType.Free(
|
||||
mediaRetentionDays = 30
|
||||
)
|
||||
),
|
||||
buttonsEnabled = true
|
||||
)
|
||||
item {
|
||||
BackupCard(
|
||||
backupState = BackupState.ActiveFree(
|
||||
messageBackupsType = MessageBackupsType.Free(
|
||||
mediaRetentionDays = 30
|
||||
)
|
||||
),
|
||||
isPaidTierPricingAvailable = true,
|
||||
buttonsEnabled = true
|
||||
)
|
||||
}
|
||||
|
||||
item {
|
||||
BackupCard(
|
||||
backupState = BackupState.ActiveFree(
|
||||
messageBackupsType = MessageBackupsType.Free(
|
||||
mediaRetentionDays = 30
|
||||
)
|
||||
),
|
||||
isPaidTierPricingAvailable = false,
|
||||
buttonsEnabled = true
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ data class RemoteBackupsSettingsState(
|
||||
val canRestoreUsingCellular: Boolean = false,
|
||||
val hasRedemptionError: Boolean = false,
|
||||
val isOutOfStorageSpace: Boolean = false,
|
||||
val isPaidTierPricingAvailable: Boolean = false,
|
||||
val totalAllowedStorageSpace: String = "",
|
||||
val backupState: BackupState,
|
||||
val backupMediaSize: Long = -1L,
|
||||
|
||||
@@ -83,6 +83,20 @@ class RemoteBackupsSettingsViewModel : ViewModel() {
|
||||
val restoreState: StateFlow<BackupRestoreState> = _restoreState
|
||||
|
||||
init {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val isBillingApiAvailable = AppDependencies.billingApi.isApiAvailable()
|
||||
if (isBillingApiAvailable) {
|
||||
_state.update {
|
||||
it.copy(isPaidTierPricingAvailable = true)
|
||||
}
|
||||
} else {
|
||||
val paidType = BackupRepository.getPaidType()
|
||||
_state.update {
|
||||
it.copy(isPaidTierPricingAvailable = paidType is NetworkResult.Success)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
refreshBackupMediaSizeState()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user