feat: implement device verification flow with new UI components and protocol handling

This commit is contained in:
2026-02-18 04:40:22 +05:00
parent edff3b32c3
commit cacd6dc029
24 changed files with 1645 additions and 195 deletions

View File

@@ -49,8 +49,9 @@ class PreferencesManager(private val context: Context) {
// Language
val APP_LANGUAGE = stringPreferencesKey("app_language") // "en", "ru", etc.
// Appearance / Customization
val BACKGROUND_BLUR_COLOR_ID = stringPreferencesKey("background_blur_color_id") // id from BackgroundBlurPresets
// Appearance / Customization (legacy global key)
val BACKGROUND_BLUR_COLOR_ID =
stringPreferencesKey("background_blur_color_id") // id from BackgroundBlurPresets
// Pinned Chats (max 3)
val PINNED_CHATS = stringSetPreferencesKey("pinned_chats") // Set of opponent public keys
@@ -219,6 +220,12 @@ class PreferencesManager(private val context: Context) {
// 🎨 APPEARANCE / CUSTOMIZATION
// ═════════════════════════════════════════════════════════════
private fun buildBackgroundBlurColorKey(account: String): Preferences.Key<String>? {
val trimmedAccount = account.trim()
if (trimmedAccount.isBlank()) return null
return stringPreferencesKey("background_blur_color_id::$trimmedAccount")
}
val backgroundBlurColorId: Flow<String> =
context.dataStore.data.map { preferences ->
preferences[BACKGROUND_BLUR_COLOR_ID] ?: "avatar" // Default: use avatar blur
@@ -228,6 +235,21 @@ class PreferencesManager(private val context: Context) {
context.dataStore.edit { preferences -> preferences[BACKGROUND_BLUR_COLOR_ID] = value }
}
fun backgroundBlurColorIdForAccount(account: String): Flow<String> =
context.dataStore.data.map { preferences ->
val scopedKey = buildBackgroundBlurColorKey(account)
if (scopedKey != null) preferences[scopedKey] ?: "avatar" else "avatar"
}
suspend fun setBackgroundBlurColorId(account: String, value: String) {
val scopedKey = buildBackgroundBlurColorKey(account)
context.dataStore.edit { preferences ->
if (scopedKey != null) {
preferences[scopedKey] = value
}
}
}
// ═════════════════════════════════════════════════════════════
// 📌 PINNED CHATS
// ═════════════════════════════════════════════════════════════