diff --git a/composeApp/src/androidMain/kotlin/zed/rainxch/githubstore/app/GithubStoreApp.kt b/composeApp/src/androidMain/kotlin/zed/rainxch/githubstore/app/GithubStoreApp.kt index da27698b..e8d5dc80 100644 --- a/composeApp/src/androidMain/kotlin/zed/rainxch/githubstore/app/GithubStoreApp.kt +++ b/composeApp/src/androidMain/kotlin/zed/rainxch/githubstore/app/GithubStoreApp.kt @@ -127,7 +127,14 @@ class GithubStoreApp : Application() { private fun scheduleBackgroundUpdateChecks() { appScope.launch { try { - val intervalHours = get().getUpdateCheckInterval().first() + val tweaks = get() + val enabled = tweaks.getUpdateCheckEnabled().first() + if (!enabled) { + UpdateScheduler.cancel(this@GithubStoreApp) + Logger.i { "Background update check disabled — skipping schedule" } + return@launch + } + val intervalHours = tweaks.getUpdateCheckInterval().first() UpdateScheduler.schedule( context = this@GithubStoreApp, intervalHours = intervalHours, diff --git a/core/data/src/androidMain/kotlin/zed/rainxch/core/data/services/AndroidUpdateScheduleManager.kt b/core/data/src/androidMain/kotlin/zed/rainxch/core/data/services/AndroidUpdateScheduleManager.kt index 17a61497..f98f1127 100644 --- a/core/data/src/androidMain/kotlin/zed/rainxch/core/data/services/AndroidUpdateScheduleManager.kt +++ b/core/data/src/androidMain/kotlin/zed/rainxch/core/data/services/AndroidUpdateScheduleManager.kt @@ -9,4 +9,8 @@ class AndroidUpdateScheduleManager( override fun reschedule(intervalHours: Long) { UpdateScheduler.reschedule(context, intervalHours) } + + override fun cancel() { + UpdateScheduler.cancel(context) + } } diff --git a/core/data/src/androidMain/kotlin/zed/rainxch/core/data/services/BootReceiver.kt b/core/data/src/androidMain/kotlin/zed/rainxch/core/data/services/BootReceiver.kt index 6cf70ea1..c8f5d5de 100644 --- a/core/data/src/androidMain/kotlin/zed/rainxch/core/data/services/BootReceiver.kt +++ b/core/data/src/androidMain/kotlin/zed/rainxch/core/data/services/BootReceiver.kt @@ -4,6 +4,10 @@ import android.content.BroadcastReceiver import android.content.Context import android.content.Intent import co.touchlab.kermit.Logger +import kotlinx.coroutines.flow.first +import kotlinx.coroutines.runBlocking +import org.koin.core.context.GlobalContext +import zed.rainxch.core.domain.repository.TweaksRepository /** * Reschedules periodic update checks after device reboot. @@ -11,9 +15,27 @@ import co.touchlab.kermit.Logger */ class BootReceiver : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent?) { - if (intent?.action == Intent.ACTION_BOOT_COMPLETED) { - Logger.i { "BootReceiver: Device booted, scheduling update checks" } - UpdateScheduler.schedule(context) + if (intent?.action != Intent.ACTION_BOOT_COMPLETED) return + val pendingResult = goAsync() + try { + val enabled = + runCatching { + runBlocking { + GlobalContext.get().get().getUpdateCheckEnabled().first() + } + }.getOrElse { + Logger.w(it) { "BootReceiver: Failed to read update-check flag, defaulting to enabled" } + true + } + if (enabled) { + Logger.i { "BootReceiver: Device booted, scheduling update checks" } + UpdateScheduler.schedule(context) + } else { + Logger.i { "BootReceiver: Device booted, update check disabled — skipping" } + UpdateScheduler.cancel(context) + } + } finally { + pendingResult.finish() } } } diff --git a/core/data/src/commonMain/kotlin/zed/rainxch/core/data/repository/TweaksRepositoryImpl.kt b/core/data/src/commonMain/kotlin/zed/rainxch/core/data/repository/TweaksRepositoryImpl.kt index 4d857f5e..90fcb68c 100644 --- a/core/data/src/commonMain/kotlin/zed/rainxch/core/data/repository/TweaksRepositoryImpl.kt +++ b/core/data/src/commonMain/kotlin/zed/rainxch/core/data/repository/TweaksRepositoryImpl.kt @@ -156,6 +156,17 @@ class TweaksRepositoryImpl( } } + override fun getUpdateCheckEnabled(): Flow = + preferences.data.map { prefs -> + prefs[UPDATE_CHECK_ENABLED_KEY] ?: true + } + + override suspend fun setUpdateCheckEnabled(enabled: Boolean) { + preferences.edit { prefs -> + prefs[UPDATE_CHECK_ENABLED_KEY] = enabled + } + } + override fun getUpdateCheckInterval(): Flow = preferences.data.map { prefs -> prefs[UPDATE_CHECK_INTERVAL_KEY] ?: DEFAULT_UPDATE_CHECK_INTERVAL_HOURS @@ -409,6 +420,7 @@ class TweaksRepositoryImpl( private val INSTALLER_TYPE_KEY = stringPreferencesKey("installer_type") private val INSTALLER_ATTRIBUTION_KEY = stringPreferencesKey("installer_attribution") private val AUTO_UPDATE_KEY = booleanPreferencesKey("auto_update_enabled") + private val UPDATE_CHECK_ENABLED_KEY = booleanPreferencesKey("update_check_enabled") private val UPDATE_CHECK_INTERVAL_KEY = longPreferencesKey("update_check_interval_hours") private val INCLUDE_PRE_RELEASES_KEY = booleanPreferencesKey("include_pre_releases") private val HIDE_SEEN_ENABLED_KEY = booleanPreferencesKey("hide_seen_enabled") diff --git a/core/data/src/jvmMain/kotlin/zed/rainxch/core/data/services/DesktopUpdateScheduleManager.kt b/core/data/src/jvmMain/kotlin/zed/rainxch/core/data/services/DesktopUpdateScheduleManager.kt index a0989f7f..e50a5702 100644 --- a/core/data/src/jvmMain/kotlin/zed/rainxch/core/data/services/DesktopUpdateScheduleManager.kt +++ b/core/data/src/jvmMain/kotlin/zed/rainxch/core/data/services/DesktopUpdateScheduleManager.kt @@ -9,4 +9,8 @@ class DesktopUpdateScheduleManager : UpdateScheduleManager { override fun reschedule(intervalHours: Long) { // No background scheduler on Desktop } + + override fun cancel() { + // No background scheduler on Desktop + } } diff --git a/core/domain/src/commonMain/kotlin/zed/rainxch/core/domain/repository/TweaksRepository.kt b/core/domain/src/commonMain/kotlin/zed/rainxch/core/domain/repository/TweaksRepository.kt index 4e88da5d..32343a46 100644 --- a/core/domain/src/commonMain/kotlin/zed/rainxch/core/domain/repository/TweaksRepository.kt +++ b/core/domain/src/commonMain/kotlin/zed/rainxch/core/domain/repository/TweaksRepository.kt @@ -41,6 +41,10 @@ interface TweaksRepository { suspend fun setAutoUpdateEnabled(enabled: Boolean) + fun getUpdateCheckEnabled(): Flow + + suspend fun setUpdateCheckEnabled(enabled: Boolean) + fun getUpdateCheckInterval(): Flow suspend fun setUpdateCheckInterval(hours: Long) diff --git a/core/domain/src/commonMain/kotlin/zed/rainxch/core/domain/system/UpdateScheduleManager.kt b/core/domain/src/commonMain/kotlin/zed/rainxch/core/domain/system/UpdateScheduleManager.kt index 135fe13c..061806a7 100644 --- a/core/domain/src/commonMain/kotlin/zed/rainxch/core/domain/system/UpdateScheduleManager.kt +++ b/core/domain/src/commonMain/kotlin/zed/rainxch/core/domain/system/UpdateScheduleManager.kt @@ -10,4 +10,10 @@ interface UpdateScheduleManager { * Takes effect immediately (replaces existing schedule). */ fun reschedule(intervalHours: Long) + + /** + * Cancels every pending update-check / auto-update worker. Used + * when the user disables background update checking entirely. + */ + fun cancel() } diff --git a/core/presentation/src/commonMain/composeResources/files/whatsnew/16.json b/core/presentation/src/commonMain/composeResources/files/whatsnew/16.json index d638bf32..79eac6b1 100644 --- a/core/presentation/src/commonMain/composeResources/files/whatsnew/16.json +++ b/core/presentation/src/commonMain/composeResources/files/whatsnew/16.json @@ -25,7 +25,8 @@ "Manual rescan surfaces every GitHub-style app on device.", "Tighter auth handling — transient 401s no longer trigger spurious sign-outs.", "Open-issues count now shown to everyone, including signed-out users — the count now comes from the backend.", - "License now shown for every repo regardless of sign-in state — sourced from backend, no more GitHub quota cost per Details open." + "License now shown for every repo regardless of sign-in state — sourced from backend, no more GitHub quota cost per Details open.", + "Background update check can be turned off entirely — saves battery if you'd rather check for updates manually." ] }, { diff --git a/core/presentation/src/commonMain/composeResources/files/whatsnew/ar/16.json b/core/presentation/src/commonMain/composeResources/files/whatsnew/ar/16.json index 2883ca6a..4dc14b94 100644 --- a/core/presentation/src/commonMain/composeResources/files/whatsnew/ar/16.json +++ b/core/presentation/src/commonMain/composeResources/files/whatsnew/ar/16.json @@ -25,7 +25,8 @@ "إعادة المسح اليدوي تُظهر كل تطبيقات GitHub الموجودة على الجهاز دون تفويت أيّ منها.", "معالجة أكثر صرامة للمصادقة: استجابات 401 العابرة لم تعد تتسبّب في تسجيل خروج خاطئ.", "عداد المشكلات المفتوحة يظهر الآن للجميع بمن فيهم غير المسجَّلين — يأتي من الخادم الخلفي دون أي تكلفة لحصص GitHub.", - "الترخيص يظهر الآن لكل مستودع بصرف النظر عن حالة تسجيل الدخول — يأتي من الخادم الخلفي بدون أي استهلاك لحصص GitHub عند فتح صفحة التفاصيل." + "الترخيص يظهر الآن لكل مستودع بصرف النظر عن حالة تسجيل الدخول — يأتي من الخادم الخلفي بدون أي استهلاك لحصص GitHub عند فتح صفحة التفاصيل.", + "يمكنك إيقاف التحقق التلقائي من التحديثات في الخلفية بالكامل — يوفّر البطارية إذا كنت تفضّل التحقق يدوياً." ] }, { diff --git a/core/presentation/src/commonMain/composeResources/files/whatsnew/bn/16.json b/core/presentation/src/commonMain/composeResources/files/whatsnew/bn/16.json index 8d09a511..9b288462 100644 --- a/core/presentation/src/commonMain/composeResources/files/whatsnew/bn/16.json +++ b/core/presentation/src/commonMain/composeResources/files/whatsnew/bn/16.json @@ -25,7 +25,8 @@ "ম্যানুয়াল রি-স্ক্যান এখন ডিভাইসে থাকা সব GitHub-ধাঁচের অ্যাপ তুলে আনে।", "অথেনটিকেশন আরও সংযত: সাময়িক 401 আর ভুল করে সাইন-আউট ঘটায় না।", "ওপেন ইস্যুর সংখ্যা এখন সবাইকে দেখানো হয়, এমনকি সাইন-ইন না করা ব্যবহারকারীদেরও — ব্যাকএন্ড থেকে আসে, GitHub কোটায় কোনো খরচ নেই।", - "লাইসেন্স এখন প্রতিটি রিপোর জন্য সাইন-ইন স্ট্যাটাস নির্বিশেষে দেখানো হয় — ব্যাকএন্ড থেকে আসে, ডিটেইলস খোলার সময় GitHub কোটায় আর কোনো খরচ নেই।" + "লাইসেন্স এখন প্রতিটি রিপোর জন্য সাইন-ইন স্ট্যাটাস নির্বিশেষে দেখানো হয় — ব্যাকএন্ড থেকে আসে, ডিটেইলস খোলার সময় GitHub কোটায় আর কোনো খরচ নেই।", + "ব্যাকগ্রাউন্ড আপডেট চেক পুরোপুরি বন্ধ করা যায় — ম্যানুয়ালি চেক করতে চাইলে ব্যাটারি বাঁচে।" ] }, { diff --git a/core/presentation/src/commonMain/composeResources/files/whatsnew/es/16.json b/core/presentation/src/commonMain/composeResources/files/whatsnew/es/16.json index 80904e2d..f10981d8 100644 --- a/core/presentation/src/commonMain/composeResources/files/whatsnew/es/16.json +++ b/core/presentation/src/commonMain/composeResources/files/whatsnew/es/16.json @@ -25,7 +25,8 @@ "El reescaneo manual muestra todas las apps tipo GitHub presentes en el dispositivo.", "Mejor manejo de autenticación: los 401 transitorios ya no provocan cierres de sesión espurios.", "El número de incidencias abiertas ahora se muestra a todos, incluidos los usuarios sin sesión — viene del backend, sin coste de cuota de GitHub.", - "La licencia ahora se muestra para cada repo independientemente del estado de inicio de sesión — viene del backend, sin coste de cuota de GitHub al abrir Detalles." + "La licencia ahora se muestra para cada repo independientemente del estado de inicio de sesión — viene del backend, sin coste de cuota de GitHub al abrir Detalles.", + "La comprobación de actualizaciones en segundo plano se puede desactivar por completo — ahorra batería si prefieres comprobar manualmente." ] }, { diff --git a/core/presentation/src/commonMain/composeResources/files/whatsnew/fr/16.json b/core/presentation/src/commonMain/composeResources/files/whatsnew/fr/16.json index b7eca817..b7d018dd 100644 --- a/core/presentation/src/commonMain/composeResources/files/whatsnew/fr/16.json +++ b/core/presentation/src/commonMain/composeResources/files/whatsnew/fr/16.json @@ -25,7 +25,8 @@ "Le rescan manuel fait remonter toutes les apps de type GitHub présentes sur l’appareil.", "Gestion d’authentification renforcée : les 401 transitoires ne déconnectent plus à tort.", "Le nombre d’issues ouvertes s’affiche désormais pour tout le monde, y compris les utilisateurs déconnectés — fourni par le backend, sans coût de quota GitHub.", - "La licence s’affiche désormais pour chaque dépôt, peu importe l’état de connexion — fournie par le backend, sans coût de quota GitHub à l’ouverture des Détails." + "La licence s’affiche désormais pour chaque dépôt, peu importe l’état de connexion — fournie par le backend, sans coût de quota GitHub à l’ouverture des Détails.", + "La vérification des mises à jour en arrière-plan peut être complètement désactivée — économise la batterie si vous préférez vérifier manuellement." ] }, { diff --git a/core/presentation/src/commonMain/composeResources/files/whatsnew/hi/16.json b/core/presentation/src/commonMain/composeResources/files/whatsnew/hi/16.json index 7834352b..47a9256a 100644 --- a/core/presentation/src/commonMain/composeResources/files/whatsnew/hi/16.json +++ b/core/presentation/src/commonMain/composeResources/files/whatsnew/hi/16.json @@ -25,7 +25,8 @@ "मैन्युअल रीस्कैन डिवाइस पर मौजूद हर GitHub-शैली के ऐप को सामने ले आता है।", "ऑथ हैंडलिंग पहले से बेहतर: अस्थायी 401 अब ग़लती से साइन-आउट नहीं कराते।", "खुले इश्यू की संख्या अब सभी को दिखाई देती है, यहाँ तक कि साइन-आउट उपयोगकर्ताओं को भी — बैकएंड से आती है, GitHub कोटे पर कोई असर नहीं।", - "लाइसेंस अब हर रेपो के लिए साइन-इन की स्थिति की परवाह किए बिना दिखता है — बैकएंड से आता है, विवरण खोलने पर अब GitHub कोटा खर्च नहीं होता।" + "लाइसेंस अब हर रेपो के लिए साइन-इन की स्थिति की परवाह किए बिना दिखता है — बैकएंड से आता है, विवरण खोलने पर अब GitHub कोटा खर्च नहीं होता।", + "बैकग्राउंड अपडेट जाँच को पूरी तरह बंद किया जा सकता है — मैन्युअल जाँच पसंद करते हैं तो बैटरी बचती है।" ] }, { diff --git a/core/presentation/src/commonMain/composeResources/files/whatsnew/it/16.json b/core/presentation/src/commonMain/composeResources/files/whatsnew/it/16.json index e9475d9a..dbac0e87 100644 --- a/core/presentation/src/commonMain/composeResources/files/whatsnew/it/16.json +++ b/core/presentation/src/commonMain/composeResources/files/whatsnew/it/16.json @@ -25,7 +25,8 @@ "La rilevazione manuale mostra tutte le app di tipo GitHub presenti sul dispositivo.", "Gestione dell’autenticazione più solida: i 401 transitori non causano più disconnessioni indebite.", "Il conteggio delle issue aperte ora è visibile a tutti, anche agli utenti non autenticati — arriva dal backend, senza costi di quota GitHub.", - "La licenza ora è mostrata per ogni repo indipendentemente dallo stato di accesso — arriva dal backend, senza costi di quota GitHub all’apertura dei Dettagli." + "La licenza ora è mostrata per ogni repo indipendentemente dallo stato di accesso — arriva dal backend, senza costi di quota GitHub all’apertura dei Dettagli.", + "La verifica aggiornamenti in background può essere disattivata del tutto — risparmia batteria se preferisci verificare manualmente." ] }, { diff --git a/core/presentation/src/commonMain/composeResources/files/whatsnew/ja/16.json b/core/presentation/src/commonMain/composeResources/files/whatsnew/ja/16.json index 9d3e376e..8534fe01 100644 --- a/core/presentation/src/commonMain/composeResources/files/whatsnew/ja/16.json +++ b/core/presentation/src/commonMain/composeResources/files/whatsnew/ja/16.json @@ -25,7 +25,8 @@ "手動での再スキャンで、端末上の GitHub 系アプリをすべて検出するようになりました。", "認証エラー処理を強化。一時的な 401 で誤ってサインアウトされなくなりました。", "オープン Issue 数を未ログインユーザーを含む全員に表示。バックエンドから取得するため GitHub のクォータを消費しません。", - "ライセンスをサインイン状態に関係なく全リポジトリで表示。バックエンドから取得するため、詳細画面を開いても GitHub のクォータを消費しません。" + "ライセンスをサインイン状態に関係なく全リポジトリで表示。バックエンドから取得するため、詳細画面を開いても GitHub のクォータを消費しません。", + "バックグラウンドの更新確認を完全にオフにできます — 手動でチェックしたい場合はバッテリーを節約できます。" ] }, { diff --git a/core/presentation/src/commonMain/composeResources/files/whatsnew/ko/16.json b/core/presentation/src/commonMain/composeResources/files/whatsnew/ko/16.json index 21ae6f42..ddec2c45 100644 --- a/core/presentation/src/commonMain/composeResources/files/whatsnew/ko/16.json +++ b/core/presentation/src/commonMain/composeResources/files/whatsnew/ko/16.json @@ -25,7 +25,8 @@ "수동 재스캔이 기기의 모든 GitHub 계열 앱을 빠짐없이 표시합니다.", "인증 처리 강화: 일시적인 401로 인해 잘못 로그아웃되지 않습니다.", "열린 이슈 수가 이제 로그아웃 사용자를 포함한 모두에게 표시됩니다 — 백엔드에서 제공되며 GitHub 할당량을 소비하지 않습니다.", - "라이선스가 로그인 여부와 관계없이 모든 저장소에 표시됩니다 — 백엔드에서 제공되며 세부 정보를 열어도 GitHub 할당량을 소비하지 않습니다." + "라이선스가 로그인 여부와 관계없이 모든 저장소에 표시됩니다 — 백엔드에서 제공되며 세부 정보를 열어도 GitHub 할당량을 소비하지 않습니다.", + "백그라운드 업데이트 확인을 완전히 끌 수 있습니다 — 수동으로 확인하고 싶다면 배터리를 절약합니다." ] }, { diff --git a/core/presentation/src/commonMain/composeResources/files/whatsnew/pl/16.json b/core/presentation/src/commonMain/composeResources/files/whatsnew/pl/16.json index c90777cf..c5d6da97 100644 --- a/core/presentation/src/commonMain/composeResources/files/whatsnew/pl/16.json +++ b/core/presentation/src/commonMain/composeResources/files/whatsnew/pl/16.json @@ -25,7 +25,8 @@ "Ręczne ponowne skanowanie pokazuje wszystkie aplikacje z GitHuba obecne na urządzeniu.", "Stabilniejsza obsługa autoryzacji — przejściowe 401 nie powodują już fałszywych wylogowań.", "Liczba otwartych zgłoszeń jest teraz pokazywana wszystkim, także użytkownikom niezalogowanym — pochodzi z backendu, bez kosztów limitu GitHuba.", - "Licencja jest teraz pokazywana dla każdego repo niezależnie od stanu zalogowania — pochodzi z backendu, bez kosztów limitu GitHuba przy otwieraniu Szczegółów." + "Licencja jest teraz pokazywana dla każdego repo niezależnie od stanu zalogowania — pochodzi z backendu, bez kosztów limitu GitHuba przy otwieraniu Szczegółów.", + "Sprawdzanie aktualizacji w tle można całkowicie wyłączyć — oszczędza baterię, jeśli wolisz sprawdzać ręcznie." ] }, { diff --git a/core/presentation/src/commonMain/composeResources/files/whatsnew/ru/16.json b/core/presentation/src/commonMain/composeResources/files/whatsnew/ru/16.json index 13f4ecf0..99dd830c 100644 --- a/core/presentation/src/commonMain/composeResources/files/whatsnew/ru/16.json +++ b/core/presentation/src/commonMain/composeResources/files/whatsnew/ru/16.json @@ -25,7 +25,8 @@ "Ручное пересканирование показывает все приложения GitHub-типа на устройстве.", "Аккуратная обработка авторизации: единичные 401 больше не вызывают ложный выход из аккаунта.", "Количество открытых задач теперь видно всем, в том числе неавторизованным пользователям — берётся из бэкенда, без расхода квоты GitHub.", - "Лицензия теперь видна для каждого репозитория независимо от статуса входа — берётся из бэкенда, без расхода квоты GitHub при открытии деталей." + "Лицензия теперь видна для каждого репозитория независимо от статуса входа — берётся из бэкенда, без расхода квоты GitHub при открытии деталей.", + "Фоновую проверку обновлений можно полностью отключить — экономит батарею, если предпочитаете проверять вручную." ] }, { diff --git a/core/presentation/src/commonMain/composeResources/files/whatsnew/tr/16.json b/core/presentation/src/commonMain/composeResources/files/whatsnew/tr/16.json index 6dae6149..f64622db 100644 --- a/core/presentation/src/commonMain/composeResources/files/whatsnew/tr/16.json +++ b/core/presentation/src/commonMain/composeResources/files/whatsnew/tr/16.json @@ -25,7 +25,8 @@ "Manuel yeniden tarama, cihazdaki tüm GitHub tipi uygulamaları görünür kılıyor.", "Daha sağlam kimlik doğrulama: geçici 401 yanıtları artık yanlışlıkla oturumu kapatmıyor.", "Açık konu sayısı artık oturum açmamış kullanıcılar dahil herkese gösteriliyor — backend'den geliyor, GitHub kotası harcamıyor.", - "Lisans artık oturum durumundan bağımsız olarak her depo için gösteriliyor — backend'den geliyor, Detayları açarken GitHub kotası harcanmıyor." + "Lisans artık oturum durumundan bağımsız olarak her depo için gösteriliyor — backend'den geliyor, Detayları açarken GitHub kotası harcanmıyor.", + "Arka plan güncelleme kontrolü tamamen kapatılabiliyor — manuel kontrolü tercih ediyorsanız pil tasarrufu sağlar." ] }, { diff --git a/core/presentation/src/commonMain/composeResources/files/whatsnew/zh-CN/16.json b/core/presentation/src/commonMain/composeResources/files/whatsnew/zh-CN/16.json index e517c182..cb80e0de 100644 --- a/core/presentation/src/commonMain/composeResources/files/whatsnew/zh-CN/16.json +++ b/core/presentation/src/commonMain/composeResources/files/whatsnew/zh-CN/16.json @@ -25,7 +25,8 @@ "手动重新扫描会列出设备上所有 GitHub 风格的应用,不再漏报。", "更稳健的鉴权处理:偶发的 401 不会再让你被错误地踢出登录。", "未登录用户也能看到「Open Issues」数量了 — 数据来自后端,不消耗任何 GitHub 配额。", - "无论是否登录,每个仓库都会显示许可证信息 — 数据来自后端,打开详情页不再消耗 GitHub 配额。" + "无论是否登录,每个仓库都会显示许可证信息 — 数据来自后端,打开详情页不再消耗 GitHub 配额。", + "可完全关闭后台更新检查 — 如果你更喜欢手动检查,这能省电。" ] }, { diff --git a/core/presentation/src/commonMain/composeResources/values-ar/strings-ar.xml b/core/presentation/src/commonMain/composeResources/values-ar/strings-ar.xml index 47a73847..006b472c 100644 --- a/core/presentation/src/commonMain/composeResources/values-ar/strings-ar.xml +++ b/core/presentation/src/commonMain/composeResources/values-ar/strings-ar.xml @@ -565,6 +565,8 @@ التحديثات فترة التحقق من التحديثات عدد مرات التحقق من تحديثات التطبيق في الخلفية + التحقق التلقائي من التحديثات + يبحث عن التحديثات في الخلفية بشكل دوري. أوقفه لتوفير البطارية — يمكنك دائماً التحقق يدوياً من شاشة تفاصيل أي تطبيق. ٣ ساعات ٦ ساعات ١٢ ساعة diff --git a/core/presentation/src/commonMain/composeResources/values-bn/strings-bn.xml b/core/presentation/src/commonMain/composeResources/values-bn/strings-bn.xml index 93f5966e..83b13955 100644 --- a/core/presentation/src/commonMain/composeResources/values-bn/strings-bn.xml +++ b/core/presentation/src/commonMain/composeResources/values-bn/strings-bn.xml @@ -564,6 +564,8 @@ আপডেট আপডেট চেক করার ব্যবধান ব্যাকগ্রাউন্ডে কতক্ষণ পর পর অ্যাপ আপডেট খোঁজা হবে + ব্যাকগ্রাউন্ড আপডেট চেক + নিয়মিত ব্যাকগ্রাউন্ডে আপডেট খোঁজে। ব্যাটারি বাঁচাতে বন্ধ করুন — আপনি যেকোনো অ্যাপের ডিটেইলস স্ক্রিন থেকে ম্যানুয়ালি চেক করতে পারবেন। ৩ঘ ৬ঘ ১২ঘ diff --git a/core/presentation/src/commonMain/composeResources/values-es/strings-es.xml b/core/presentation/src/commonMain/composeResources/values-es/strings-es.xml index afbf2e1f..94fcea06 100644 --- a/core/presentation/src/commonMain/composeResources/values-es/strings-es.xml +++ b/core/presentation/src/commonMain/composeResources/values-es/strings-es.xml @@ -525,6 +525,8 @@ Actualizaciones Intervalo de verificación Con qué frecuencia buscar actualizaciones en segundo plano + Comprobación de actualizaciones en segundo plano + Busca actualizaciones periódicamente en segundo plano. Desactívalo para ahorrar batería — puedes comprobar manualmente desde la pantalla de detalles de cualquier app. 3h 6h 12h diff --git a/core/presentation/src/commonMain/composeResources/values-fr/strings-fr.xml b/core/presentation/src/commonMain/composeResources/values-fr/strings-fr.xml index 8136a47a..31b26d20 100644 --- a/core/presentation/src/commonMain/composeResources/values-fr/strings-fr.xml +++ b/core/presentation/src/commonMain/composeResources/values-fr/strings-fr.xml @@ -526,6 +526,8 @@ Mises à jour Intervalle de vérification Fréquence de vérification des mises à jour en arrière-plan + Vérification des mises à jour en arrière-plan + Vérifie périodiquement les mises à jour en arrière-plan. Désactivez pour économiser la batterie — vous pouvez vérifier manuellement depuis la fiche détails de n'importe quelle app. 3h 6h 12h diff --git a/core/presentation/src/commonMain/composeResources/values-hi/strings-hi.xml b/core/presentation/src/commonMain/composeResources/values-hi/strings-hi.xml index b4e1468e..6ae6aa21 100644 --- a/core/presentation/src/commonMain/composeResources/values-hi/strings-hi.xml +++ b/core/presentation/src/commonMain/composeResources/values-hi/strings-hi.xml @@ -563,6 +563,8 @@ अपडेट अपडेट जाँच अंतराल पृष्ठभूमि में ऐप अपडेट कितनी बार जाँचें + पृष्ठभूमि अपडेट जाँच + पृष्ठभूमि में समय-समय पर अपडेट जाँचता है। बैटरी बचाने के लिए बंद करें — किसी भी ऐप के विवरण स्क्रीन से मैन्युअली जाँच की जा सकती है। 3घ 6घ 12घ diff --git a/core/presentation/src/commonMain/composeResources/values-it/strings-it.xml b/core/presentation/src/commonMain/composeResources/values-it/strings-it.xml index 22277c33..7f922a34 100644 --- a/core/presentation/src/commonMain/composeResources/values-it/strings-it.xml +++ b/core/presentation/src/commonMain/composeResources/values-it/strings-it.xml @@ -564,6 +564,8 @@ Aggiornamenti Intervallo di controllo Ogni quanto verificare gli aggiornamenti in background + Verifica aggiornamenti in background + Verifica periodicamente gli aggiornamenti in background. Disattiva per risparmiare batteria — puoi sempre verificare manualmente dalla schermata dettagli di qualsiasi app. 3h 6h 12h diff --git a/core/presentation/src/commonMain/composeResources/values-ja/strings-ja.xml b/core/presentation/src/commonMain/composeResources/values-ja/strings-ja.xml index e380a27a..17290288 100644 --- a/core/presentation/src/commonMain/composeResources/values-ja/strings-ja.xml +++ b/core/presentation/src/commonMain/composeResources/values-ja/strings-ja.xml @@ -527,6 +527,8 @@ アップデート アップデート確認間隔 バックグラウンドでアプリのアップデートを確認する頻度 + バックグラウンド更新確認 + バックグラウンドで定期的に更新を確認します。バッテリー節約のためオフにできます — 各アプリの詳細画面から手動で確認できます。 3時間 6時間 12時間 diff --git a/core/presentation/src/commonMain/composeResources/values-ko/strings-ko.xml b/core/presentation/src/commonMain/composeResources/values-ko/strings-ko.xml index 6d5dc471..5bd091af 100644 --- a/core/presentation/src/commonMain/composeResources/values-ko/strings-ko.xml +++ b/core/presentation/src/commonMain/composeResources/values-ko/strings-ko.xml @@ -562,6 +562,8 @@ 업데이트 업데이트 확인 주기 백그라운드에서 앱 업데이트를 확인하는 빈도 + 백그라운드 업데이트 확인 + 백그라운드에서 주기적으로 업데이트를 확인합니다. 배터리를 절약하려면 끄세요 — 앱 세부 정보 화면에서 언제든 수동으로 확인할 수 있습니다. 3시간 6시간 12시간 diff --git a/core/presentation/src/commonMain/composeResources/values-pl/strings-pl.xml b/core/presentation/src/commonMain/composeResources/values-pl/strings-pl.xml index cbf3e17a..5f1bbe1d 100644 --- a/core/presentation/src/commonMain/composeResources/values-pl/strings-pl.xml +++ b/core/presentation/src/commonMain/composeResources/values-pl/strings-pl.xml @@ -528,6 +528,8 @@ Aktualizacje Częstotliwość sprawdzania Jak często sprawdzać aktualizacje aplikacji w tle + Sprawdzanie aktualizacji w tle + Okresowo sprawdza aktualizacje w tle. Wyłącz, aby oszczędzać baterię — zawsze możesz sprawdzić ręcznie z ekranu szczegółów dowolnej aplikacji. 3g 6g 12g diff --git a/core/presentation/src/commonMain/composeResources/values-ru/strings-ru.xml b/core/presentation/src/commonMain/composeResources/values-ru/strings-ru.xml index 3b96792a..0c548e31 100644 --- a/core/presentation/src/commonMain/composeResources/values-ru/strings-ru.xml +++ b/core/presentation/src/commonMain/composeResources/values-ru/strings-ru.xml @@ -528,6 +528,8 @@ Обновления Интервал проверки обновлений Как часто проверять обновления приложения в фоне + Фоновая проверка обновлений + Периодически проверяет обновления в фоне. Отключите для экономии батареи — всегда можно проверить вручную из экрана деталей любого приложения. 12ч diff --git a/core/presentation/src/commonMain/composeResources/values-tr/strings-tr.xml b/core/presentation/src/commonMain/composeResources/values-tr/strings-tr.xml index 9953cfa4..f9ed52dc 100644 --- a/core/presentation/src/commonMain/composeResources/values-tr/strings-tr.xml +++ b/core/presentation/src/commonMain/composeResources/values-tr/strings-tr.xml @@ -562,6 +562,8 @@ Güncellemeler Güncelleme kontrol aralığı Arka planda uygulama güncellemelerinin ne sıklıkla kontrol edileceği + Arka planda güncelleme kontrolü + Arka planda düzenli aralıklarla güncellemeleri kontrol eder. Pil tasarrufu için kapatın — her zaman uygulamanın detay ekranından manuel olarak kontrol edebilirsiniz. 3s 6s 12s diff --git a/core/presentation/src/commonMain/composeResources/values-zh-rCN/strings-zh-rCN.xml b/core/presentation/src/commonMain/composeResources/values-zh-rCN/strings-zh-rCN.xml index 4d8909b0..fdd14e15 100644 --- a/core/presentation/src/commonMain/composeResources/values-zh-rCN/strings-zh-rCN.xml +++ b/core/presentation/src/commonMain/composeResources/values-zh-rCN/strings-zh-rCN.xml @@ -528,6 +528,8 @@ 更新 更新检查间隔 在后台检查应用更新的频率 + 后台检查更新 + 在后台周期性检查更新。可关闭以节省电量 — 你随时可在任意应用的详情页手动检查。 3小时 6小时 12小时 diff --git a/core/presentation/src/commonMain/composeResources/values/strings.xml b/core/presentation/src/commonMain/composeResources/values/strings.xml index f2e92e1f..31bf678d 100644 --- a/core/presentation/src/commonMain/composeResources/values/strings.xml +++ b/core/presentation/src/commonMain/composeResources/values/strings.xml @@ -658,6 +658,8 @@ Updates Update check interval How often to check for app updates in background + Background update check + Periodically check for updates in the background. Turn off to save battery — you can still check manually from any app's details screen. 3h 6h 12h diff --git a/feature/tweaks/presentation/src/commonMain/kotlin/zed/rainxch/tweaks/presentation/TweaksAction.kt b/feature/tweaks/presentation/src/commonMain/kotlin/zed/rainxch/tweaks/presentation/TweaksAction.kt index e89c4ef2..e513dcc8 100644 --- a/feature/tweaks/presentation/src/commonMain/kotlin/zed/rainxch/tweaks/presentation/TweaksAction.kt +++ b/feature/tweaks/presentation/src/commonMain/kotlin/zed/rainxch/tweaks/presentation/TweaksAction.kt @@ -95,6 +95,10 @@ sealed interface TweaksAction { val hours: Long, ) : TweaksAction + data class OnUpdateCheckEnabledToggled( + val enabled: Boolean, + ) : TweaksAction + data class OnIncludePreReleasesToggled( val enabled: Boolean, ) : TweaksAction diff --git a/feature/tweaks/presentation/src/commonMain/kotlin/zed/rainxch/tweaks/presentation/TweaksState.kt b/feature/tweaks/presentation/src/commonMain/kotlin/zed/rainxch/tweaks/presentation/TweaksState.kt index eb214dc4..6376e1e1 100644 --- a/feature/tweaks/presentation/src/commonMain/kotlin/zed/rainxch/tweaks/presentation/TweaksState.kt +++ b/feature/tweaks/presentation/src/commonMain/kotlin/zed/rainxch/tweaks/presentation/TweaksState.kt @@ -29,6 +29,7 @@ data class TweaksState( val shizukuAvailability: ShizukuAvailability = ShizukuAvailability.UNAVAILABLE, val dhizukuAvailability: DhizukuAvailability = DhizukuAvailability.UNAVAILABLE, val autoUpdateEnabled: Boolean = false, + val updateCheckEnabled: Boolean = true, val updateCheckIntervalHours: Long = 6L, val includePreReleases: Boolean = false, val isHideSeenEnabled: Boolean = false, diff --git a/feature/tweaks/presentation/src/commonMain/kotlin/zed/rainxch/tweaks/presentation/TweaksViewModel.kt b/feature/tweaks/presentation/src/commonMain/kotlin/zed/rainxch/tweaks/presentation/TweaksViewModel.kt index 87a079bf..2e6edd78 100644 --- a/feature/tweaks/presentation/src/commonMain/kotlin/zed/rainxch/tweaks/presentation/TweaksViewModel.kt +++ b/feature/tweaks/presentation/src/commonMain/kotlin/zed/rainxch/tweaks/presentation/TweaksViewModel.kt @@ -69,6 +69,7 @@ class TweaksViewModel( loadInstallerPreference() loadAutoUpdatePreference() loadUpdateCheckInterval() + loadUpdateCheckEnabled() loadIncludePreReleases() loadHideSeenEnabled() loadScrollbarEnabled() @@ -367,6 +368,16 @@ class TweaksViewModel( } } + private fun loadUpdateCheckEnabled() { + viewModelScope.launch { + tweaksRepository.getUpdateCheckEnabled().collect { enabled -> + _state.update { + it.copy(updateCheckEnabled = enabled) + } + } + } + } + private fun loadHideSeenEnabled() { viewModelScope.launch { tweaksRepository.getHideSeenEnabled().collect { enabled -> @@ -683,7 +694,20 @@ class TweaksViewModel( is TweaksAction.OnUpdateCheckIntervalChanged -> { viewModelScope.launch { tweaksRepository.setUpdateCheckInterval(action.hours) - updateScheduleManager.reschedule(action.hours) + if (_state.value.updateCheckEnabled) { + updateScheduleManager.reschedule(action.hours) + } + } + } + + is TweaksAction.OnUpdateCheckEnabledToggled -> { + viewModelScope.launch { + tweaksRepository.setUpdateCheckEnabled(action.enabled) + if (action.enabled) { + updateScheduleManager.reschedule(_state.value.updateCheckIntervalHours) + } else { + updateScheduleManager.cancel() + } } } diff --git a/feature/tweaks/presentation/src/commonMain/kotlin/zed/rainxch/tweaks/presentation/components/sections/Installation.kt b/feature/tweaks/presentation/src/commonMain/kotlin/zed/rainxch/tweaks/presentation/components/sections/Installation.kt index cf18f095..b804e9cf 100644 --- a/feature/tweaks/presentation/src/commonMain/kotlin/zed/rainxch/tweaks/presentation/components/sections/Installation.kt +++ b/feature/tweaks/presentation/src/commonMain/kotlin/zed/rainxch/tweaks/presentation/components/sections/Installation.kt @@ -293,8 +293,18 @@ fun LazyListScope.updatesSection( Spacer(Modifier.height(8.dp)) + BackgroundUpdateCheckToggleCard( + enabled = state.updateCheckEnabled, + onToggle = { enabled -> + onAction(TweaksAction.OnUpdateCheckEnabledToggled(enabled)) + } + ) + + Spacer(Modifier.height(12.dp)) + UpdateCheckIntervalCard( selectedIntervalHours = state.updateCheckIntervalHours, + enabled = state.updateCheckEnabled, onIntervalSelected = { hours -> onAction(TweaksAction.OnUpdateCheckIntervalChanged(hours)) } @@ -311,6 +321,44 @@ fun LazyListScope.updatesSection( } } +@OptIn(ExperimentalMaterial3ExpressiveApi::class) +@Composable +private fun BackgroundUpdateCheckToggleCard( + enabled: Boolean, + onToggle: (Boolean) -> Unit, +) { + ExpressiveCard { + Row( + modifier = Modifier + .fillMaxWidth() + .padding(16.dp), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(12.dp) + ) { + Column( + modifier = Modifier.weight(1f), + verticalArrangement = Arrangement.spacedBy(2.dp) + ) { + Text( + text = stringResource(Res.string.update_check_enabled_title), + style = MaterialTheme.typography.titleMedium, + color = MaterialTheme.colorScheme.onSurface, + fontWeight = FontWeight.SemiBold + ) + Text( + text = stringResource(Res.string.update_check_enabled_description), + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onSurfaceVariant + ) + } + Switch( + checked = enabled, + onCheckedChange = onToggle + ) + } + } +} + @OptIn(ExperimentalMaterial3ExpressiveApi::class) @Composable private fun InstallerTypeCard( @@ -654,6 +702,7 @@ private fun AutoUpdateCard( @Composable private fun UpdateCheckIntervalCard( selectedIntervalHours: Long, + enabled: Boolean, onIntervalSelected: (Long) -> Unit, ) { val intervals = listOf( @@ -711,6 +760,7 @@ private fun UpdateCheckIntervalCard( FilterChip( selected = isSelected, + enabled = enabled, onClick = { onIntervalSelected(hours) }, label = { Text(