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

@@ -71,6 +71,11 @@ class _AddAppPageState extends State<AddAppPage> {
otherAdditionalData, otherAdditionalData,
'trackOnlyFormItemKey') == 'trackOnlyFormItemKey') ==
'true'; 'true';
var userPickedNoVersionDetection = findGeneratedFormValueByKey(
pickedSource!.additionalAppSpecificSourceAgnosticFormItems,
otherAdditionalData,
'noVersionDetectionKey') ==
'true';
var cont = true; var cont = true;
if ((userPickedTrackOnly || pickedSource!.enforceTrackOnly) && if ((userPickedTrackOnly || pickedSource!.enforceTrackOnly) &&
await showDialog( await showDialog(
@@ -91,12 +96,27 @@ class _AddAppPageState extends State<AddAppPage> {
null) { null) {
cont = false; 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) { if (cont) {
HapticFeedback.selectionClick(); HapticFeedback.selectionClick();
var trackOnly = pickedSource!.enforceTrackOnly || userPickedTrackOnly; var trackOnly = pickedSource!.enforceTrackOnly || userPickedTrackOnly;
App app = await sourceProvider.getApp( App app = await sourceProvider.getApp(
pickedSource!, userInput, sourceSpecificAdditionalData, pickedSource!, userInput, sourceSpecificAdditionalData,
trackOnly: trackOnly); trackOnlyOverride: trackOnly,
noVersionDetectionOverride: userPickedNoVersionDetection);
if (!trackOnly) { if (!trackOnly) {
await settingsProvider.getInstallPermission(); await settingsProvider.getInstallPermission();
} }

View File

@@ -461,7 +461,8 @@ class AppsProvider with ChangeNotifier {
app.installedVersion = installedInfo!.versionName; app.installedVersion = installedInfo!.versionName;
modded = true; modded = true;
} else if (installedInfo?.versionName != null && } else if (installedInfo?.versionName != null &&
installedInfo!.versionName != app.installedVersion) { installedInfo!.versionName != app.installedVersion &&
!app.noVersionDetection) {
String? correctedInstalledVersion = reconcileRealAndInternalVersions( String? correctedInstalledVersion = reconcileRealAndInternalVersions(
installedInfo.versionName!, app.installedVersion!); installedInfo.versionName!, app.installedVersion!);
if (correctedInstalledVersion != null) { if (correctedInstalledVersion != null) {
@@ -470,7 +471,8 @@ class AppsProvider with ChangeNotifier {
} }
} }
if (app.installedVersion != null && if (app.installedVersion != null &&
app.installedVersion != app.latestVersion) { app.installedVersion != app.latestVersion &&
!app.noVersionDetection) {
app.installedVersion = reconcileRealAndInternalVersions( app.installedVersion = reconcileRealAndInternalVersions(
app.installedVersion!, app.latestVersion, app.installedVersion!, app.latestVersion,
matchMode: true) ?? matchMode: true) ??
@@ -624,11 +626,7 @@ class AppsProvider with ChangeNotifier {
sourceProvider.getSource(currentApp.url), sourceProvider.getSource(currentApp.url),
currentApp.url, currentApp.url,
currentApp.additionalData, currentApp.additionalData,
name: currentApp.name, currentApp: currentApp);
id: currentApp.id,
pinned: currentApp.pinned,
trackOnly: currentApp.trackOnly,
installedVersion: currentApp.installedVersion);
if (currentApp.preferredApkIndex < newApp.apkUrls.length) { if (currentApp.preferredApkIndex < newApp.apkUrls.length) {
newApp.preferredApkIndex = currentApp.preferredApkIndex; newApp.preferredApkIndex = currentApp.preferredApkIndex;
} }

View File

@@ -48,6 +48,7 @@ class App {
late DateTime? lastUpdateCheck; late DateTime? lastUpdateCheck;
bool pinned = false; bool pinned = false;
bool trackOnly = false; bool trackOnly = false;
bool noVersionDetection = false;
App( App(
this.id, this.id,
this.url, this.url,
@@ -60,7 +61,8 @@ class App {
this.additionalData, this.additionalData,
this.lastUpdateCheck, this.lastUpdateCheck,
this.pinned, this.pinned,
this.trackOnly); this.trackOnly,
{this.noVersionDetection = false});
@override @override
String toString() { String toString() {
@@ -89,7 +91,8 @@ class App {
? null ? null
: DateTime.fromMicrosecondsSinceEpoch(json['lastUpdateCheck']), : DateTime.fromMicrosecondsSinceEpoch(json['lastUpdateCheck']),
json['pinned'] ?? false, json['pinned'] ?? false,
json['trackOnly'] ?? false); json['trackOnly'] ?? false,
noVersionDetection: json['noVersionDetection'] ?? false);
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
'id': id, 'id': id,
@@ -103,7 +106,8 @@ class App {
'additionalData': jsonEncode(additionalData), 'additionalData': jsonEncode(additionalData),
'lastUpdateCheck': lastUpdateCheck?.microsecondsSinceEpoch, 'lastUpdateCheck': lastUpdateCheck?.microsecondsSinceEpoch,
'pinned': pinned, 'pinned': pinned,
'trackOnly': trackOnly 'trackOnly': trackOnly,
'noVersionDetection': noVersionDetection
}; };
} }
@@ -165,9 +169,13 @@ class AppSource {
GeneratedFormItem( GeneratedFormItem(
label: tr('trackOnly'), label: tr('trackOnly'),
type: FormItemType.bool, 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 // Some Sources may have additional settings at the Source level (not specific to Apps) - these use SettingsProvider
List<GeneratedFormItem> additionalSourceSpecificSettingFormItems = []; List<GeneratedFormItem> additionalSourceSpecificSettingFormItems = [];
@@ -275,11 +283,11 @@ class SourceProvider {
} }
Future<App> getApp(AppSource source, String url, List<String> additionalData, Future<App> getApp(AppSource source, String url, List<String> additionalData,
{String name = '', {App? currentApp,
String? id, bool trackOnlyOverride = false,
bool pinned = false, noVersionDetectionOverride = false}) async {
bool trackOnly = false, var trackOnly = trackOnlyOverride || (currentApp?.trackOnly ?? false);
String? installedVersion}) async {
String standardUrl = source.standardizeURL(preStandardizeUrl(url)); String standardUrl = source.standardizeURL(preStandardizeUrl(url));
APKDetails apk = await source APKDetails apk = await source
.getLatestAPKDetails(standardUrl, additionalData, trackOnly: trackOnly); .getLatestAPKDetails(standardUrl, additionalData, trackOnly: trackOnly);
@@ -287,8 +295,10 @@ class SourceProvider {
throw NoAPKError(); throw NoAPKError();
} }
String apkVersion = apk.version.replaceAll('/', '-'); String apkVersion = apk.version.replaceAll('/', '-');
var name = currentApp?.name.trim() ??
apk.names.name[0].toUpperCase() + apk.names.name.substring(1);
return App( return App(
id ?? currentApp?.id ??
source.tryInferringAppId(standardUrl, source.tryInferringAppId(standardUrl,
additionalData: additionalData) ?? additionalData: additionalData) ??
generateTempID(apk.names, source), generateTempID(apk.names, source),
@@ -297,14 +307,16 @@ class SourceProvider {
name.trim().isNotEmpty name.trim().isNotEmpty
? name ? name
: apk.names.name[0].toUpperCase() + apk.names.name.substring(1), : apk.names.name[0].toUpperCase() + apk.names.name.substring(1),
installedVersion, currentApp?.installedVersion,
apkVersion, apkVersion,
apk.apkUrls, apk.apkUrls,
apk.apkUrls.length - 1, apk.apkUrls.length - 1,
additionalData, additionalData,
DateTime.now(), DateTime.now(),
pinned, currentApp?.pinned ?? false,
trackOnly); trackOnly,
noVersionDetection: noVersionDetectionOverride ||
(currentApp?.noVersionDetection ?? false));
} }
// Returns errors in [results, errors] instead of throwing them // Returns errors in [results, errors] instead of throwing them