chore: merge dev to main (#1120)

This commit is contained in:
Ushie 2023-08-10 03:00:27 +03:00 committed by GitHub
commit c6a5f42d23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 72 additions and 5 deletions

View File

@ -10,6 +10,7 @@
"yesButton": "Yes",
"noButton": "No",
"warning": "Warning",
"notice": "Notice",
"new": "New",
"navigationView": {
"dashboardTab": "Dashboard",
@ -71,7 +72,8 @@
"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?",
"armv7WarningDialogText": "Patching on ARMv7 devices is not yet supported and might fail. Proceed anyways?",
"splitApkWarningDialogText": "Patching a split APK is not yet supported and might fail. Proceed anyways?"
"splitApkWarningDialogText": "Patching a split APK is not yet supported and might fail. Proceed anyways?",
"removedPatchesWarningDialogText": "The following patches have been removed since the last time you used them.\n\n{patches}\n\nProceed anyways?"
},
"appSelectorCard": {
"widgetTitle": "Select an application",
@ -198,6 +200,7 @@
"logsLabel": "Logs",
"logsHint": "Share Manager's logs",
"autoUpdatePatchesLabel": "Auto update patches",
"autoUpdatePatchesHint": "Automatically update ReVanced Patches to the latest version",
"experimentalUniversalPatchesLabel": "Experimental universal patches support",
"experimentalUniversalPatchesHint": "Display all applications to use with universal patches, loading list of apps may be slower",

View File

@ -104,7 +104,8 @@ class ManagerAPI {
}
List<Patch> getSavedPatches(String packageName) {
final List<String> patchesJson = _prefs.getStringList('savedPatches-$packageName') ?? [];
final List<String> patchesJson =
_prefs.getStringList('savedPatches-$packageName') ?? [];
final List<Patch> patches = patchesJson.map((String patchJson) {
return Patch.fromJson(jsonDecode(patchJson));
}).toList();
@ -118,6 +119,22 @@ class ManagerAPI {
await _prefs.setStringList('savedPatches-$packageName', patchesJson);
}
List<Patch> getUsedPatches(String packageName) {
final List<String> patchesJson =
_prefs.getStringList('usedPatches-$packageName') ?? [];
final List<Patch> patches = patchesJson.map((String patchJson) {
return Patch.fromJson(jsonDecode(patchJson));
}).toList();
return patches;
}
Future<void> setUsedPatches(List<Patch> patches, String packageName) async {
final List<String> patchesJson = patches.map((Patch patch) {
return jsonEncode(patch.toJson());
}).toList();
await _prefs.setStringList('usedPatches-$packageName', patchesJson);
}
String getIntegrationsRepo() {
return _prefs.getString('integrationsRepo') ?? defaultIntegrationsRepo;
}

View File

@ -153,6 +153,9 @@ class RootAPI {
}
Future<void> installServiceDScript(String packageName) async {
await Root.exec(
cmd: 'mkdir -p "$_serviceDDirPath"',
);
final String content = '#!/system/bin/sh\n'
'while [ "\$(getprop sys.boot_completed | tr -d \'"\'"\'\\\\r\'"\'"\')" != "1" ]; do sleep 3; done\n'
'base_path=$_revancedDirPath/$packageName/base.apk\n'
@ -166,6 +169,9 @@ class RootAPI {
}
Future<void> installPostFsDataScript(String packageName) async {
await Root.exec(
cmd: 'mkdir -p "$_postFsDataDirPath"',
);
final String content = '#!/system/bin/sh\n'
'stock_path=\$(pm path $packageName | grep base | sed \'"\'"\'s/package://g\'"\'"\')\n'
r'[ ! -z $stock_path ] && umount -l $stock_path';

View File

@ -101,6 +101,7 @@ class InstallerViewModel extends BaseViewModel {
_patcherAPI.getFilteredPatches(_app.packageName),
_app.packageName,
);
await _managerAPI.setUsedPatches(_patches, _app.packageName);
} else if (value == -100.0) {
isPatching = false;
hasErrors = true;

View File

@ -22,7 +22,7 @@ class PatcherView extends StatelessWidget {
child: FloatingActionButton.extended(
label: I18nText('patcherView.patchButton'),
icon: const Icon(Icons.build),
onPressed: () => model.showPatchConfirmationDialog(context),
onPressed: () => model.showRemovedPatchesDialog(context),
),
),
body: CustomScrollView(

View File

@ -22,6 +22,7 @@ class PatcherViewModel extends BaseViewModel {
final PatcherAPI _patcherAPI = locator<PatcherAPI>();
PatchedApplication? selectedApp;
List<Patch> selectedPatches = [];
List<String> removedPatches = [];
void navigateToAppSelector() {
_navigationService.navigateTo(Routes.appSelectorView);
@ -86,6 +87,38 @@ class PatcherViewModel extends BaseViewModel {
}
}
Future<void> showRemovedPatchesDialog(BuildContext context) async {
if (removedPatches.isNotEmpty) {
return showDialog(
context: context,
builder: (context) => AlertDialog(
title: I18nText('notice'),
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
content: I18nText(
'patcherView.removedPatchesWarningDialogText',
translationParams: {'patches': removedPatches.join('\n')},
),
actions: <Widget>[
CustomMaterialButton(
isFilled: false,
label: I18nText('noButton'),
onPressed: () => Navigator.of(context).pop(),
),
CustomMaterialButton(
label: I18nText('yesButton'),
onPressed: () {
Navigator.of(context).pop();
navigateToInstaller();
},
),
],
),
);
} else {
showArmv7WarningDialog(context);
}
}
Future<void> showArmv7WarningDialog(BuildContext context) async {
final bool armv7 = await AboutInfo.getInfo().then((info) {
final List<String> archs = info['supportedArch'];
@ -150,6 +183,7 @@ class PatcherViewModel extends BaseViewModel {
Future<void> loadLastSelectedPatches() async {
this.selectedPatches.clear();
removedPatches.clear();
final List<String> selectedPatches =
await _managerAPI.getSelectedPatches(selectedApp!.originalPackageName);
final List<Patch> patches =
@ -165,6 +199,12 @@ class PatcherViewModel extends BaseViewModel {
.selectedPatches
.removeWhere((patch) => patch.compatiblePackages.isEmpty);
}
final usedPatches = _managerAPI.getUsedPatches(selectedApp!.originalPackageName);
for (final patch in usedPatches){
if (!patches.any((p) => p.name == patch.name)){
removedPatches.add('\u2022 ${patch.name}');
}
}
notifyListeners();
}
}

View File

@ -117,7 +117,7 @@ class PatchesSelectorViewModel extends BaseViewModel {
return false;
} else {
return !savedPatches
.any((p) => p.name == patch.name.toLowerCase().replaceAll(' ', '-'));
.any((p) => p.getSimpleName() == patch.getSimpleName());
}
}

View File

@ -17,7 +17,7 @@ class _SAutoUpdatePatchesState extends State<SAutoUpdatePatches> {
return SwitchListTile(
contentPadding: const EdgeInsets.symmetric(horizontal: 20.0),
title: I18nText(
'homeView.patchesConsentDialogText3',
'settingsView.autoUpdatePatchesLabel',
child: const Text(
'',
style: TextStyle(