From 85ce587b14b9c2f5c5eb58c9ee0e05ee1f90797e Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Fri, 18 Oct 2024 11:55:45 -0300 Subject: [PATCH] Create AppCheckerWorker and wire it up --- .../com/stevesoltys/seedvault/repo/Checker.kt | 6 ++ .../seedvault/settings/AppCheckFragment.kt | 3 +- .../seedvault/settings/SettingsViewModel.kt | 5 ++ .../notification/BackupNotificationManager.kt | 22 ++++- .../seedvault/worker/AppCheckerWorker.kt | 82 +++++++++++++++++++ app/src/main/res/values/strings.xml | 3 + 6 files changed, 118 insertions(+), 3 deletions(-) create mode 100644 app/src/main/java/com/stevesoltys/seedvault/worker/AppCheckerWorker.kt diff --git a/app/src/main/java/com/stevesoltys/seedvault/repo/Checker.kt b/app/src/main/java/com/stevesoltys/seedvault/repo/Checker.kt index ffcdf627..9dbb4c1a 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/repo/Checker.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/repo/Checker.kt @@ -8,6 +8,7 @@ package com.stevesoltys.seedvault.repo import androidx.annotation.WorkerThread import com.stevesoltys.seedvault.backend.BackendManager import com.stevesoltys.seedvault.crypto.Crypto +import kotlinx.coroutines.delay import org.calyxos.seedvault.core.backends.AppBackupFileType import org.calyxos.seedvault.core.backends.TopLevelFolder @@ -36,4 +37,9 @@ internal class Checker( return sizeMap.values.sumOf { it.toLong() } } + suspend fun check(percent: Int) { + check(percent in 0..100) { "Percent $percent out of bounds." } + delay(20_000) + } + } diff --git a/app/src/main/java/com/stevesoltys/seedvault/settings/AppCheckFragment.kt b/app/src/main/java/com/stevesoltys/seedvault/settings/AppCheckFragment.kt index 076e8a3f..6512b1cd 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/settings/AppCheckFragment.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/settings/AppCheckFragment.kt @@ -58,7 +58,8 @@ class AppCheckFragment : Fragment() { } v.requireViewById