Skip to content

Commit

Permalink
Merge pull request #1024 from ImranR98/dev
Browse files Browse the repository at this point in the history
Don't replace / in versions (#1023), Fix HTML version extraction (#1021), Update check only for installed apps (#1012)
  • Loading branch information
ImranR98 authored Oct 18, 2023
2 parents 6ead8d2 + a083da1 commit b8c0e18
Show file tree
Hide file tree
Showing 22 changed files with 106 additions and 35 deletions.
1 change: 1 addition & 0 deletions assets/translations/bs.json
Original file line number Diff line number Diff line change
Expand Up @@ -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?"
Expand Down
1 change: 1 addition & 0 deletions assets/translations/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -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?"
Expand Down
1 change: 1 addition & 0 deletions assets/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -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?"
Expand Down
1 change: 1 addition & 0 deletions assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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?"
Expand Down
1 change: 1 addition & 0 deletions assets/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -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?"
Expand Down
1 change: 1 addition & 0 deletions assets/translations/fa.json
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@
"downloadingXNotifChannel": "در حال دانلود {}",
"completeAppInstallationNotifChannel": "نصب کامل برنامه",
"checkingForUpdatesNotifChannel": "بررسی به‌روزرسانی‌ها",
"onlyCheckInstalledOrTrackOnlyApps": "Only check installed and Track-Only apps for updates",
"removeAppQuestion": {
"one": "برنامه حذف شود؟",
"other": "برنامه ها حذف شوند؟"
Expand Down
1 change: 1 addition & 0 deletions assets/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?"
Expand Down
1 change: 1 addition & 0 deletions assets/translations/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -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?"
Expand Down
1 change: 1 addition & 0 deletions assets/translations/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -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?"
Expand Down
1 change: 1 addition & 0 deletions assets/translations/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@
"downloadingXNotifChannel": "{} をダウンロード中",
"completeAppInstallationNotifChannel": "アプリのインストールを完了する",
"checkingForUpdatesNotifChannel": "アップデートを確認中",
"onlyCheckInstalledOrTrackOnlyApps": "Only check installed and Track-Only apps for updates",
"removeAppQuestion": {
"one": "アプリを削除しますか?",
"other": "アプリを削除しますか?"
Expand Down
1 change: 1 addition & 0 deletions assets/translations/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -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?",
Expand Down
1 change: 1 addition & 0 deletions assets/translations/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -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?"
Expand Down
1 change: 1 addition & 0 deletions assets/translations/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@
"downloadingXNotifChannel": "Загрузка {}",
"completeAppInstallationNotifChannel": "Завершение установки приложения",
"checkingForUpdatesNotifChannel": "Проверка обновлений",
"onlyCheckInstalledOrTrackOnlyApps": "Only check installed and Track-Only apps for updates",
"removeAppQuestion": {
"one": "Удалить приложение?",
"other": "Удалить приложения?"
Expand Down
1 change: 1 addition & 0 deletions assets/translations/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@
"downloadingXNotifChannel": "正在下载{}",
"completeAppInstallationNotifChannel": "完成应用安装",
"checkingForUpdatesNotifChannel": "正在检查更新",
"onlyCheckInstalledOrTrackOnlyApps": "Only check installed and Track-Only apps for updates",
"removeAppQuestion": {
"one": "是否删除应用?",
"other": "是否删除应用?"
Expand Down
4 changes: 3 additions & 1 deletion lib/app_sources/html.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.30';
const String currentVersion = '0.14.31';
const String currentReleaseTag =
'v$currentVersion-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES

Expand Down
20 changes: 19 additions & 1 deletion lib/pages/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,23 @@ class _SettingsPageState extends State<SettingsPage> {
})
],
),
height16,
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Flexible(
child: Text(tr(
'onlyCheckInstalledOrTrackOnlyApps'))),
Switch(
value: settingsProvider
.onlyCheckInstalledOrTrackOnlyApps,
onChanged: (value) {
settingsProvider
.onlyCheckInstalledOrTrackOnlyApps =
value;
})
],
),
height32,
Text(
tr('sourceSpecific'),
Expand Down Expand Up @@ -535,7 +552,8 @@ class _SettingsPageState extends State<SettingsPage> {
onPressed: () {
context.read<LogsProvider>().get().then((logs) {
if (logs.isEmpty) {
showMessage(ObtainiumError(tr('noLogs')), context);
showMessage(
ObtainiumError(tr('noLogs')), context);
} else {
showDialog(
context: context,
Expand Down
45 changes: 33 additions & 12 deletions lib/providers/apps_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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' &&
Expand All @@ -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
Expand Down Expand Up @@ -1055,12 +1060,21 @@ class AppsProvider with ChangeNotifier {
}

List<String> getAppsSortedByUpdateCheckTime(
{DateTime? ignoreAppsCheckedAfter}) {
{DateTime? ignoreAppsCheckedAfter,
bool onlyCheckInstalledOrTrackOnlyApps = false}) {
List<String> 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) =>
Expand All @@ -1073,14 +1087,18 @@ class AppsProvider with ChangeNotifier {
Future<List<App>> checkUpdates(
{DateTime? ignoreAppsCheckedAfter,
bool throwErrorsForRetry = false,
List<String>? specificIds}) async {
List<String>? specificIds,
SettingsProvider? sp}) async {
SettingsProvider settingsProvider = sp ?? this.settingsProvider;
List<App> updates = [];
MultiAppMultiError errors = MultiAppMultiError();
if (!gettingUpdates) {
gettingUpdates = true;
try {
List<String> appIds = getAppsSortedByUpdateCheckTime(
ignoreAppsCheckedAfter: ignoreAppsCheckedAfter);
ignoreAppsCheckedAfter: ignoreAppsCheckedAfter,
onlyCheckInstalledOrTrackOnlyApps:
settingsProvider.onlyCheckInstalledOrTrackOnlyApps);
if (specificIds != null) {
appIds = appIds.where((aId) => specificIds.contains(aId)).toList();
}
Expand Down Expand Up @@ -1362,7 +1380,9 @@ Future<void> bgUpdateCheck(int taskId, Map<String, dynamic>? params) async {
entry['key'] as String, entry['value'] as int))
.toList() ??
appsProvider
.getAppsSortedByUpdateCheckTime()
.getAppsSortedByUpdateCheckTime(
onlyCheckInstalledOrTrackOnlyApps: appsProvider
.settingsProvider.onlyCheckInstalledOrTrackOnlyApps)
.map((e) => MapEntry(e, 0)))
];
List<MapEntry<String, int>> toInstall = <MapEntry<String, int>>[
Expand Down Expand Up @@ -1446,7 +1466,8 @@ Future<void> bgUpdateCheck(int taskId, Map<String, dynamic>? 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) {
Expand Down
9 changes: 9 additions & 0 deletions lib/providers/settings_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
3 changes: 1 addition & 2 deletions lib/providers/source_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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,
Expand Down
Loading

0 comments on commit b8c0e18

Please sign in to comment.