mirror of
https://github.com/ReVanced/revanced-manager.git
synced 2024-11-10 01:01:56 +01:00
feat: experimental settings to allow patch on any app version.
This commit is contained in:
parent
293f7150f1
commit
ba5234e850
6 changed files with 86 additions and 13 deletions
|
@ -84,7 +84,8 @@
|
|||
"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}\nCurrent supported versions:\n{supportedVersions}",
|
||||
"unsupportedPatchVersion": "Patch is not supported for this app version. Enable experimental toggle in settings to proceed."
|
||||
},
|
||||
"installerView": {
|
||||
"widgetTitle": "Installer",
|
||||
|
@ -132,6 +133,9 @@
|
|||
"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",
|
||||
"aboutLabel": "About",
|
||||
"snackbarMessage": "Copied to clipboard",
|
||||
"sentryLabel": "Sentry Logging",
|
||||
|
|
|
@ -90,6 +90,14 @@ class ManagerAPI {
|
|||
// await _prefs.setBool('sentryEnabled', value);
|
||||
// }
|
||||
|
||||
bool areExperimentalPatchesEnabled() {
|
||||
return _prefs.getBool('experimentalPatchesEnabled') ?? false;
|
||||
}
|
||||
|
||||
Future<void> enableExperimentalPatchesStatus(bool value) async {
|
||||
await _prefs.setBool('experimentalPatchesEnabled', value);
|
||||
}
|
||||
|
||||
Future<void> deleteTempFolder() async {
|
||||
final Directory dir = Directory('/data/local/tmp/revanced-manager');
|
||||
if (await dir.exists()) {
|
||||
|
|
|
@ -136,6 +136,23 @@ class SettingsView extends StatelessWidget {
|
|||
subtitle: 'settingsView.sourcesLabelHint',
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
subtitle:
|
||||
I18nText('settingsView.experimentalPatchesHint'),
|
||||
value: model.areExperimentalPatchesEnabled(),
|
||||
onTap: (value) =>
|
||||
model.useExperimentalPatches(value)),
|
||||
ListTile(
|
||||
contentPadding:
|
||||
const EdgeInsets.symmetric(horizontal: 20.0),
|
||||
|
|
|
@ -325,6 +325,16 @@ class SettingsViewModel extends BaseViewModel {
|
|||
// notifyListeners();
|
||||
// }
|
||||
|
||||
bool areExperimentalPatchesEnabled() {
|
||||
return _managerAPI.areExperimentalPatchesEnabled();
|
||||
}
|
||||
|
||||
void useExperimentalPatches(bool value) {
|
||||
_managerAPI.enableExperimentalPatchesStatus(value);
|
||||
_toast.showBottom('settingsView.enabledExperimentalPatches');
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void deleteKeystore() {
|
||||
_managerAPI.deleteKeystore();
|
||||
_toast.showBottom('settingsView.deletedKeystore');
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_i18n/flutter_i18n.dart';
|
||||
import 'package:revanced_manager/app/app.locator.dart';
|
||||
import 'package:revanced_manager/services/manager_api.dart';
|
||||
import 'package:revanced_manager/services/toast.dart';
|
||||
import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart';
|
||||
import 'package:revanced_manager/ui/widgets/shared/custom_card.dart';
|
||||
|
||||
|
@ -15,6 +18,8 @@ class PatchItem extends StatefulWidget {
|
|||
bool isSelected;
|
||||
final Function(bool) onChanged;
|
||||
final Widget? child;
|
||||
final toast = locator<Toast>();
|
||||
final _managerAPI = locator<ManagerAPI>();
|
||||
|
||||
PatchItem(
|
||||
{Key? key,
|
||||
|
@ -40,8 +45,21 @@ class _PatchItemState extends State<PatchItem> {
|
|||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4.0),
|
||||
child: CustomCard(
|
||||
backgroundColor: widget.isUnsupported &&
|
||||
widget._managerAPI.areExperimentalPatchesEnabled() == false
|
||||
? Theme.of(context).colorScheme.brightness == Brightness.light
|
||||
? Colors.grey[400]
|
||||
: Colors.grey[700]
|
||||
: null,
|
||||
onTap: () {
|
||||
setState(() => widget.isSelected = !widget.isSelected);
|
||||
setState(() {
|
||||
if (widget.isUnsupported) {
|
||||
widget.isSelected = false;
|
||||
widget.toast.showBottom('patchItem.unsupportedPatchVersion');
|
||||
} else {
|
||||
widget.isSelected = !widget.isSelected;
|
||||
}
|
||||
});
|
||||
widget.onChanged(widget.isSelected);
|
||||
},
|
||||
child: Column(
|
||||
|
@ -83,7 +101,9 @@ class _PatchItemState extends State<PatchItem> {
|
|||
overflow: TextOverflow.visible,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Theme.of(context).colorScheme.onSecondaryContainer,
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.onSecondaryContainer,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
@ -101,7 +121,18 @@ class _PatchItemState extends State<PatchItem> {
|
|||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
onChanged: (newValue) {
|
||||
setState(() => widget.isSelected = newValue!);
|
||||
setState(() {
|
||||
if (widget.isUnsupported &&
|
||||
widget._managerAPI
|
||||
.areExperimentalPatchesEnabled() ==
|
||||
false) {
|
||||
widget.isSelected = false;
|
||||
widget.toast
|
||||
.showBottom('patchItem.unsupportedPatchVersion');
|
||||
} else {
|
||||
widget.isSelected = newValue!;
|
||||
}
|
||||
});
|
||||
widget.onChanged(widget.isSelected);
|
||||
},
|
||||
),
|
||||
|
|
|
@ -5,22 +5,25 @@ class CustomCard extends StatelessWidget {
|
|||
final Widget child;
|
||||
final Function()? onTap;
|
||||
final EdgeInsetsGeometry? padding;
|
||||
final Color? backgroundColor;
|
||||
|
||||
const CustomCard({
|
||||
Key? key,
|
||||
this.isFilled = true,
|
||||
required this.child,
|
||||
this.onTap,
|
||||
this.padding,
|
||||
}) : super(key: key);
|
||||
const CustomCard(
|
||||
{Key? key,
|
||||
this.isFilled = true,
|
||||
required this.child,
|
||||
this.onTap,
|
||||
this.padding,
|
||||
this.backgroundColor})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Material(
|
||||
type: isFilled ? MaterialType.card : MaterialType.transparency,
|
||||
color: isFilled
|
||||
? Theme.of(context).colorScheme.secondaryContainer.withOpacity(0.4)
|
||||
: Colors.transparent,
|
||||
? backgroundColor?.withOpacity(0.4) ??
|
||||
Theme.of(context).colorScheme.secondaryContainer.withOpacity(0.4)
|
||||
: backgroundColor ?? Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
|
|
Loading…
Reference in a new issue