Exclude tracker credentials in backups

(cherry picked from commit 730f3a6e5209197c7a026c36371545d5aef85851)

# Conflicts:
#	app/build.gradle.kts
This commit is contained in:
arkon
2023-10-08 11:07:42 -04:00
committed by Jobobby04
parent b97dbca402
commit 92daa4ea28
6 changed files with 64 additions and 15 deletions
@@ -21,6 +21,24 @@ interface Preference<T> {
fun changes(): Flow<T>
fun stateIn(scope: CoroutineScope): StateFlow<T>
val isPrivate: Boolean
get() = key().startsWith(PRIVATE_PREFIX)
companion object {
/**
* A preference that should not be exposed in places like backups.
*/
fun isPrivate(key: String): Boolean {
return key.startsWith(PRIVATE_PREFIX)
}
fun privateKey(key: String): String {
return "${PRIVATE_PREFIX}$key"
}
private const val PRIVATE_PREFIX = "__PRIVATE_"
}
}
inline fun <reified T, R : T> Preference<T>.getAndSet(crossinline block: (T) -> R) = set(