mirror of
https://github.com/revanced/revanced-manager
synced 2024-05-14 13:56:57 +02:00
feat(patcher-view): show notice for removed patches that were used previously (#1107)
This commit is contained in:
parent
ea05d13a1f
commit
acec064cb7
@ -10,6 +10,7 @@
|
|||||||
"yesButton": "Yes",
|
"yesButton": "Yes",
|
||||||
"noButton": "No",
|
"noButton": "No",
|
||||||
"warning": "Warning",
|
"warning": "Warning",
|
||||||
|
"notice": "Notice",
|
||||||
"new": "New",
|
"new": "New",
|
||||||
"navigationView": {
|
"navigationView": {
|
||||||
"dashboardTab": "Dashboard",
|
"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?",
|
"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?",
|
"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": {
|
"appSelectorCard": {
|
||||||
"widgetTitle": "Select an application",
|
"widgetTitle": "Select an application",
|
||||||
|
@ -104,7 +104,8 @@ class ManagerAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<Patch> getSavedPatches(String packageName) {
|
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) {
|
final List<Patch> patches = patchesJson.map((String patchJson) {
|
||||||
return Patch.fromJson(jsonDecode(patchJson));
|
return Patch.fromJson(jsonDecode(patchJson));
|
||||||
}).toList();
|
}).toList();
|
||||||
@ -118,6 +119,22 @@ class ManagerAPI {
|
|||||||
await _prefs.setStringList('savedPatches-$packageName', patchesJson);
|
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() {
|
String getIntegrationsRepo() {
|
||||||
return _prefs.getString('integrationsRepo') ?? defaultIntegrationsRepo;
|
return _prefs.getString('integrationsRepo') ?? defaultIntegrationsRepo;
|
||||||
}
|
}
|
||||||
|
@ -101,6 +101,7 @@ class InstallerViewModel extends BaseViewModel {
|
|||||||
_patcherAPI.getFilteredPatches(_app.packageName),
|
_patcherAPI.getFilteredPatches(_app.packageName),
|
||||||
_app.packageName,
|
_app.packageName,
|
||||||
);
|
);
|
||||||
|
await _managerAPI.setUsedPatches(_patches, _app.packageName);
|
||||||
} else if (value == -100.0) {
|
} else if (value == -100.0) {
|
||||||
isPatching = false;
|
isPatching = false;
|
||||||
hasErrors = true;
|
hasErrors = true;
|
||||||
|
@ -22,7 +22,7 @@ class PatcherView extends StatelessWidget {
|
|||||||
child: FloatingActionButton.extended(
|
child: FloatingActionButton.extended(
|
||||||
label: I18nText('patcherView.patchButton'),
|
label: I18nText('patcherView.patchButton'),
|
||||||
icon: const Icon(Icons.build),
|
icon: const Icon(Icons.build),
|
||||||
onPressed: () => model.showPatchConfirmationDialog(context),
|
onPressed: () => model.showRemovedPatchesDialog(context),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
body: CustomScrollView(
|
body: CustomScrollView(
|
||||||
|
@ -22,6 +22,7 @@ class PatcherViewModel extends BaseViewModel {
|
|||||||
final PatcherAPI _patcherAPI = locator<PatcherAPI>();
|
final PatcherAPI _patcherAPI = locator<PatcherAPI>();
|
||||||
PatchedApplication? selectedApp;
|
PatchedApplication? selectedApp;
|
||||||
List<Patch> selectedPatches = [];
|
List<Patch> selectedPatches = [];
|
||||||
|
List<String> removedPatches = [];
|
||||||
|
|
||||||
void navigateToAppSelector() {
|
void navigateToAppSelector() {
|
||||||
_navigationService.navigateTo(Routes.appSelectorView);
|
_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 {
|
Future<void> showArmv7WarningDialog(BuildContext context) async {
|
||||||
final bool armv7 = await AboutInfo.getInfo().then((info) {
|
final bool armv7 = await AboutInfo.getInfo().then((info) {
|
||||||
final List<String> archs = info['supportedArch'];
|
final List<String> archs = info['supportedArch'];
|
||||||
@ -150,6 +183,7 @@ class PatcherViewModel extends BaseViewModel {
|
|||||||
|
|
||||||
Future<void> loadLastSelectedPatches() async {
|
Future<void> loadLastSelectedPatches() async {
|
||||||
this.selectedPatches.clear();
|
this.selectedPatches.clear();
|
||||||
|
removedPatches.clear();
|
||||||
final List<String> selectedPatches =
|
final List<String> selectedPatches =
|
||||||
await _managerAPI.getSelectedPatches(selectedApp!.originalPackageName);
|
await _managerAPI.getSelectedPatches(selectedApp!.originalPackageName);
|
||||||
final List<Patch> patches =
|
final List<Patch> patches =
|
||||||
@ -165,6 +199,12 @@ class PatcherViewModel extends BaseViewModel {
|
|||||||
.selectedPatches
|
.selectedPatches
|
||||||
.removeWhere((patch) => patch.compatiblePackages.isEmpty);
|
.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();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user