From d08ff3fbae774d5c30b8c3862bc908064252cbd0 Mon Sep 17 00:00:00 2001 From: Imran Remtulla Date: Mon, 21 Aug 2023 20:32:41 -0400 Subject: [PATCH] Add BG update toggle --- assets/translations/bs.json | 2 ++ assets/translations/de.json | 2 ++ assets/translations/en.json | 3 ++ assets/translations/es.json | 2 ++ assets/translations/fa.json | 2 ++ assets/translations/fr.json | 2 ++ assets/translations/hu.json | 2 ++ assets/translations/it.json | 2 ++ assets/translations/ja.json | 2 ++ assets/translations/pl.json | 2 ++ assets/translations/ru.json | 2 ++ assets/translations/zh.json | 2 ++ lib/pages/settings.dart | 46 ++++++++++++++++++++++++++++ lib/providers/settings_provider.dart | 9 ++++++ 14 files changed, 80 insertions(+) diff --git a/assets/translations/bs.json b/assets/translations/bs.json index 7c86b74..cd14a19 100644 --- a/assets/translations/bs.json +++ b/assets/translations/bs.json @@ -244,6 +244,8 @@ "appsPossiblyUpdated": "App Updates Attempted", "appsPossiblyUpdatedNotifDescription": "Notifies the user that updates to one or more Apps were potentially applied in the background", "xWasPossiblyUpdatedToY": "{} may have been updated to {}.", + "backgroundUpdateReqsExplanation": "Background updates may not be possible for all apps.", + "backgroundUpdateLimitsExplanation": "The success of a background install can only be determined when Obtainium is opened.", "removeAppQuestion": { "one": "Želite li ukloniti aplikaciju?", "other": "Želite li ukloniti aplikacije?" diff --git a/assets/translations/de.json b/assets/translations/de.json index 973c229..9227e9f 100644 --- a/assets/translations/de.json +++ b/assets/translations/de.json @@ -244,6 +244,8 @@ "appsPossiblyUpdated": "App Updates Attempted", "appsPossiblyUpdatedNotifDescription": "Notifies the user that updates to one or more Apps were potentially applied in the background", "xWasPossiblyUpdatedToY": "{} may have been updated to {}.", + "backgroundUpdateReqsExplanation": "Background updates may not be possible for all apps.", + "backgroundUpdateLimitsExplanation": "The success of a background install can only be determined when Obtainium is opened.", "removeAppQuestion": { "one": "App entfernen?", "other": "Apps entfernen?" diff --git a/assets/translations/en.json b/assets/translations/en.json index 7a76230..165b4ff 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -244,6 +244,9 @@ "appsPossiblyUpdated": "App Updates Attempted", "appsPossiblyUpdatedNotifDescription": "Notifies the user that updates to one or more Apps were potentially applied in the background", "xWasPossiblyUpdatedToY": "{} may have been updated to {}.", + "enableBackgroundUpdates": "Enable background updates", + "backgroundUpdateReqsExplanation": "Background updates may not be possible for all apps.", + "backgroundUpdateLimitsExplanation": "The success of a background install can only be determined when Obtainium is opened.", "removeAppQuestion": { "one": "Remove App?", "other": "Remove Apps?" diff --git a/assets/translations/es.json b/assets/translations/es.json index 63f9dc1..bbed509 100644 --- a/assets/translations/es.json +++ b/assets/translations/es.json @@ -244,6 +244,8 @@ "appsPossiblyUpdated": "App Updates Attempted", "appsPossiblyUpdatedNotifDescription": "Notifies the user that updates to one or more Apps were potentially applied in the background", "xWasPossiblyUpdatedToY": "{} may have been updated to {}.", + "backgroundUpdateReqsExplanation": "Background updates may not be possible for all apps.", + "backgroundUpdateLimitsExplanation": "The success of a background install can only be determined when Obtainium is opened.", "removeAppQuestion": { "one": "¿Eliminar Aplicación?", "other": "¿Eliminar Aplicaciones?" diff --git a/assets/translations/fa.json b/assets/translations/fa.json index 4342244..93caa25 100644 --- a/assets/translations/fa.json +++ b/assets/translations/fa.json @@ -244,6 +244,8 @@ "appsPossiblyUpdated": "App Updates Attempted", "appsPossiblyUpdatedNotifDescription": "Notifies the user that updates to one or more Apps were potentially applied in the background", "xWasPossiblyUpdatedToY": "{} may have been updated to {}.", + "backgroundUpdateReqsExplanation": "Background updates may not be possible for all apps.", + "backgroundUpdateLimitsExplanation": "The success of a background install can only be determined when Obtainium is opened.", "removeAppQuestion": { "one": "برنامه حذف شود؟", "other": "برنامه ها حذف شوند؟" diff --git a/assets/translations/fr.json b/assets/translations/fr.json index 1bc1a6e..bfbbfcc 100644 --- a/assets/translations/fr.json +++ b/assets/translations/fr.json @@ -244,6 +244,8 @@ "appsPossiblyUpdated": "App Updates Attempted", "appsPossiblyUpdatedNotifDescription": "Notifies the user that updates to one or more Apps were potentially applied in the background", "xWasPossiblyUpdatedToY": "{} may have been updated to {}.", + "backgroundUpdateReqsExplanation": "Background updates may not be possible for all apps.", + "backgroundUpdateLimitsExplanation": "The success of a background install can only be determined when Obtainium is opened.", "removeAppQuestion": { "one": "Supprimer l'application ?", "other": "Supprimer les applications ?" diff --git a/assets/translations/hu.json b/assets/translations/hu.json index 117bd54..5c5fd49 100644 --- a/assets/translations/hu.json +++ b/assets/translations/hu.json @@ -243,6 +243,8 @@ "appsPossiblyUpdated": "App Updates Attempted", "appsPossiblyUpdatedNotifDescription": "Notifies the user that updates to one or more Apps were potentially applied in the background", "xWasPossiblyUpdatedToY": "{} may have been updated to {}.", + "backgroundUpdateReqsExplanation": "Background updates may not be possible for all apps.", + "backgroundUpdateLimitsExplanation": "The success of a background install can only be determined when Obtainium is opened.", "removeAppQuestion": { "one": "Eltávolítja az alkalmazást?", "other": "Eltávolítja az alkalmazást?" diff --git a/assets/translations/it.json b/assets/translations/it.json index e3a5211..14586d4 100644 --- a/assets/translations/it.json +++ b/assets/translations/it.json @@ -244,6 +244,8 @@ "appsPossiblyUpdated": "App Updates Attempted", "appsPossiblyUpdatedNotifDescription": "Notifies the user that updates to one or more Apps were potentially applied in the background", "xWasPossiblyUpdatedToY": "{} may have been updated to {}.", + "backgroundUpdateReqsExplanation": "Background updates may not be possible for all apps.", + "backgroundUpdateLimitsExplanation": "The success of a background install can only be determined when Obtainium is opened.", "removeAppQuestion": { "one": "Rimuovere l'app?", "other": "Rimuovere le app?" diff --git a/assets/translations/ja.json b/assets/translations/ja.json index f228582..386a512 100644 --- a/assets/translations/ja.json +++ b/assets/translations/ja.json @@ -244,6 +244,8 @@ "appsPossiblyUpdated": "App Updates Attempted", "appsPossiblyUpdatedNotifDescription": "Notifies the user that updates to one or more Apps were potentially applied in the background", "xWasPossiblyUpdatedToY": "{} may have been updated to {}.", + "backgroundUpdateReqsExplanation": "Background updates may not be possible for all apps.", + "backgroundUpdateLimitsExplanation": "The success of a background install can only be determined when Obtainium is opened.", "removeAppQuestion": { "one": "アプリを削除しますか?", "other": "アプリを削除しますか?" diff --git a/assets/translations/pl.json b/assets/translations/pl.json index 1b5809c..327e720 100644 --- a/assets/translations/pl.json +++ b/assets/translations/pl.json @@ -248,6 +248,8 @@ "appsPossiblyUpdated": "App Updates Attempted", "appsPossiblyUpdatedNotifDescription": "Notifies the user that updates to one or more Apps were potentially applied in the background", "xWasPossiblyUpdatedToY": "{} may have been updated to {}.", + "backgroundUpdateReqsExplanation": "Background updates may not be possible for all apps.", + "backgroundUpdateLimitsExplanation": "The success of a background install can only be determined when Obtainium is opened.", "removeAppQuestion": { "one": "Usunąć aplikację?", "other": "Usunąć aplikacje?" diff --git a/assets/translations/ru.json b/assets/translations/ru.json index 798793a..e8a2507 100644 --- a/assets/translations/ru.json +++ b/assets/translations/ru.json @@ -244,6 +244,8 @@ "appsPossiblyUpdated": "App Updates Attempted", "appsPossiblyUpdatedNotifDescription": "Notifies the user that updates to one or more Apps were potentially applied in the background", "xWasPossiblyUpdatedToY": "{} may have been updated to {}.", + "backgroundUpdateReqsExplanation": "Background updates may not be possible for all apps.", + "backgroundUpdateLimitsExplanation": "The success of a background install can only be determined when Obtainium is opened.", "removeAppQuestion": { "one": "Удалить приложение?", "other": "Удалить приложения?" diff --git a/assets/translations/zh.json b/assets/translations/zh.json index 05f3bc3..eac5e3e 100644 --- a/assets/translations/zh.json +++ b/assets/translations/zh.json @@ -244,6 +244,8 @@ "appsPossiblyUpdated": "App Updates Attempted", "appsPossiblyUpdatedNotifDescription": "Notifies the user that updates to one or more Apps were potentially applied in the background", "xWasPossiblyUpdatedToY": "{} may have been updated to {}.", + "backgroundUpdateReqsExplanation": "Background updates may not be possible for all apps.", + "backgroundUpdateLimitsExplanation": "The success of a background install can only be determined when Obtainium is opened.", "removeAppQuestion": { "one": "是否删除应用?", "other": "是否删除应用?" diff --git a/lib/pages/settings.dart b/lib/pages/settings.dart index 2ea391e..f98d8a0 100644 --- a/lib/pages/settings.dart +++ b/lib/pages/settings.dart @@ -1,3 +1,4 @@ +import 'package:device_info_plus/device_info_plus.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:obtainium/components/custom_app_bar.dart'; @@ -184,6 +185,10 @@ class _SettingsPageState extends State { } }); + const height8 = SizedBox( + height: 8, + ); + const height16 = SizedBox( height: 16, ); @@ -211,6 +216,47 @@ class _SettingsPageState extends State { color: Theme.of(context).colorScheme.primary), ), intervalDropdown, + FutureBuilder( + builder: (ctx, val) { + return (val.data?.version.sdkInt ?? 0) >= 30 + ? Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + height16, + Row( + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + children: [ + Flexible( + child: Text(tr( + 'enableBackgroundUpdates'))), + Switch( + value: settingsProvider + .enableBackgroundUpdates, + onChanged: (value) { + settingsProvider + .enableBackgroundUpdates = + value; + }) + ], + ), + height8, + Text(tr('backgroundUpdateReqsExplanation'), + style: Theme.of(context) + .textTheme + .labelSmall), + Text(tr('backgroundUpdateLimitsExplanation'), + style: Theme.of(context) + .textTheme + .labelSmall), + height8 + ], + ) + : const SizedBox.shrink(); + }, + future: DeviceInfoPlugin().androidInfo), height16, Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, diff --git a/lib/providers/settings_provider.dart b/lib/providers/settings_provider.dart index ea79e38..f5aba32 100644 --- a/lib/providers/settings_provider.dart +++ b/lib/providers/settings_provider.dart @@ -309,4 +309,13 @@ class SettingsProvider with ChangeNotifier { prefs?.setBool('reversePageTransitions', show); notifyListeners(); } + + bool get enableBackgroundUpdates { + return prefs?.getBool('enableBackgroundUpdates') ?? true; + } + + set enableBackgroundUpdates(bool val) { + prefs?.setBool('enableBackgroundUpdates', val); + notifyListeners(); + } }