From 7931eb97b9356e91f3aeae0475640c2203ff7792 Mon Sep 17 00:00:00 2001 From: Benjamin <73490201+BenjaminHalko@users.noreply.github.com> Date: Sat, 25 Nov 2023 17:06:18 -0800 Subject: [PATCH 01/47] feat: updated logs (#1526) --- .../views/installer/installer_viewmodel.dart | 55 +++++++++++++++---- 1 file changed, 44 insertions(+), 11 deletions(-) diff --git a/lib/ui/views/installer/installer_viewmodel.dart b/lib/ui/views/installer/installer_viewmodel.dart index 01226fac..53a03040 100644 --- a/lib/ui/views/installer/installer_viewmodel.dart +++ b/lib/ui/views/installer/installer_viewmodel.dart @@ -179,18 +179,48 @@ class InstallerViewModel extends BaseViewModel { } } + void _trimLogs(List logLines, String keyword, String? newString) { + final lineCount = logLines.where((line) => line.endsWith(keyword)).length; + final index = logLines.indexWhere((line) => line.endsWith(keyword)); + if (newString != null && lineCount > 0) { + logLines.insert(index, newString.replaceAll('{lineCount}', lineCount.toString())); + } + logLines.removeWhere((lines) => lines.endsWith(keyword)); + } + + dynamic _getPatchOptionValue(String patchName, Option option) { + final Option? savedOption = _managerAPI.getPatchOption(_app.packageName, patchName, option.key); + if (savedOption != null) { + return savedOption.value; + } else { + return option.value; + } + } + + String _formatPatches(List patches) { + if (patches.isEmpty) { + return 'None'; + } + return patches.map((p) => p.name + (p.options.isEmpty ? '' : ' [${p.options.map((o) => '${o.title}: ${_getPatchOptionValue(p.name, o)}').join(", ")}]')).toList().join(', '); + } + Future copyLogs() async { final info = await AboutInfo.getInfo(); - dynamic getValue(String patchName, Option option) { - final Option? savedOption = - _managerAPI.getPatchOption(_app.packageName, patchName, option.key); - if (savedOption != null) { - return savedOption.value; - } else { - return option.value; - } - } + // Trim out extra lines + final logsTrimmed = logs.split('\n'); + _trimLogs(logsTrimmed, 'succeeded', 'Applied {lineCount} patches'); + _trimLogs(logsTrimmed, '.dex', 'Compiled {lineCount} dex files'); + + // Get patches added / removed + final defaultPatches = _patcherAPI.getFilteredPatches(_app.packageName).where((p) => !p.excluded).toList(); + final patchesAdded = _patches.where((p) => !defaultPatches.contains(p)).toList(); + final patchesRemoved = defaultPatches.where((p) => !_patches.contains(p)).toList(); + + // Options changed + final patchesChanged = defaultPatches.where((p) => _patches.contains(p) && p.options.any((o) => _getPatchOptionValue(p.name, o) != o.value)).toList(); + + // Add Info final formattedLogs = [ '- Device Info', 'ReVanced Manager: ${info['version']}', @@ -203,7 +233,10 @@ class InstallerViewModel extends BaseViewModel { '\n- Patch Info', 'App: ${_app.packageName} v${_app.version}', 'Patches version: ${_managerAPI.patchesVersion}', - 'Patches: ${_patches.map((p) => p.name + (p.options.isEmpty ? '' : ' [${p.options.map((o) => '${o.title}: ${getValue(p.name, o)}').join(", ")}]')).toList().join(", ")}', + 'Patches added: ${_formatPatches(patchesAdded)}', + 'Patches removed: ${_formatPatches(patchesRemoved)}', + 'Options changed: ${_formatPatches(patchesChanged)}', + '\n- Settings', 'Allow changing patch selection: ${_managerAPI.isPatchesChangeEnabled()}', 'Version compatibility check: ${_managerAPI.isVersionCompatibilityCheckEnabled()}', @@ -212,7 +245,7 @@ class InstallerViewModel extends BaseViewModel { 'Integration source: ${_managerAPI.getIntegrationsRepo()}', '\n- Logs', - logs, + logsTrimmed.join('\n'), ]; Clipboard.setData(ClipboardData(text: formattedLogs.join('\n'))); From bace26063dd900aaff9a2eb43c5a1f6eaeac245c Mon Sep 17 00:00:00 2001 From: Ushie Date: Mon, 27 Nov 2023 11:05:56 +0300 Subject: [PATCH 02/47] build: Bump version to v1.17.0 --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 0f9ea933..b10e3400 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,7 @@ homepage: https://github.com/revanced/revanced-manager publish_to: 'none' -version: 1.16.0+101600000 +version: 1.17.0+101700000 environment: sdk: '>=3.0.0 <4.0.0' From c9412a97d025cf39feac7e4e01a8be7d27a76372 Mon Sep 17 00:00:00 2001 From: Ax333l Date: Fri, 1 Dec 2023 13:22:38 +0100 Subject: [PATCH 03/47] build(dependency): Bump patcher to 19.1.0 --- android/app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 0b83c0af..36f9fb29 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -99,7 +99,7 @@ dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" // ReVanced - implementation "app.revanced:revanced-patcher:19.0.0" + implementation "app.revanced:revanced-patcher:19.1.0" // Signing & aligning implementation("org.bouncycastle:bcpkix-jdk15on:1.70") From de51fbd7bee532be020bb7bfe5c672742dd93ced Mon Sep 17 00:00:00 2001 From: Dhruvan Bhalara <53393418+dhruvanbhalara@users.noreply.github.com> Date: Fri, 1 Dec 2023 17:54:00 +0530 Subject: [PATCH 04/47] fix: Incorrect duplicate filename handling when exporting files (#1541) --- lib/services/patcher_api.dart | 5 +++-- lib/ui/views/settings/settings_viewmodel.dart | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/services/patcher_api.dart b/lib/services/patcher_api.dart index 4266a880..65f5ecc0 100644 --- a/lib/services/patcher_api.dart +++ b/lib/services/patcher_api.dart @@ -237,9 +237,10 @@ void exportPatchedFile(String appName, String version) { if (outFile != null) { final String newName = _getFileName(appName, version); FlutterFileDialog.saveFile( - params: SaveFileDialogParams( + params: SaveFileDialogParams( sourceFilePath: outFile!.path, fileName: newName, + mimeTypesFilter: ['application/vnd.android.package-archive'], ), ); } @@ -287,7 +288,7 @@ Future exportPatcherLog(String logs) async { final File log = File('${logDir.path}/$fileName'); log.writeAsStringSync(logs); FlutterFileDialog.saveFile( - params: SaveFileDialogParams( + params:SaveFileDialogParams( sourceFilePath: log.path, fileName: fileName, ), diff --git a/lib/ui/views/settings/settings_viewmodel.dart b/lib/ui/views/settings/settings_viewmodel.dart index d1dbfd7e..e51b1382 100644 --- a/lib/ui/views/settings/settings_viewmodel.dart +++ b/lib/ui/views/settings/settings_viewmodel.dart @@ -210,7 +210,7 @@ class SettingsViewModel extends BaseViewModel { final String dateTime = DateTime.now().toString().replaceAll(' ', '_').split('.').first; await FlutterFileDialog.saveFile( - params: SaveFileDialogParams( + params: SaveFileDialogParams( sourceFilePath: outFile.path, fileName: 'selected_patches_$dateTime.json', ), @@ -261,7 +261,7 @@ class SettingsViewModel extends BaseViewModel { final String dateTime = DateTime.now().toString().replaceAll(' ', '_').split('.').first; await FlutterFileDialog.saveFile( - params: SaveFileDialogParams( + params: SaveFileDialogParams( sourceFilePath: outFile.path, fileName: 'keystore_$dateTime.keystore', ), From b1fb9dd7d3a28ad5fbe1b83581274f4f614b194a Mon Sep 17 00:00:00 2001 From: Ushie Date: Sat, 2 Dec 2023 03:44:51 +0300 Subject: [PATCH 05/47] build: Bump version to `v1.17.1` --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index b10e3400..b3f701d6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,7 @@ homepage: https://github.com/revanced/revanced-manager publish_to: 'none' -version: 1.17.0+101700000 +version: 1.17.1+101700100 environment: sdk: '>=3.0.0 <4.0.0' From 71b5bb3f8f8f7ad0bce64e40598ee7ae7218bff4 Mon Sep 17 00:00:00 2001 From: validcube Date: Sat, 2 Dec 2023 17:33:42 +0700 Subject: [PATCH 06/47] build(dart-dependency): prefer immutable for dependency using git --- pubspec.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pubspec.yaml b/pubspec.yaml index b3f701d6..efc7e968 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,7 +15,7 @@ dependencies: device_apps: git: # switch back to ponces fork once https://github.com/ponces/flutter_plugin_device_apps/pull/1 is merged url: https://github.com/BenjaminHalko/flutter_plugin_device_apps - ref: revanced-manager + ref: 0efbeba41657158a66bbc92c55d1226df56d0f1b # Branch: revanced-manager device_info_plus: ^9.1.0 dynamic_color: ^1.6.3 dio: ^5.0.0 @@ -27,7 +27,7 @@ dependencies: flutter_background: git: # remove once https://github.com/JulianAssmann/flutter_background/pull/79 is merged url: https://github.com/BenjaminHalko/flutter_background - ref: specify-namespace + ref: 560d21c4148b53933313573e7eafca0b0eb9aadf # Branch: specify-namespace flutter_cache_manager: ^3.3.0 flutter_i18n: ^0.34.0 flutter_local_notifications: ^16.1.0 @@ -48,7 +48,7 @@ dependencies: logcat: git: url: https://github.com/BenjaminHalko/logcat - ref: master + ref: 4a6d5e0e22292c8eb160cfb9365b9ea29735fd43 # Branch: master package_info_plus: ^4.2.0 path_provider: ^2.0.14 permission_handler: ^11.0.1 @@ -56,7 +56,7 @@ dependencies: root: git: url: https://github.com/validcube/root - ref: 68e5678a535a2a3344828a14a39017fa74b9098c + ref: 68e5678a535a2a3344828a14a39017fa74b9098c # Branch: libsu-521 shared_preferences: ^2.1.0 skeletons: ^0.0.3 stacked: ^3.2.0 @@ -71,11 +71,11 @@ dependencies: install_plugin: git: # remove once https://github.com/hui-z/flutter_install_plugin/pull/67 is merged url: https://github.com/BenjaminHalko/flutter_install_plugin - ref: master + ref: 5f9b1a8c956fc3355ae655eefcbcadb457bd10f7 # Branch: master screenshot_callback: git: # remove once https://github.com/flutter-moum/flutter_screenshot_callback/pull/81 is merged url: https://github.com/BenjaminHalko/flutter_screenshot_callback - ref: master + ref: 1a1616ac91e16cd1f3dd170a81febf27ffce3587 # Branch: master synchronized: ^3.1.0 connectivity_plus: ^5.0.1 flutter_file_dialog: ^3.0.2 From 6339a31fec1b7f66bfa688cc3222cf948356b8f5 Mon Sep 17 00:00:00 2001 From: validcube Date: Sat, 2 Dec 2023 17:35:35 +0700 Subject: [PATCH 07/47] build(dart-dependency): bump FlutterToast to v8.2.4 --- pubspec.yaml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pubspec.yaml b/pubspec.yaml index efc7e968..28d31565 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -34,10 +34,7 @@ dependencies: flutter_localizations: sdk: flutter flutter_svg: ^2.0.4 - fluttertoast: - git: # remove once the next fluttertoast version is release (> 8.2.2) - url: https://github.com/ponnamkarthik/FlutterToast - ref: f4e7b4e1afc8c760eb5bac80f6a2e299906d83ca + fluttertoast: ^8.2.4 font_awesome_flutter: ^10.4.0 get_it: ^7.6.4 google_fonts: ^6.1.0 From 8480b3ac3d209af52a6f363f145e035bf8094eb4 Mon Sep 17 00:00:00 2001 From: validcube Date: Sat, 2 Dec 2023 17:39:02 +0700 Subject: [PATCH 08/47] chore: update repository's owner name --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 28d31565..b59eefcc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: revanced_manager description: Patch your favorite apps, right on your device. -homepage: https://github.com/revanced/revanced-manager +homepage: https://github.com/ReVanced/revanced-manager publish_to: 'none' From eb6e75b1568a94d145f082a3a153213d4fc493aa Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Tue, 5 Dec 2023 09:43:04 +0700 Subject: [PATCH 09/47] ci: use migrate setup-java to Node 20 (#1542) --- .github/workflows/pr-build.yml | 2 +- .github/workflows/release-build.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml index 993298dc..009cef0d 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/pr-build.yml @@ -59,7 +59,7 @@ jobs: persist-credentials: false - name: Setup JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: '17' distribution: 'zulu' diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index d8f3d745..2db06f3f 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -13,7 +13,7 @@ jobs: - name: Set env run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - name: Set up JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: "17" distribution: "zulu" @@ -47,4 +47,4 @@ jobs: with: repo_token: "${{ secrets.GITHUB_TOKEN }}" prerelease: false - files: revanced-manager-${{ env.RELEASE_VERSION }}.apk \ No newline at end of file + files: revanced-manager-${{ env.RELEASE_VERSION }}.apk From 7df1ae7ed84a0e527b9fd7d67aa075f68d4e1b7a Mon Sep 17 00:00:00 2001 From: Dhruvan Bhalara <53393418+dhruvanbhalara@users.noreply.github.com> Date: Tue, 5 Dec 2023 09:19:16 +0530 Subject: [PATCH 10/47] feat: append patch version to the APK name while sharing/exporting (#1547) --- lib/services/patcher_api.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/services/patcher_api.dart b/lib/services/patcher_api.dart index 65f5ecc0..f79d02e5 100644 --- a/lib/services/patcher_api.dart +++ b/lib/services/patcher_api.dart @@ -237,7 +237,7 @@ void exportPatchedFile(String appName, String version) { if (outFile != null) { final String newName = _getFileName(appName, version); FlutterFileDialog.saveFile( - params: SaveFileDialogParams( + params: SaveFileDialogParams( sourceFilePath: outFile!.path, fileName: newName, mimeTypesFilter: ['application/vnd.android.package-archive'], @@ -269,8 +269,9 @@ void sharePatchedFile(String appName, String version) { } String _getFileName(String appName, String version) { + final String patchVersion = _managerAPI.patchesVersion!; final String prefix = appName.toLowerCase().replaceAll(' ', '-'); - final String newName = '$prefix-revanced_v$version.apk'; + final String newName = '$prefix-revanced_v$version-patches_$patchVersion.apk'; return newName; } From 61a025de4daa9cb54e717590a37418852d40b88c Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Sat, 9 Dec 2023 11:47:26 +0700 Subject: [PATCH 11/47] docs: correct styling issue --- docs/4_building.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/docs/4_building.md b/docs/4_building.md index fec5b7e9..29168acc 100644 --- a/docs/4_building.md +++ b/docs/4_building.md @@ -2,29 +2,31 @@ This page will guide you through building ReVanced Manager from source. -1. Setup the Flutter environment for your [platform](https://docs.flutter.dev/get-started/install) +1\. Setup the Flutter environment for your [platform](https://docs.flutter.dev/get-started/install) -2. Clone the repository +2\. Clone the repository ```sh git clone https://github.com/revanced/revanced-manager.git && cd revanced-manager ``` -3. Get dependencies +3\. Get dependencies ```sh flutter pub get ``` -4. Delete conflicting outputs +4\. Delete conflicting outputs + +> [!TIP] +> Must be run every time you sync your local repository with the remote repository. ```sh dart run build_runner build --delete-conflicting-outputs ``` - > [!Note] - > Must be run every time you sync your local repository with the remote repository. -5. Build the APK + +5\. Build the APK ```sh flutter build apk From 093cfa52694b9f4363e371e9fd1dc572204d4c09 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Sat, 9 Dec 2023 11:48:20 +0700 Subject: [PATCH 12/47] docs(contributing): use correct semantic --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d261a86a..67e0adc7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -69,7 +69,7 @@ If you encounter a bug while using the ReVanced Manager app, open an issue using ## 📝 How to contribute -> [!NOTE] +> [!TIP] > We recommend that you discuss your changes with > the maintainers of ReVanced Manager before contributing. > This will help you determine whether your change is acceptable. From d9a316abbbf85267f7afdf3c1fab250495699625 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Sat, 9 Dec 2023 11:49:19 +0700 Subject: [PATCH 13/47] docs(contributing): update branding --- CONTRIBUTING.md | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 67e0adc7..52d99b39 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,7 +12,10 @@
- + + + +     @@ -21,13 +24,22 @@     - + + + +     - + + + +     - + + + +     @@ -36,7 +48,10 @@     - + + + +

From 637641cf54b9f609671caccd2f90e8d3335c8f56 Mon Sep 17 00:00:00 2001 From: Pun Butrach Date: Mon, 11 Dec 2023 11:26:52 +0700 Subject: [PATCH 14/47] feat: output suggested version into patch log (#1557) Signed-off-by: validcube --- .../views/installer/installer_viewmodel.dart | 54 ++++++++++++++----- 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/lib/ui/views/installer/installer_viewmodel.dart b/lib/ui/views/installer/installer_viewmodel.dart index 53a03040..02691bb3 100644 --- a/lib/ui/views/installer/installer_viewmodel.dart +++ b/lib/ui/views/installer/installer_viewmodel.dart @@ -183,13 +183,15 @@ class InstallerViewModel extends BaseViewModel { final lineCount = logLines.where((line) => line.endsWith(keyword)).length; final index = logLines.indexWhere((line) => line.endsWith(keyword)); if (newString != null && lineCount > 0) { - logLines.insert(index, newString.replaceAll('{lineCount}', lineCount.toString())); + logLines.insert( + index, newString.replaceAll('{lineCount}', lineCount.toString())); } logLines.removeWhere((lines) => lines.endsWith(keyword)); } dynamic _getPatchOptionValue(String patchName, Option option) { - final Option? savedOption = _managerAPI.getPatchOption(_app.packageName, patchName, option.key); + final Option? savedOption = + _managerAPI.getPatchOption(_app.packageName, patchName, option.key); if (savedOption != null) { return savedOption.value; } else { @@ -201,7 +203,24 @@ class InstallerViewModel extends BaseViewModel { if (patches.isEmpty) { return 'None'; } - return patches.map((p) => p.name + (p.options.isEmpty ? '' : ' [${p.options.map((o) => '${o.title}: ${_getPatchOptionValue(p.name, o)}').join(", ")}]')).toList().join(', '); + return patches + .map((p) => + p.name + + (p.options.isEmpty + ? '' + : ' [${p.options.map((o) => '${o.title}: ${_getPatchOptionValue(p.name, o)}').join(", ")}]')) + .toList() + .join(', '); + } + + String _getSuggestedVersion(String packageName) { + String suggestedVersion = _patcherAPI.getSuggestedVersion(_app.packageName); + if (suggestedVersion.isEmpty) { + suggestedVersion = 'Any'; + } else { + suggestedVersion = 'v$suggestedVersion'; + } + return suggestedVersion; } Future copyLogs() async { @@ -213,12 +232,21 @@ class InstallerViewModel extends BaseViewModel { _trimLogs(logsTrimmed, '.dex', 'Compiled {lineCount} dex files'); // Get patches added / removed - final defaultPatches = _patcherAPI.getFilteredPatches(_app.packageName).where((p) => !p.excluded).toList(); - final patchesAdded = _patches.where((p) => !defaultPatches.contains(p)).toList(); - final patchesRemoved = defaultPatches.where((p) => !_patches.contains(p)).toList(); + final defaultPatches = _patcherAPI + .getFilteredPatches(_app.packageName) + .where((p) => !p.excluded) + .toList(); + final patchesAdded = + _patches.where((p) => !defaultPatches.contains(p)).toList(); + final patchesRemoved = + defaultPatches.where((p) => !_patches.contains(p)).toList(); // Options changed - final patchesChanged = defaultPatches.where((p) => _patches.contains(p) && p.options.any((o) => _getPatchOptionValue(p.name, o) != o.value)).toList(); + final patchesChanged = defaultPatches + .where((p) => + _patches.contains(p) && + p.options.any((o) => _getPatchOptionValue(p.name, o) != o.value)) + .toList(); // Add Info final formattedLogs = [ @@ -228,22 +256,22 @@ class InstallerViewModel extends BaseViewModel { 'Model: ${info['model']}', 'Android version: ${info['androidVersion']}', 'Supported architectures: ${info['supportedArch'].join(", ")}', - 'Root permissions: ${isRooted ? 'Yes' : 'No'}', - + 'Root permissions: ${isRooted ? 'Yes' : 'No'}', // + '\n- Patch Info', - 'App: ${_app.packageName} v${_app.version}', + 'App: ${_app.packageName} v${_app.version} (Suggested: ${_getSuggestedVersion(_app.packageName)})', 'Patches version: ${_managerAPI.patchesVersion}', 'Patches added: ${_formatPatches(patchesAdded)}', 'Patches removed: ${_formatPatches(patchesRemoved)}', - 'Options changed: ${_formatPatches(patchesChanged)}', + 'Options changed: ${_formatPatches(patchesChanged)}', // '\n- Settings', 'Allow changing patch selection: ${_managerAPI.isPatchesChangeEnabled()}', 'Version compatibility check: ${_managerAPI.isVersionCompatibilityCheckEnabled()}', 'Show universal patches: ${_managerAPI.areUniversalPatchesEnabled()}', 'Patches source: ${_managerAPI.getPatchesRepo()}', - 'Integration source: ${_managerAPI.getIntegrationsRepo()}', - + 'Integration source: ${_managerAPI.getIntegrationsRepo()}', // + '\n- Logs', logsTrimmed.join('\n'), ]; From 7f26c5bd45378b61e78fe3b81ff021fb461c00ef Mon Sep 17 00:00:00 2001 From: validcube Date: Mon, 11 Dec 2023 19:02:13 +0700 Subject: [PATCH 15/47] revert: "feat: improve predictive back (#1487)" This reverts commit 06ff36c83628099f4214b1f129d94b7e103a3394. Signed-off-by: validcube --- lib/services/manager_api.dart | 4 +- lib/ui/views/installer/installer_view.dart | 6 +-- .../views/installer/installer_viewmodel.dart | 45 +++++++------------ lib/ui/views/navigation/navigation_view.dart | 10 +++-- 4 files changed, 27 insertions(+), 38 deletions(-) diff --git a/lib/services/manager_api.dart b/lib/services/manager_api.dart index 85306873..7a9e091d 100644 --- a/lib/services/manager_api.dart +++ b/lib/services/manager_api.dart @@ -582,8 +582,8 @@ class ManagerAPI { return showDialog( barrierDismissible: false, context: context, - builder: (context) => PopScope( - canPop: false, + builder: (context) => WillPopScope( + onWillPop: () async => false, child: AlertDialog( backgroundColor: Theme.of(context).colorScheme.secondaryContainer, title: I18nText('warning'), diff --git a/lib/ui/views/installer/installer_view.dart b/lib/ui/views/installer/installer_view.dart index 45d20519..d1626ed5 100644 --- a/lib/ui/views/installer/installer_view.dart +++ b/lib/ui/views/installer/installer_view.dart @@ -15,8 +15,7 @@ class InstallerView extends StatelessWidget { return ViewModelBuilder.reactive( onViewModelReady: (model) => model.initialize(context), viewModelBuilder: () => InstallerViewModel(), - builder: (context, model, child) => PopScope( - onPopInvoked: (bool didPop) => model.onPopInvoked(context, didPop), + builder: (context, model, child) => WillPopScope( child: SafeArea( top: false, bottom: model.isPatching, @@ -84,7 +83,7 @@ class InstallerView extends StatelessWidget { maxLines: 1, overflow: TextOverflow.ellipsis, ), - onBackButtonPressed: () => model.onBackButtonInvoked(context), + onBackButtonPressed: () => model.onWillPop(context), bottom: PreferredSize( preferredSize: const Size(double.infinity, 1.0), child: GradientProgressIndicator(progress: model.progress), @@ -112,6 +111,7 @@ class InstallerView extends StatelessWidget { ), ), ), + onWillPop: () => model.onWillPop(context), ), ); } diff --git a/lib/ui/views/installer/installer_viewmodel.dart b/lib/ui/views/installer/installer_viewmodel.dart index 02691bb3..d16f1309 100644 --- a/lib/ui/views/installer/installer_viewmodel.dart +++ b/lib/ui/views/installer/installer_viewmodel.dart @@ -489,38 +489,25 @@ class InstallerViewModel extends BaseViewModel { } } - bool canPop() { - return !isPatching; - } - - void onBackButtonInvoked(BuildContext context) { - if (canPop()) { - onPopInvoked(context, true); - } else { - onPopInvoked(context, false); - } - } - - Future onPopInvoked(BuildContext context, bool didPop) async { - if (didPop) { + Future onWillPop(BuildContext context) async { + if (isPatching) { if (!cancel) { - cleanPatcher(); + cancel = true; + _toast.showBottom('installerView.pressBackAgain'); + } else if (!isCanceled) { + await stopPatcher(); } else { - _patcherAPI.cleanPatcher(); - } - screenshotCallback.dispose(); - Navigator.of(context).pop(); - } else { - if (isPatching) { - if (!cancel) { - cancel = true; - _toast.showBottom('installerView.pressBackAgain'); - } else if (!isCanceled) { - await stopPatcher(); - } else { - _toast.showBottom('installerView.noExit'); - } + _toast.showBottom('installerView.noExit'); } + return false; } + if (!cancel) { + cleanPatcher(); + } else { + _patcherAPI.cleanPatcher(); + } + screenshotCallback.dispose(); + Navigator.of(context).pop(); + return true; } } diff --git a/lib/ui/views/navigation/navigation_view.dart b/lib/ui/views/navigation/navigation_view.dart index 56c24d17..13a4457e 100644 --- a/lib/ui/views/navigation/navigation_view.dart +++ b/lib/ui/views/navigation/navigation_view.dart @@ -13,11 +13,13 @@ class NavigationView extends StatelessWidget { return ViewModelBuilder.reactive( onViewModelReady: (model) => model.initialize(context), viewModelBuilder: () => locator(), - builder: (context, model, child) => PopScope( - canPop: model.currentIndex == 0, - onPopInvoked: (bool didPop) { - if (!didPop) { + builder: (context, model, child) => WillPopScope( + onWillPop: () async { + if (model.currentIndex == 0) { + return true; + } else { model.setIndex(0); + return false; } }, child: Scaffold( From 1fad90441cda88d6632307adc207adb0eadf4964 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Tue, 12 Dec 2023 02:32:45 +0100 Subject: [PATCH 16/47] perf: Use hashset for fast comparison --- .../patches_selector_viewmodel.dart | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/ui/views/patches_selector/patches_selector_viewmodel.dart b/lib/ui/views/patches_selector/patches_selector_viewmodel.dart index 173c1f53..6b6d7d24 100644 --- a/lib/ui/views/patches_selector/patches_selector_viewmodel.dart +++ b/lib/ui/views/patches_selector/patches_selector_viewmodel.dart @@ -25,6 +25,9 @@ class PatchesSelectorViewModel extends BaseViewModel { locator().selectedPatches; PatchedApplication? selectedApp = locator().selectedApp; String? patchesVersion = ''; + + Set savedPatchNames = {}; + bool isDefaultPatchesRepo() { return _managerAPI.getPatchesRepo() == 'revanced/revanced-patches'; } @@ -48,6 +51,9 @@ class PatchesSelectorViewModel extends BaseViewModel { }); currentSelection.clear(); currentSelection.addAll(selectedPatches); + + savedPatchNames = _managerAPI.getSavedPatches(selectedApp!.packageName).map((p) => p.name).toSet(); + notifyListeners(); } @@ -281,13 +287,10 @@ class PatchesSelectorViewModel extends BaseViewModel { } bool isPatchNew(Patch patch) { - final List savedPatches = - _managerAPI.getSavedPatches(selectedApp!.packageName); - if (savedPatches.isEmpty) { + if (savedPatchNames.isEmpty) { return false; } else { - return !savedPatches - .any((p) => p.getSimpleName() == patch.getSimpleName()); + return !savedPatchNames.contains(patch.name); } } From 7831a3438d46630dad78425eba18c209210e6d1d Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Tue, 12 Dec 2023 02:32:57 +0100 Subject: [PATCH 17/47] fix: Include new patches that are used by default --- .../views/patches_selector/patches_selector_viewmodel.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/ui/views/patches_selector/patches_selector_viewmodel.dart b/lib/ui/views/patches_selector/patches_selector_viewmodel.dart index 6b6d7d24..399fe349 100644 --- a/lib/ui/views/patches_selector/patches_selector_viewmodel.dart +++ b/lib/ui/views/patches_selector/patches_selector_viewmodel.dart @@ -59,8 +59,9 @@ class PatchesSelectorViewModel extends BaseViewModel { bool isSelected(Patch patch) { return selectedPatches.any( - (element) => element.name == patch.name, - ); + (element) => element.name == patch.name, + ) || + (isPatchNew(patch) && !patch.excluded); } void navigateToPatchOptions(List