Skip to content

Commit

Permalink
chore: merge dev to main (ReVanced#1545)
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminHalko authored Dec 12, 2023
2 parents a9878db + 7831a34 commit ca9ef54
Show file tree
Hide file tree
Showing 11 changed files with 122 additions and 86 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -47,4 +47,4 @@ jobs:
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
files: revanced-manager-${{ env.RELEASE_VERSION }}.apk
files: revanced-manager-${{ env.RELEASE_VERSION }}.apk
27 changes: 21 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
</picture>
<br>
<a href="https://revanced.app/">
<img height="24px" src="assets/revanced-logo/revanced-logo-round.svg" />
<picture>
<source height="24px" media="(prefers-color-scheme: dark)" srcset="assets/revanced-logo/revanced-logo-round.svg" />
<img height="24px" src="assets/revanced-logo/revanced-logo-round.svg" />
</picture>
</a>&nbsp;&nbsp;&nbsp;
<a href="https://github.com/ReVanced">
<picture>
Expand All @@ -21,13 +24,22 @@
</picture>
</a>&nbsp;&nbsp;&nbsp;
<a href="http://revanced.app/discord">
<img height="24px" src="https://user-images.githubusercontent.com/13122796/178032563-d4e084b7-244e-4358-af50-26bde6dd4996.png" />
<picture>
<source height="24px" media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/13122796/178032563-d4e084b7-244e-4358-af50-26bde6dd4996.png" />
<img height="24px" src="https://user-images.githubusercontent.com/13122796/178032563-d4e084b7-244e-4358-af50-26bde6dd4996.png" />
</picture>
</a>&nbsp;&nbsp;&nbsp;
<a href="https://reddit.com/r/revancedapp">
<img height="24px" src="https://user-images.githubusercontent.com/13122796/178032351-9d9d5619-8ef7-470a-9eec-2744ece54553.png" />
<picture>
<source height="24px" media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/13122796/178032351-9d9d5619-8ef7-470a-9eec-2744ece54553.png" />
<img height="24px" src="https://user-images.githubusercontent.com/13122796/178032351-9d9d5619-8ef7-470a-9eec-2744ece54553.png" />
</picture>
</a>&nbsp;&nbsp;&nbsp;
<a href="https://t.me/app_revanced">
<img height="24px" src="https://user-images.githubusercontent.com/13122796/178032213-faf25ab8-0bc3-4a94-a730-b524c96df124.png" />
<picture>
<source height="24px" media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/13122796/178032213-faf25ab8-0bc3-4a94-a730-b524c96df124.png" />
<img height="24px" src="https://user-images.githubusercontent.com/13122796/178032213-faf25ab8-0bc3-4a94-a730-b524c96df124.png" />
</picture>
</a>&nbsp;&nbsp;&nbsp;
<a href="https://x.com/revancedapp">
<picture>
Expand All @@ -36,7 +48,10 @@
</picture>
</a>&nbsp;&nbsp;&nbsp;
<a href="https://www.youtube.com/@ReVanced">
<img height="24px" src="https://user-images.githubusercontent.com/13122796/178032714-c51c7492-0666-44ac-99c2-f003a695ab50.png" />
<picture>
<source height="24px" media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/13122796/178032714-c51c7492-0666-44ac-99c2-f003a695ab50.png" />
<img height="24px" src="https://user-images.githubusercontent.com/13122796/178032714-c51c7492-0666-44ac-99c2-f003a695ab50.png" />
</picture>
</a>
<br>
<br>
Expand Down Expand Up @@ -69,7 +84,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.
Expand Down
16 changes: 9 additions & 7 deletions docs/4_building.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/services/manager_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
5 changes: 3 additions & 2 deletions lib/services/patcher_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down Expand Up @@ -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;
}

Expand Down
6 changes: 3 additions & 3 deletions lib/ui/views/installer/installer_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ class InstallerView extends StatelessWidget {
return ViewModelBuilder<InstallerViewModel>.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,
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -112,6 +111,7 @@ class InstallerView extends StatelessWidget {
),
),
),
onWillPop: () => model.onWillPop(context),
),
);
}
Expand Down
97 changes: 56 additions & 41 deletions lib/ui/views/installer/installer_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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<void> copyLogs() async {
Expand All @@ -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 = [
Expand All @@ -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'),
];
Expand Down Expand Up @@ -461,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<void> onPopInvoked(BuildContext context, bool didPop) async {
if (didPop) {
Future<bool> onWillPop(BuildContext context) async {
if (isPatching) {
if (!cancel) {
cleanPatcher();
cancel = true;
_toast.showBottom('installerView.pressBackAgain');
} else if (!isCanceled) {
await stopPatcher();
} else {
_patcherAPI.cleanPatcher();
_toast.showBottom('installerView.noExit');
}
screenshotCallback.dispose();
Navigator.of(context).pop();
return false;
}
if (!cancel) {
cleanPatcher();
} else {
if (isPatching) {
if (!cancel) {
cancel = true;
_toast.showBottom('installerView.pressBackAgain');
} else if (!isCanceled) {
await stopPatcher();
} else {
_toast.showBottom('installerView.noExit');
}
}
_patcherAPI.cleanPatcher();
}
screenshotCallback.dispose();
Navigator.of(context).pop();
return true;
}
}
10 changes: 6 additions & 4 deletions lib/ui/views/navigation/navigation_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ class NavigationView extends StatelessWidget {
return ViewModelBuilder<NavigationViewModel>.reactive(
onViewModelReady: (model) => model.initialize(context),
viewModelBuilder: () => locator<NavigationViewModel>(),
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(
Expand Down
18 changes: 11 additions & 7 deletions lib/ui/views/patches_selector/patches_selector_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class PatchesSelectorViewModel extends BaseViewModel {
locator<PatcherViewModel>().selectedPatches;
PatchedApplication? selectedApp = locator<PatcherViewModel>().selectedApp;
String? patchesVersion = '';

Set<String> savedPatchNames = {};

bool isDefaultPatchesRepo() {
return _managerAPI.getPatchesRepo() == 'revanced/revanced-patches';
}
Expand All @@ -48,13 +51,17 @@ class PatchesSelectorViewModel extends BaseViewModel {
});
currentSelection.clear();
currentSelection.addAll(selectedPatches);

savedPatchNames = _managerAPI.getSavedPatches(selectedApp!.packageName).map((p) => p.name).toSet();

notifyListeners();
}

bool isSelected(Patch patch) {
return selectedPatches.any(
(element) => element.name == patch.name,
);
(element) => element.name == patch.name,
) ||
(isPatchNew(patch) && !patch.excluded);
}

void navigateToPatchOptions(List<Option> setOptions, Patch patch) {
Expand Down Expand Up @@ -281,13 +288,10 @@ class PatchesSelectorViewModel extends BaseViewModel {
}

bool isPatchNew(Patch patch) {
final List<Patch> 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);
}
}

Expand Down
Loading

0 comments on commit ca9ef54

Please sign in to comment.