diff --git a/lib/pages/add_app.dart b/lib/pages/add_app.dart index 6dd6b5f..40e1f40 100644 --- a/lib/pages/add_app.dart +++ b/lib/pages/add_app.dart @@ -71,6 +71,11 @@ class _AddAppPageState extends State { otherAdditionalData, 'trackOnlyFormItemKey') == 'true'; + var userPickedNoVersionDetection = findGeneratedFormValueByKey( + pickedSource!.additionalAppSpecificSourceAgnosticFormItems, + otherAdditionalData, + 'noVersionDetectionKey') == + 'true'; var cont = true; if ((userPickedTrackOnly || pickedSource!.enforceTrackOnly) && await showDialog( @@ -91,12 +96,27 @@ class _AddAppPageState extends State { null) { cont = false; } + if (userPickedNoVersionDetection && + await showDialog( + context: context, + builder: (BuildContext ctx) { + return GeneratedFormModal( + title: 'Disable Version Detection', // TODO + items: const [], + defaultValues: const [], + message: 'TODO', + ); + }) == + null) { + cont = false; + } if (cont) { HapticFeedback.selectionClick(); var trackOnly = pickedSource!.enforceTrackOnly || userPickedTrackOnly; App app = await sourceProvider.getApp( pickedSource!, userInput, sourceSpecificAdditionalData, - trackOnly: trackOnly); + trackOnlyOverride: trackOnly, + noVersionDetectionOverride: userPickedNoVersionDetection); if (!trackOnly) { await settingsProvider.getInstallPermission(); } diff --git a/lib/providers/apps_provider.dart b/lib/providers/apps_provider.dart index ec605e2..5a1cf8a 100644 --- a/lib/providers/apps_provider.dart +++ b/lib/providers/apps_provider.dart @@ -461,7 +461,8 @@ class AppsProvider with ChangeNotifier { app.installedVersion = installedInfo!.versionName; modded = true; } else if (installedInfo?.versionName != null && - installedInfo!.versionName != app.installedVersion) { + installedInfo!.versionName != app.installedVersion && + !app.noVersionDetection) { String? correctedInstalledVersion = reconcileRealAndInternalVersions( installedInfo.versionName!, app.installedVersion!); if (correctedInstalledVersion != null) { @@ -470,7 +471,8 @@ class AppsProvider with ChangeNotifier { } } if (app.installedVersion != null && - app.installedVersion != app.latestVersion) { + app.installedVersion != app.latestVersion && + !app.noVersionDetection) { app.installedVersion = reconcileRealAndInternalVersions( app.installedVersion!, app.latestVersion, matchMode: true) ?? @@ -624,11 +626,7 @@ class AppsProvider with ChangeNotifier { sourceProvider.getSource(currentApp.url), currentApp.url, currentApp.additionalData, - name: currentApp.name, - id: currentApp.id, - pinned: currentApp.pinned, - trackOnly: currentApp.trackOnly, - installedVersion: currentApp.installedVersion); + currentApp: currentApp); if (currentApp.preferredApkIndex < newApp.apkUrls.length) { newApp.preferredApkIndex = currentApp.preferredApkIndex; } diff --git a/lib/providers/source_provider.dart b/lib/providers/source_provider.dart index a623477..28a203f 100644 --- a/lib/providers/source_provider.dart +++ b/lib/providers/source_provider.dart @@ -48,6 +48,7 @@ class App { late DateTime? lastUpdateCheck; bool pinned = false; bool trackOnly = false; + bool noVersionDetection = false; App( this.id, this.url, @@ -60,7 +61,8 @@ class App { this.additionalData, this.lastUpdateCheck, this.pinned, - this.trackOnly); + this.trackOnly, + {this.noVersionDetection = false}); @override String toString() { @@ -89,7 +91,8 @@ class App { ? null : DateTime.fromMicrosecondsSinceEpoch(json['lastUpdateCheck']), json['pinned'] ?? false, - json['trackOnly'] ?? false); + json['trackOnly'] ?? false, + noVersionDetection: json['noVersionDetection'] ?? false); Map toJson() => { 'id': id, @@ -103,7 +106,8 @@ class App { 'additionalData': jsonEncode(additionalData), 'lastUpdateCheck': lastUpdateCheck?.microsecondsSinceEpoch, 'pinned': pinned, - 'trackOnly': trackOnly + 'trackOnly': trackOnly, + 'noVersionDetection': noVersionDetection }; } @@ -165,9 +169,13 @@ class AppSource { GeneratedFormItem( label: tr('trackOnly'), type: FormItemType.bool, - key: 'trackOnlyFormItemKey') + key: 'trackOnlyFormItemKey'), + GeneratedFormItem( + label: 'Do not attempt version detection', // TODO + type: FormItemType.bool, + key: 'noVersionDetectionKey') ]; - final List additionalAppSpecificSourceAgnosticDefaults = ['']; + final List additionalAppSpecificSourceAgnosticDefaults = ['', '']; // Some Sources may have additional settings at the Source level (not specific to Apps) - these use SettingsProvider List additionalSourceSpecificSettingFormItems = []; @@ -275,11 +283,11 @@ class SourceProvider { } Future getApp(AppSource source, String url, List additionalData, - {String name = '', - String? id, - bool pinned = false, - bool trackOnly = false, - String? installedVersion}) async { + {App? currentApp, + bool trackOnlyOverride = false, + noVersionDetectionOverride = false}) async { + var trackOnly = trackOnlyOverride || (currentApp?.trackOnly ?? false); + String standardUrl = source.standardizeURL(preStandardizeUrl(url)); APKDetails apk = await source .getLatestAPKDetails(standardUrl, additionalData, trackOnly: trackOnly); @@ -287,8 +295,10 @@ class SourceProvider { throw NoAPKError(); } String apkVersion = apk.version.replaceAll('/', '-'); + var name = currentApp?.name.trim() ?? + apk.names.name[0].toUpperCase() + apk.names.name.substring(1); return App( - id ?? + currentApp?.id ?? source.tryInferringAppId(standardUrl, additionalData: additionalData) ?? generateTempID(apk.names, source), @@ -297,14 +307,16 @@ class SourceProvider { name.trim().isNotEmpty ? name : apk.names.name[0].toUpperCase() + apk.names.name.substring(1), - installedVersion, + currentApp?.installedVersion, apkVersion, apk.apkUrls, apk.apkUrls.length - 1, additionalData, DateTime.now(), - pinned, - trackOnly); + currentApp?.pinned ?? false, + trackOnly, + noVersionDetection: noVersionDetectionOverride || + (currentApp?.noVersionDetection ?? false)); } // Returns errors in [results, errors] instead of throwing them