From 5e0333c4c8530bab1346b240ad19803a9a961e22 Mon Sep 17 00:00:00 2001 From: Praveen Kumar Date: Sun, 20 Oct 2024 19:56:19 +0530 Subject: [PATCH 1/4] Add Custom app ID --- lib/providers/source_provider.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/providers/source_provider.dart b/lib/providers/source_provider.dart index 8e77f544..74052df2 100644 --- a/lib/providers/source_provider.dart +++ b/lib/providers/source_provider.dart @@ -571,7 +571,8 @@ abstract class AppSource { GeneratedFormSwitch('skipUpdateNotifications', label: tr('skipUpdateNotifications')) ], - [GeneratedFormTextField('about', label: tr('about'), required: false)] + [GeneratedFormTextField('about', label: tr('about'), required: false)], + [GeneratedFormTextField('appId', label: tr('appId'), required: false)] ]; // Previous 2 variables combined into one at runtime for convenient usage @@ -922,6 +923,9 @@ class SourceProvider { name = name.isNotEmpty ? name : apk.names.name; App finalApp = App( currentApp?.id ?? + ((additionalSettings['appId'] != null) + ? additionalSettings['appId'] + : null) ?? (!trackOnly && (!source.appIdInferIsOptional || (source.appIdInferIsOptional && inferAppIdIfOptional)) From c1c06b3f9c378ebe7b0c2ef77fb07456016cd214 Mon Sep 17 00:00:00 2001 From: Praveen Kumar Date: Sun, 20 Oct 2024 21:46:13 +0530 Subject: [PATCH 2/4] Make appId Assignable only once --- lib/pages/add_app.dart | 16 ++++++++++++++++ lib/providers/source_provider.dart | 1 - 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/pages/add_app.dart b/lib/pages/add_app.dart index bdeb203c..029e4064 100644 --- a/lib/pages/add_app.dart +++ b/lib/pages/add_app.dart @@ -538,6 +538,22 @@ class AddAppPageState extends State { }); } }), + if (pickedSource != null) + GeneratedForm( + key: const Key('appId'), + items: [ + [ + GeneratedFormTextField('appId', + label: tr('appId'), required: false), + ] + ], + onValueChanges: (values, valid, isBuilding) { + if (!isBuilding) { + setState(() { + additionalSettings['appId'] = values['appId']; + }); + } + }), ], ); diff --git a/lib/providers/source_provider.dart b/lib/providers/source_provider.dart index 74052df2..29dff111 100644 --- a/lib/providers/source_provider.dart +++ b/lib/providers/source_provider.dart @@ -572,7 +572,6 @@ abstract class AppSource { label: tr('skipUpdateNotifications')) ], [GeneratedFormTextField('about', label: tr('about'), required: false)], - [GeneratedFormTextField('appId', label: tr('appId'), required: false)] ]; // Previous 2 variables combined into one at runtime for convenient usage From 9d5ce75e27cee16ee82e2243a75f0a3f720a59c3 Mon Sep 17 00:00:00 2001 From: Praveen Kumar Date: Sun, 20 Oct 2024 22:47:13 +0530 Subject: [PATCH 3/4] Fixed a Bug, Added Validation --- lib/pages/add_app.dart | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/pages/add_app.dart b/lib/pages/add_app.dart index 029e4064..546377e5 100644 --- a/lib/pages/add_app.dart +++ b/lib/pages/add_app.dart @@ -540,11 +540,27 @@ class AddAppPageState extends State { }), if (pickedSource != null) GeneratedForm( - key: const Key('appId'), + key: Key( + '${pickedSource.runtimeType.toString()}-${pickedSource?.hostChanged.toString()}-${pickedSource?.hostIdenticalDespiteAnyChange.toString()}-appId'), items: [ [ GeneratedFormTextField('appId', - label: tr('appId'), required: false), + label: tr('appId'), + required: false, + additionalValidators: [ + (value) { + if (value == null || value.isEmpty) { + return null; + } + final isValid = RegExp( + r'^([A-Za-z]{1}[A-Za-z\d_]*\.)+[A-Za-z][A-Za-z\d_]*$') + .hasMatch(value); + if (!isValid) { + return tr('invalidInput'); + } + return null; + } + ]), ] ], onValueChanges: (values, valid, isBuilding) { From 9f7c4e23d5406b70b00e56d317edec02d4b508f7 Mon Sep 17 00:00:00 2001 From: Praveen Kumar Date: Mon, 21 Oct 2024 21:52:40 +0530 Subject: [PATCH 4/4] Change behaviour of Custom App ID --- lib/pages/add_app.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pages/add_app.dart b/lib/pages/add_app.dart index 546377e5..851c0b71 100644 --- a/lib/pages/add_app.dart +++ b/lib/pages/add_app.dart @@ -538,7 +538,7 @@ class AddAppPageState extends State { }); } }), - if (pickedSource != null) + if (pickedSource != null && pickedSource!.enforceTrackOnly) GeneratedForm( key: Key( '${pickedSource.runtimeType.toString()}-${pickedSource?.hostChanged.toString()}-${pickedSource?.hostIdenticalDespiteAnyChange.toString()}-appId'),