From 2518c70ec890f952ef99083f615b18997294f753 Mon Sep 17 00:00:00 2001 From: Imran Remtulla Date: Wed, 18 Oct 2023 19:42:15 -0400 Subject: [PATCH] Bugfixes Don't replace / in versions (#1023) Fix HTML version extraction (#1021) Update check only for installed apps (#1012) --- assets/translations/bs.json | 1 + assets/translations/cs.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/pt.json | 1 + assets/translations/ru.json | 1 + assets/translations/zh.json | 1 + lib/app_sources/html.dart | 4 ++- lib/pages/settings.dart | 20 ++++++++++++- lib/providers/apps_provider.dart | 45 ++++++++++++++++++++-------- lib/providers/settings_provider.dart | 9 ++++++ lib/providers/source_provider.dart | 3 +- 19 files changed, 79 insertions(+), 16 deletions(-) diff --git a/assets/translations/bs.json b/assets/translations/bs.json index acca651..d3bf65a 100644 --- a/assets/translations/bs.json +++ b/assets/translations/bs.json @@ -274,6 +274,7 @@ "downloadingXNotifChannel": "Preuzimanje {}", "completeAppInstallationNotifChannel": "Dovršite instalaciju aplikacije", "checkingForUpdatesNotifChannel": "Tražim moguće nadogradnje", + "onlyCheckInstalledOrTrackOnlyApps": "Only check installed and Track-Only apps for updates", "removeAppQuestion": { "one": "Želite li ukloniti aplikaciju?", "other": "Želite li ukloniti aplikacije?" diff --git a/assets/translations/cs.json b/assets/translations/cs.json index df3be45..b4b052e 100644 --- a/assets/translations/cs.json +++ b/assets/translations/cs.json @@ -274,6 +274,7 @@ "downloadingXNotifChannel": "download {}", "completeAppInstallationNotifChannel": "Dokončit instalaci aplikace", "checkingForUpdatesNotifChannel": "Zkontrolovat aktualizace", + "onlyCheckInstalledOrTrackOnlyApps": "Only check installed and Track-Only apps for updates", "removeAppQuestion": { "one": "Odstranit Apku?", "other": "Odstranit Apky?" diff --git a/assets/translations/de.json b/assets/translations/de.json index b8a39ad..f25949f 100644 --- a/assets/translations/de.json +++ b/assets/translations/de.json @@ -274,6 +274,7 @@ "downloadingXNotifChannel": "Lade {} herunter", "completeAppInstallationNotifChannel": "App Installation abschließen", "checkingForUpdatesNotifChannel": "Nach Aktualisierungen suchen", + "onlyCheckInstalledOrTrackOnlyApps": "Only check installed and Track-Only apps for updates", "removeAppQuestion": { "one": "App entfernen?", "other": "Apps entfernen?" diff --git a/assets/translations/en.json b/assets/translations/en.json index 6d8311c..4e4626a 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -274,6 +274,7 @@ "downloadingXNotifChannel": "Downloading {}", "completeAppInstallationNotifChannel": "Complete App Installation", "checkingForUpdatesNotifChannel": "Checking for Updates", + "onlyCheckInstalledOrTrackOnlyApps": "Only check installed and Track-Only apps for updates", "removeAppQuestion": { "one": "Remove App?", "other": "Remove Apps?" diff --git a/assets/translations/es.json b/assets/translations/es.json index a73970b..481838a 100644 --- a/assets/translations/es.json +++ b/assets/translations/es.json @@ -274,6 +274,7 @@ "downloadingXNotifChannel": "Descargando {}", "completeAppInstallationNotifChannel": "Instalación Completa de la Aplicación", "checkingForUpdatesNotifChannel": "Buscando Actualizaciones", + "onlyCheckInstalledOrTrackOnlyApps": "Only check installed and Track-Only apps for updates", "removeAppQuestion": { "one": "¿Eliminar Aplicación?", "other": "¿Eliminar Aplicaciones?" diff --git a/assets/translations/fa.json b/assets/translations/fa.json index f051b48..013ee34 100644 --- a/assets/translations/fa.json +++ b/assets/translations/fa.json @@ -274,6 +274,7 @@ "downloadingXNotifChannel": "در حال دانلود {}", "completeAppInstallationNotifChannel": "نصب کامل برنامه", "checkingForUpdatesNotifChannel": "بررسی به‌روزرسانی‌ها", + "onlyCheckInstalledOrTrackOnlyApps": "Only check installed and Track-Only apps for updates", "removeAppQuestion": { "one": "برنامه حذف شود؟", "other": "برنامه ها حذف شوند؟" diff --git a/assets/translations/fr.json b/assets/translations/fr.json index 649b0ff..e5d3bba 100644 --- a/assets/translations/fr.json +++ b/assets/translations/fr.json @@ -274,6 +274,7 @@ "downloadingXNotifChannel": "Téléchargement {}", "completeAppInstallationNotifChannel": "Installation complète de l'application", "checkingForUpdatesNotifChannel": "Vérification des mises à jour", + "onlyCheckInstalledOrTrackOnlyApps": "Only check installed and Track-Only apps for updates", "removeAppQuestion": { "one": "Supprimer l'application ?", "other": "Supprimer les applications ?" diff --git a/assets/translations/hu.json b/assets/translations/hu.json index b41dfb4..12a288f 100644 --- a/assets/translations/hu.json +++ b/assets/translations/hu.json @@ -274,6 +274,7 @@ "downloadingXNotifChannel": "{} letöltés", "completeAppInstallationNotifChannel": "Teljes app telepítés", "checkingForUpdatesNotifChannel": "Frissítések keresése", + "onlyCheckInstalledOrTrackOnlyApps": "Only check installed and Track-Only apps for updates", "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 3a0f8a8..e00c0b8 100644 --- a/assets/translations/it.json +++ b/assets/translations/it.json @@ -274,6 +274,7 @@ "downloadingXNotifChannel": "Scaricamento di {} in corso", "completeAppInstallationNotifChannel": "Completa l'installazione dell'app", "checkingForUpdatesNotifChannel": "Controllo degli aggiornamenti in corso", + "onlyCheckInstalledOrTrackOnlyApps": "Only check installed and Track-Only apps for updates", "removeAppQuestion": { "one": "Rimuovere l'app?", "other": "Rimuovere le app?" diff --git a/assets/translations/ja.json b/assets/translations/ja.json index 596669d..385de2d 100644 --- a/assets/translations/ja.json +++ b/assets/translations/ja.json @@ -274,6 +274,7 @@ "downloadingXNotifChannel": "{} をダウンロード中", "completeAppInstallationNotifChannel": "アプリのインストールを完了する", "checkingForUpdatesNotifChannel": "アップデートを確認中", + "onlyCheckInstalledOrTrackOnlyApps": "Only check installed and Track-Only apps for updates", "removeAppQuestion": { "one": "アプリを削除しますか?", "other": "アプリを削除しますか?" diff --git a/assets/translations/pl.json b/assets/translations/pl.json index 9aa9f31..bb55a51 100644 --- a/assets/translations/pl.json +++ b/assets/translations/pl.json @@ -274,6 +274,7 @@ "downloadingXNotifChannel": "Pobieranie aplikacji", "completeAppInstallationNotifChannel": "Ukończenie instalacji aplikacji", "checkingForUpdatesNotifChannel": "Sprawdzanie dostępności aktualizacji", + "onlyCheckInstalledOrTrackOnlyApps": "Only check installed and Track-Only apps for updates", "removeAppQuestion": { "one": "Usunąć aplikację?", "few": "Usunąć aplikacje?", diff --git a/assets/translations/pt.json b/assets/translations/pt.json index 047b9f8..9611468 100644 --- a/assets/translations/pt.json +++ b/assets/translations/pt.json @@ -274,6 +274,7 @@ "downloadingXNotifChannel": "Baixando {}", "completeAppInstallationNotifChannel": "Instalação completa do App", "checkingForUpdatesNotifChannel": "Checando por Atualizações", + "onlyCheckInstalledOrTrackOnlyApps": "Only check installed and Track-Only apps for updates", "removeAppQuestion": { "one": "Remover App?", "other": "Remover Apps?" diff --git a/assets/translations/ru.json b/assets/translations/ru.json index 1f9d373..f02a7da 100644 --- a/assets/translations/ru.json +++ b/assets/translations/ru.json @@ -274,6 +274,7 @@ "downloadingXNotifChannel": "Загрузка {}", "completeAppInstallationNotifChannel": "Завершение установки приложения", "checkingForUpdatesNotifChannel": "Проверка обновлений", + "onlyCheckInstalledOrTrackOnlyApps": "Only check installed and Track-Only apps for updates", "removeAppQuestion": { "one": "Удалить приложение?", "other": "Удалить приложения?" diff --git a/assets/translations/zh.json b/assets/translations/zh.json index b6580ce..d1e64e8 100644 --- a/assets/translations/zh.json +++ b/assets/translations/zh.json @@ -274,6 +274,7 @@ "downloadingXNotifChannel": "正在下载{}", "completeAppInstallationNotifChannel": "完成应用安装", "checkingForUpdatesNotifChannel": "正在检查更新", + "onlyCheckInstalledOrTrackOnlyApps": "Only check installed and Track-Only apps for updates", "removeAppQuestion": { "one": "是否删除应用?", "other": "是否删除应用?" diff --git a/lib/app_sources/html.dart b/lib/app_sources/html.dart index 91911e7..a2dacdb 100644 --- a/lib/app_sources/html.dart +++ b/lib/app_sources/html.dart @@ -219,7 +219,9 @@ class HTML extends AppSource { additionalSettings['versionExtractionRegEx'] as String?; if (versionExtractionRegEx?.isNotEmpty == true) { var match = RegExp(versionExtractionRegEx!).allMatches( - res.body.split('\r\n').join('\n').split('\n').join('\\n')); + additionalSettings['versionExtractWholePage'] == true + ? res.body.split('\r\n').join('\n').split('\n').join('\\n') + : rel); if (match.isEmpty) { throw NoVersionError(); } diff --git a/lib/pages/settings.dart b/lib/pages/settings.dart index 265be4e..c36c958 100644 --- a/lib/pages/settings.dart +++ b/lib/pages/settings.dart @@ -310,6 +310,23 @@ class _SettingsPageState extends State { }) ], ), + height16, + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Flexible( + child: Text(tr( + 'onlyCheckInstalledOrTrackOnlyApps'))), + Switch( + value: settingsProvider + .onlyCheckInstalledOrTrackOnlyApps, + onChanged: (value) { + settingsProvider + .onlyCheckInstalledOrTrackOnlyApps = + value; + }) + ], + ), height32, Text( tr('sourceSpecific'), @@ -535,7 +552,8 @@ class _SettingsPageState extends State { onPressed: () { context.read().get().then((logs) { if (logs.isEmpty) { - showMessage(ObtainiumError(tr('noLogs')), context); + showMessage( + ObtainiumError(tr('noLogs')), context); } else { showDialog( context: context, diff --git a/lib/providers/apps_provider.dart b/lib/providers/apps_provider.dart index 3ef8e73..d4085d6 100644 --- a/lib/providers/apps_provider.dart +++ b/lib/providers/apps_provider.dart @@ -281,7 +281,8 @@ class AppsProvider with ChangeNotifier { '${downloadedFile.parent.path}/${app.id}-${downloadUrl.hashCode}.${downloadedFile.path.split('.').last}'); if (apps[originalAppId] != null) { await removeApps([originalAppId]); - await saveApps([app], onlyIfExists: !isTempIdBool && !idChangeWasAllowed); + await saveApps([app], + onlyIfExists: !isTempIdBool && !idChangeWasAllowed); } } } else if (isTempIdBool) { @@ -716,9 +717,11 @@ class AppsProvider with ChangeNotifier { if (app?.app == null) { return false; } - var naiveStandardVersionDetection = SourceProvider() - .getSource(app!.app.url, overrideSource: app.app.overrideSource) - .naiveStandardVersionDetection; + var naiveStandardVersionDetection = + app!.app.additionalSettings['naiveStandardVersionDetection'] == true || + SourceProvider() + .getSource(app.app.url, overrideSource: app.app.overrideSource) + .naiveStandardVersionDetection; return app.app.additionalSettings['trackOnly'] != true && app.app.additionalSettings['versionDetection'] != 'releaseDateAsVersion' && @@ -739,9 +742,11 @@ class AppsProvider with ChangeNotifier { var versionDetectionIsStandard = app.additionalSettings['versionDetection'] == 'standardVersionDetection'; - var naiveStandardVersionDetection = SourceProvider() - .getSource(app.url, overrideSource: app.overrideSource) - .naiveStandardVersionDetection; + var naiveStandardVersionDetection = + app.additionalSettings['naiveStandardVersionDetection'] == true || + SourceProvider() + .getSource(app.url, overrideSource: app.overrideSource) + .naiveStandardVersionDetection; // FIRST, COMPARE THE APP'S REPORTED AND REAL INSTALLED VERSIONS, WHERE ONE IS NULL if (installedInfo == null && app.installedVersion != null && !trackOnly) { // App says it's installed but isn't really (and isn't track only) - set to not installed @@ -1055,12 +1060,21 @@ class AppsProvider with ChangeNotifier { } List getAppsSortedByUpdateCheckTime( - {DateTime? ignoreAppsCheckedAfter}) { + {DateTime? ignoreAppsCheckedAfter, + bool onlyCheckInstalledOrTrackOnlyApps = false}) { List appIds = apps.values .where((app) => app.app.lastUpdateCheck == null || ignoreAppsCheckedAfter == null || app.app.lastUpdateCheck!.isBefore(ignoreAppsCheckedAfter)) + .where((app) { + if (!onlyCheckInstalledOrTrackOnlyApps) { + return true; + } else { + return app.app.installedVersion != null || + app.app.additionalSettings['trackOnly'] == true; + } + }) .map((e) => e.app.id) .toList(); appIds.sort((a, b) => @@ -1073,14 +1087,18 @@ class AppsProvider with ChangeNotifier { Future> checkUpdates( {DateTime? ignoreAppsCheckedAfter, bool throwErrorsForRetry = false, - List? specificIds}) async { + List? specificIds, + SettingsProvider? sp}) async { + SettingsProvider settingsProvider = sp ?? this.settingsProvider; List updates = []; MultiAppMultiError errors = MultiAppMultiError(); if (!gettingUpdates) { gettingUpdates = true; try { List appIds = getAppsSortedByUpdateCheckTime( - ignoreAppsCheckedAfter: ignoreAppsCheckedAfter); + ignoreAppsCheckedAfter: ignoreAppsCheckedAfter, + onlyCheckInstalledOrTrackOnlyApps: + settingsProvider.onlyCheckInstalledOrTrackOnlyApps); if (specificIds != null) { appIds = appIds.where((aId) => specificIds.contains(aId)).toList(); } @@ -1362,7 +1380,9 @@ Future bgUpdateCheck(int taskId, Map? params) async { entry['key'] as String, entry['value'] as int)) .toList() ?? appsProvider - .getAppsSortedByUpdateCheckTime() + .getAppsSortedByUpdateCheckTime( + onlyCheckInstalledOrTrackOnlyApps: appsProvider + .settingsProvider.onlyCheckInstalledOrTrackOnlyApps) .map((e) => MapEntry(e, 0))) ]; List> toInstall = >[ @@ -1446,7 +1466,8 @@ Future bgUpdateCheck(int taskId, Map? params) async { // Check for updates notificationsProvider.notify(notif, cancelExisting: true); updates = await appsProvider.checkUpdates( - specificIds: toCheck.map((e) => e.key).toList()); + specificIds: toCheck.map((e) => e.key).toList(), + sp: appsProvider.settingsProvider); } catch (e) { // If there were errors, group them into toRetry and toThrow based on max retry count per app if (e is Map) { diff --git a/lib/providers/settings_provider.dart b/lib/providers/settings_provider.dart index 2085168..d72fd8d 100644 --- a/lib/providers/settings_provider.dart +++ b/lib/providers/settings_provider.dart @@ -406,4 +406,13 @@ class SettingsProvider with ChangeNotifier { prefs?.setBool('autoExportOnChanges', val); notifyListeners(); } + + bool get onlyCheckInstalledOrTrackOnlyApps { + return prefs?.getBool('onlyCheckInstalledOrTrackOnlyApps') ?? false; + } + + set onlyCheckInstalledOrTrackOnlyApps(bool val) { + prefs?.setBool('onlyCheckInstalledOrTrackOnlyApps', val); + notifyListeners(); + } } diff --git a/lib/providers/source_provider.dart b/lib/providers/source_provider.dart index 0285aa7..e5ea114 100644 --- a/lib/providers/source_provider.dart +++ b/lib/providers/source_provider.dart @@ -676,7 +676,6 @@ class SourceProvider { } } } - String apkVersion = apk.version.replaceAll('/', '-'); var name = currentApp != null ? currentApp.name.trim() : ''; name = name.isNotEmpty ? name : apk.names.name; App finalApp = App( @@ -691,7 +690,7 @@ class SourceProvider { apk.names.author, name, currentApp?.installedVersion, - apkVersion, + apk.version, apk.apkUrls, apk.apkUrls.length - 1 >= 0 ? apk.apkUrls.length - 1 : 0, additionalSettings,