Clearer version detection settings

This commit is contained in:
Imran Remtulla
2024-01-18 23:46:23 -05:00
parent 2da9a8cd59
commit 183fb26988
20 changed files with 94 additions and 85 deletions

View File

@@ -820,8 +820,7 @@ class AppsProvider with ChangeNotifier {
? app.installedInfo?.versionCode.toString()
: app.installedInfo?.versionName;
return app.app.additionalSettings['trackOnly'] != true &&
app.app.additionalSettings['versionDetection'] !=
'releaseDateAsVersion' &&
app.app.additionalSettings['releaseDateAsVersion'] != true &&
realInstalledVersion != null &&
app.app.installedVersion != null &&
(reconcileVersionDifferences(
@@ -837,8 +836,7 @@ class AppsProvider with ChangeNotifier {
var modded = false;
var trackOnly = app.additionalSettings['trackOnly'] == true;
var versionDetectionIsStandard =
app.additionalSettings['versionDetection'] ==
'standardVersionDetection';
app.additionalSettings['versionDetection'] == true;
var naiveStandardVersionDetection =
app.additionalSettings['naiveStandardVersionDetection'] == true ||
SourceProvider()
@@ -892,7 +890,7 @@ class AppsProvider with ChangeNotifier {
versionDetectionIsStandard &&
!isVersionDetectionPossible(
AppInMemory(app, null, installedInfo, null))) {
app.additionalSettings['versionDetection'] = 'noVersionDetection';
app.additionalSettings['versionDetection'] = false;
logs.add('Could not reconcile version formats for: ${app.id}');
modded = true;
}

View File

@@ -103,6 +103,15 @@ appJSONCompatibilityModifiers(Map<String, dynamic> json) {
additionalSettings.remove('releaseDateAsVersion');
}
}
// Convert dropdown style version detection options back into bool style
if (additionalSettings['versionDetection'] == 'standardVersionDetection') {
additionalSettings['versionDetection'] = true;
} else if (additionalSettings['versionDetection'] == 'noVersionDetection') {
additionalSettings['versionDetection'] = false;
} else if (additionalSettings['versionDetection'] == 'releaseDateAsVersion') {
additionalSettings['versionDetection'] = false;
additionalSettings['releaseDateAsVersion'] = true;
}
// Ensure additionalSettings are correctly typed
for (var item in formItems) {
if (additionalSettings[item.key] != null) {
@@ -380,28 +389,23 @@ abstract class AppSource {
bool allowSubDomains = false;
bool naiveStandardVersionDetection = false;
bool neverAutoSelect = false;
bool showReleaseDateAsVersionToggle = false;
bool versionDetectionDisallowed = false;
AppSource() {
name = runtimeType.toString();
}
overrideVersionDetectionFormDefault(String vd,
{bool disableStandard = false, bool disableRelDate = false}) {
additionalAppSpecificSourceAgnosticSettingFormItems =
additionalAppSpecificSourceAgnosticSettingFormItems.map((e) {
overrideAdditionalAppSpecificSourceAgnosticSettingSwitch(String key,
{bool disabled = true, bool defaultValue = true}) {
additionalAppSpecificSourceAgnosticSettingFormItemsNeverUseDirectly =
additionalAppSpecificSourceAgnosticSettingFormItemsNeverUseDirectly
.map((e) {
return e.map((e2) {
if (e2.key == 'versionDetection') {
var item = e2 as GeneratedFormDropdown;
item.defaultValue = vd;
item.disabledOptKeys = [];
if (disableStandard) {
item.disabledOptKeys?.add('standardVersionDetection');
}
if (disableRelDate) {
item.disabledOptKeys?.add('releaseDateAsVersion');
}
item.disabledOptKeys =
item.disabledOptKeys?.where((element) => element != vd).toList();
if (e2.key == key) {
var item = e2 as GeneratedFormSwitch;
item.disabled = disabled;
item.defaultValue = defaultValue;
}
return e2;
}).toList();
@@ -457,7 +461,7 @@ abstract class AppSource {
// Some additional data may be needed for Apps regardless of Source
List<List<GeneratedFormItem>>
additionalAppSpecificSourceAgnosticSettingFormItems = [
additionalAppSpecificSourceAgnosticSettingFormItemsNeverUseDirectly = [
[
GeneratedFormSwitch(
'trackOnly',
@@ -475,16 +479,8 @@ abstract class AppSource {
label: tr('matchGroupToUse'), required: false, hint: '\$0')
],
[
GeneratedFormDropdown(
'versionDetection',
[
MapEntry(
'standardVersionDetection', tr('standardVersionDetection')),
MapEntry('releaseDateAsVersion', tr('releaseDateAsVersion')),
MapEntry('noVersionDetection', tr('noVersionDetection'))
],
label: tr('versionDetection'),
defaultValue: 'standardVersionDetection')
GeneratedFormSwitch('versionDetection',
label: tr('versionDetection'), defaultValue: true)
],
[
GeneratedFormSwitch('useVersionCodeAsOSVersion',
@@ -518,9 +514,39 @@ abstract class AppSource {
// Previous 2 variables combined into one at runtime for convenient usage
List<List<GeneratedFormItem>> get combinedAppSpecificSettingFormItems {
if (showReleaseDateAsVersionToggle == true) {
if (additionalAppSpecificSourceAgnosticSettingFormItemsNeverUseDirectly
.indexWhere((List<GeneratedFormItem> e) =>
e.indexWhere((GeneratedFormItem i) =>
i.key == 'releaseDateAsVersion') >=
0) <
0) {
additionalAppSpecificSourceAgnosticSettingFormItemsNeverUseDirectly.insert(
additionalAppSpecificSourceAgnosticSettingFormItemsNeverUseDirectly
.indexWhere((List<GeneratedFormItem> e) =>
e.indexWhere((GeneratedFormItem i) =>
i.key == 'versionDetection') >=
0) +
1,
[
GeneratedFormSwitch('releaseDateAsVersion',
label: tr('releaseDateAsVersion'), defaultValue: false)
]);
}
}
if (versionDetectionDisallowed) {
overrideAdditionalAppSpecificSourceAgnosticSettingSwitch(
'versionDetection',
disabled: true,
defaultValue: false);
overrideAdditionalAppSpecificSourceAgnosticSettingSwitch(
'useVersionCodeAsOSVersion',
disabled: true,
defaultValue: false);
}
return [
...additionalSourceAppSpecificSettingFormItems,
...additionalAppSpecificSourceAgnosticSettingFormItems
...additionalAppSpecificSourceAgnosticSettingFormItemsNeverUseDirectly
];
}
@@ -773,7 +799,7 @@ class SourceProvider {
}
}
if (additionalSettings['versionDetection'] == 'releaseDateAsVersion' &&
if (additionalSettings['releaseDateAsVersion'] == true &&
apk.releaseDate != null) {
apk.version = apk.releaseDate!.microsecondsSinceEpoch.toString();
}