From c9c2b3f4833680b1f6d27e1c1157fa98ba72b78e Mon Sep 17 00:00:00 2001 From: silentbil Date: Thu, 9 Jul 2026 23:54:38 +0300 Subject: [PATCH 1/2] preload subs and gemini update --- .../tv/data/repository/CloudSyncRepository.kt | 8 + .../com/arflix/tv/server/AiKeyWebPage.kt | 2 +- .../tv/ui/screens/player/PlayerScreen.kt | 215 ++++++++++++++-- .../tv/ui/screens/player/PlayerViewModel.kt | 170 ++++++++++++- .../tv/ui/screens/player/SubtitleAiModel.kt | 2 + .../player/SubtitleTranslationService.kt | 234 +++++++++++++++--- .../tv/ui/screens/settings/SettingsScreen.kt | 24 +- .../ui/screens/settings/SettingsViewModel.kt | 12 + app/src/main/res/values-iw/strings.xml | 2 + app/src/main/res/values/strings.xml | 2 + docs/subtitle-auto-match.md | 65 ++++- 11 files changed, 672 insertions(+), 64 deletions(-) diff --git a/app/src/main/kotlin/com/arflix/tv/data/repository/CloudSyncRepository.kt b/app/src/main/kotlin/com/arflix/tv/data/repository/CloudSyncRepository.kt index 18488300b..d63acb19d 100644 --- a/app/src/main/kotlin/com/arflix/tv/data/repository/CloudSyncRepository.kt +++ b/app/src/main/kotlin/com/arflix/tv/data/repository/CloudSyncRepository.kt @@ -353,6 +353,7 @@ class CloudSyncRepository @Inject constructor( private val subtitleAiEnabledKey = androidx.datastore.preferences.core.booleanPreferencesKey("subtitle_ai_enabled") private val subtitleAiAutoSelectKey = androidx.datastore.preferences.core.booleanPreferencesKey("subtitle_ai_auto_select") private val subtitleAiFindBestMatchKey = androidx.datastore.preferences.core.booleanPreferencesKey("subtitle_ai_find_best_match") + private val subtitlePreloadEnabledKey = androidx.datastore.preferences.core.booleanPreferencesKey("subtitle_preload_enabled") private val subtitleAiApiKeyKey = androidx.datastore.preferences.core.stringPreferencesKey("subtitle_ai_api_key") private val subtitleAiModelKey = androidx.datastore.preferences.core.stringPreferencesKey("subtitle_ai_model") private val subtitleRemoveHearingImpairedKey = androidx.datastore.preferences.core.booleanPreferencesKey("subtitle_remove_hearing_impaired") @@ -491,6 +492,7 @@ class CloudSyncRepository @Inject constructor( root.put("subtitleAiEnabled", prefs[subtitleAiEnabledKey] ?: false) root.put("subtitleAiAutoSelect", prefs[subtitleAiAutoSelectKey] ?: false) root.put("subtitleAiFindBestMatch", prefs[subtitleAiFindBestMatchKey] ?: false) + root.put("subtitlePreloadEnabled", prefs[subtitlePreloadEnabledKey] ?: true) root.put("subtitleAiApiKey", prefs[subtitleAiApiKeyKey] ?: "") root.put("subtitleAiModel", prefs[subtitleAiModelKey] ?: "GROQ_LLAMA_70B") root.put("subtitleRemoveHearingImpaired", prefs[subtitleRemoveHearingImpairedKey] ?: true) @@ -1230,6 +1232,12 @@ class CloudSyncRepository @Inject constructor( prefs[subtitleAiEnabledKey] = root.optBoolean("subtitleAiEnabled", false) prefs[subtitleAiAutoSelectKey] = root.optBoolean("subtitleAiAutoSelect", false) prefs[subtitleAiFindBestMatchKey] = root.optBoolean("subtitleAiFindBestMatch", false) + // Only apply when the backup actually carries the field — backups pushed by app + // versions that predate the setting must not reset it (realtime sync pulls after + // EVERY push from any device, so one old-version device would keep wiping it). + if (root.has("subtitlePreloadEnabled")) { + prefs[subtitlePreloadEnabledKey] = root.optBoolean("subtitlePreloadEnabled", false) + } val apiKey = root.optString("subtitleAiApiKey", "") if (apiKey.isNotBlank()) prefs[subtitleAiApiKeyKey] = apiKey val model = root.optString("subtitleAiModel", "GROQ_LLAMA_70B") diff --git a/app/src/main/kotlin/com/arflix/tv/server/AiKeyWebPage.kt b/app/src/main/kotlin/com/arflix/tv/server/AiKeyWebPage.kt index 28ebd6b6f..bddd2476a 100644 --- a/app/src/main/kotlin/com/arflix/tv/server/AiKeyWebPage.kt +++ b/app/src/main/kotlin/com/arflix/tv/server/AiKeyWebPage.kt @@ -75,7 +75,7 @@ $sharedCss BETTER QUALITY Google Gemini - Gemini 2.5 Flash · Free tier available + Gemini 3.5 Flash · Free tier available