From 9a4b0301be3124b54d61ccea84b056eda0f0edbf Mon Sep 17 00:00:00 2001 From: Imran Remtulla Date: Sun, 25 Sep 2022 00:21:41 -0400 Subject: [PATCH] Updated version, standardized quotes, deleted test_page --- lib/app_sources/github.dart | 14 +++---- lib/components/generated_form.dart | 10 ++--- lib/components/generated_form_modal.dart | 4 +- lib/main.dart | 4 +- lib/pages/add_app.dart | 10 ++--- lib/pages/apps.dart | 36 ++++++++-------- lib/pages/test_page.dart | 53 ------------------------ lib/providers/apps_provider.dart | 3 -- lib/providers/source_provider.dart | 2 +- pubspec.yaml | 2 +- 10 files changed, 41 insertions(+), 97 deletions(-) delete mode 100644 lib/pages/test_page.dart diff --git a/lib/app_sources/github.dart b/lib/app_sources/github.dart index c957a37..6cbfc3f 100644 --- a/lib/app_sources/github.dart +++ b/lib/app_sources/github.dart @@ -21,9 +21,9 @@ class GitHub implements AppSource { Future getLatestAPKDetails( String standardUrl, List additionalData) async { var includePrereleases = - additionalData.isNotEmpty && additionalData[0] == "true"; + additionalData.isNotEmpty && additionalData[0] == 'true'; var fallbackToOlderReleases = - additionalData.length >= 2 && additionalData[1] == "true"; + additionalData.length >= 2 && additionalData[1] == 'true'; var regexFilter = additionalData.length >= 3 && additionalData[2].isNotEmpty ? additionalData[2] : null; @@ -92,14 +92,14 @@ class GitHub implements AppSource { @override List> additionalDataFormItems = [ - [GeneratedFormItem(label: "Include prereleases", type: FormItemType.bool)], + [GeneratedFormItem(label: 'Include prereleases', type: FormItemType.bool)], [ GeneratedFormItem( - label: "Fallback to older releases", type: FormItemType.bool) + label: 'Fallback to older releases', type: FormItemType.bool) ], [ GeneratedFormItem( - label: "Filter Release Titles by Regular Expression", + label: 'Filter Release Titles by Regular Expression', type: FormItemType.string, required: false, additionalValidators: [ @@ -110,7 +110,7 @@ class GitHub implements AppSource { try { RegExp(value); } catch (e) { - return "Invalid regular expression"; + return 'Invalid regular expression'; } return null; } @@ -119,5 +119,5 @@ class GitHub implements AppSource { ]; @override - List additionalDataDefaults = ["true", "true", ""]; + List additionalDataDefaults = ['true', 'true', '']; } diff --git a/lib/components/generated_form.dart b/lib/components/generated_form.dart index 24577f7..d646b0f 100644 --- a/lib/components/generated_form.dart +++ b/lib/components/generated_form.dart @@ -12,7 +12,7 @@ class GeneratedFormItem { late List additionalValidators; GeneratedFormItem( - {this.label = "Input", + {this.label = 'Input', this.type = FormItemType.string, this.required = true, this.max = 1, @@ -69,7 +69,7 @@ class _GeneratedFormState extends State { .map((row) => row.map((e) { return j < widget.defaultValues.length ? widget.defaultValues[j++] - : ""; + : ''; }).toList()) .toList(); @@ -89,7 +89,7 @@ class _GeneratedFormState extends State { }); }, decoration: InputDecoration( - helperText: e.value.label + (e.value.required ? " *" : "")), + helperText: e.value.label + (e.value.required ? ' *' : '')), minLines: e.value.max <= 1 ? null : e.value.max, maxLines: e.value.max <= 1 ? 1 : e.value.max, validator: (value) { @@ -122,10 +122,10 @@ class _GeneratedFormState extends State { children: [ Text(widget.items[r][e].label), Switch( - value: values[r][e] == "true", + value: values[r][e] == 'true', onChanged: (value) { setState(() { - values[r][e] = value ? "true" : ""; + values[r][e] = value ? 'true' : ''; someValueChanged(); }); }) diff --git a/lib/components/generated_form_modal.dart b/lib/components/generated_form_modal.dart index 27df229..ab6e558 100644 --- a/lib/components/generated_form_modal.dart +++ b/lib/components/generated_form_modal.dart @@ -9,7 +9,7 @@ class GeneratedFormModal extends StatefulWidget { required this.items, required this.defaultValues, this.initValid = false, - this.message = ""}); + this.message = ''}); final String title; final String message; @@ -40,7 +40,7 @@ class _GeneratedFormModalState extends State { Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [ if (widget.message.isNotEmpty) Text(widget.message), if (widget.message.isNotEmpty) - SizedBox( + const SizedBox( height: 16, ), GeneratedForm( diff --git a/lib/main.dart b/lib/main.dart index 95e3da4..9d9db25 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -13,7 +13,7 @@ import 'package:dynamic_color/dynamic_color.dart'; import 'package:device_info_plus/device_info_plus.dart'; const String currentReleaseTag = - 'v0.3.2-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES + 'v0.4.0-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES @pragma('vm:entry-point') void bgTaskCallback() { @@ -118,7 +118,7 @@ class MyApp extends StatelessWidget { currentReleaseTag, [], 0, - ["true"])); + ['true'])); } } diff --git a/lib/pages/add_app.dart b/lib/pages/add_app.dart index e8a909c..a86b0cc 100644 --- a/lib/pages/add_app.dart +++ b/lib/pages/add_app.dart @@ -19,7 +19,7 @@ class AddAppPage extends StatefulWidget { class _AddAppPageState extends State { bool gettingAppInfo = false; - String userInput = ""; + String userInput = ''; AppSource? pickedSource; List additionalData = []; bool validAdditionalData = true; @@ -44,19 +44,19 @@ class _AddAppPageState extends State { items: [ [ GeneratedFormItem( - label: "App Source Url", + label: 'App Source Url', additionalValidators: [ (value) { try { sourceProvider - .getSource(value ?? "") + .getSource(value ?? '') .standardizeURL( makeUrlHttps( - value ?? "")); + value ?? '')); } catch (e) { return e is String ? e - : "Error"; + : 'Error'; } return null; } diff --git a/lib/pages/apps.dart b/lib/pages/apps.dart index 1744241..aad265f 100644 --- a/lib/pages/apps.dart +++ b/lib/pages/apps.dart @@ -247,13 +247,13 @@ class AppsPageState extends State { formInputs.add([ GeneratedFormItem( label: - "Update ${existingUpdateIdsSelected.length} Apps?", + 'Update ${existingUpdateIdsSelected.length} Apps?', type: FormItemType.bool) ]); formInputs.add([ GeneratedFormItem( label: - "Install ${newInstallIdsSelected.length} new Apps?", + 'Install ${newInstallIdsSelected.length} new Apps?', type: FormItemType.bool) ]); } @@ -261,13 +261,13 @@ class AppsPageState extends State { context: context, builder: (BuildContext ctx) { return GeneratedFormModal( - title: "Install Selected Apps?", + title: 'Install Selected Apps?', message: - "${existingUpdateIdsSelected.length} update${existingUpdateIdsSelected.length == 1 ? '' : 's'} and ${newInstallIdsSelected.length} new install${newInstallIdsSelected.length == 1 ? '' : 's'}.", + '${existingUpdateIdsSelected.length} update${existingUpdateIdsSelected.length == 1 ? '' : 's'} and ${newInstallIdsSelected.length} new install${newInstallIdsSelected.length == 1 ? '' : 's'}.', items: formInputs, defaultValues: const [ - "true", - "true" + 'true', + 'true' ], initValid: true, ); @@ -275,10 +275,10 @@ class AppsPageState extends State { if (values != null) { bool shouldInstallUpdates = values.length < 2 || - values[0] == "true"; + values[0] == 'true'; bool shouldInstallNew = values.length < 2 || - values[1] == "true"; + values[1] == 'true'; settingsProvider .getInstallPermission() .then((_) { @@ -323,18 +323,18 @@ class AppsPageState extends State { items: [ [ GeneratedFormItem( - label: "App Name", required: false), + label: 'App Name', required: false), GeneratedFormItem( - label: "Author", required: false) + label: 'Author', required: false) ], [ GeneratedFormItem( - label: "Up to Date Apps", + label: 'Up to Date Apps', type: FormItemType.bool) ], [ GeneratedFormItem( - label: "Non-Installed Apps", + label: 'Non-Installed Apps', type: FormItemType.bool) ] ], @@ -371,8 +371,8 @@ class AppsFilter { late bool includeNonInstalled; AppsFilter( - {this.nameFilter = "", - this.authorFilter = "", + {this.nameFilter = '', + this.authorFilter = '', this.includeUptodate = true, this.includeNonInstalled = true}); @@ -380,16 +380,16 @@ class AppsFilter { return [ nameFilter, authorFilter, - includeUptodate ? "true" : "", - includeNonInstalled ? "true" : "" + includeUptodate ? 'true' : '', + includeNonInstalled ? 'true' : '' ]; } AppsFilter.fromValuesArray(List values) { nameFilter = values[0]; authorFilter = values[1]; - includeUptodate = values[2] == "true"; - includeNonInstalled = values[3] == "true"; + includeUptodate = values[2] == 'true'; + includeNonInstalled = values[3] == 'true'; } bool isIdenticalTo(AppsFilter other) => diff --git a/lib/pages/test_page.dart b/lib/pages/test_page.dart deleted file mode 100644 index c15679e..0000000 --- a/lib/pages/test_page.dart +++ /dev/null @@ -1,53 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:obtainium/components/generated_form.dart'; - -class TestPage extends StatefulWidget { - const TestPage({super.key}); - - @override - State createState() => _TestPageState(); -} - -class _TestPageState extends State { - List? sourceSpecificData; - bool valid = false; - - List> sourceSpecificInputs = [ - [GeneratedFormItem(label: 'Test Item 1')], - [ - GeneratedFormItem(label: 'Test Item 2', required: false), - GeneratedFormItem(label: 'Test Item 3') - ], - [GeneratedFormItem(label: 'Test Item 4', type: FormItemType.bool)] - ]; - - List defaultInputValues = ["ABC"]; - - void onSourceSpecificDataChanges( - List valuesFromForm, bool formValid) { - setState(() { - sourceSpecificData = valuesFromForm; - valid = formValid; - }); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar(title: const Text('Test Page')), - backgroundColor: Theme.of(context).colorScheme.surface, - body: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), - child: Column(children: [ - GeneratedForm( - items: sourceSpecificInputs, - onValueChanges: onSourceSpecificDataChanges, - defaultValues: defaultInputValues, - ), - ...(sourceSpecificData != null - ? (sourceSpecificData as List) - .map((e) => Text(e ?? "")) - : [Container()]) - ]))); - } -} diff --git a/lib/providers/apps_provider.dart b/lib/providers/apps_provider.dart index 7c6dbfc..c92e3a7 100644 --- a/lib/providers/apps_provider.dart +++ b/lib/providers/apps_provider.dart @@ -113,9 +113,6 @@ class AppsProvider with ChangeNotifier { cancelExisting: true); await FGBGEvents.stream.first == FGBGType.foreground; await notificationsProvider.cancel(completeInstallationNotification.id); - // We need to wait for the App to come to the foreground to install it - // Can't try to call install plugin in a background isolate (may not have worked anyways) because of: - // https://github.com/flutter/flutter/issues/13937 } } diff --git a/lib/providers/source_provider.dart b/lib/providers/source_provider.dart index 1e3915f..095b139 100644 --- a/lib/providers/source_provider.dart +++ b/lib/providers/source_provider.dart @@ -85,7 +85,7 @@ class App { escapeRegEx(String s) { return s.replaceAllMapped(RegExp(r'[.*+?^${}()|[\]\\]'), (x) { - return "\\${x[0]}"; + return '\\${x[0]}'; }); } diff --git a/pubspec.yaml b/pubspec.yaml index 057dad2..c803cd6 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.3.2+18 # When changing this, update the tag in main() accordingly +version: 0.4.0+19 # When changing this, update the tag in main() accordingly environment: sdk: '>=2.19.0-79.0.dev <3.0.0'