update + Fix
This commit is contained in:
1 parent
a84c22f04b
commit
1d88b4f6e7
10 files changed
+241
-9
No files matched your search
@@ -15,6 +15,8 @@ data class AppSettings(
|
||||
val cutoffIntervalMinutes: Int = 15,
|
||||
val baselineMobileBytesAtReset: Long = 0L,
|
||||
val whitelistedPackages: Set<String> = emptySet(),
|
||||
val whitelistedPackagesWifi: Set<String> = emptySet(),
|
||||
val wifiFilterEnabled: Boolean = false,
|
||||
val showSystemApps: Boolean = false,
|
||||
val passwordHash: String? = null,
|
||||
val passwordSalt: String? = null,
|
||||
|
||||
@@ -33,6 +33,8 @@ class SettingsRepository @Inject constructor(
|
||||
val CUTOFF_INTERVAL_MINUTES = intPreferencesKey("cutoff_interval_minutes")
|
||||
val BASELINE_MOBILE_BYTES = longPreferencesKey("baseline_mobile_bytes")
|
||||
val WHITELISTED_PACKAGES = stringSetPreferencesKey("whitelisted_packages")
|
||||
val WHITELISTED_PACKAGES_WIFI = stringSetPreferencesKey("whitelisted_packages_wifi")
|
||||
val WIFI_FILTER_ENABLED = booleanPreferencesKey("wifi_filter_enabled")
|
||||
val SHOW_SYSTEM_APPS = booleanPreferencesKey("show_system_apps")
|
||||
val PASSWORD_HASH = stringPreferencesKey("password_hash")
|
||||
val PASSWORD_SALT = stringPreferencesKey("password_salt")
|
||||
@@ -53,6 +55,8 @@ class SettingsRepository @Inject constructor(
|
||||
cutoffIntervalMinutes = prefs[Keys.CUTOFF_INTERVAL_MINUTES] ?: defaults.cutoffIntervalMinutes,
|
||||
baselineMobileBytesAtReset = prefs[Keys.BASELINE_MOBILE_BYTES] ?: defaults.baselineMobileBytesAtReset,
|
||||
whitelistedPackages = prefs[Keys.WHITELISTED_PACKAGES] ?: defaults.whitelistedPackages,
|
||||
whitelistedPackagesWifi = prefs[Keys.WHITELISTED_PACKAGES_WIFI] ?: defaults.whitelistedPackagesWifi,
|
||||
wifiFilterEnabled = prefs[Keys.WIFI_FILTER_ENABLED] ?: defaults.wifiFilterEnabled,
|
||||
showSystemApps = prefs[Keys.SHOW_SYSTEM_APPS] ?: defaults.showSystemApps,
|
||||
passwordHash = prefs[Keys.PASSWORD_HASH],
|
||||
passwordSalt = prefs[Keys.PASSWORD_SALT],
|
||||
@@ -91,6 +95,14 @@ class SettingsRepository @Inject constructor(
|
||||
context.dataStore.edit { it[Keys.WHITELISTED_PACKAGES] = packages }
|
||||
}
|
||||
|
||||
suspend fun setWhitelistedPackagesWifi(packages: Set<String>) {
|
||||
context.dataStore.edit { it[Keys.WHITELISTED_PACKAGES_WIFI] = packages }
|
||||
}
|
||||
|
||||
suspend fun setWifiFilterEnabled(enabled: Boolean) {
|
||||
context.dataStore.edit { it[Keys.WIFI_FILTER_ENABLED] = enabled }
|
||||
}
|
||||
|
||||
suspend fun setShowSystemApps(show: Boolean) {
|
||||
context.dataStore.edit { it[Keys.SHOW_SYSTEM_APPS] = show }
|
||||
}
|
||||
@@ -108,6 +120,16 @@ class SettingsRepository @Inject constructor(
|
||||
context.dataStore.edit { it[Keys.BASELINE_MOBILE_BYTES] = currentMobileBytes }
|
||||
}
|
||||
|
||||
/**
|
||||
* Force la consommation affichée à [consumedMo] sans changer la date de début du cycle, en
|
||||
* recalculant la base de référence à partir du compteur système actuel ([currentTotalBytes]).
|
||||
* Utile pour recaler l'app sur le décompte opérateur réel.
|
||||
*/
|
||||
suspend fun setConsumedMo(consumedMo: Long, currentTotalBytes: Long) {
|
||||
val baseline = (currentTotalBytes - UsageRepository.moToBytes(consumedMo)).coerceAtLeast(0L)
|
||||
context.dataStore.edit { it[Keys.BASELINE_MOBILE_BYTES] = baseline }
|
||||
}
|
||||
|
||||
/** Définit (ou supprime, si [password] est vide/null) le mot de passe de verrouillage. */
|
||||
suspend fun setPassword(password: String?) {
|
||||
if (password.isNullOrBlank()) {
|
||||
|
||||
Reference in new issue
Block a user