DbPrivacyPreferences.kt
composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/database/DbPrivacyPreferences.kt
1package eu.friedcutlet.yokan.database23import kotlinx.serialization.Serializable45/** When the app hides its content from screenshots, screen recording and the app switcher. */6@Serializable7enum class DbSecureScreen { Never, Incognito, Always }89@Serializable10data class DbPrivacyPreferences(11 val secureScreen: DbSecureScreen = DbSecureScreen.Never,12 /** Replaces titles in system notifications with generic text, with or without app lock. */13 val hideNotificationContent: Boolean = false,14 /** Minutes in the background before app lock asks again; 0 = as soon as the app leaves, -1 = never. */15 val appLockTimeoutMinutes: Int = 0,16 /** Sources whose titles are always read/watched incognito. */17 val incognitoSourceIds: Set<Long> = emptySet(),18)1920/** Global incognito, or the title's source is marked incognito. */21fun DbSettings.isIncognitoFor(sourceId: Long?): Boolean =22 incognitoMode || (sourceId != null && sourceId in features.privacy.incognitoSourceIds)2324fun DbSettings.secureScreenActive(): Boolean = when (features.privacy.secureScreen) {25 DbSecureScreen.Never -> false26 DbSecureScreen.Incognito -> incognitoMode27 DbSecureScreen.Always -> true28}2930val AppLockTimeoutChoices = listOf(0, 1, 2, 5, 10, -1)3132/** Whether returning after [backgroundedAtMillis] must lock again under [timeoutMinutes]. */33fun appLockDue(timeoutMinutes: Int, backgroundedAtMillis: Long, nowMillis: Long): Boolean = when {34 timeoutMinutes < 0 -> false35 else -> nowMillis - backgroundedAtMillis >= timeoutMinutes * 60_000L36}37