From 2f471b3de457e0d6304675935c8025eef39d087c Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sat, 5 Aug 2023 15:19:03 +0200 Subject: [PATCH 01/10] fix: use user friendly strings (#1088) --- assets/i18n/en_US.json | 8 ++++---- lib/ui/views/home/home_viewmodel.dart | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/assets/i18n/en_US.json b/assets/i18n/en_US.json index 532cf3d4..4a0383ad 100644 --- a/assets/i18n/en_US.json +++ b/assets/i18n/en_US.json @@ -33,10 +33,10 @@ "updatePatchesDialogTitle": "Update ReVanced Patches", "updateChangelogTitle": "Changelog", - "patchesConsentDialogText": "ReVanced Patches need to be downloaded to patch apps.", - "patchesConsentDialogText2": "This will reveal your IP address to {url}.", - "patchesConsentDialogText3": "Auto update", - "patchesConsentDialogText3Sub": "You can still change this in the settings later", + "patchesConsentDialogText": "ReVanced Patches needs to be downloaded.", + "patchesConsentDialogText2": "This will connect you to {url}.", + "patchesConsentDialogText3": "Auto update?", + "patchesConsentDialogText3Sub": "You can change this in settings at a later time.", "notificationTitle": "Update downloaded", "notificationText": "Tap to install the update", diff --git a/lib/ui/views/home/home_viewmodel.dart b/lib/ui/views/home/home_viewmodel.dart index 3abe3c3b..70a06d57 100644 --- a/lib/ui/views/home/home_viewmodel.dart +++ b/lib/ui/views/home/home_viewmodel.dart @@ -174,7 +174,7 @@ class HomeViewModel extends BaseViewModel { context: context, barrierDismissible: false, builder: (context) => AlertDialog( - title: const Text('ReVanced Patches'), + title: const Text('Download ReVanced Patches?'), content: ValueListenableBuilder( valueListenable: autoUpdate, builder: (context, value, child) { From 5346f6e1bf2d49fe18595931c5958e1ae50ebd6f Mon Sep 17 00:00:00 2001 From: aAbed <39409020+TheAabedKhan@users.noreply.github.com> Date: Sat, 5 Aug 2023 19:04:36 +0545 Subject: [PATCH 02/10] fix(patch-item): hide universal patches if not enabled (#1087) --- lib/services/patcher_api.dart | 22 +++++++++++-------- .../patches_selector_viewmodel.dart | 9 +++++++- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/lib/services/patcher_api.dart b/lib/services/patcher_api.dart index 568e6183..df99db8b 100644 --- a/lib/services/patcher_api.dart +++ b/lib/services/patcher_api.dart @@ -103,16 +103,20 @@ class PatcherAPI { } List getFilteredPatches(String packageName) { - if (!filteredPatches.keys.contains(packageName)) { - final List patches = _patches - .where( - (patch) => - patch.compatiblePackages.isEmpty || - !patch.name.contains('settings') && - patch.compatiblePackages - .any((pack) => pack.name == packageName), - ) + final List patches = _patches + .where( + (patch) => + patch.compatiblePackages.isEmpty || + !patch.name.contains('settings') && + patch.compatiblePackages + .any((pack) => pack.name == packageName), + ) + .toList(); + if (!_managerAPI.areUniversalPatchesEnabled()) { + filteredPatches[packageName] = patches + .where((patch) => patch.compatiblePackages.isNotEmpty) .toList(); + } else { filteredPatches[packageName] = patches; } return filteredPatches[packageName]; diff --git a/lib/ui/views/patches_selector/patches_selector_viewmodel.dart b/lib/ui/views/patches_selector/patches_selector_viewmodel.dart index ca776ccf..b480f51c 100644 --- a/lib/ui/views/patches_selector/patches_selector_viewmodel.dart +++ b/lib/ui/views/patches_selector/patches_selector_viewmodel.dart @@ -81,7 +81,7 @@ class PatchesSelectorViewModel extends BaseViewModel { } List getQueriedPatches(String query) { - return patches + final List patch = patches .where( (patch) => query.isEmpty || @@ -90,6 +90,13 @@ class PatchesSelectorViewModel extends BaseViewModel { patch.getSimpleName().toLowerCase().contains(query.toLowerCase()), ) .toList(); + if (_managerAPI.areUniversalPatchesEnabled()) { + return patch; + } else { + return patch + .where((patch) => patch.compatiblePackages.isNotEmpty) + .toList(); + } } String getAppVersion() { From 5abcc7191fea9a3b601234c7915bb58f110a5d15 Mon Sep 17 00:00:00 2001 From: aAbed <39409020+TheAabedKhan@users.noreply.github.com> Date: Sun, 6 Aug 2023 10:55:57 +0545 Subject: [PATCH 03/10] fix: experimental/universal patches being used even when turned off (#1090) Co-authored-by: Pun Butrach --- lib/ui/views/patcher/patcher_viewmodel.dart | 9 +++++++++ .../widgets/patchesSelectorView/patch_item.dart | 7 ------- .../settings_experimental_patches.dart | 15 ++++++++------- .../settings_experimental_universal_patches.dart | 11 +++++++++++ 4 files changed, 28 insertions(+), 14 deletions(-) diff --git a/lib/ui/views/patcher/patcher_viewmodel.dart b/lib/ui/views/patcher/patcher_viewmodel.dart index 68f35397..2827eedc 100644 --- a/lib/ui/views/patcher/patcher_viewmodel.dart +++ b/lib/ui/views/patcher/patcher_viewmodel.dart @@ -11,6 +11,7 @@ import 'package:revanced_manager/services/manager_api.dart'; import 'package:revanced_manager/services/patcher_api.dart'; import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart'; import 'package:revanced_manager/utils/about_info.dart'; +import 'package:revanced_manager/utils/check_for_supported_patch.dart'; import 'package:stacked/stacked.dart'; import 'package:stacked_services/stacked_services.dart'; @@ -156,6 +157,14 @@ class PatcherViewModel extends BaseViewModel { this .selectedPatches .addAll(patches.where((patch) => selectedPatches.contains(patch.name))); + if (!_managerAPI.areExperimentalPatchesEnabled()) { + this.selectedPatches.removeWhere((patch) => !isPatchSupported(patch)); + } + if (!_managerAPI.areUniversalPatchesEnabled()) { + this + .selectedPatches + .removeWhere((patch) => patch.compatiblePackages.isEmpty); + } notifyListeners(); } } diff --git a/lib/ui/widgets/patchesSelectorView/patch_item.dart b/lib/ui/widgets/patchesSelectorView/patch_item.dart index fd616062..af62f8c6 100644 --- a/lib/ui/widgets/patchesSelectorView/patch_item.dart +++ b/lib/ui/widgets/patchesSelectorView/patch_item.dart @@ -3,7 +3,6 @@ import 'package:flutter_i18n/flutter_i18n.dart'; import 'package:revanced_manager/app/app.locator.dart'; import 'package:revanced_manager/services/manager_api.dart'; import 'package:revanced_manager/services/toast.dart'; -import 'package:revanced_manager/ui/widgets/settingsView/settings_experimental_patches.dart'; import 'package:revanced_manager/ui/widgets/shared/custom_card.dart'; import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart'; @@ -126,12 +125,6 @@ class _PatchItemState extends State { } else { widget.isSelected = newValue!; } - if (widget.isUnsupported && - widget.isSelected && - !selectedUnsupportedPatches - .contains(widget.name)) { - selectedUnsupportedPatches.add(widget.name); - } }); widget.onChanged(widget.isSelected); }, diff --git a/lib/ui/widgets/settingsView/settings_experimental_patches.dart b/lib/ui/widgets/settingsView/settings_experimental_patches.dart index 1b2e2542..be704c73 100644 --- a/lib/ui/widgets/settingsView/settings_experimental_patches.dart +++ b/lib/ui/widgets/settingsView/settings_experimental_patches.dart @@ -1,7 +1,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_i18n/widgets/I18nText.dart'; +import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart'; import 'package:revanced_manager/ui/views/patches_selector/patches_selector_viewmodel.dart'; import 'package:revanced_manager/ui/views/settings/settings_viewmodel.dart'; +import 'package:revanced_manager/utils/check_for_supported_patch.dart'; class SExperimentalPatches extends StatefulWidget { const SExperimentalPatches({super.key}); @@ -11,7 +13,8 @@ class SExperimentalPatches extends StatefulWidget { } final _settingsViewModel = SettingsViewModel(); -final List selectedUnsupportedPatches = []; +final _patchesSelectorViewModel = PatchesSelectorViewModel(); +final _patcherViewModel = PatcherViewModel(); class _SExperimentalPatchesState extends State { @override @@ -35,12 +38,10 @@ class _SExperimentalPatchesState extends State { _settingsViewModel.useExperimentalPatches(value); }); if (!value) { - for (final patch in selectedUnsupportedPatches) { - PatchesSelectorViewModel() - .selectedPatches - .removeWhere((element) => patch == element.name); - } - selectedUnsupportedPatches.clear(); + _patcherViewModel.selectedPatches + .removeWhere((patch) => !isPatchSupported(patch)); + _patchesSelectorViewModel.selectedPatches + .removeWhere((patch) => !isPatchSupported(patch)); } }, ); diff --git a/lib/ui/widgets/settingsView/settings_experimental_universal_patches.dart b/lib/ui/widgets/settingsView/settings_experimental_universal_patches.dart index 38e534fb..fa9dad27 100644 --- a/lib/ui/widgets/settingsView/settings_experimental_universal_patches.dart +++ b/lib/ui/widgets/settingsView/settings_experimental_universal_patches.dart @@ -2,6 +2,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_i18n/widgets/I18nText.dart'; import 'package:revanced_manager/ui/views/settings/settings_viewmodel.dart'; +import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart'; +import 'package:revanced_manager/ui/views/patches_selector/patches_selector_viewmodel.dart'; + class SExperimentalUniversalPatches extends StatefulWidget { const SExperimentalUniversalPatches({super.key}); @@ -11,6 +14,8 @@ class SExperimentalUniversalPatches extends StatefulWidget { } final _settingsViewModel = SettingsViewModel(); +final _patchesSelectorViewModel = PatchesSelectorViewModel(); +final _patcherViewModel = PatcherViewModel(); class _SExperimentalUniversalPatchesState extends State { @@ -34,6 +39,12 @@ class _SExperimentalUniversalPatchesState setState(() { _settingsViewModel.showUniversalPatches(value); }); + if (!value) { + _patcherViewModel.selectedPatches + .removeWhere((patch) => patch.compatiblePackages.isEmpty); + _patchesSelectorViewModel.selectedPatches + .removeWhere((patch) => patch.compatiblePackages.isEmpty); + } }, ); } From 0b529c26298a6a68851211870f26f8bbff41c39d Mon Sep 17 00:00:00 2001 From: aAbed <39409020+TheAabedKhan@users.noreply.github.com> Date: Sun, 6 Aug 2023 10:57:01 +0545 Subject: [PATCH 04/10] fix(patches-selector): separate all universal patches to the bottom (#1092) --- assets/i18n/en_US.json | 1 + .../patches_selector_view.dart | 51 ++++++++++++++++--- 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/assets/i18n/en_US.json b/assets/i18n/en_US.json index 4a0383ad..a9ac05c3 100644 --- a/assets/i18n/en_US.json +++ b/assets/i18n/en_US.json @@ -112,6 +112,7 @@ "patchesSelectorView": { "viewTitle": "Select patches", "searchBarHint": "Search patches", + "universalPatches": "Universal patches", "doneButton": "Done", diff --git a/lib/ui/views/patches_selector/patches_selector_view.dart b/lib/ui/views/patches_selector/patches_selector_view.dart index 6359403a..5ee6ad83 100644 --- a/lib/ui/views/patches_selector/patches_selector_view.dart +++ b/lib/ui/views/patches_selector/patches_selector_view.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.dart' hide SearchBar; import 'package:flutter_i18n/flutter_i18n.dart'; +import 'package:revanced_manager/app/app.locator.dart'; +import 'package:revanced_manager/services/manager_api.dart'; import 'package:revanced_manager/ui/views/patches_selector/patches_selector_viewmodel.dart'; import 'package:revanced_manager/ui/widgets/patchesSelectorView/patch_item.dart'; import 'package:revanced_manager/ui/widgets/shared/custom_popup_menu.dart'; @@ -16,6 +18,7 @@ class PatchesSelectorView extends StatefulWidget { class _PatchesSelectorViewState extends State { String _query = ''; + final _managerAPI = locator(); @override Widget build(BuildContext context) { @@ -165,10 +168,10 @@ class _PatchesSelectorViewState extends State { ), ], ), - ...model - .getQueriedPatches(_query) - .map( - (patch) => PatchItem( + ...model.getQueriedPatches(_query).map( + (patch) { + if (patch.compatiblePackages.isNotEmpty) { + return PatchItem( name: patch.name, simpleName: patch.getSimpleName(), description: patch.description, @@ -179,9 +182,45 @@ class _PatchesSelectorViewState extends State { isSelected: model.isSelected(patch), onChanged: (value) => model.selectPatch(patch, value), + ); + } else { + return Container(); + } + }, + ), + if (_managerAPI.areUniversalPatchesEnabled()) + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.symmetric( + vertical: 10.0, + ), + child: I18nText( + 'patchesSelectorView.universalPatches', + ), ), - ) - .toList(), + ...model.getQueriedPatches(_query).map((patch) { + if (patch.compatiblePackages.isEmpty) { + return PatchItem( + name: patch.name, + simpleName: patch.getSimpleName(), + description: patch.description, + packageVersion: model.getAppVersion(), + supportedPackageVersions: + model.getSupportedVersions(patch), + isUnsupported: !isPatchSupported(patch), + isSelected: model.isSelected(patch), + onChanged: (value) => + model.selectPatch(patch, value), + ); + } else { + return Container(); + } + }), + ], + ), + const SizedBox(height: 70.0), ], ), ), From 264d8d90c409e2dd91a049255efcff27d5460e74 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Sun, 6 Aug 2023 14:39:46 +0700 Subject: [PATCH 05/10] refactor: apply changes according to analysis trailing commas, and sort import alphabetically --- lib/main.dart | 2 +- .../views/contributors/contributors_view.dart | 2 +- lib/ui/views/home/home_viewmodel.dart | 18 ++++++++++++------ .../views/installer/installer_viewmodel.dart | 2 +- lib/ui/views/patcher/patcher_viewmodel.dart | 4 ++-- .../patches_selector_view.dart | 2 +- .../settings_manage_api_url.dart | 6 +++--- .../settings_manage_keystore_password.dart | 4 ++-- .../settings_manage_sources.dart | 8 ++++---- .../appInfoView/app_info_viewmodel.dart | 6 +++--- .../appSelectorView/installed_app_item.dart | 2 +- .../widgets/homeView/installed_apps_card.dart | 2 +- .../homeView/update_confirmation_dialog.dart | 2 +- .../patchesSelectorView/patch_item.dart | 4 ++-- lib/ui/widgets/settingsView/custom_switch.dart | 2 +- .../settings_advanced_section.dart | 4 ++-- ...ettings_experimental_universal_patches.dart | 3 +-- .../settingsView/settings_export_section.dart | 4 ++-- lib/utils/about_info.dart | 2 +- 19 files changed, 42 insertions(+), 37 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index f386c75d..29b715b9 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -58,7 +58,7 @@ class MyApp extends StatelessWidget { }, ), GlobalMaterialLocalizations.delegate, - GlobalWidgetsLocalizations.delegate + GlobalWidgetsLocalizations.delegate, ], ); } diff --git a/lib/ui/views/contributors/contributors_view.dart b/lib/ui/views/contributors/contributors_view.dart index 1fdc6d40..26cdb12b 100644 --- a/lib/ui/views/contributors/contributors_view.dart +++ b/lib/ui/views/contributors/contributors_view.dart @@ -57,7 +57,7 @@ class ContributorsView extends StatelessWidget { title: 'contributorsView.managerContributors', contributors: model.managerContributors, ), - SizedBox(height: MediaQuery.of(context).viewPadding.bottom) + SizedBox(height: MediaQuery.of(context).viewPadding.bottom), ], ), ), diff --git a/lib/ui/views/home/home_viewmodel.dart b/lib/ui/views/home/home_viewmodel.dart index 70a06d57..161993ee 100644 --- a/lib/ui/views/home/home_viewmodel.dart +++ b/lib/ui/views/home/home_viewmodel.dart @@ -43,7 +43,7 @@ class HomeViewModel extends BaseViewModel { Future initialize(BuildContext context) async { _latestManagerVersion = await _managerAPI.getLatestManagerVersion(); - if(!_managerAPI.getPatchesConsent()){ + if (!_managerAPI.getPatchesConsent()) { await showPatchesConsent(context); } await _patcherAPI.initialize(); @@ -168,7 +168,7 @@ class HomeViewModel extends BaseViewModel { } } - Future showPatchesConsent(BuildContext context) async{ + Future showPatchesConsent(BuildContext context) async { final ValueNotifier autoUpdate = ValueNotifier(true); await showDialog( context: context, @@ -197,7 +197,9 @@ class HomeViewModel extends BaseViewModel { padding: const EdgeInsets.symmetric(vertical: 10), child: I18nText( 'homeView.patchesConsentDialogText2', - translationParams: {'url': _managerAPI.defaultApiUrl.split('/')[2]}, + translationParams: { + 'url': _managerAPI.defaultApiUrl.split('/')[2], + }, child: Text( '', style: TextStyle( @@ -211,8 +213,12 @@ class HomeViewModel extends BaseViewModel { CheckboxListTile( value: value, contentPadding: EdgeInsets.zero, - title: I18nText('homeView.patchesConsentDialogText3',), - subtitle: I18nText('homeView.patchesConsentDialogText3Sub',), + title: I18nText( + 'homeView.patchesConsentDialogText3', + ), + subtitle: I18nText( + 'homeView.patchesConsentDialogText3Sub', + ), onChanged: (selected) { autoUpdate.value = selected!; }, @@ -237,7 +243,7 @@ class HomeViewModel extends BaseViewModel { Navigator.of(context).pop(); }, label: I18nText('okButton'), - ) + ), ], ), ); diff --git a/lib/ui/views/installer/installer_viewmodel.dart b/lib/ui/views/installer/installer_viewmodel.dart index c33d85a2..2200c40d 100644 --- a/lib/ui/views/installer/installer_viewmodel.dart +++ b/lib/ui/views/installer/installer_viewmodel.dart @@ -203,7 +203,7 @@ class InstallerViewModel extends BaseViewModel { CustomMaterialButton( label: I18nText('okButton'), onPressed: () => Navigator.of(context).pop(), - ) + ), ], ), ); diff --git a/lib/ui/views/patcher/patcher_viewmodel.dart b/lib/ui/views/patcher/patcher_viewmodel.dart index 2827eedc..1087a078 100644 --- a/lib/ui/views/patcher/patcher_viewmodel.dart +++ b/lib/ui/views/patcher/patcher_viewmodel.dart @@ -78,7 +78,7 @@ class PatcherViewModel extends BaseViewModel { Navigator.of(context).pop(); showArmv7WarningDialog(context); }, - ) + ), ], ), ); @@ -111,7 +111,7 @@ class PatcherViewModel extends BaseViewModel { Navigator.of(context).pop(); navigateToInstaller(); }, - ) + ), ], ), ); diff --git a/lib/ui/views/patches_selector/patches_selector_view.dart b/lib/ui/views/patches_selector/patches_selector_view.dart index 5ee6ad83..acecf5e4 100644 --- a/lib/ui/views/patches_selector/patches_selector_view.dart +++ b/lib/ui/views/patches_selector/patches_selector_view.dart @@ -33,7 +33,7 @@ class _PatchesSelectorViewState extends State { label: Row( children: [ I18nText('patchesSelectorView.doneButton'), - Text(' (${model.selectedPatches.length})') + Text(' (${model.selectedPatches.length})'), ], ), icon: const Icon(Icons.check), diff --git a/lib/ui/views/settings/settingsFragment/settings_manage_api_url.dart b/lib/ui/views/settings/settingsFragment/settings_manage_api_url.dart index c1b1ec2d..964254be 100644 --- a/lib/ui/views/settings/settingsFragment/settings_manage_api_url.dart +++ b/lib/ui/views/settings/settingsFragment/settings_manage_api_url.dart @@ -30,7 +30,7 @@ class SManageApiUrl extends BaseViewModel { icon: const Icon(Icons.manage_history_outlined), onPressed: () => showApiUrlResetDialog(context), color: Theme.of(context).colorScheme.secondary, - ) + ), ], ), backgroundColor: Theme.of(context).colorScheme.secondaryContainer, @@ -69,7 +69,7 @@ class SManageApiUrl extends BaseViewModel { _managerAPI.setApiUrl(apiUrl); Navigator.of(context).pop(); }, - ) + ), ], ), ); @@ -97,7 +97,7 @@ class SManageApiUrl extends BaseViewModel { ..pop() ..pop(); }, - ) + ), ], ), ); diff --git a/lib/ui/views/settings/settingsFragment/settings_manage_keystore_password.dart b/lib/ui/views/settings/settingsFragment/settings_manage_keystore_password.dart index ca4bd7e8..4ac4689b 100644 --- a/lib/ui/views/settings/settingsFragment/settings_manage_keystore_password.dart +++ b/lib/ui/views/settings/settingsFragment/settings_manage_keystore_password.dart @@ -30,7 +30,7 @@ class SManageKeystorePassword extends BaseViewModel { onPressed: () => _keystorePasswordController.text = _managerAPI.defaultKeystorePassword, color: Theme.of(context).colorScheme.secondary, - ) + ), ], ), backgroundColor: Theme.of(context).colorScheme.secondaryContainer, @@ -62,7 +62,7 @@ class SManageKeystorePassword extends BaseViewModel { _managerAPI.setKeystorePassword(passwd); Navigator.of(context).pop(); }, - ) + ), ], ), ); diff --git a/lib/ui/views/settings/settingsFragment/settings_manage_sources.dart b/lib/ui/views/settings/settingsFragment/settings_manage_sources.dart index 66572e01..97dd35be 100644 --- a/lib/ui/views/settings/settingsFragment/settings_manage_sources.dart +++ b/lib/ui/views/settings/settingsFragment/settings_manage_sources.dart @@ -40,7 +40,7 @@ class SManageSources extends BaseViewModel { icon: const Icon(Icons.manage_history_outlined), onPressed: () => showResetConfirmationDialog(context), color: Theme.of(context).colorScheme.secondary, - ) + ), ], ), backgroundColor: Theme.of(context).colorScheme.secondaryContainer, @@ -102,7 +102,7 @@ class SManageSources extends BaseViewModel { onChanged: (value) => notifyListeners(), ), const SizedBox(height: 20), - I18nText('settingsView.sourcesUpdateNote') + I18nText('settingsView.sourcesUpdateNote'), ], ), ), @@ -132,7 +132,7 @@ class SManageSources extends BaseViewModel { _toast.showBottom('settingsView.restartAppForChanges'); Navigator.of(context).pop(); }, - ) + ), ], ), ); @@ -163,7 +163,7 @@ class SManageSources extends BaseViewModel { ..pop() ..pop(); }, - ) + ), ], ), ); diff --git a/lib/ui/widgets/appInfoView/app_info_viewmodel.dart b/lib/ui/widgets/appInfoView/app_info_viewmodel.dart index 0f6184a1..dd364c7d 100644 --- a/lib/ui/widgets/appInfoView/app_info_viewmodel.dart +++ b/lib/ui/widgets/appInfoView/app_info_viewmodel.dart @@ -74,7 +74,7 @@ class AppInfoViewModel extends BaseViewModel { CustomMaterialButton( label: I18nText('okButton'), onPressed: () => Navigator.of(context).pop(), - ) + ), ], ), ); @@ -103,7 +103,7 @@ class AppInfoViewModel extends BaseViewModel { Navigator.of(context).pop(); Navigator.of(context).pop(); }, - ) + ), ], ), ); @@ -140,7 +140,7 @@ class AppInfoViewModel extends BaseViewModel { CustomMaterialButton( label: I18nText('okButton'), onPressed: () => Navigator.of(context).pop(), - ) + ), ], ), ); diff --git a/lib/ui/widgets/appSelectorView/installed_app_item.dart b/lib/ui/widgets/appSelectorView/installed_app_item.dart index 7e96e655..ae129cbf 100644 --- a/lib/ui/widgets/appSelectorView/installed_app_item.dart +++ b/lib/ui/widgets/appSelectorView/installed_app_item.dart @@ -66,7 +66,7 @@ class _InstalledAppItemState extends State { context, 'installed', translationParams: { - 'version': 'v${widget.installedVersion}' + 'version': 'v${widget.installedVersion}', }, ), ), diff --git a/lib/ui/widgets/homeView/installed_apps_card.dart b/lib/ui/widgets/homeView/installed_apps_card.dart index e99dbaa0..7a989856 100644 --- a/lib/ui/widgets/homeView/installed_apps_card.dart +++ b/lib/ui/widgets/homeView/installed_apps_card.dart @@ -64,7 +64,7 @@ class InstalledAppsCard extends StatelessWidget { Theme.of(context).colorScheme.secondary, ), ), - ) + ), ], ), ), diff --git a/lib/ui/widgets/homeView/update_confirmation_dialog.dart b/lib/ui/widgets/homeView/update_confirmation_dialog.dart index 4d3b877e..7839536a 100644 --- a/lib/ui/widgets/homeView/update_confirmation_dialog.dart +++ b/lib/ui/widgets/homeView/update_confirmation_dialog.dart @@ -95,7 +95,7 @@ class UpdateConfirmationDialog extends StatelessWidget { ? model.updatePatches(context) : model.updateManager(context); }, - ) + ), ], ), ), diff --git a/lib/ui/widgets/patchesSelectorView/patch_item.dart b/lib/ui/widgets/patchesSelectorView/patch_item.dart index af62f8c6..f814a28b 100644 --- a/lib/ui/widgets/patchesSelectorView/patch_item.dart +++ b/lib/ui/widgets/patchesSelectorView/patch_item.dart @@ -129,7 +129,7 @@ class _PatchItemState extends State { widget.onChanged(widget.isSelected); }, ), - ) + ), ], ), if (widget.isUnsupported && @@ -190,7 +190,7 @@ class _PatchItemState extends State { CustomMaterialButton( label: I18nText('okButton'), onPressed: () => Navigator.of(context).pop(), - ) + ), ], ), ); diff --git a/lib/ui/widgets/settingsView/custom_switch.dart b/lib/ui/widgets/settingsView/custom_switch.dart index 6561ea0e..8328c90b 100644 --- a/lib/ui/widgets/settingsView/custom_switch.dart +++ b/lib/ui/widgets/settingsView/custom_switch.dart @@ -50,7 +50,7 @@ class CustomSwitch extends StatelessWidget { color: Colors.black12.withOpacity(0.1), spreadRadius: 0.5, blurRadius: 1, - ) + ), ], ), ), diff --git a/lib/ui/widgets/settingsView/settings_advanced_section.dart b/lib/ui/widgets/settingsView/settings_advanced_section.dart index 2cf1c3d7..694aa1d5 100644 --- a/lib/ui/widgets/settingsView/settings_advanced_section.dart +++ b/lib/ui/widgets/settingsView/settings_advanced_section.dart @@ -93,9 +93,9 @@ class SAdvancedSection extends StatelessWidget { label: I18nText('yesButton'), onPressed: () => { Navigator.of(context).pop(), - _settingsViewModel.deleteKeystore() + _settingsViewModel.deleteKeystore(), }, - ) + ), ], ), ); diff --git a/lib/ui/widgets/settingsView/settings_experimental_universal_patches.dart b/lib/ui/widgets/settingsView/settings_experimental_universal_patches.dart index fa9dad27..b8a58412 100644 --- a/lib/ui/widgets/settingsView/settings_experimental_universal_patches.dart +++ b/lib/ui/widgets/settingsView/settings_experimental_universal_patches.dart @@ -1,9 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_i18n/widgets/I18nText.dart'; -import 'package:revanced_manager/ui/views/settings/settings_viewmodel.dart'; - import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart'; import 'package:revanced_manager/ui/views/patches_selector/patches_selector_viewmodel.dart'; +import 'package:revanced_manager/ui/views/settings/settings_viewmodel.dart'; class SExperimentalUniversalPatches extends StatefulWidget { const SExperimentalUniversalPatches({super.key}); diff --git a/lib/ui/widgets/settingsView/settings_export_section.dart b/lib/ui/widgets/settingsView/settings_export_section.dart index e4881a09..817f9825 100644 --- a/lib/ui/widgets/settingsView/settings_export_section.dart +++ b/lib/ui/widgets/settingsView/settings_export_section.dart @@ -119,9 +119,9 @@ class SExportSection extends StatelessWidget { label: I18nText('yesButton'), onPressed: () => { Navigator.of(context).pop(), - _settingsViewModel.resetSelectedPatches() + _settingsViewModel.resetSelectedPatches(), }, - ) + ), ], ), ); diff --git a/lib/utils/about_info.dart b/lib/utils/about_info.dart index 5220e861..0b7dcffc 100644 --- a/lib/utils/about_info.dart +++ b/lib/utils/about_info.dart @@ -11,7 +11,7 @@ class AboutInfo { 'flavor': kReleaseMode ? 'release' : 'debug', 'model': info.model, 'androidVersion': info.version.release, - 'supportedArch': info.supportedAbis + 'supportedArch': info.supportedAbis, }; } } From 218e53ae756372ddd1454d8dd16a1b7357280840 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Sun, 6 Aug 2023 14:41:15 +0700 Subject: [PATCH 06/10] refactor(analysis): migrate deprecated rule deprecated since Dart 2.0, yike --- analysis_options.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index da2ffc37..1c02c24c 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -71,12 +71,11 @@ linter: - flutter_style_todos - hash_and_equals - implementation_imports - - iterable_contains_unrelated_type + - collection_methods_unrelated_type - leading_newlines_in_multiline_strings - library_names - library_prefixes - library_private_types_in_public_api - - list_remove_unrelated_type - missing_whitespace_between_adjacent_strings - no_adjacent_strings_in_list - no_duplicate_case_values From 1be284f8d81060cf84a9a587e37a03fa006eb79c Mon Sep 17 00:00:00 2001 From: aAbed <39409020+TheAabedKhan@users.noreply.github.com> Date: Mon, 7 Aug 2023 15:59:16 +0545 Subject: [PATCH 07/10] feat: switch to the new ReVanced API (#1101) --- lib/services/manager_api.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/services/manager_api.dart b/lib/services/manager_api.dart index 0155cf44..9aedc368 100644 --- a/lib/services/manager_api.dart +++ b/lib/services/manager_api.dart @@ -28,7 +28,7 @@ class ManagerAPI { String keystoreFile = '/sdcard/Android/data/app.revanced.manager.flutter/files/revanced-manager.keystore'; String defaultKeystorePassword = 's3cur3p@ssw0rd'; - String defaultApiUrl = 'https://releases.revanced.app/'; + String defaultApiUrl = 'https://api.revanced.app/'; String defaultRepoUrl = 'https://api.github.com'; String defaultPatcherRepo = 'revanced/revanced-patcher'; String defaultPatchesRepo = 'revanced/revanced-patches'; From 131df28110b0878f17367ac79e2659084fb96239 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 7 Aug 2023 20:13:23 +0700 Subject: [PATCH 08/10] docs(managing): update to reflect current changes The chip was removed because it was not implemented for too long. --- docs/2_2_managing.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/2_2_managing.md b/docs/2_2_managing.md index 1a04e220..5e8e378b 100644 --- a/docs/2_2_managing.md +++ b/docs/2_2_managing.md @@ -5,9 +5,8 @@ After patching an app, you may want to manage it. This page will guide you throu ## 🪜 Steps to manage patched apps 1. Tap on the **Dashboard** tab in the bottom navigation bar -2. Select the **Installed** chip -3. Tap on the **Info** button for the app you want to manage -4. Choose one of the options from the menu +2. Tap on the **Info** button for the app you want to manage +3. Choose one of the options from the menu ## ⏭️ What's next From 1714c3fa865e33dff5f1eddb6f338be0aa9bbb6e Mon Sep 17 00:00:00 2001 From: aAbed <39409020+TheAabedKhan@users.noreply.github.com> Date: Mon, 7 Aug 2023 21:13:09 +0545 Subject: [PATCH 09/10] feat(patches-selector): show `New` tag for new patches (#1099) --- assets/i18n/en_US.json | 6 +- lib/services/manager_api.dart | 15 +++++ .../views/installer/installer_viewmodel.dart | 6 +- .../patches_selector_view.dart | 10 ++- .../patches_selector_viewmodel.dart | 26 ++++++-- .../patchesSelectorView/patch_item.dart | 62 ++++++++++++++++--- 6 files changed, 108 insertions(+), 17 deletions(-) diff --git a/assets/i18n/en_US.json b/assets/i18n/en_US.json index a9ac05c3..de6e660a 100644 --- a/assets/i18n/en_US.json +++ b/assets/i18n/en_US.json @@ -10,6 +10,7 @@ "yesButton": "Yes", "noButton": "No", "warning": "Warning", + "new": "New", "navigationView": { "dashboardTab": "Dashboard", "patcherTab": "Patcher", @@ -130,7 +131,10 @@ }, "patchItem": { "unsupportedDialogText": "Selecting this patch may result in patching errors.\n\nApp version: {packageVersion}\nSupported versions:\n{supportedVersions}", - "unsupportedPatchVersion": "Patch is not supported for this app version. Enable the experimental toggle in settings to proceed." + "unsupportedPatchVersion": "Patch is not supported for this app version. Enable the experimental toggle in settings to proceed.", + + "newPatchDialogText": "This is a new patch that has been added since the last time you have patched this app.", + "newPatch": "New patch" }, "installerView": { "widgetTitle": "Installer", diff --git a/lib/services/manager_api.dart b/lib/services/manager_api.dart index 9aedc368..de11e598 100644 --- a/lib/services/manager_api.dart +++ b/lib/services/manager_api.dart @@ -98,6 +98,21 @@ class ManagerAPI { await _prefs.setBool('patchesAutoUpdate', value); } + List getSavedPatches(String packageName) { + final List patchesJson = _prefs.getStringList('savedPatches-$packageName') ?? []; + final List patches = patchesJson.map((String patchJson) { + return Patch.fromJson(jsonDecode(patchJson)); + }).toList(); + return patches; + } + + Future savePatches(List patches, String packageName) async { + final List patchesJson = patches.map((Patch patch) { + return jsonEncode(patch.toJson()); + }).toList(); + await _prefs.setStringList('savedPatches-$packageName', patchesJson); + } + String getIntegrationsRepo() { return _prefs.getString('integrationsRepo') ?? defaultIntegrationsRepo; } diff --git a/lib/ui/views/installer/installer_viewmodel.dart b/lib/ui/views/installer/installer_viewmodel.dart index 2200c40d..162de9e1 100644 --- a/lib/ui/views/installer/installer_viewmodel.dart +++ b/lib/ui/views/installer/installer_viewmodel.dart @@ -85,7 +85,7 @@ class InstallerViewModel extends BaseViewModel { }); } - void update(double value, String header, String log) { + Future update(double value, String header, String log) async { if (value >= 0.0) { progress = value; } @@ -97,6 +97,10 @@ class InstallerViewModel extends BaseViewModel { } else if (value == 1.0) { isPatching = false; hasErrors = false; + await _managerAPI.savePatches( + _patcherAPI.getFilteredPatches(_app.packageName), + _app.packageName, + ); } else if (value == -100.0) { isPatching = false; hasErrors = true; diff --git a/lib/ui/views/patches_selector/patches_selector_view.dart b/lib/ui/views/patches_selector/patches_selector_view.dart index acecf5e4..f5f4a7bd 100644 --- a/lib/ui/views/patches_selector/patches_selector_view.dart +++ b/lib/ui/views/patches_selector/patches_selector_view.dart @@ -175,10 +175,14 @@ class _PatchesSelectorViewState extends State { name: patch.name, simpleName: patch.getSimpleName(), description: patch.description, - packageVersion: model.getAppVersion(), + packageVersion: model.getAppInfo().version, supportedPackageVersions: model.getSupportedVersions(patch), isUnsupported: !isPatchSupported(patch), + isNew: model.isPatchNew( + patch, + model.getAppInfo().packageName, + ), isSelected: model.isSelected(patch), onChanged: (value) => model.selectPatch(patch, value), @@ -206,10 +210,12 @@ class _PatchesSelectorViewState extends State { name: patch.name, simpleName: patch.getSimpleName(), description: patch.description, - packageVersion: model.getAppVersion(), + packageVersion: + model.getAppInfo().version, supportedPackageVersions: model.getSupportedVersions(patch), isUnsupported: !isPatchSupported(patch), + isNew: false, isSelected: model.isSelected(patch), onChanged: (value) => model.selectPatch(patch, value), diff --git a/lib/ui/views/patches_selector/patches_selector_viewmodel.dart b/lib/ui/views/patches_selector/patches_selector_viewmodel.dart index b480f51c..744b3e07 100644 --- a/lib/ui/views/patches_selector/patches_selector_viewmodel.dart +++ b/lib/ui/views/patches_selector/patches_selector_viewmodel.dart @@ -15,6 +15,7 @@ class PatchesSelectorViewModel extends BaseViewModel { final List patches = []; final List selectedPatches = locator().selectedPatches; + PatchedApplication? selectedApp = locator().selectedApp; String? patchesVersion = ''; bool isDefaultPatchesRepo() { return _managerAPI.getPatchesRepo() == 'revanced/revanced-patches'; @@ -24,10 +25,17 @@ class PatchesSelectorViewModel extends BaseViewModel { getPatchesVersion().whenComplete(() => notifyListeners()); patches.addAll( _patcherAPI.getFilteredPatches( - locator().selectedApp!.originalPackageName, + selectedApp!.originalPackageName, ), ); - patches.sort((a, b) => a.name.compareTo(b.name)); + patches.sort((a, b) { + if (isPatchNew(a, selectedApp!.packageName) == + isPatchNew(b, selectedApp!.packageName)) { + return a.name.compareTo(b.name); + } else { + return isPatchNew(b, selectedApp!.packageName) ? 1 : -1; + } + }); notifyListeners(); } @@ -99,8 +107,18 @@ class PatchesSelectorViewModel extends BaseViewModel { } } - String getAppVersion() { - return locator().selectedApp!.version; + PatchedApplication getAppInfo() { + return locator().selectedApp!; + } + + bool isPatchNew(Patch patch, String packageName) { + final List savedPatches = _managerAPI.getSavedPatches(packageName); + if (savedPatches.isEmpty) { + return false; + } else { + return !savedPatches + .any((p) => p.name == patch.name.toLowerCase().replaceAll(' ', '-')); + } } List getSupportedVersions(Patch patch) { diff --git a/lib/ui/widgets/patchesSelectorView/patch_item.dart b/lib/ui/widgets/patchesSelectorView/patch_item.dart index f814a28b..21bd4726 100644 --- a/lib/ui/widgets/patchesSelectorView/patch_item.dart +++ b/lib/ui/widgets/patchesSelectorView/patch_item.dart @@ -16,6 +16,7 @@ class PatchItem extends StatefulWidget { required this.packageVersion, required this.supportedPackageVersions, required this.isUnsupported, + required this.isNew, required this.isSelected, required this.onChanged, this.child, @@ -26,6 +27,7 @@ class PatchItem extends StatefulWidget { final String packageVersion; final List supportedPackageVersions; final bool isUnsupported; + final bool isNew; bool isSelected; final Function(bool) onChanged; final Widget? child; @@ -132,12 +134,12 @@ class _PatchItemState extends State { ), ], ), - if (widget.isUnsupported && - widget._managerAPI.areExperimentalPatchesEnabled()) - Row( - children: [ + Row( + children: [ + if (widget.isUnsupported && + widget._managerAPI.areExperimentalPatchesEnabled()) Padding( - padding: const EdgeInsets.only(top: 8), + padding: const EdgeInsets.only(top: 8, right: 8), child: TextButton.icon( label: I18nText('warning'), icon: const Icon(Icons.warning, size: 20.0), @@ -160,10 +162,33 @@ class _PatchItemState extends State { ), ), ), - ], - ) - else - Container(), + if (widget.isNew) + Padding( + padding: const EdgeInsets.only(top: 8), + child: TextButton.icon( + label: I18nText('new'), + icon: const Icon(Icons.star, size: 20.0), + onPressed: () => _showNewPatchDialog(), + style: ButtonStyle( + shape: MaterialStateProperty.all( + RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + side: BorderSide( + color: Theme.of(context).colorScheme.secondary, + ), + ), + ), + backgroundColor: MaterialStateProperty.all( + Colors.transparent, + ), + foregroundColor: MaterialStateProperty.all( + Theme.of(context).colorScheme.secondary, + ), + ), + ), + ) + ], + ), widget.child ?? const SizedBox(), ], ), @@ -195,4 +220,23 @@ class _PatchItemState extends State { ), ); } + + Future _showNewPatchDialog() { + return showDialog( + context: context, + builder: (context) => AlertDialog( + title: I18nText('patchItem.newPatch'), + backgroundColor: Theme.of(context).colorScheme.secondaryContainer, + content: I18nText( + 'patchItem.newPatchDialogText', + ), + actions: [ + CustomMaterialButton( + label: I18nText('okButton'), + onPressed: () => Navigator.of(context).pop(), + ), + ], + ), + ); + } } From 722a5859a54e052794a300f57ab3eacf1c242386 Mon Sep 17 00:00:00 2001 From: aAbed <39409020+TheAabedKhan@users.noreply.github.com> Date: Tue, 8 Aug 2023 06:15:48 +0545 Subject: [PATCH 10/10] fix: pair integrations and patches updates (#1102) --- lib/services/manager_api.dart | 51 ++++++++++++++++++++++----- lib/ui/views/home/home_viewmodel.dart | 5 ++- 2 files changed, 46 insertions(+), 10 deletions(-) diff --git a/lib/services/manager_api.dart b/lib/services/manager_api.dart index de11e598..a2eed1b4 100644 --- a/lib/services/manager_api.dart +++ b/lib/services/manager_api.dart @@ -36,10 +36,15 @@ class ManagerAPI { String defaultCliRepo = 'revanced/revanced-cli'; String defaultManagerRepo = 'revanced/revanced-manager'; String? patchesVersion = ''; + String? integrationsVersion = ''; bool isDefaultPatchesRepo() { return getPatchesRepo() == 'revanced/revanced-patches'; } + bool isDefaultIntegrationsRepo() { + return getIntegrationsRepo() == 'revanced/revanced-integrations'; + } + Future initialize() async { _prefs = await SharedPreferences.getInstance(); isRooted = await _rootAPI.isRooted(); @@ -267,14 +272,12 @@ class ManagerAPI { Future downloadIntegrations() async { try { final String repoName = getIntegrationsRepo(); - if (repoName == defaultIntegrationsRepo) { - return await _revancedAPI.getLatestReleaseFile( - '.apk', - defaultIntegrationsRepo, - ); - } else { - return await _githubAPI.getLatestReleaseFile('.apk', repoName); - } + final String currentVersion = await getCurrentIntegrationsVersion(); + return await _githubAPI.getPatchesReleaseFile( + '.apk', + repoName, + currentVersion, + ); } on Exception catch (e) { if (kDebugMode) { print(e); @@ -323,6 +326,22 @@ class ManagerAPI { ); } + Future getLatestIntegrationsVersion() async { + if (isDefaultIntegrationsRepo()) { + return await _revancedAPI.getLatestReleaseVersion( + '.apk', + defaultIntegrationsRepo, + ); + } else { + final release = await _githubAPI.getLatestRelease(getIntegrationsRepo()); + if (release != null) { + return release['tag_name']; + } else { + return null; + } + } + } + Future getLatestPatchesVersion() async { if (isDefaultPatchesRepo()) { return await _revancedAPI.getLatestReleaseVersion( @@ -330,7 +349,8 @@ class ManagerAPI { defaultPatchesRepo, ); } else { - final release = await _githubAPI.getLatestPatchesRelease(getPatchesRepo()); + final release = + await _githubAPI.getLatestPatchesRelease(getPatchesRepo()); if (release != null) { return release['tag_name']; } else { @@ -357,6 +377,19 @@ class ManagerAPI { await _prefs.setString('patchesVersion', version); } + Future getCurrentIntegrationsVersion() async { + integrationsVersion = _prefs.getString('integrationsVersion') ?? '0.0.0'; + if (integrationsVersion == '0.0.0' || isPatchesAutoUpdate()) { + integrationsVersion = await getLatestIntegrationsVersion() ?? '0.0.0'; + await setCurrentIntegrationsVersion(integrationsVersion!); + } + return integrationsVersion!; + } + + Future setCurrentIntegrationsVersion(String version) async { + await _prefs.setString('integrationsVersion', version); + } + Future> getAppsToRemove( List patchedApps, ) async { diff --git a/lib/ui/views/home/home_viewmodel.dart b/lib/ui/views/home/home_viewmodel.dart index 161993ee..e2ce5125 100644 --- a/lib/ui/views/home/home_viewmodel.dart +++ b/lib/ui/views/home/home_viewmodel.dart @@ -253,9 +253,12 @@ class HomeViewModel extends BaseViewModel { _toast.showBottom('homeView.downloadingMessage'); final String patchesVersion = await _managerAPI.getLatestPatchesVersion() ?? '0.0.0'; - if (patchesVersion != '0.0.0') { + final String integrationsVersion = + await _managerAPI.getLatestIntegrationsVersion() ?? '0.0.0'; + if (patchesVersion != '0.0.0' && integrationsVersion != '0.0.0') { _toast.showBottom('homeView.downloadedMessage'); await _managerAPI.setCurrentPatchesVersion(patchesVersion); + await _managerAPI.setCurrentIntegrationsVersion(integrationsVersion); forceRefresh(context); } else { _toast.showBottom('homeView.errorDownloadMessage');