package eu.friedcutlet.yokan.database import kotlinx.serialization.Serializable /** When the app hides its content from screenshots, screen recording and the app switcher. */ @Serializable enum class DbSecureScreen { Never, Incognito, Always } @Serializable data class DbPrivacyPreferences( val secureScreen: DbSecureScreen = DbSecureScreen.Never, /** Replaces titles in system notifications with generic text, with or without app lock. */ val hideNotificationContent: Boolean = false, /** Minutes in the background before app lock asks again; 0 = as soon as the app leaves, -1 = never. */ val appLockTimeoutMinutes: Int = 0, /** Sources whose titles are always read/watched incognito. */ val incognitoSourceIds: Set = emptySet(), ) /** Global incognito, or the title's source is marked incognito. */ fun DbSettings.isIncognitoFor(sourceId: Long?): Boolean = incognitoMode || (sourceId != null && sourceId in features.privacy.incognitoSourceIds) fun DbSettings.secureScreenActive(): Boolean = when (features.privacy.secureScreen) { DbSecureScreen.Never -> false DbSecureScreen.Incognito -> incognitoMode DbSecureScreen.Always -> true } val AppLockTimeoutChoices = listOf(0, 1, 2, 5, 10, -1) /** Whether returning after [backgroundedAtMillis] must lock again under [timeoutMinutes]. */ fun appLockDue(timeoutMinutes: Int, backgroundedAtMillis: Long, nowMillis: Long): Boolean = when { timeoutMinutes < 0 -> false else -> nowMillis - backgroundedAtMillis >= timeoutMinutes * 60_000L }