Compare commits

...

12 Commits

Author SHA1 Message Date
Aunali321
30376c960f build: bump version to v0.0.40 2022-11-10 12:14:50 +05:30
Palm
405147b1c5 fix(i18n): locale capitalization and grammar (#496)
* fix(i18n): locale capitalization and grammar

* fix(i18n): add some more changes requested
2022-11-09 19:07:28 +05:30
Aunali321
d545dfe49b refactor: move exporting patches to another section 2022-11-09 14:20:32 +05:30
Boris M
c571cf2c53 feat: ability to store and load selected patches (#469)
* feat: ability to store and load selected patches

* fix: I18n

* fix: do not append but truncate file

* fix: use json file, minor fixes

* fix: better ui

* WIP

* feat: load patches selection after app selection

* feat: import/export json file

* fix: reformat code

* fix: rare bug on import feature fixed

* fix: move export/ipmort to settings page & import full json

* fix: minor improvements

* fix: minor code quality improvements

* fix: export filename fix

* fix: select list element istead of removing it
2022-11-09 13:06:04 +05:30
Boris M
fd5d71e24d fix: delete cached apk files when picking new one (#481) 2022-11-09 13:05:26 +05:30
Boris M
2c3809d2bc feat: show selected patches count in patches selector view & patch selector card (#466)
* feat: show selected patches count in patches selector view & patch selector card

* fix: add Widget on row

* fix: formatting

* fix: same text style for count
2022-11-09 13:02:39 +05:30
Ushie
0fc8e7cbc8 feat: crowdin workflow 2022-11-05 01:31:56 +03:00
Ushie
787e47f634 Update Crowdin configuration file 2022-11-04 23:14:55 +03:00
nkitsaini
dc47da75f2 feat: Adding support for Exporting APK (#439)
* feat: Adding Export APK support

* Using cr_file_saver to simplify export
2022-11-02 17:22:40 +05:30
Ushie
6b999b0a0c build: bump version to v0.0.39 2022-11-02 00:06:29 +03:00
oSumAtrIX
b00d2d16d4 feat: simplify logging (#305)
Co-authored-by: Ushie <ushiekane@gmail.com>
2022-11-02 00:02:51 +03:00
Boris M
97d4da568b fix: allow tapping on patch card when experimental switch is enabled (#464) 2022-11-02 00:02:33 +03:00
17 changed files with 435 additions and 79 deletions

45
.github/workflows/crowdin.yml vendored Normal file
View File

@@ -0,0 +1,45 @@
name: Sync Crowdin translations
on:
push:
branches:
- "flutter"
paths:
- "assets/i18n/en_US.json"
- ".github/workflows/crowdin.yml"
schedule:
- cron: "0 0 * * *" # daily
workflow_dispatch:
jobs:
sync-crowdin:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Crowdin
uses: crowdin/github-action@1.0.4
with:
config: crowdin.yml
upload_translations: true
download_translations: true
push_translations: true
create_pull_request: false
localization_branch_name: i18n_flutter
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
# commented due to Manager not being ready for the translated files to be in the main branch
# - name: GitHub is so dumb i just cant
# run: |
# sudo chmod -R ugo+rwX .
# - name: Merge
# run: |
# git checkout flutter
# git add *
# git merge i18n_flutter
# git push

View File

@@ -180,7 +180,7 @@ class MainActivity : FlutterActivity() {
patcher.addPatches(patches)
patcher.executePatches().forEach { (patch, res) ->
if (res.isSuccess) {
val msg = "[success] $patch"
val msg = "Applied $patch"
handler.post {
installerChannel.invokeMethod(
"update",
@@ -193,7 +193,7 @@ class MainActivity : FlutterActivity() {
}
return@forEach
}
val msg = "[error] $patch:" + res.exceptionOrNull()!!.printStackTrace()
val msg = "$patch failed.\nError:\n" + res.exceptionOrNull()!!.printStackTrace()
handler.post {
installerChannel.invokeMethod(
"update",

View File

@@ -13,16 +13,16 @@
"homeView": {
"widgetTitle": "Dashboard",
"updatesSubtitle": "Updates",
"patchedSubtitle": "Patched Applications",
"patchedSubtitle": "Patched applications",
"updatesAvailable": "Updates available",
"noUpdates": "No updates available",
"WIP": "Work In Progress",
"WIP": "Work in progress...",
"noInstallations": "No patched applications installed",
"installed": "Installed",
"updateDialogTitle": "Update Manager",
"updateDialogText": "Are you sure you want to download and update ReVanced Manager?",
"notificationTitle": "ReVanced Manager was updated",
"notificationText": "Tap to open the app",
"notificationTitle": "Update downloaded",
"notificationText": "Tap to install the update",
"downloadingMessage": "Downloading update...",
"installingMessage": "Installing update...",
"errorDownloadMessage": "Unable to download update",
@@ -46,13 +46,13 @@
"widgetTitle": "Patcher",
"patchButton": "Patch",
"patchDialogTitle": "Warning",
"patchDialogText": "You have selected a resource patch and a split APK installation was detected so patching errors may occur.\nAre you sure you want to proceed with patching a split base APK?"
"patchDialogText": "You have selected a resource patch and a split APK installation has been detected, so patching errors may occur.\nAre you sure you want to proceed?"
},
"appSelectorCard": {
"widgetTitle": "Select application",
"widgetTitle": "Select an application",
"widgetTitleSelected": "Selected application",
"widgetSubtitle": "No application selected",
"noAppsLabel": "No applications found.",
"noAppsLabel": "No applications found",
"currentVersion": "Current",
"recommendedVersion": "Recommended",
"anyVersion": "any"
@@ -68,15 +68,17 @@
"widgetSubtitle": "We are online!"
},
"appSelectorView": {
"viewTitle": "Select application",
"viewTitle": "Select an application",
"searchBarHint": "Search applications",
"storageButton": "Storage",
"errorMessage": "Unable to use selected application."
"errorMessage": "Unable to use selected application"
},
"patchesSelectorView": {
"viewTitle": "Select patches",
"searchBarHint": "Search patches",
"doneButton": "Done",
"loadPatchesSelection": "Load patches selection",
"noSavedPatches": "No saved patches for the selected app\nPress Done to save current selection",
"noPatchesFound": "No patches found for the selected app",
"selectAllPatchesWarningTitle": "Warning",
"selectAllPatchesWarningContent": "You are about to select all patches, that includes unrecommended patches and can cause unwanted behavior."
@@ -84,7 +86,7 @@
"patchItem": {
"unsupportedWarningButton": "Warning",
"unsupportedDialogTitle": "Warning",
"unsupportedDialogText": "Selecting this patch may result in patching errors.\n\nApp version: {packageVersion}\nCurrent supported versions:\n{supportedVersions}",
"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 experimental toggle in settings to proceed."
},
"installerView": {
@@ -96,12 +98,13 @@
"notificationTitle": "ReVanced Manager is patching",
"notificationText": "Tap to return to the installer",
"shareApkMenuOption": "Share APK",
"exportApkMenuOption": "Export APK",
"shareLogMenuOption": "Share log",
"installErrorDialogTitle": "Error",
"installErrorDialogText1": "Root install is not possible with the current patches selection.\nRepatch your app or choose non-root install.",
"installErrorDialogText2": "Non-root install is not possible with the current patches selection.\nRepatch your app or choose root install if you have your device rooted.",
"installErrorDialogText3": "Root install is not possible as the original APK was selected from storage.\nSelect an installed app or choose non-root install.",
"noExit": "Installer is still running..."
"noExit": "Installer is still running, cannot exit..."
},
"settingsView": {
"widgetTitle": "Settings",
@@ -110,8 +113,8 @@
"infoSectionTitle": "Info",
"advancedSectionTitle": "Advanced",
"logsSectionTitle": "Logs",
"darkThemeLabel": "Dark Mode",
"darkThemeHint": "Welcome to the Dark Side",
"darkThemeLabel": "Dark mode",
"darkThemeHint": "Welcome to the dark side",
"dynamicThemeLabel": "Material You",
"dynamicThemeHint": "Enjoy an experience closer to your device",
"languageLabel": "Language",
@@ -119,64 +122,76 @@
"frenchOption": "French",
"sourcesLabel": "Sources",
"sourcesLabelHint": "Configure your custom sources",
"orgPatchesLabel": "Patches Organization",
"sourcesPatchesLabel": "Patches Source",
"orgIntegrationsLabel": "Integrations Organization",
"sourcesIntegrationsLabel": "Integrations Source",
"orgPatchesLabel": "Patches organization",
"sourcesPatchesLabel": "Patches source",
"orgIntegrationsLabel": "Integrations organization",
"sourcesIntegrationsLabel": "Integrations source",
"sourcesResetDialogTitle": "Reset",
"sourcesResetDialogText": "Are you sure you want to reset custom sources to their default values?",
"apiURLResetDialogText": "Are you sure you want to reset API URL to its default value?",
"contributorsLabel": "Contributors",
"contributorsHint": "A list of contributors of ReVanced",
"logsLabel": "Logs",
"logsHint": "Share device debug logs",
"logsHint": "Share Manager's logs",
"apiURLLabel": "API URL",
"apiURLHint": "Configure your custom API URL",
"selectApiURL": "Select URL",
"experimentalPatchesLabel": "Experimental Patch support",
"experimentalPatchesHint": "Enable to use unsupported patches in any app version",
"enabledExperimentalPatches": "Experimental patches enabled",
"selectApiURL": "API URL",
"experimentalPatchesLabel": "Experimental patches support",
"experimentalPatchesHint": "Enable usage of unsupported patches in any app version",
"enabledExperimentalPatches": "Experimental patches support enabled",
"exportSectionTitle": "Import & export",
"aboutLabel": "About",
"snackbarMessage": "Copied to clipboard",
"sentryLabel": "Sentry Logging",
"sentryLabel": "Sentry logging",
"sentryHint": "Send anonymous logs to help us improve ReVanced Manager",
"restartAppForChanges": "Restart the app to apply changes",
"deleteKeystoreLabel": "Delete keystore",
"deleteKeystoreHint": "Delete the keystore used to sign the app",
"deletedKeystore": "Keystore deleted",
"deleteTempDirLabel": "Delete temp directory",
"deleteTempDirHint": "Delete the temporary directory used to store temporary files",
"deletedTempDir": "Temp directory deleted",
"deleteTempDirLabel": "Delete temporary files",
"deleteTempDirHint": "Delete the unused temporary files",
"deletedTempDir": "Temporary files deleted",
"exportPatchesLabel": "Export patches selection",
"exportPatchesHint": "Export patches selection to a JSON file",
"exportedPatches": "Patches selection exported",
"noExportFileFound": "No patches selection to export",
"importPatchesLabel": "Import patches selection",
"importPatchesHint": "Import patches selection from a JSON file",
"importedPatches": "Patches selection imported",
"resetStoredPatchesLabel": "Reset patches",
"resetStoredPatchesHint": "Reset the stored patches selection",
"resetStoredPatches": "Patches selection has been reset",
"jsonSelectorErrorMessage": "Unable to use selected JSON file",
"deleteLogsLabel": "Delete logs",
"deleteLogsHint": "Delete collected manager logs",
"deletedLogs": "Logs deleted"
},
"appInfoView": {
"widgetTitle": "App Info",
"widgetTitle": "App info",
"openButton": "Open",
"uninstallButton": "Uninstall",
"patchButton": "Patch",
"unpatchButton": "Unpatch",
"unpatchDialogText": "Are you sure you want to unpatch this app?",
"rootDialogTitle": "Error",
"rootDialogText": "App was installed with root mode enabled but currently root mode is disabled.\nPlease enable root mode first.",
"packageNameLabel": "Package Name",
"originalPackageNameLabel": "Original Package Name",
"installTypeLabel": "Installation Type",
"rootDialogText": "App was installed with superuser permissions, but currently ReVanced Manager has no permissions.\nPlease grant superuser permissions first.",
"packageNameLabel": "Package name",
"originalPackageNameLabel": "Original package name",
"installTypeLabel": "Installation type",
"rootTypeLabel": "Root",
"nonRootTypeLabel": "Non-root",
"patchedDateLabel": "Patched Date",
"patchedDateLabel": "Patched date",
"patchedDateHint": "{date} at {time}",
"appliedPatchesLabel": "Applied Patches",
"appliedPatchesLabel": "Applied patches",
"appliedPatchesHint": "{quantity} applied patches",
"updateNotImplemented": "Update functionality not implemented yet"
"updateNotImplemented": "This feature has not been implemented yet"
},
"contributorsView": {
"widgetTitle": "Contributors",
"patcherContributors": "Patcher Contributors",
"patchesContributors": "Patches Contributors",
"integrationsContributors": "Integrations Contributors",
"cliContributors": "CLI Contributors",
"managerContributors": "Manager Contributors"
"patcherContributors": "Patcher contributors",
"patchesContributors": "Patches contributors",
"integrationsContributors": "Integrations contributors",
"cliContributors": "CLI contributors",
"managerContributors": "Manager contributors"
}
}

View File

@@ -1,3 +1,9 @@
project_id_env: CROWDIN_PROJECT_ID
api_token_env: CROWDIN_PERSONAL_TOKEN
commit_message: 'chore(i18n): sync translations'
preserve_hierarchy: true
files:
- source: /assets/i18n/en.json
translation: /assets/i18n/%locale_with_underscore%.json
- source: assets/i18n/en_US.json
translation: assets/i18n/%locale_with_underscore%.json

View File

@@ -3,6 +3,7 @@ import 'dart:io';
import 'package:device_apps/device_apps.dart';
import 'package:injectable/injectable.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:path_provider/path_provider.dart';
import 'package:revanced_manager/app/app.locator.dart';
import 'package:revanced_manager/models/patch.dart';
import 'package:revanced_manager/models/patched_application.dart';
@@ -19,6 +20,7 @@ class ManagerAPI {
final RootAPI _rootAPI = RootAPI();
final String patcherRepo = 'revanced-patcher';
final String cliRepo = 'revanced-cli';
late String storedPatchesFile = '/selected-patches.json';
late SharedPreferences _prefs;
String defaultApiUrl = 'https://releases.revanced.app/';
String defaultPatcherRepo = 'revanced/revanced-patcher';
@@ -29,6 +31,8 @@ class ManagerAPI {
Future<void> initialize() async {
_prefs = await SharedPreferences.getInstance();
storedPatchesFile =
(await getApplicationDocumentsDirectory()).path + storedPatchesFile;
}
String getApiUrl() {
@@ -391,4 +395,43 @@ class ManagerAPI {
}
return app != null && app.isSplit;
}
Future<void> setSelectedPatches(String app, List<String> patches) async {
final File selectedPatchesFile = File(storedPatchesFile);
Map<String, dynamic> patchesMap = await readSelectedPatchesFile();
if (patches.isEmpty) {
patchesMap.remove(app);
} else {
patchesMap[app] = patches;
}
if (selectedPatchesFile.existsSync()) {
selectedPatchesFile.createSync(recursive: true);
}
selectedPatchesFile.writeAsString(jsonEncode(patchesMap));
}
Future<List<String>> getSelectedPatches(String app) async {
Map<String, dynamic> patchesMap = await readSelectedPatchesFile();
if (patchesMap.isNotEmpty) {
final List<String> patches =
List.from(patchesMap.putIfAbsent(app, () => List.empty()));
return patches;
}
return List.empty();
}
Future<Map<String, dynamic>> readSelectedPatchesFile() async {
final File selectedPatchesFile = File(storedPatchesFile);
if (selectedPatchesFile.existsSync()) {
String string = selectedPatchesFile.readAsStringSync();
if (string.trim().isEmpty) return {};
return json.decode(string);
}
return {};
}
Future<void> resetLastSelectedPatches() async {
final File selectedPatchesFile = File(storedPatchesFile);
selectedPatchesFile.deleteSync();
}
}

View File

@@ -12,6 +12,7 @@ import 'package:revanced_manager/services/manager_api.dart';
import 'package:revanced_manager/services/root_api.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:share_extend/share_extend.dart';
import 'package:cr_file_saver/file_saver.dart';
@lazySingleton
class PatcherAPI {
@@ -228,11 +229,32 @@ class PatcherAPI {
return false;
}
void exportPatchedFile(String appName, String version) {
try {
if (_outFile != null) {
String newName = _getFileName(appName, version);
// This is temporary workaround to populate initial file name
// ref: https://github.com/Cleveroad/cr_file_saver/issues/7
int lastSeparator = _outFile!.path.lastIndexOf('/');
String newSourcePath = _outFile!.path.substring(0, lastSeparator + 1) + newName;
_outFile!.copySync(newSourcePath);
CRFileSaver.saveFileWithDialog(SaveFileDialogParams(
sourceFilePath: newSourcePath,
destinationFileName: newName
));
}
} on Exception catch (e, s) {
Sentry.captureException(e, stackTrace: s);
}
}
void sharePatchedFile(String appName, String version) {
try {
if (_outFile != null) {
String prefix = appName.toLowerCase().replaceAll(' ', '-');
String newName = '$prefix-revanced_v$version.apk';
String newName = _getFileName(appName, version);
int lastSeparator = _outFile!.path.lastIndexOf('/');
String newPath =
_outFile!.path.substring(0, lastSeparator + 1) + newName;
@@ -244,6 +266,13 @@ class PatcherAPI {
}
}
String _getFileName(String appName, String version) {
String prefix = appName.toLowerCase().replaceAll(' ', '-');
String newName = '$prefix-revanced_v$version.apk';
return newName;
}
Future<void> sharePatcherLog(String logs) async {
Directory appCache = await getTemporaryDirectory();
Directory logDir = Directory('${appCache.path}/logs');

View File

@@ -2,6 +2,7 @@ import 'dart:io';
import 'package:device_apps/device_apps.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:revanced_manager/app/app.locator.dart';
import 'package:revanced_manager/models/patched_application.dart';
import 'package:revanced_manager/services/patcher_api.dart';
@@ -33,7 +34,7 @@ class AppSelectorViewModel extends BaseViewModel {
icon: application.icon,
patchDate: DateTime.now(),
);
locator<PatcherViewModel>().selectedPatches.clear();
locator<PatcherViewModel>().loadLastSelectedPatches();
locator<PatcherViewModel>().notifyListeners();
}
@@ -45,6 +46,11 @@ class AppSelectorViewModel extends BaseViewModel {
);
if (result != null && result.files.single.path != null) {
File apkFile = File(result.files.single.path!);
List<String> pathSplit = result.files.single.path!.split("/");
pathSplit.removeLast();
Directory filePickerCacheDir = Directory(pathSplit.join("/"));
Iterable<File> deletableFiles = (await filePickerCacheDir.list().toList()).whereType<File>();
for (var file in deletableFiles) { if (file.path != apkFile.path && file.path.endsWith(".apk")) file.delete(); }
ApplicationWithIcon? application = await DeviceApps.getAppFromStorage(
apkFile.path,
true,
@@ -60,7 +66,7 @@ class AppSelectorViewModel extends BaseViewModel {
patchDate: DateTime.now(),
isFromStorage: true,
);
locator<PatcherViewModel>().selectedPatches.clear();
locator<PatcherViewModel>().loadLastSelectedPatches();
locator<PatcherViewModel>().notifyListeners();
}
}

View File

@@ -48,7 +48,16 @@ class InstallerView extends StatelessWidget {
),
),
),
1: I18nText(
1: I18nText(
'installerView.exportApkMenuOption',
child: const Text(
'',
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
),
2: I18nText(
'installerView.shareLogMenuOption',
child: const Text(
'',

View File

@@ -217,6 +217,14 @@ class InstallerViewModel extends BaseViewModel {
}
}
void exportResult() {
try {
_patcherAPI.exportPatchedFile(_app.name, _app.version);
} on Exception catch (e, s) {
Sentry.captureException(e, stackTrace: s);
}
}
void shareResult() {
try {
_patcherAPI.sharePatchedFile(_app.name, _app.version);
@@ -250,6 +258,9 @@ class InstallerViewModel extends BaseViewModel {
shareResult();
break;
case 1:
exportResult();
break;
case 2:
shareLog();
break;
}

View File

@@ -107,4 +107,15 @@ class PatcherViewModel extends BaseViewModel {
'appSelectorCard.recommendedVersion',
)}: $recommendedVersion';
}
Future<void> loadLastSelectedPatches() async {
this.selectedPatches.clear();
List<String> selectedPatches =
await _managerAPI.getSelectedPatches(selectedApp!.originalPackageName);
List<Patch> patches =
await _patcherAPI.getFilteredPatches(selectedApp!.originalPackageName);
this.selectedPatches
.addAll(patches.where((patch) => selectedPatches.contains(patch.name)));
notifyListeners();
}
}

View File

@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.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';
import 'package:revanced_manager/ui/widgets/shared/search_bar.dart';
import 'package:stacked/stacked.dart';
@@ -25,7 +26,12 @@ class _PatchesSelectorViewState extends State<PatchesSelectorView> {
floatingActionButton: Visibility(
visible: model.patches.isNotEmpty,
child: FloatingActionButton.extended(
label: I18nText('patchesSelectorView.doneButton'),
label: Row(
children: <Widget>[
I18nText('patchesSelectorView.doneButton'),
Text(' (${model.selectedPatches.length})')
],
),
icon: const Icon(Icons.check),
onPressed: () {
model.selectPatches();
@@ -58,7 +64,7 @@ class _PatchesSelectorViewState extends State<PatchesSelectorView> {
actions: [
Container(
height: 2,
margin: const EdgeInsets.only(right: 16, top: 12, bottom: 12),
margin: const EdgeInsets.only(top: 12, bottom: 12),
padding:
const EdgeInsets.symmetric(horizontal: 6, vertical: 6),
decoration: BoxDecoration(
@@ -73,6 +79,22 @@ class _PatchesSelectorViewState extends State<PatchesSelectorView> {
),
),
),
CustomPopupMenu(
onSelected: (value) => {
model.onMenuSelection(value)
},
children: {
0: I18nText(
'patchesSelectorView.loadPatchesSelection',
child: const Text(
'',
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
),
},
),
],
bottom: PreferredSize(
preferredSize: const Size.fromHeight(64.0),

View File

@@ -5,6 +5,7 @@ import 'package:revanced_manager/models/patch.dart';
import 'package:revanced_manager/models/patched_application.dart';
import 'package:revanced_manager/services/manager_api.dart';
import 'package:revanced_manager/services/patcher_api.dart';
import 'package:revanced_manager/services/toast.dart';
import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart';
import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart';
import 'package:stacked/stacked.dart';
@@ -76,6 +77,7 @@ class PatchesSelectorViewModel extends BaseViewModel {
void selectPatches() {
locator<PatcherViewModel>().selectedPatches = selectedPatches;
saveSelectedPatches();
locator<PatcherViewModel>().notifyListeners();
}
@@ -117,4 +119,33 @@ class PatchesSelectorViewModel extends BaseViewModel {
pack.name == app.packageName &&
(pack.versions.isEmpty || pack.versions.contains(app.version)));
}
void onMenuSelection(value) {
switch (value) {
case 0:
loadSelectedPatches();
break;
}
}
Future<void> saveSelectedPatches() async {
List<String> selectedPatches =
this.selectedPatches.map((patch) => patch.name).toList();
await _managerAPI.setSelectedPatches(
locator<PatcherViewModel>().selectedApp!.originalPackageName,
selectedPatches);
}
Future<void> loadSelectedPatches() async {
List<String> selectedPatches = await _managerAPI.getSelectedPatches(
locator<PatcherViewModel>().selectedApp!.originalPackageName);
if (selectedPatches.isNotEmpty) {
this.selectedPatches.clear();
this.selectedPatches.addAll(
patches.where((patch) => selectedPatches.contains(patch.name)));
} else {
locator<Toast>().showBottom('patchesSelectorView.noSavedPatches');
}
notifyListeners();
}
}

View File

@@ -137,22 +137,22 @@ class SettingsView extends StatelessWidget {
onTap: () => model.showSourcesDialog(context),
),
CustomSwitchTile(
padding: const EdgeInsets.symmetric(horizontal: 20.0),
title: I18nText(
'settingsView.experimentalPatchesLabel',
child: const Text(
'',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
),
padding: const EdgeInsets.symmetric(horizontal: 20.0),
title: I18nText(
'settingsView.experimentalPatchesLabel',
child: const Text(
'',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
),
),
subtitle:
I18nText('settingsView.experimentalPatchesHint'),
value: model.areExperimentalPatchesEnabled(),
onTap: (value) =>
model.useExperimentalPatches(value)),
),
subtitle:
I18nText('settingsView.experimentalPatchesHint'),
value: model.areExperimentalPatchesEnabled(),
onTap: (value) => model.useExperimentalPatches(value),
),
ListTile(
contentPadding:
const EdgeInsets.symmetric(horizontal: 20.0),
@@ -204,6 +204,61 @@ class SettingsView extends StatelessWidget {
],
),
_settingsDivider,
SettingsSection(
title: 'settingsView.exportSectionTitle',
children: <Widget>[
ListTile(
contentPadding:
const EdgeInsets.symmetric(horizontal: 20.0),
title: I18nText(
'settingsView.exportPatchesLabel',
child: const Text(
'',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
),
),
),
subtitle: I18nText('settingsView.exportPatchesHint'),
onTap: () => model.exportPatches(),
),
ListTile(
contentPadding:
const EdgeInsets.symmetric(horizontal: 20.0),
title: I18nText(
'settingsView.importPatchesLabel',
child: const Text(
'',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
),
),
),
subtitle: I18nText('settingsView.importPatchesHint'),
onTap: () => model.importPatches(),
),
ListTile(
contentPadding:
const EdgeInsets.symmetric(horizontal: 20.0),
title: I18nText(
'settingsView.resetStoredPatchesLabel',
child: const Text(
'',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
),
),
),
subtitle:
I18nText('settingsView.resetStoredPatchesHint'),
onTap: () => model.resetSelectedPatches(),
),
],
),
_settingsDivider,
// SettingsSection(
// title: 'settingsView.logsSectionTitle',
// children: <Widget>[

View File

@@ -1,7 +1,9 @@
// ignore_for_file: use_build_context_synchronously
import 'dart:io';
import 'package:cr_file_saver/file_saver.dart';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:dynamic_themes/dynamic_themes.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_i18n/flutter_i18n.dart';
@@ -11,8 +13,10 @@ import 'package:revanced_manager/app/app.locator.dart';
import 'package:revanced_manager/app/app.router.dart';
import 'package:revanced_manager/services/manager_api.dart';
import 'package:revanced_manager/services/toast.dart';
import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart';
import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart';
import 'package:revanced_manager/ui/widgets/settingsView/custom_text_field.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:share_extend/share_extend.dart';
import 'package:stacked/stacked.dart';
import 'package:stacked_services/stacked_services.dart';
@@ -347,6 +351,60 @@ class SettingsViewModel extends BaseViewModel {
notifyListeners();
}
Future<void> exportPatches() async {
try {
File outFile = File(_managerAPI.storedPatchesFile);
if (outFile.existsSync()) {
String dateTime = DateTime.now()
.toString()
.replaceAll(' ', '_')
.split('.').first;
String tempFilePath = '${outFile.path.substring(0, outFile.path.lastIndexOf('/') + 1)}selected_patches_$dateTime.json';
outFile.copySync(tempFilePath);
await CRFileSaver.saveFileWithDialog(SaveFileDialogParams(
sourceFilePath: tempFilePath,
destinationFileName: ''
));
File(tempFilePath).delete();
locator<Toast>().showBottom('settingsView.exportedPatches');
} else {
locator<Toast>().showBottom('settingsView.noExportFileFound');
}
} on Exception catch (e, s) {
Sentry.captureException(e, stackTrace: s);
}
}
Future<void> importPatches() async {
try {
FilePickerResult? result = await FilePicker.platform.pickFiles(
type: FileType.custom,
allowedExtensions: ['json'],
);
if (result != null && result.files.single.path != null) {
File inFile = File(result.files.single.path!);
final File storedPatchesFile = File(_managerAPI.storedPatchesFile);
if (!storedPatchesFile.existsSync()) {
storedPatchesFile.createSync(recursive: true);
}
inFile.copySync(storedPatchesFile.path);
inFile.delete();
if (locator<PatcherViewModel>().selectedApp != null) {
locator<PatcherViewModel>().loadLastSelectedPatches();
}
locator<Toast>().showBottom('settingsView.importedPatches');
}
} on Exception catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
locator<Toast>().showBottom('settingsView.jsonSelectorErrorMessage');
}
}
void resetSelectedPatches() {
_managerAPI.resetLastSelectedPatches();
_toast.showBottom('settingsView.resetStoredPatches');
}
Future<int> getSdkVersion() async {
AndroidDeviceInfo info = await DeviceInfoPlugin().androidInfo;
return info.version.sdkInt ?? -1;

View File

@@ -20,17 +20,30 @@ class PatchSelectorCard extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
I18nText(
locator<PatcherViewModel>().selectedPatches.isEmpty
? 'patchSelectorCard.widgetTitle'
: 'patchSelectorCard.widgetTitleSelected',
child: const Text(
'',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w500,
Row(
children: <Widget>[
I18nText(
locator<PatcherViewModel>().selectedPatches.isEmpty
? 'patchSelectorCard.widgetTitle'
: 'patchSelectorCard.widgetTitleSelected',
child: const Text(
'',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w500,
),
),
),
),
Text(
locator<PatcherViewModel>().selectedPatches.isEmpty
? ''
: ' (${locator<PatcherViewModel>().selectedPatches.length})',
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.w500,
),
),
],
),
const SizedBox(height: 4),
locator<PatcherViewModel>().selectedApp == null

View File

@@ -53,7 +53,9 @@ class _PatchItemState extends State<PatchItem> {
: null,
onTap: () {
setState(() {
if (widget.isUnsupported) {
if (widget.isUnsupported &&
!widget._managerAPI.areExperimentalPatchesEnabled()
) {
widget.isSelected = false;
widget.toast.showBottom('patchItem.unsupportedPatchVersion');
} else {
@@ -123,9 +125,8 @@ class _PatchItemState extends State<PatchItem> {
onChanged: (newValue) {
setState(() {
if (widget.isUnsupported &&
widget._managerAPI
.areExperimentalPatchesEnabled() ==
false) {
!widget._managerAPI.areExperimentalPatchesEnabled()
) {
widget.isSelected = false;
widget.toast
.showBottom('patchItem.unsupportedPatchVersion');

View File

@@ -4,7 +4,7 @@ homepage: https://github.com/revanced/revanced-manager
publish_to: 'none'
version: 0.0.38+38
version: 0.0.40+40
environment:
sdk: ">=2.17.5 <3.0.0"
@@ -15,6 +15,7 @@ dependencies:
app_installer: ^1.1.0
collection: ^1.16.0
cross_connectivity: ^3.0.5
cr_file_saver: ^0.0.1+2
device_apps:
git:
url: https://github.com/ponces/flutter_plugin_device_apps