From 0a6e1f9cc6c1e56fa63d5be114c05847429de2b2 Mon Sep 17 00:00:00 2001 From: Imran Remtulla Date: Sun, 27 Aug 2023 15:43:17 -0400 Subject: [PATCH 1/7] Switch back to upstream package manager (from custom branch) --- pubspec.lock | 11 +++++------ pubspec.yaml | 5 +---- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/pubspec.lock b/pubspec.lock index 0bd8a3c..b717324 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -29,12 +29,11 @@ packages: android_package_manager: dependency: "direct main" description: - path: "." - ref: master - resolved-ref: c7c2f992a9dc452393c94d96cdf2b1f5a5ce7c80 - url: "https://github.com/ImranR98/android_package_manager" - source: git - version: "0.5.4" + name: android_package_manager + sha256: b873fe5856f7c442aca9751dac05d117285be9e4de08eb15d1ffb811fd1b688d + url: "https://pub.dev" + source: hosted + version: "0.6.0" animations: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index d388e51..60254c0 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -55,10 +55,7 @@ dependencies: git: url: https://github.com/ImranR98/android_package_installer ref: main - android_package_manager: - git: - url: https://github.com/ImranR98/android_package_manager - ref: master + android_package_manager: ^0.6.0 share_plus: ^7.0.0 android_alarm_manager_plus: ^3.0.0 sqflite: ^2.2.0+3 From dcb8807fa741dc57488f8a53d7867ee469f018aa Mon Sep 17 00:00:00 2001 From: Imran Remtulla Date: Mon, 28 Aug 2023 19:11:22 -0400 Subject: [PATCH 2/7] Add "Intermediate Link" option to HTML Source (#820) --- assets/translations/bs.json | 2 +- assets/translations/en.json | 4 +++- assets/translations/es.json | 2 +- assets/translations/fr.json | 2 +- assets/translations/hu.json | 2 +- assets/translations/it.json | 2 +- assets/translations/ru.json | 2 +- lib/app_sources/html.dart | 24 ++++++++++++++++++++++++ lib/app_sources/huaweiappgallery.dart | 3 ++- lib/app_sources/jenkins.dart | 3 ++- lib/providers/source_provider.dart | 11 +++++++++-- 11 files changed, 46 insertions(+), 11 deletions(-) diff --git a/assets/translations/bs.json b/assets/translations/bs.json index 830a3ac..9590708 100644 --- a/assets/translations/bs.json +++ b/assets/translations/bs.json @@ -240,7 +240,7 @@ "gitlabSourceNote": "GitLab APK extraction may not work without an API key.", "sortByFileNamesNotLinks": "Sort by file names instead of full links", "filterReleaseNotesByRegEx": "Filter Release Notes by Regular Expression", - "customLinkFilterRegex": "Custom Link Filter by Regular Expression (Default '.apk$')", + "customLinkFilterRegex": "Custom APK Link Filter by Regular Expression (Default '.apk$')", "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 {}.", diff --git a/assets/translations/en.json b/assets/translations/en.json index e3a7684..d86d9a1 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -240,7 +240,7 @@ "gitlabSourceNote": "GitLab APK extraction may not work without an API key.", "sortByFileNamesNotLinks": "Sort by file names instead of full links", "filterReleaseNotesByRegEx": "Filter Release Notes by Regular Expression", - "customLinkFilterRegex": "Custom Link Filter by Regular Expression (Default '.apk$')", + "customLinkFilterRegex": "Custom APK Link Filter by Regular Expression (Default '.apk$')", "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 {}.", @@ -248,6 +248,8 @@ "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.", "verifyLatestTag": "Verify the 'latest' tag", + "intermediateLinkRegex": "Filter for an 'Intermediate' Link to Visit First", + "intermediateLinkNotFound": "Intermediate link not found", "removeAppQuestion": { "one": "Remove App?", "other": "Remove Apps?" diff --git a/assets/translations/es.json b/assets/translations/es.json index afe6e5e..a7968a7 100644 --- a/assets/translations/es.json +++ b/assets/translations/es.json @@ -240,7 +240,7 @@ "gitlabSourceNote": "GitLab APK extraction may not work without an API key.", "sortByFileNamesNotLinks": "Sort by file names instead of full links", "filterReleaseNotesByRegEx": "Filter Release Notes by Regular Expression", - "customLinkFilterRegex": "Custom Link Filter by Regular Expression (Default '.apk$')", + "customLinkFilterRegex": "Custom APK Link Filter by Regular Expression (Default '.apk$')", "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 {}.", diff --git a/assets/translations/fr.json b/assets/translations/fr.json index 2ab4bb8..4f7e585 100644 --- a/assets/translations/fr.json +++ b/assets/translations/fr.json @@ -240,7 +240,7 @@ "gitlabSourceNote": "GitLab APK extraction may not work without an API key.", "sortByFileNamesNotLinks": "Sort by file names instead of full links", "filterReleaseNotesByRegEx": "Filter Release Notes by Regular Expression", - "customLinkFilterRegex": "Custom Link Filter by Regular Expression (Default '.apk$')", + "customLinkFilterRegex": "Custom APK Link Filter by Regular Expression (Default '.apk$')", "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 {}.", diff --git a/assets/translations/hu.json b/assets/translations/hu.json index d30c802..8c3a71e 100644 --- a/assets/translations/hu.json +++ b/assets/translations/hu.json @@ -239,7 +239,7 @@ "gitlabSourceNote": "Előfordulhat, hogy a GitLab APK kibontása nem működik API-kulcs nélkül.", "sortByFileNamesNotLinks": "Fájlnevek szerinti elrendezés teljes linkek helyett", "filterReleaseNotesByRegEx": "Kiadási megjegyzések szűrése reguláris kifejezéssel", - "customLinkFilterRegex": "Custom Link Filter by Regular Expression (Default '.apk$')", + "customLinkFilterRegex": "Custom APK Link Filter by Regular Expression (Default '.apk$')", "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 {}.", diff --git a/assets/translations/it.json b/assets/translations/it.json index b4d0359..75d5778 100644 --- a/assets/translations/it.json +++ b/assets/translations/it.json @@ -240,7 +240,7 @@ "gitlabSourceNote": "GitLab APK extraction may not work without an API key.", "sortByFileNamesNotLinks": "Sort by file names instead of full links", "filterReleaseNotesByRegEx": "Filter Release Notes by Regular Expression", - "customLinkFilterRegex": "Custom Link Filter by Regular Expression (Default '.apk$')", + "customLinkFilterRegex": "Custom APK Link Filter by Regular Expression (Default '.apk$')", "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 {}.", diff --git a/assets/translations/ru.json b/assets/translations/ru.json index 703f057..6c91980 100644 --- a/assets/translations/ru.json +++ b/assets/translations/ru.json @@ -240,7 +240,7 @@ "gitlabSourceNote": "Извлечение APK из GitLab может не работать без ключа API.", "sortByFileNamesNotLinks": "Sort by file names instead of full links", "filterReleaseNotesByRegEx": "Filter Release Notes by Regular Expression", - "customLinkFilterRegex": "Custom Link Filter by Regular Expression (Default '.apk$')", + "customLinkFilterRegex": "Custom APK Link Filter by Regular Expression (Default '.apk$')", "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 {}.", diff --git a/lib/app_sources/html.dart b/lib/app_sources/html.dart index 8df2add..753e3f1 100644 --- a/lib/app_sources/html.dart +++ b/lib/app_sources/html.dart @@ -103,7 +103,16 @@ class HTML extends AppSource { } ]) ], + [ + GeneratedFormTextField('intermediateLinkRegex', + label: tr('intermediateLinkRegex'), + hint: '([0-9]+\.)*[0-9]+/\$', + required: false, + additionalValidators: [(value) => regExValidator(value)]) + ] ]; + overrideVersionDetectionFormDefault('noVersionDetection', + disableStandard: true, disableRelDate: true); } @override @@ -132,6 +141,21 @@ class HTML extends AppSource { .map((element) => element.attributes['href'] ?? '') .toList(); List links = []; + if ((additionalSettings['intermediateLinkRegex'] as String?) + ?.isNotEmpty == + true) { + var reg = RegExp(additionalSettings['intermediateLinkRegex']); + links = allLinks.where((element) => reg.hasMatch(element)).toList(); + links.sort((a, b) => compareAlphaNumeric(a, b)); + if (links.isEmpty) { + throw ObtainiumError(tr('intermediateLinkNotFound')); + } + Map additionalSettingsTemp = + Map.from(additionalSettings); + additionalSettingsTemp['intermediateLinkRegex'] = null; + return getLatestAPKDetails( + ensureAbsoluteUrl(links.last, uri), additionalSettingsTemp); + } if ((additionalSettings['customLinkFilterRegex'] as String?) ?.isNotEmpty == true) { diff --git a/lib/app_sources/huaweiappgallery.dart b/lib/app_sources/huaweiappgallery.dart index 1a97774..76388e9 100644 --- a/lib/app_sources/huaweiappgallery.dart +++ b/lib/app_sources/huaweiappgallery.dart @@ -7,7 +7,8 @@ class HuaweiAppGallery extends AppSource { HuaweiAppGallery() { name = 'Huawei AppGallery'; host = 'appgallery.huawei.com'; - overrideVersionDetectionFormDefault('releaseDateAsVersion', true); + overrideVersionDetectionFormDefault('releaseDateAsVersion', + disableStandard: true); } @override diff --git a/lib/app_sources/jenkins.dart b/lib/app_sources/jenkins.dart index 2aa8853..9e5af8d 100644 --- a/lib/app_sources/jenkins.dart +++ b/lib/app_sources/jenkins.dart @@ -6,7 +6,8 @@ import 'package:obtainium/providers/source_provider.dart'; class Jenkins extends AppSource { Jenkins() { - overrideVersionDetectionFormDefault('releaseDateAsVersion', true); + overrideVersionDetectionFormDefault('releaseDateAsVersion', + disableStandard: true); } String trimJobUrl(String url) { diff --git a/lib/providers/source_provider.dart b/lib/providers/source_provider.dart index 3371ee4..3611566 100644 --- a/lib/providers/source_provider.dart +++ b/lib/providers/source_provider.dart @@ -329,16 +329,23 @@ abstract class AppSource { name = runtimeType.toString(); } - overrideVersionDetectionFormDefault(String vd, bool disableStandard) { + overrideVersionDetectionFormDefault(String vd, + {bool disableStandard = false, bool disableRelDate = false}) { additionalAppSpecificSourceAgnosticSettingFormItems = additionalAppSpecificSourceAgnosticSettingFormItems.map((e) { return e.map((e2) { if (e2.key == 'versionDetection') { var item = e2 as GeneratedFormDropdown; item.defaultValue = vd; + item.disabledOptKeys = []; if (disableStandard) { - item.disabledOptKeys = ['standardVersionDetection']; + item.disabledOptKeys?.add('standardVersionDetection'); } + if (disableRelDate) { + item.disabledOptKeys?.add('releaseDateAsVersion'); + } + item.disabledOptKeys = + item.disabledOptKeys?.where((element) => element != vd).toList(); } return e2; }).toList(); From 075ecae540c1c78019dd7e2be00a75e46a9d6e07 Mon Sep 17 00:00:00 2001 From: Imran Remtulla Date: Mon, 28 Aug 2023 19:36:02 -0400 Subject: [PATCH 3/7] Re-add VLC with better error messaging when no mirror available (#821) --- lib/app_sources/vlc.dart | 63 +++++++++++++++++++++++------- lib/providers/source_provider.dart | 3 +- 2 files changed, 50 insertions(+), 16 deletions(-) diff --git a/lib/app_sources/vlc.dart b/lib/app_sources/vlc.dart index 6787996..51adb7f 100644 --- a/lib/app_sources/vlc.dart +++ b/lib/app_sources/vlc.dart @@ -1,3 +1,4 @@ +import 'package:easy_localization/easy_localization.dart'; import 'package:html/parser.dart'; import 'package:http/http.dart'; import 'package:obtainium/app_sources/html.dart'; @@ -41,27 +42,59 @@ class VLC extends AppSource { String standardUrl, Map additionalSettings, ) async { - String? version = await getLatestVersion(standardUrl); - if (version == null) { - throw NoVersionError(); - } - String? targetUrl = '$dwUrlBase$version/'; - Response res = await sourceRequest(targetUrl); - List apkUrls = []; + Response res = await get( + Uri.parse('https://www.videolan.org/vlc/download-android.html')); if (res.statusCode == 200) { - apkUrls = parse(res.body) + var dwUrlBase = 'get.videolan.org/vlc-android'; + var dwLinks = parse(res.body) .querySelectorAll('a') - .map((e) => e.attributes['href']?.split('/').last) - .where((h) => - h != null && h.isNotEmpty && h.toLowerCase().endsWith('.apk')) - .map((e) => targetUrl + e!) + .where((element) => + element.attributes['href']?.contains(dwUrlBase) ?? false) .toList(); + String? version = dwLinks.isNotEmpty + ? dwLinks.first.attributes['href'] + ?.split('/') + .where((s) => s.isNotEmpty) + .last + : null; + if (version == null) { + throw NoVersionError(); + } + + String? targetUrl = 'https://$dwUrlBase/$version/'; + Response res2 = await get(Uri.parse(targetUrl)); + List apkUrls = []; + if (res2.statusCode == 200) { + apkUrls = parse(res2.body) + .querySelectorAll('a') + .map((e) => e.attributes['href']?.split('/').last) + .where((h) => + h != null && h.isNotEmpty && h.toLowerCase().endsWith('.apk')) + .map((e) => targetUrl + e!) + .toList(); + } else if (res2.statusCode == 500 && + res2.body.toLowerCase().indexOf('mirror') > 0) { + var html = parse(res2.body); + var err = ''; + html.body?.nodes.forEach((element) { + if (element.text != null) { + err += '${element.text}\n'; + } + }); + err = err.trim(); + if (err.isEmpty) { + err = tr('err'); + } + throw ObtainiumError(err); + } else { + throw getObtainiumHttpError(res2); + } + + return APKDetails( + version, getApkUrlsFromUrls(apkUrls), AppNames('VideoLAN', 'VLC')); } else { throw getObtainiumHttpError(res); } - - return APKDetails( - version, getApkUrlsFromUrls(apkUrls), AppNames('VideoLAN', 'VLC')); } @override diff --git a/lib/providers/source_provider.dart b/lib/providers/source_provider.dart index 3611566..9eef449 100644 --- a/lib/providers/source_provider.dart +++ b/lib/providers/source_provider.dart @@ -25,6 +25,7 @@ import 'package:obtainium/app_sources/sourceforge.dart'; import 'package:obtainium/app_sources/sourcehut.dart'; import 'package:obtainium/app_sources/steammobile.dart'; import 'package:obtainium/app_sources/telegramapp.dart'; +import 'package:obtainium/app_sources/vlc.dart'; import 'package:obtainium/components/generated_form.dart'; import 'package:obtainium/custom_errors.dart'; import 'package:obtainium/mass_app_sources/githubstars.dart'; @@ -523,7 +524,7 @@ class SourceProvider { // APKCombo(), // Can't get past their scraping blocking yet (get 403 Forbidden) Mullvad(), Signal(), - // VLC(), // As of 2023-08-26 this site randomly messes up the 'latest' version (one minute it's 3.5.4, next minute back to 3.5.3) + VLC(), // As of 2023-08-26 this site randomly messes up the 'latest' version (one minute it's 3.5.4, next minute back to 3.5.3) // WhatsApp(), // As of 2023-03-20 this is unusable as the version on the webpage is months out of date TelegramApp(), SteamMobile(), From 551643b11cf38b54d81bc18faef1c0be0ee56844 Mon Sep 17 00:00:00 2001 From: Imran Remtulla Date: Mon, 28 Aug 2023 19:51:49 -0400 Subject: [PATCH 4/7] More UI feedback when app updated (#814) --- lib/pages/app.dart | 5 +++++ lib/pages/apps.dart | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/lib/pages/app.dart b/lib/pages/app.dart index 710c3fb..45812d0 100644 --- a/lib/pages/app.dart +++ b/lib/pages/app.dart @@ -341,10 +341,15 @@ class _AppPageState extends State { app?.app.id != null ? [app!.app.id] : [], globalNavigatorKey.currentContext, settingsProvider); + if (app?.app.installedVersion != null && !trackOnly) { + // ignore: use_build_context_synchronously + showError(tr('appsUpdated'), context); + } if (res.isNotEmpty && mounted) { Navigator.of(context).pop(); } } catch (e) { + // ignore: use_build_context_synchronously showError(e, context); } } diff --git a/lib/pages/apps.dart b/lib/pages/apps.dart index 41c0f7d..835be74 100644 --- a/lib/pages/apps.dart +++ b/lib/pages/apps.dart @@ -689,6 +689,10 @@ class AppsPageState extends State { .catchError((e) { showError(e, context); return []; + }).then((value) { + if (shouldInstallUpdates) { + showError(tr('appsUpdated'), context); + } }); } }); From bd8f608ee66e30cc4f8392b2f64719ee018d7c30 Mon Sep 17 00:00:00 2001 From: Imran Remtulla Date: Mon, 28 Aug 2023 20:02:09 -0400 Subject: [PATCH 5/7] Allow apps to be exempted from BG updates (#822) --- assets/translations/bs.json | 1 + assets/translations/de.json | 1 + assets/translations/en.json | 1 + assets/translations/es.json | 1 + assets/translations/fa.json | 1 + assets/translations/fr.json | 1 + assets/translations/hu.json | 1 + assets/translations/it.json | 1 + assets/translations/ja.json | 1 + assets/translations/pl.json | 1 + assets/translations/ru.json | 1 + assets/translations/zh.json | 1 + lib/providers/apps_provider.dart | 3 +++ lib/providers/source_provider.dart | 6 +++++- 14 files changed, 20 insertions(+), 1 deletion(-) diff --git a/assets/translations/bs.json b/assets/translations/bs.json index 9590708..7a928a6 100644 --- a/assets/translations/bs.json +++ b/assets/translations/bs.json @@ -247,6 +247,7 @@ "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.", "verifyLatestTag": "Verify the 'latest' tag", + "examptFromBackgroundUpdates": "Exempt from background updates (if enabled)", "removeAppQuestion": { "one": "Želite li ukloniti aplikaciju?", "other": "Želite li ukloniti aplikacije?" diff --git a/assets/translations/de.json b/assets/translations/de.json index cd31e8a..1c588a6 100644 --- a/assets/translations/de.json +++ b/assets/translations/de.json @@ -247,6 +247,7 @@ "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.", "verifyLatestTag": "Verify the 'latest' tag", + "examptFromBackgroundUpdates": "Exempt from background updates (if enabled)", "removeAppQuestion": { "one": "App entfernen?", "other": "Apps entfernen?" diff --git a/assets/translations/en.json b/assets/translations/en.json index d86d9a1..bbebf39 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -250,6 +250,7 @@ "verifyLatestTag": "Verify the 'latest' tag", "intermediateLinkRegex": "Filter for an 'Intermediate' Link to Visit First", "intermediateLinkNotFound": "Intermediate link not found", + "examptFromBackgroundUpdates": "Exempt from background updates (if enabled)", "removeAppQuestion": { "one": "Remove App?", "other": "Remove Apps?" diff --git a/assets/translations/es.json b/assets/translations/es.json index a7968a7..95626c1 100644 --- a/assets/translations/es.json +++ b/assets/translations/es.json @@ -247,6 +247,7 @@ "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.", "verifyLatestTag": "Verify the 'latest' tag", + "examptFromBackgroundUpdates": "Exempt from background updates (if enabled)", "removeAppQuestion": { "one": "¿Eliminar Aplicación?", "other": "¿Eliminar Aplicaciones?" diff --git a/assets/translations/fa.json b/assets/translations/fa.json index 5d7e754..b2bb37a 100644 --- a/assets/translations/fa.json +++ b/assets/translations/fa.json @@ -247,6 +247,7 @@ "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.", "verifyLatestTag": "Verify the 'latest' tag", + "examptFromBackgroundUpdates": "Exempt from background updates (if enabled)", "removeAppQuestion": { "one": "برنامه حذف شود؟", "other": "برنامه ها حذف شوند؟" diff --git a/assets/translations/fr.json b/assets/translations/fr.json index 4f7e585..0b0a4d3 100644 --- a/assets/translations/fr.json +++ b/assets/translations/fr.json @@ -247,6 +247,7 @@ "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.", "verifyLatestTag": "Verify the 'latest' tag", + "examptFromBackgroundUpdates": "Exempt from background updates (if enabled)", "removeAppQuestion": { "one": "Supprimer l'application ?", "other": "Supprimer les applications ?" diff --git a/assets/translations/hu.json b/assets/translations/hu.json index 8c3a71e..80db119 100644 --- a/assets/translations/hu.json +++ b/assets/translations/hu.json @@ -246,6 +246,7 @@ "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.", "verifyLatestTag": "Verify the 'latest' tag", + "examptFromBackgroundUpdates": "Exempt from background updates (if enabled)", "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 75d5778..addad9e 100644 --- a/assets/translations/it.json +++ b/assets/translations/it.json @@ -247,6 +247,7 @@ "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.", "verifyLatestTag": "Verify the 'latest' tag", + "examptFromBackgroundUpdates": "Exempt from background updates (if enabled)", "removeAppQuestion": { "one": "Rimuovere l'app?", "other": "Rimuovere le app?" diff --git a/assets/translations/ja.json b/assets/translations/ja.json index e2d360c..1366fd0 100644 --- a/assets/translations/ja.json +++ b/assets/translations/ja.json @@ -248,6 +248,7 @@ "backgroundUpdateReqsExplanation": "バックグラウンドアップデートは、すべてのアプリで可能とは限りません。", "backgroundUpdateLimitsExplanation": "バックグラウンドアップデートが成功したかどうかは、Obtainiumを起動したときにしか判断できません。", "verifyLatestTag": "'latest'タグを確認する", + "examptFromBackgroundUpdates": "Exempt from background updates (if enabled)", "removeAppQuestion": { "one": "アプリを削除しますか?", "other": "アプリを削除しますか?" diff --git a/assets/translations/pl.json b/assets/translations/pl.json index e6ca53d..eacaa63 100644 --- a/assets/translations/pl.json +++ b/assets/translations/pl.json @@ -253,6 +253,7 @@ "backgroundUpdateReqsExplanation": "Aktualizacje w tle mogą nie być możliwe dla wszystkich aplikacji.", "backgroundUpdateLimitsExplanation": "Powodzenie instalacji w tle można określić dopiero po otwarciu Obtainium.", "verifyLatestTag": "Zweryfikuj najnowszy tag", + "examptFromBackgroundUpdates": "Exempt from background updates (if enabled)", "removeAppQuestion": { "one": "Usunąć aplikację?", "few": "Usunąć aplikacje?", diff --git a/assets/translations/ru.json b/assets/translations/ru.json index 6c91980..48f47f3 100644 --- a/assets/translations/ru.json +++ b/assets/translations/ru.json @@ -247,6 +247,7 @@ "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.", "verifyLatestTag": "Verify the 'latest' tag", + "examptFromBackgroundUpdates": "Exempt from background updates (if enabled)", "removeAppQuestion": { "one": "Удалить приложение?", "other": "Удалить приложения?" diff --git a/assets/translations/zh.json b/assets/translations/zh.json index 5ab313d..9457fe1 100644 --- a/assets/translations/zh.json +++ b/assets/translations/zh.json @@ -247,6 +247,7 @@ "enableBackgroundUpdates": "启用后台更新", "backgroundUpdateReqsExplanation": "后台更新未必适用于所有的应用。", "backgroundUpdateLimitsExplanation": "只有在启动 Obtainium 时才能确认安装是否成功。", + "examptFromBackgroundUpdates": "Exempt from background updates (if enabled)", "verifyLatestTag": "验证“Latest”标签", "removeAppQuestion": { "one": "是否删除应用?", diff --git a/lib/providers/apps_provider.dart b/lib/providers/apps_provider.dart index 5b673b6..08523c4 100644 --- a/lib/providers/apps_provider.dart +++ b/lib/providers/apps_provider.dart @@ -366,6 +366,9 @@ class AppsProvider with ChangeNotifier { if (!settingsProvider.enableBackgroundUpdates) { return false; } + if (app.additionalSettings['examptFromBackgroundUpdates'] == true) { + return false; + } if (app.apkUrls.length > 1) { // Manual API selection means silent install is not possible return false; diff --git a/lib/providers/source_provider.dart b/lib/providers/source_provider.dart index 9eef449..e0e11e7 100644 --- a/lib/providers/source_provider.dart +++ b/lib/providers/source_provider.dart @@ -425,7 +425,11 @@ abstract class AppSource { GeneratedFormSwitch('autoApkFilterByArch', label: tr('autoApkFilterByArch'), defaultValue: true) ], - [GeneratedFormTextField('appName', label: tr('appName'), required: false)] + [GeneratedFormTextField('appName', label: tr('appName'), required: false)], + [ + GeneratedFormSwitch('examptFromBackgroundUpdates', + label: tr('examptFromBackgroundUpdates')) + ] ]; // Previous 2 variables combined into one at runtime for convenient usage From 8f739d9e0b2ac3c04d3348f0238b71d22182062a Mon Sep 17 00:00:00 2001 From: Imran Remtulla Date: Mon, 28 Aug 2023 20:24:15 -0400 Subject: [PATCH 6/7] WiFi only BG update toggle (#819) + typo fix --- assets/translations/bs.json | 3 ++- assets/translations/de.json | 3 ++- assets/translations/en.json | 3 ++- assets/translations/es.json | 3 ++- assets/translations/fa.json | 3 ++- assets/translations/fr.json | 3 ++- assets/translations/hu.json | 3 ++- assets/translations/it.json | 3 ++- assets/translations/ja.json | 3 ++- assets/translations/pl.json | 3 ++- assets/translations/ru.json | 3 ++- assets/translations/zh.json | 3 ++- lib/pages/settings.dart | 27 ++++++++++++++++++++++++++- lib/providers/apps_provider.dart | 14 +++++++++++--- lib/providers/settings_provider.dart | 9 +++++++++ lib/providers/source_provider.dart | 4 ++-- pubspec.lock | 24 ++++++++++++++++++++++++ pubspec.yaml | 1 + 18 files changed, 97 insertions(+), 18 deletions(-) diff --git a/assets/translations/bs.json b/assets/translations/bs.json index 7a928a6..533ad5a 100644 --- a/assets/translations/bs.json +++ b/assets/translations/bs.json @@ -247,7 +247,8 @@ "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.", "verifyLatestTag": "Verify the 'latest' tag", - "examptFromBackgroundUpdates": "Exempt from background updates (if enabled)", + "exemptFromBackgroundUpdates": "Exempt from background updates (if enabled)", + "bgUpdatesOnWiFiOnly": "Disable background updates when not on WiFi", "removeAppQuestion": { "one": "Želite li ukloniti aplikaciju?", "other": "Želite li ukloniti aplikacije?" diff --git a/assets/translations/de.json b/assets/translations/de.json index 1c588a6..2233355 100644 --- a/assets/translations/de.json +++ b/assets/translations/de.json @@ -247,7 +247,8 @@ "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.", "verifyLatestTag": "Verify the 'latest' tag", - "examptFromBackgroundUpdates": "Exempt from background updates (if enabled)", + "exemptFromBackgroundUpdates": "Exempt from background updates (if enabled)", + "bgUpdatesOnWiFiOnly": "Disable background updates when not on WiFi", "removeAppQuestion": { "one": "App entfernen?", "other": "Apps entfernen?" diff --git a/assets/translations/en.json b/assets/translations/en.json index bbebf39..afb64d2 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -250,7 +250,8 @@ "verifyLatestTag": "Verify the 'latest' tag", "intermediateLinkRegex": "Filter for an 'Intermediate' Link to Visit First", "intermediateLinkNotFound": "Intermediate link not found", - "examptFromBackgroundUpdates": "Exempt from background updates (if enabled)", + "exemptFromBackgroundUpdates": "Exempt from background updates (if enabled)", + "bgUpdatesOnWiFiOnly": "Disable background updates when not on WiFi", "removeAppQuestion": { "one": "Remove App?", "other": "Remove Apps?" diff --git a/assets/translations/es.json b/assets/translations/es.json index 95626c1..6c07acc 100644 --- a/assets/translations/es.json +++ b/assets/translations/es.json @@ -247,7 +247,8 @@ "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.", "verifyLatestTag": "Verify the 'latest' tag", - "examptFromBackgroundUpdates": "Exempt from background updates (if enabled)", + "exemptFromBackgroundUpdates": "Exempt from background updates (if enabled)", + "bgUpdatesOnWiFiOnly": "Disable background updates when not on WiFi", "removeAppQuestion": { "one": "¿Eliminar Aplicación?", "other": "¿Eliminar Aplicaciones?" diff --git a/assets/translations/fa.json b/assets/translations/fa.json index b2bb37a..a35fb49 100644 --- a/assets/translations/fa.json +++ b/assets/translations/fa.json @@ -247,7 +247,8 @@ "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.", "verifyLatestTag": "Verify the 'latest' tag", - "examptFromBackgroundUpdates": "Exempt from background updates (if enabled)", + "exemptFromBackgroundUpdates": "Exempt from background updates (if enabled)", + "bgUpdatesOnWiFiOnly": "Disable background updates when not on WiFi", "removeAppQuestion": { "one": "برنامه حذف شود؟", "other": "برنامه ها حذف شوند؟" diff --git a/assets/translations/fr.json b/assets/translations/fr.json index 0b0a4d3..83a1d60 100644 --- a/assets/translations/fr.json +++ b/assets/translations/fr.json @@ -247,7 +247,8 @@ "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.", "verifyLatestTag": "Verify the 'latest' tag", - "examptFromBackgroundUpdates": "Exempt from background updates (if enabled)", + "exemptFromBackgroundUpdates": "Exempt from background updates (if enabled)", + "bgUpdatesOnWiFiOnly": "Disable background updates when not on WiFi", "removeAppQuestion": { "one": "Supprimer l'application ?", "other": "Supprimer les applications ?" diff --git a/assets/translations/hu.json b/assets/translations/hu.json index 80db119..54ca69b 100644 --- a/assets/translations/hu.json +++ b/assets/translations/hu.json @@ -246,7 +246,8 @@ "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.", "verifyLatestTag": "Verify the 'latest' tag", - "examptFromBackgroundUpdates": "Exempt from background updates (if enabled)", + "exemptFromBackgroundUpdates": "Exempt from background updates (if enabled)", + "bgUpdatesOnWiFiOnly": "Disable background updates when not on WiFi", "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 addad9e..210bce0 100644 --- a/assets/translations/it.json +++ b/assets/translations/it.json @@ -247,7 +247,8 @@ "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.", "verifyLatestTag": "Verify the 'latest' tag", - "examptFromBackgroundUpdates": "Exempt from background updates (if enabled)", + "exemptFromBackgroundUpdates": "Exempt from background updates (if enabled)", + "bgUpdatesOnWiFiOnly": "Disable background updates when not on WiFi", "removeAppQuestion": { "one": "Rimuovere l'app?", "other": "Rimuovere le app?" diff --git a/assets/translations/ja.json b/assets/translations/ja.json index 1366fd0..fc11db1 100644 --- a/assets/translations/ja.json +++ b/assets/translations/ja.json @@ -248,7 +248,8 @@ "backgroundUpdateReqsExplanation": "バックグラウンドアップデートは、すべてのアプリで可能とは限りません。", "backgroundUpdateLimitsExplanation": "バックグラウンドアップデートが成功したかどうかは、Obtainiumを起動したときにしか判断できません。", "verifyLatestTag": "'latest'タグを確認する", - "examptFromBackgroundUpdates": "Exempt from background updates (if enabled)", + "exemptFromBackgroundUpdates": "Exempt from background updates (if enabled)", + "bgUpdatesOnWiFiOnly": "Disable background updates when not on WiFi", "removeAppQuestion": { "one": "アプリを削除しますか?", "other": "アプリを削除しますか?" diff --git a/assets/translations/pl.json b/assets/translations/pl.json index eacaa63..e3c4d34 100644 --- a/assets/translations/pl.json +++ b/assets/translations/pl.json @@ -253,7 +253,8 @@ "backgroundUpdateReqsExplanation": "Aktualizacje w tle mogą nie być możliwe dla wszystkich aplikacji.", "backgroundUpdateLimitsExplanation": "Powodzenie instalacji w tle można określić dopiero po otwarciu Obtainium.", "verifyLatestTag": "Zweryfikuj najnowszy tag", - "examptFromBackgroundUpdates": "Exempt from background updates (if enabled)", + "exemptFromBackgroundUpdates": "Exempt from background updates (if enabled)", + "bgUpdatesOnWiFiOnly": "Disable background updates when not on WiFi", "removeAppQuestion": { "one": "Usunąć aplikację?", "few": "Usunąć aplikacje?", diff --git a/assets/translations/ru.json b/assets/translations/ru.json index 48f47f3..91c5572 100644 --- a/assets/translations/ru.json +++ b/assets/translations/ru.json @@ -247,7 +247,8 @@ "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.", "verifyLatestTag": "Verify the 'latest' tag", - "examptFromBackgroundUpdates": "Exempt from background updates (if enabled)", + "exemptFromBackgroundUpdates": "Exempt from background updates (if enabled)", + "bgUpdatesOnWiFiOnly": "Disable background updates when not on WiFi", "removeAppQuestion": { "one": "Удалить приложение?", "other": "Удалить приложения?" diff --git a/assets/translations/zh.json b/assets/translations/zh.json index 9457fe1..6ab56a0 100644 --- a/assets/translations/zh.json +++ b/assets/translations/zh.json @@ -247,8 +247,9 @@ "enableBackgroundUpdates": "启用后台更新", "backgroundUpdateReqsExplanation": "后台更新未必适用于所有的应用。", "backgroundUpdateLimitsExplanation": "只有在启动 Obtainium 时才能确认安装是否成功。", - "examptFromBackgroundUpdates": "Exempt from background updates (if enabled)", "verifyLatestTag": "验证“Latest”标签", + "exemptFromBackgroundUpdates": "Exempt from background updates (if enabled)", + "bgUpdatesOnWiFiOnly": "Disable background updates when not on WiFi", "removeAppQuestion": { "one": "是否删除应用?", "other": "是否删除应用?" diff --git a/lib/pages/settings.dart b/lib/pages/settings.dart index cd5ce5a..ec19efb 100644 --- a/lib/pages/settings.dart +++ b/lib/pages/settings.dart @@ -252,7 +252,32 @@ class _SettingsPageState extends State { style: Theme.of(context) .textTheme .labelSmall), - height8 + height8, + if (settingsProvider + .enableBackgroundUpdates) + Column( + children: [ + height16, + Row( + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + children: [ + Flexible( + child: Text(tr( + 'bgUpdatesOnWiFiOnly'))), + Switch( + value: settingsProvider + .bgUpdatesOnWiFiOnly, + onChanged: (value) { + settingsProvider + .bgUpdatesOnWiFiOnly = + value; + }) + ], + ), + ], + ), ], ) : const SizedBox.shrink(); diff --git a/lib/providers/apps_provider.dart b/lib/providers/apps_provider.dart index 08523c4..5017e26 100644 --- a/lib/providers/apps_provider.dart +++ b/lib/providers/apps_provider.dart @@ -9,6 +9,7 @@ import 'package:android_alarm_manager_plus/android_alarm_manager_plus.dart'; import 'package:android_intent_plus/flag.dart'; import 'package:android_package_installer/android_package_installer.dart'; import 'package:android_package_manager/android_package_manager.dart'; +import 'package:connectivity_plus/connectivity_plus.dart'; import 'package:device_info_plus/device_info_plus.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; @@ -366,7 +367,7 @@ class AppsProvider with ChangeNotifier { if (!settingsProvider.enableBackgroundUpdates) { return false; } - if (app.additionalSettings['examptFromBackgroundUpdates'] == true) { + if (app.additionalSettings['exemptFromBackgroundUpdates'] == true) { return false; } if (app.apkUrls.length > 1) { @@ -1323,6 +1324,12 @@ Future bgUpdateCheck(int taskId, Map? params) async { // If in update mode... var didCompleteChecking = false; CheckingUpdatesNotification? notif; + var networkRestricted = false; + if (settingsProvider.bgUpdatesOnWiFiOnly) { + var netResult = await (Connectivity().checkConnectivity()); + networkRestricted = (netResult != ConnectivityResult.wifi) && + (netResult != ConnectivityResult.ethernet); + } // Loop through all updates and check each for (int i = 0; i < toCheck.length; i++) { var appId = toCheck[i].key; @@ -1335,8 +1342,9 @@ Future bgUpdateCheck(int taskId, Map? params) async { cancelExisting: true); App? newApp = await appsProvider.checkUpdate(appId); if (newApp != null) { - if (!(await appsProvider.canInstallSilently( - app!.app, settingsProvider))) { + if (networkRestricted || + !(await appsProvider.canInstallSilently( + app!.app, settingsProvider))) { notificationsProvider.notify( UpdateNotification([newApp], id: newApp.id.hashCode - 1)); } else { diff --git a/lib/providers/settings_provider.dart b/lib/providers/settings_provider.dart index 7495c9b..0ccae4a 100644 --- a/lib/providers/settings_provider.dart +++ b/lib/providers/settings_provider.dart @@ -319,6 +319,15 @@ class SettingsProvider with ChangeNotifier { notifyListeners(); } + bool get bgUpdatesOnWiFiOnly { + return prefs?.getBool('bgUpdatesOnWiFiOnly') ?? false; + } + + set bgUpdatesOnWiFiOnly(bool val) { + prefs?.setBool('bgUpdatesOnWiFiOnly', val); + notifyListeners(); + } + DateTime get lastBGCheckTime { int? temp = prefs?.getInt('lastBGCheckTime'); return temp != null diff --git a/lib/providers/source_provider.dart b/lib/providers/source_provider.dart index e0e11e7..5494362 100644 --- a/lib/providers/source_provider.dart +++ b/lib/providers/source_provider.dart @@ -427,8 +427,8 @@ abstract class AppSource { ], [GeneratedFormTextField('appName', label: tr('appName'), required: false)], [ - GeneratedFormSwitch('examptFromBackgroundUpdates', - label: tr('examptFromBackgroundUpdates')) + GeneratedFormSwitch('exemptFromBackgroundUpdates', + label: tr('exemptFromBackgroundUpdates')) ] ]; diff --git a/pubspec.lock b/pubspec.lock index b717324..a9d3711 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -114,6 +114,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.17.2" + connectivity_plus: + dependency: "direct main" + description: + name: connectivity_plus + sha256: "77a180d6938f78ca7d2382d2240eb626c0f6a735d0bfdce227d8ffb80f95c48b" + url: "https://pub.dev" + source: hosted + version: "4.0.2" + connectivity_plus_platform_interface: + dependency: transitive + description: + name: connectivity_plus_platform_interface + sha256: cf1d1c28f4416f8c654d7dc3cd638ec586076255d407cef3ddbdaf178272a71a + url: "https://pub.dev" + source: hosted + version: "1.2.4" convert: dependency: transitive description: @@ -454,6 +470,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.0" + nm: + dependency: transitive + description: + name: nm + sha256: "2c9aae4127bdc8993206464fcc063611e0e36e72018696cd9631023a31b24254" + url: "https://pub.dev" + source: hosted + version: "0.5.0" path: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 60254c0..3810687 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -64,6 +64,7 @@ dependencies: flutter_markdown: ^0.6.14 flutter_archive: ^5.0.0 hsluv: ^1.1.3 + connectivity_plus: ^4.0.2 dev_dependencies: flutter_test: From 408c1a541f34e56ff51e940d87e04e9c0514c3cd Mon Sep 17 00:00:00 2001 From: Imran Remtulla Date: Mon, 28 Aug 2023 20:26:21 -0400 Subject: [PATCH 7/7] Increment version --- lib/main.dart | 2 +- pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 594dc7c..6be8e29 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -19,7 +19,7 @@ import 'package:easy_localization/src/easy_localization_controller.dart'; // ignore: implementation_imports import 'package:easy_localization/src/localization.dart'; -const String currentVersion = '0.14.1'; +const String currentVersion = '0.14.2'; const String currentReleaseTag = 'v$currentVersion-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES diff --git a/pubspec.yaml b/pubspec.yaml index 3810687..ad5c919 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,7 +17,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 0.14.1+193 # When changing this, update the tag in main() accordingly +version: 0.14.2+194 # When changing this, update the tag in main() accordingly environment: sdk: '>=2.18.2 <3.0.0'