diff --git a/lib/components/generated_form.dart b/lib/components/generated_form.dart index 1a7e45e..c84b630 100644 --- a/lib/components/generated_form.dart +++ b/lib/components/generated_form.dart @@ -150,6 +150,7 @@ class _GeneratedFormState extends State { Map values = {}; late List> formInputs; List> rows = []; + String? initKey; // If any value changes, call this to update the parent with value and validity void someValueChanged({bool isBuilding = false}) { @@ -169,13 +170,10 @@ class _GeneratedFormState extends State { widget.onValueChanges(returnValues, valid, isBuilding); } - @override - void initState() { - super.initState(); - + initForm() { + initKey = widget.key.toString(); // Initialize form values as all empty values.clear(); - int j = 0; for (var row in widget.items) { for (var e in row) { values[e.key] = e.defaultValue; @@ -245,8 +243,17 @@ class _GeneratedFormState extends State { someValueChanged(isBuilding: true); } + @override + void initState() { + super.initState(); + initForm(); + } + @override Widget build(BuildContext context) { + if (widget.key.toString() != initKey) { + initForm(); + } for (var r = 0; r < formInputs.length; r++) { for (var e = 0; e < formInputs[r].length; e++) { if (widget.items[r][e] is GeneratedFormSwitch) { diff --git a/lib/main.dart b/lib/main.dart index fdef815..d098cbe 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -21,7 +21,7 @@ import 'package:easy_localization/src/easy_localization_controller.dart'; // ignore: implementation_imports import 'package:easy_localization/src/localization.dart'; -const String currentVersion = '0.10.5'; +const String currentVersion = '0.10.6'; const String currentReleaseTag = 'v$currentVersion-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES diff --git a/lib/pages/add_app.dart b/lib/pages/add_app.dart index a216a7e..80720a1 100644 --- a/lib/pages/add_app.dart +++ b/lib/pages/add_app.dart @@ -32,6 +32,7 @@ class _AddAppPageState extends State { Map additionalSettings = {}; bool additionalSettingsValid = true; List pickedCategories = []; + int searchnum = 0; @override Widget build(BuildContext context) { @@ -40,10 +41,14 @@ class _AddAppPageState extends State { bool doingSomething = gettingAppInfo || searching; - changeUserInput(String input, bool valid, bool isBuilding) { + changeUserInput(String input, bool valid, bool isBuilding, + {bool isSearch = false}) { userInput = input; if (!isBuilding) { setState(() { + if (isSearch) { + searchnum++; + } var source = valid ? sourceProvider.getSource(userInput) : null; if (pickedSource.runtimeType != source.runtimeType) { pickedSource = source; @@ -169,30 +174,32 @@ class _AddAppPageState extends State { children: [ Expanded( child: GeneratedForm( + key: Key(searchnum.toString()), items: [ - [ - GeneratedFormTextField('appSourceURL', - label: tr('appSourceURL'), - additionalValidators: [ - (value) { - try { - sourceProvider - .getSource(value ?? '') - .standardizeURL( - preStandardizeUrl( - value ?? '')); - } catch (e) { - return e is String - ? e - : e is ObtainiumError - ? e.toString() - : tr('error'); - } - return null; - } - ]) - ] - ], + [ + GeneratedFormTextField('appSourceURL', + label: tr('appSourceURL'), + defaultValue: userInput, + additionalValidators: [ + (value) { + try { + sourceProvider + .getSource(value ?? '') + .standardizeURL( + preStandardizeUrl( + value ?? '')); + } catch (e) { + return e is String + ? e + : e is ObtainiumError + ? e.toString() + : tr('error'); + } + return null; + } + ]) + ] + ], onValueChanges: (values, valid, isBuilding) { changeUserInput(values['appSourceURL']!, valid, isBuilding); @@ -296,8 +303,8 @@ class _AddAppPageState extends State { if (selectedUrls != null && selectedUrls.isNotEmpty) { changeUserInput( - selectedUrls[0], true, false); - addApp(resetUserInputAfter: true); + selectedUrls[0], true, false, + isSearch: true); } }).catchError((e) { showError(e, context); @@ -327,6 +334,7 @@ class _AddAppPageState extends State { height: 16, ), GeneratedForm( + key: Key(pickedSource.runtimeType.toString()), items: pickedSource! .combinedAppSpecificSettingFormItems, onValueChanges: (values, valid, isBuilding) { diff --git a/lib/pages/import_export.dart b/lib/pages/import_export.dart index f6d1dcf..df29739 100644 --- a/lib/pages/import_export.dart +++ b/lib/pages/import_export.dart @@ -564,18 +564,22 @@ class _UrlSelectionModalState extends State { widget.onlyOneSelectionAllowed ? tr('selectURL') : tr('selectURLs')), content: Column(children: [ ...urlWithDescriptionSelections.keys.map((urlWithD) { + select(bool? value) { + setState(() { + value ??= false; + if (value! && widget.onlyOneSelectionAllowed) { + selectOnlyOne(urlWithD.key); + } else { + urlWithDescriptionSelections[urlWithD] = value!; + } + }); + } + return Row(children: [ Checkbox( value: urlWithDescriptionSelections[urlWithD], onChanged: (value) { - setState(() { - value ??= false; - if (value! && widget.onlyOneSelectionAllowed) { - selectOnlyOne(urlWithD.key); - } else { - urlWithDescriptionSelections[urlWithD] = value!; - } - }); + select(value); }), const SizedBox( width: 8, @@ -599,12 +603,17 @@ class _UrlSelectionModalState extends State { const TextStyle(decoration: TextDecoration.underline), textAlign: TextAlign.start, )), - Text( - urlWithD.value.length > 128 - ? '${urlWithD.value.substring(0, 128)}...' - : urlWithD.value, - style: const TextStyle( - fontStyle: FontStyle.italic, fontSize: 12), + GestureDetector( + onTap: () { + select(!(urlWithDescriptionSelections[urlWithD] ?? false)); + }, + child: Text( + urlWithD.value.length > 128 + ? '${urlWithD.value.substring(0, 128)}...' + : urlWithD.value, + style: const TextStyle( + fontStyle: FontStyle.italic, fontSize: 12), + ), ), const SizedBox( height: 8, diff --git a/lib/providers/apps_provider.dart b/lib/providers/apps_provider.dart index a8380c6..5036ff2 100644 --- a/lib/providers/apps_provider.dart +++ b/lib/providers/apps_provider.dart @@ -247,7 +247,11 @@ class AppsProvider with ChangeNotifier { !(await canDowngradeApps())) { throw DowngradeError(); } - await InstallPlugin.installApk(file.file.path, 'dev.imranr.obtainium'); + await InstallPlugin.installApk(file.file.path, obtainiumId); + if (file.appId == obtainiumId) { + // Obtainium prompt should be lowest + await Future.delayed(const Duration(milliseconds: 500)); + } apps[file.appId]!.app.installedVersion = apps[file.appId]!.app.latestVersion; // Don't correct install status as installation may not be done yet diff --git a/pubspec.yaml b/pubspec.yaml index 6b4cccb..105ad20 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,7 +17,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 0.10.5+111 # When changing this, update the tag in main() accordingly +version: 0.10.6+112 # When changing this, update the tag in main() accordingly environment: sdk: '>=2.18.2 <3.0.0'