Integrate the backup size into backup settings.

This commit is contained in:
Clark
2024-05-06 12:55:13 -04:00
committed by Alex Hart
parent b2efc42357
commit de3b0d4ca2
6 changed files with 46 additions and 6 deletions

View File

@@ -60,6 +60,7 @@ import org.thoughtcrime.securesms.compose.ComposeFragment
import org.thoughtcrime.securesms.conversation.v2.registerForLifecycle
import org.thoughtcrime.securesms.payments.FiatMoneyUtil
import org.thoughtcrime.securesms.util.DateUtils
import org.thoughtcrime.securesms.util.Util
import org.thoughtcrime.securesms.util.navigation.safeNavigate
import org.thoughtcrime.securesms.util.viewModel
import java.util.Locale
@@ -88,7 +89,8 @@ class RemoteBackupsSettingsFragment : ComposeFragment() {
requestedDialog = state.dialog,
requestedSnackbar = state.snackbar,
contentCallbacks = callbacks,
backupProgress = state.backupProgress
backupProgress = state.backupProgress,
backupSize = state.backupSize
)
}
@@ -181,7 +183,8 @@ private fun RemoteBackupsSettingsContent(
requestedDialog: RemoteBackupsSettingsState.Dialog,
requestedSnackbar: RemoteBackupsSettingsState.Snackbar,
contentCallbacks: ContentCallbacks,
backupProgress: BackupV2Event?
backupProgress: BackupV2Event?,
backupSize: Long
) {
val snackbarHostState = remember {
SnackbarHostState()
@@ -245,7 +248,7 @@ private fun RemoteBackupsSettingsContent(
color = MaterialTheme.colorScheme.onSurface
)
Text(
text = "2.3GB",
text = Util.getPrettyFileSize(backupSize ?: 0),
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
@@ -572,7 +575,8 @@ private fun RemoteBackupsSettingsContentPreview() {
requestedDialog = RemoteBackupsSettingsState.Dialog.NONE,
requestedSnackbar = RemoteBackupsSettingsState.Snackbar.NONE,
contentCallbacks = object : ContentCallbacks {},
backupProgress = null
backupProgress = null,
backupSize = 2300000
)
}
}

View File

@@ -29,7 +29,8 @@ class RemoteBackupsSettingsViewModel : ViewModel() {
} else {
null
},
lastBackupTimestamp = SignalStore.backup().lastBackupTime
lastBackupTimestamp = SignalStore.backup().lastBackupTime,
backupSize = SignalStore.backup().totalBackupSize
)
)
@@ -60,7 +61,15 @@ class RemoteBackupsSettingsViewModel : ViewModel() {
}
fun updateBackupProgress(backupEvent: BackupV2Event?) {
internalState.value = state.value.copy(backupProgress = backupEvent, lastBackupTimestamp = SignalStore.backup().lastBackupTime)
internalState.value = state.value.copy(backupProgress = backupEvent)
refreshBackupState()
}
private fun refreshBackupState() {
internalState.value = state.value.copy(
lastBackupTimestamp = SignalStore.backup().lastBackupTime,
backupSize = SignalStore.backup().totalBackupSize
)
}
fun onBackupNowClick() {