mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-07-24 18:09:42 +02:00
Clearer version detection settings
This commit is contained in:
@@ -6,6 +6,7 @@ import 'package:obtainium/providers/source_provider.dart';
|
||||
class APKCombo extends AppSource {
|
||||
APKCombo() {
|
||||
hosts = ['apkcombo.com'];
|
||||
showReleaseDateAsVersionToggle = true;
|
||||
}
|
||||
|
||||
@override
|
||||
|
@@ -11,6 +11,7 @@ class APKMirror extends AppSource {
|
||||
APKMirror() {
|
||||
hosts = ['apkmirror.com'];
|
||||
enforceTrackOnly = true;
|
||||
showReleaseDateAsVersionToggle = true;
|
||||
|
||||
additionalSourceAppSpecificSettingFormItems = [
|
||||
[
|
||||
|
@@ -23,6 +23,7 @@ class APKPure extends AppSource {
|
||||
hosts = ['apkpure.net', 'apkpure.com'];
|
||||
allowSubDomains = true;
|
||||
naiveStandardVersionDetection = true;
|
||||
showReleaseDateAsVersionToggle = true;
|
||||
}
|
||||
|
||||
@override
|
||||
|
@@ -10,6 +10,7 @@ class Aptoide extends AppSource {
|
||||
name = 'Aptoide';
|
||||
allowSubDomains = true;
|
||||
naiveStandardVersionDetection = true;
|
||||
showReleaseDateAsVersionToggle = true;
|
||||
}
|
||||
|
||||
@override
|
||||
|
@@ -10,6 +10,7 @@ class FDroidRepo extends AppSource {
|
||||
canSearch = true;
|
||||
excludeFromMassSearch = true;
|
||||
neverAutoSelect = true;
|
||||
showReleaseDateAsVersionToggle = true;
|
||||
|
||||
additionalSourceAppSpecificSettingFormItems = [
|
||||
[
|
||||
|
@@ -16,6 +16,7 @@ class GitHub extends AppSource {
|
||||
GitHub() {
|
||||
hosts = ['github.com'];
|
||||
appIdInferIsOptional = true;
|
||||
showReleaseDateAsVersionToggle = true;
|
||||
|
||||
sourceConfigSettingFormItems = [
|
||||
GeneratedFormTextField('github-creds',
|
||||
|
@@ -15,6 +15,7 @@ class GitLab extends AppSource {
|
||||
GitLab() {
|
||||
hosts = ['gitlab.com'];
|
||||
canSearch = true;
|
||||
showReleaseDateAsVersionToggle = true;
|
||||
|
||||
sourceConfigSettingFormItems = [
|
||||
GeneratedFormTextField('gitlab-creds',
|
||||
|
@@ -174,8 +174,6 @@ class HTML extends AppSource {
|
||||
])
|
||||
]
|
||||
];
|
||||
overrideVersionDetectionFormDefault('noVersionDetection',
|
||||
disableStandard: false, disableRelDate: true);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@@ -7,8 +7,8 @@ class HuaweiAppGallery extends AppSource {
|
||||
HuaweiAppGallery() {
|
||||
name = 'Huawei AppGallery';
|
||||
hosts = ['appgallery.huawei.com'];
|
||||
overrideVersionDetectionFormDefault('releaseDateAsVersion',
|
||||
disableStandard: true);
|
||||
versionDetectionDisallowed = true;
|
||||
showReleaseDateAsVersionToggle = true;
|
||||
}
|
||||
|
||||
@override
|
||||
|
@@ -6,9 +6,9 @@ import 'package:obtainium/providers/source_provider.dart';
|
||||
|
||||
class Jenkins extends AppSource {
|
||||
Jenkins() {
|
||||
overrideVersionDetectionFormDefault('releaseDateAsVersion',
|
||||
disableStandard: true);
|
||||
versionDetectionDisallowed = true;
|
||||
neverAutoSelect = true;
|
||||
showReleaseDateAsVersionToggle = true;
|
||||
}
|
||||
|
||||
String trimJobUrl(String url) {
|
||||
|
@@ -6,6 +6,7 @@ import 'package:obtainium/providers/source_provider.dart';
|
||||
class NeutronCode extends AppSource {
|
||||
NeutronCode() {
|
||||
hosts = ['neutroncode.com'];
|
||||
showReleaseDateAsVersionToggle = true;
|
||||
}
|
||||
|
||||
@override
|
||||
|
@@ -9,6 +9,7 @@ import 'package:easy_localization/easy_localization.dart';
|
||||
class SourceHut extends AppSource {
|
||||
SourceHut() {
|
||||
hosts = ['git.sr.ht'];
|
||||
showReleaseDateAsVersionToggle = true;
|
||||
|
||||
additionalSourceAppSpecificSettingFormItems = [
|
||||
[
|
||||
|
@@ -9,6 +9,7 @@ class Uptodown extends AppSource {
|
||||
hosts = ['uptodown.com'];
|
||||
allowSubDomains = true;
|
||||
naiveStandardVersionDetection = true;
|
||||
showReleaseDateAsVersionToggle = true;
|
||||
}
|
||||
|
||||
@override
|
||||
|
@@ -6,8 +6,7 @@ import 'package:obtainium/providers/source_provider.dart';
|
||||
class WhatsApp extends AppSource {
|
||||
WhatsApp() {
|
||||
hosts = ['whatsapp.com'];
|
||||
overrideVersionDetectionFormDefault('noVersionDetection',
|
||||
disableStandard: true, disableRelDate: true);
|
||||
versionDetectionDisallowed = true;
|
||||
}
|
||||
|
||||
@override
|
||||
|
@@ -96,11 +96,14 @@ class GeneratedFormDropdown extends GeneratedFormItem {
|
||||
}
|
||||
|
||||
class GeneratedFormSwitch extends GeneratedFormItem {
|
||||
bool disabled = false;
|
||||
|
||||
GeneratedFormSwitch(
|
||||
super.key, {
|
||||
super.label,
|
||||
super.belowWidgets,
|
||||
bool super.defaultValue = false,
|
||||
bool disabled = false,
|
||||
List<String? Function(bool value)> super.additionalValidators = const [],
|
||||
});
|
||||
|
||||
@@ -115,6 +118,7 @@ class GeneratedFormSwitch extends GeneratedFormItem {
|
||||
label: label,
|
||||
belowWidgets: belowWidgets,
|
||||
defaultValue: defaultValue,
|
||||
disabled: false,
|
||||
additionalValidators: List.from(additionalValidators));
|
||||
}
|
||||
}
|
||||
@@ -368,12 +372,15 @@ class _GeneratedFormState extends State<GeneratedForm> {
|
||||
),
|
||||
Switch(
|
||||
value: values[fieldKey],
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
values[fieldKey] = value;
|
||||
someValueChanged();
|
||||
});
|
||||
})
|
||||
onChanged:
|
||||
(widget.items[r][e] as GeneratedFormSwitch).disabled
|
||||
? null
|
||||
: (value) {
|
||||
setState(() {
|
||||
values[fieldKey] = value;
|
||||
someValueChanged();
|
||||
});
|
||||
})
|
||||
],
|
||||
);
|
||||
} else if (widget.items[r][e] is GeneratedFormTagInput) {
|
||||
|
@@ -183,10 +183,7 @@ class _ObtainiumState extends State<Obtainium> {
|
||||
value.versionName!,
|
||||
[],
|
||||
0,
|
||||
{
|
||||
'includePrereleases': true,
|
||||
'versionDetection': 'standardVersionDetection'
|
||||
},
|
||||
{'includePrereleases': true, 'versionDetection': true},
|
||||
null,
|
||||
false)
|
||||
], onlyIfExists: false);
|
||||
|
@@ -135,8 +135,7 @@ class AddAppPageState extends State<AddAppPage> {
|
||||
|
||||
getReleaseDateAsVersionConfirmationIfNeeded(
|
||||
bool userPickedTrackOnly) async {
|
||||
return (!(additionalSettings['versionDetection'] ==
|
||||
'releaseDateAsVersion' &&
|
||||
return (!(additionalSettings['releaseDateAsVersion'] == true &&
|
||||
// ignore: use_build_context_synchronously
|
||||
await showDialog(
|
||||
context: context,
|
||||
@@ -192,8 +191,7 @@ class AddAppPageState extends State<AddAppPage> {
|
||||
throw ObtainiumError(tr('appAlreadyAdded'));
|
||||
}
|
||||
if (app.additionalSettings['trackOnly'] == true ||
|
||||
app.additionalSettings['versionDetection'] !=
|
||||
'standardVersionDetection') {
|
||||
app.additionalSettings['versionDetection'] != true) {
|
||||
app.installedVersion = app.latestVersion;
|
||||
}
|
||||
app.categories = pickedCategories;
|
||||
|
@@ -1,7 +1,6 @@
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:obtainium/components/generated_form.dart';
|
||||
import 'package:obtainium/components/generated_form_modal.dart';
|
||||
import 'package:obtainium/custom_errors.dart';
|
||||
import 'package:obtainium/main.dart';
|
||||
@@ -54,13 +53,11 @@ class _AppPageState extends State<AppPage> {
|
||||
var trackOnly = app?.app.additionalSettings['trackOnly'] == true;
|
||||
|
||||
bool isVersionDetectionStandard =
|
||||
app?.app.additionalSettings['versionDetection'] ==
|
||||
'standardVersionDetection';
|
||||
app?.app.additionalSettings['versionDetection'] == true;
|
||||
|
||||
bool installedVersionIsEstimate = trackOnly ||
|
||||
(app?.app.installedVersion != null &&
|
||||
app?.app.additionalSettings['versionDetection'] ==
|
||||
'noVersionDetection');
|
||||
app?.app.additionalSettings['versionDetection'] != true);
|
||||
|
||||
getInfoColumn() => Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
@@ -287,25 +284,6 @@ class _AppPageState extends State<AppPage> {
|
||||
return row;
|
||||
}).toList();
|
||||
|
||||
items = items.map((row) {
|
||||
row = row.map((e) {
|
||||
if (e.key == 'versionDetection' && e is GeneratedFormDropdown) {
|
||||
e.disabledOptKeys ??= [];
|
||||
if (app?.app.installedVersion != null &&
|
||||
app?.app.additionalSettings['versionDetection'] !=
|
||||
'releaseDateAsVersion' &&
|
||||
!appsProvider.isVersionDetectionPossible(app)) {
|
||||
e.disabledOptKeys!.add('standardVersionDetection');
|
||||
}
|
||||
if (app?.app.releaseDate == null) {
|
||||
e.disabledOptKeys!.add('releaseDateAsVersion');
|
||||
}
|
||||
}
|
||||
return e;
|
||||
}).toList();
|
||||
return row;
|
||||
}).toList();
|
||||
|
||||
return GeneratedFormModal(
|
||||
title: tr('additionalOptions'), items: items);
|
||||
});
|
||||
@@ -320,9 +298,8 @@ class _AppPageState extends State<AppPage> {
|
||||
// ignore: use_build_context_synchronously
|
||||
showMessage(tr('appsFromSourceAreTrackOnly'), context);
|
||||
}
|
||||
if (app.app.additionalSettings['versionDetection'] ==
|
||||
'releaseDateAsVersion') {
|
||||
if (originalSettings['versionDetection'] != 'releaseDateAsVersion') {
|
||||
if (app.app.additionalSettings['releaseDateAsVersion'] == true) {
|
||||
if (originalSettings['releaseDateAsVersion'] != true) {
|
||||
if (app.app.releaseDate != null) {
|
||||
bool isUpdated =
|
||||
app.app.installedVersion == app.app.latestVersion;
|
||||
@@ -333,8 +310,7 @@ class _AppPageState extends State<AppPage> {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (originalSettings['versionDetection'] ==
|
||||
'releaseDateAsVersion') {
|
||||
} else if (originalSettings['releaseDateAsVersion'] == true) {
|
||||
app.app.installedVersion =
|
||||
app.installedInfo?.versionName ?? app.app.installedVersion;
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user