diff --git a/lib/providers/apps_provider.dart b/lib/providers/apps_provider.dart index 212f576..e349c96 100644 --- a/lib/providers/apps_provider.dart +++ b/lib/providers/apps_provider.dart @@ -416,7 +416,15 @@ class AppsProvider with ChangeNotifier { app.installedVersion = null; modded = true; } else if (installedInfo != null && app.installedVersion == null) { - app.installedVersion = installedInfo.versionName; + if (app.enhancedVersionDetection) { + app.installedVersion = installedInfo.versionName; + } else { + if (app.latestVersion.contains(installedInfo.versionName!)) { + app.installedVersion = app.latestVersion; + } else { + app.installedVersion = installedInfo.versionName; + } + } modded = true; } else if (installedInfo?.versionName != app.installedVersion && app.enhancedVersionDetection && diff --git a/lib/providers/source_provider.dart b/lib/providers/source_provider.dart index 0052e7a..525064f 100644 --- a/lib/providers/source_provider.dart +++ b/lib/providers/source_provider.dart @@ -27,13 +27,12 @@ class AppNames { class APKDetails { late String version; + late String versionFromSource; late List apkUrls; - late bool isStandardVersionName; - APKDetails(version, this.apkUrls) { - var standardVersion = extractStandardVersionName(version); - isStandardVersionName = standardVersion != null; - this.version = standardVersion ?? version; + APKDetails(this.versionFromSource, this.apkUrls) { + version = + extractStandardVersionName(versionFromSource) ?? versionFromSource; } } @@ -201,7 +200,7 @@ ObtainiumError getObtainiumHttpError(Response res) { String? extractStandardVersionName(String version, {bool strict = false}) { var match = RegExp( - '${strict ? '^' : ''}[0-9]+(\\.[0-9]+)+(-(alpha|beta)\\+?[0-9]+)?${strict ? '\$' : ''}') + '${strict ? '^' : ''}[0-9]+(\\.[0-9]+)+(-(alpha|beta|ocs)([0-9]+|\\+[0-9]+)?)?${strict ? '\$' : ''}') .firstMatch(version); return match != null ? version.substring(match.start, match.end) : null; } @@ -284,6 +283,12 @@ class SourceProvider { if (apk.apkUrls.isEmpty && !trackOnly) { throw NoAPKError(); } + bool enhancedVersionDetection = apk.version != apk.versionFromSource && + installedVersion != null && + extractStandardVersionName(installedVersion, strict: true) != null; + if (!enhancedVersionDetection) { + apk.version = apk.versionFromSource; + } String apkVersion = apk.version.replaceAll('/', '-'); return App( id ?? @@ -302,10 +307,7 @@ class SourceProvider { DateTime.now(), pinned, trackOnly, - apk.isStandardVersionName && - (installedVersion == null || - extractStandardVersionName(installedVersion, strict: true) != - null)); + enhancedVersionDetection); } // Returns errors in [results, errors] instead of throwing them