Added 'no version detection' option

This commit is contained in:
Imran Remtulla
2022-12-18 02:46:25 -05:00
parent 67b986de93
commit 63034dd3f9
3 changed files with 52 additions and 22 deletions

View File

@@ -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;
}

View File

@@ -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<String, dynamic> 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<String> additionalAppSpecificSourceAgnosticDefaults = [''];
final List<String> additionalAppSpecificSourceAgnosticDefaults = ['', ''];
// Some Sources may have additional settings at the Source level (not specific to Apps) - these use SettingsProvider
List<GeneratedFormItem> additionalSourceSpecificSettingFormItems = [];
@@ -275,11 +283,11 @@ class SourceProvider {
}
Future<App> getApp(AppSource source, String url, List<String> 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