diff --git a/lib/main.dart b/lib/main.dart index 72b1129..972acfa 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -21,7 +21,7 @@ import 'package:easy_localization/src/easy_localization_controller.dart'; // ignore: implementation_imports import 'package:easy_localization/src/localization.dart'; -const String currentVersion = '0.8.5'; +const String currentVersion = '0.8.6'; const String currentReleaseTag = 'v$currentVersion-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES @@ -194,7 +194,6 @@ class _ObtainiumState extends State { ['true'], null, false, - false, false) ]); } diff --git a/lib/pages/app.dart b/lib/pages/app.dart index 3465641..b9492e1 100644 --- a/lib/pages/app.dart +++ b/lib/pages/app.dart @@ -114,7 +114,7 @@ class _AppPageState extends State { height: 32, ), Text( - 'Last Update Check: ${app?.app.lastUpdateCheck == null ? 'Never' : '\n${app?.app.lastUpdateCheck?.toLocal()}'}${app?.app.enhancedVersionDetection == true ? '\n\nThis App has enhanced version detection.' : ''}', + 'Last Update Check: ${app?.app.lastUpdateCheck == null ? 'Never' : '\n${app?.app.lastUpdateCheck?.toLocal()}'}', textAlign: TextAlign.center, style: const TextStyle( fontStyle: FontStyle.italic, fontSize: 12), @@ -141,9 +141,7 @@ class _AppPageState extends State { children: [ if (app?.app.installedVersion != null && app?.app.trackOnly == false && - app?.app.installedVersion != - app?.app.latestVersion && - app?.app.enhancedVersionDetection != true) + app?.app.installedVersion != app?.app.latestVersion) IconButton( onPressed: app?.downloadProgress != null ? null diff --git a/lib/pages/apps.dart b/lib/pages/apps.dart index 1a19455..28d52df 100644 --- a/lib/pages/apps.dart +++ b/lib/pages/apps.dart @@ -526,8 +526,8 @@ class AppsPageState extends State { .selectionClick(); appsProvider .saveApps(selectedApps.map((a) { - if (a.installedVersion != null && - !a.enhancedVersionDetection) { + if (a.installedVersion != + null) { a.installedVersion = a.latestVersion; } return a; diff --git a/lib/providers/apps_provider.dart b/lib/providers/apps_provider.dart index e349c96..7ade187 100644 --- a/lib/providers/apps_provider.dart +++ b/lib/providers/apps_provider.dart @@ -9,6 +9,7 @@ import 'package:device_info_plus/device_info_plus.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:fluttertoast/fluttertoast.dart'; import 'package:install_plugin_v2/install_plugin_v2.dart'; import 'package:installed_apps/app_info.dart'; import 'package:installed_apps/installed_apps.dart'; @@ -400,9 +401,9 @@ class AppsProvider with ChangeNotifier { } // If the App says it is installed but installedInfo is null, set it to not installed - // If the App says is is not installed but installedInfo exists, set it to the real installed version - // If the internal version does not match the real one, sync them if the App supports enhanced version detection - // Enhanced version detection will be true if the version extracted from source matches the standard version format + // If the App says is is not installed but installedInfo exists, try to set it to installed as latest version... + // ...if the latestVersion seems to match the version in installedInfo (not guaranteed) + // If that fails, just set it to the actual version string (all we can do at that point) // Don't save changes, just return the object if changes were made (else null) // If in a background isolate, return null straight away as the required plugin won't work anyways App? getCorrectedInstallStatusAppIfPossible(App app, AppInfo? installedInfo) { @@ -415,22 +416,30 @@ class AppsProvider with ChangeNotifier { !app.trackOnly) { app.installedVersion = null; modded = true; - } else if (installedInfo != null && app.installedVersion == null) { - if (app.enhancedVersionDetection) { - app.installedVersion = installedInfo.versionName; + } + if (installedInfo != null && app.installedVersion == null) { + if (app.latestVersion.characters + .where((p0) => [ + // TODO: Won't work for other charsets + '0', + '1', + '2', + '3', + '4', + '5', + '6', + '7', + '8', + '9', + '.' + ].contains(p0)) + .join('') == + installedInfo.versionName) { + app.installedVersion = app.latestVersion; } else { - if (app.latestVersion.contains(installedInfo.versionName!)) { - app.installedVersion = app.latestVersion; - } else { - app.installedVersion = installedInfo.versionName; - } + app.installedVersion = installedInfo.versionName; } modded = true; - } else if (installedInfo?.versionName != app.installedVersion && - app.enhancedVersionDetection && - !app.trackOnly) { - app.installedVersion = installedInfo?.versionName; - modded = true; } return modded ? app : null; } diff --git a/lib/providers/source_provider.dart b/lib/providers/source_provider.dart index 1e7cf72..ac192a8 100644 --- a/lib/providers/source_provider.dart +++ b/lib/providers/source_provider.dart @@ -27,15 +27,9 @@ class AppNames { class APKDetails { late String version; - late String versionFromSource; - late bool isStandardVersion; late List apkUrls; - APKDetails(this.versionFromSource, this.apkUrls) { - var temp = extractStandardVersionName(versionFromSource); - isStandardVersion = temp != null; - version = temp ?? versionFromSource; - } + APKDetails(this.version, this.apkUrls); } class App { @@ -51,7 +45,6 @@ class App { late DateTime? lastUpdateCheck; bool pinned = false; bool trackOnly = false; - bool enhancedVersionDetection = false; App( this.id, this.url, @@ -64,8 +57,7 @@ class App { this.additionalData, this.lastUpdateCheck, this.pinned, - this.trackOnly, - this.enhancedVersionDetection); + this.trackOnly); @override String toString() { @@ -94,8 +86,7 @@ class App { ? null : DateTime.fromMicrosecondsSinceEpoch(json['lastUpdateCheck']), json['pinned'] ?? false, - json['trackOnly'] ?? false, - json['enhancedVersionDetection'] ?? false); + json['trackOnly'] ?? false); Map toJson() => { 'id': id, @@ -109,8 +100,7 @@ class App { 'additionalData': jsonEncode(additionalData), 'lastUpdateCheck': lastUpdateCheck?.microsecondsSinceEpoch, 'pinned': pinned, - 'trackOnly': trackOnly, - 'enhancedVersionDetection': enhancedVersionDetection + 'trackOnly': trackOnly }; } @@ -200,13 +190,6 @@ ObtainiumError getObtainiumHttpError(Response res) { tr('errorWithHttpStatusCode', args: [res.statusCode.toString()])); } -String? extractStandardVersionName(String version, {bool strict = false}) { - var match = - RegExp('${strict ? '^' : ''}[0-9]+(\\.[0-9]+)+${strict ? '\$' : ''}') - .firstMatch(version); - return match != null ? version.substring(match.start, match.end) : null; -} - abstract class MassAppUrlSource { late String name; late List requiredArgs; @@ -285,12 +268,6 @@ class SourceProvider { if (apk.apkUrls.isEmpty && !trackOnly) { throw NoAPKError(); } - bool enhancedVersionDetection = apk.isStandardVersion && - installedVersion != null && - extractStandardVersionName(installedVersion, strict: true) != null; - if (!enhancedVersionDetection) { - apk.version = apk.versionFromSource; - } String apkVersion = apk.version.replaceAll('/', '-'); return App( id ?? @@ -308,8 +285,7 @@ class SourceProvider { additionalData, DateTime.now(), pinned, - trackOnly, - enhancedVersionDetection); + trackOnly); } // Returns errors in [results, errors] instead of throwing them