mirror of
https://github.com/revanced/revanced-manager
synced 2024-05-14 13:56:57 +02:00
Added setting
This commit is contained in:
parent
8ac25bfb40
commit
cebf97464d
@ -239,6 +239,9 @@
|
||||
"universalPatchesLabel": "Show universal patches",
|
||||
"universalPatchesHint": "Display all apps and universal patches (may slow down the app list)",
|
||||
|
||||
"patchHistoryLabel": "Save patched app",
|
||||
"patchHistoryHint": "Save the last patched app to install/export later",
|
||||
|
||||
"versionCompatibilityCheckLabel": "Version compatibility check",
|
||||
"versionCompatibilityCheckHint": "Restricts patches to supported app versions",
|
||||
"requireSuggestedAppVersionLabel": "Require suggested app version",
|
||||
|
@ -268,6 +268,14 @@ class ManagerAPI {
|
||||
await _prefs.setBool('requireSuggestedAppVersionEnabled', value);
|
||||
}
|
||||
|
||||
bool isPatchHistoryEnabled() {
|
||||
return _prefs.getBool('patchHistoryEnabled') ?? true;
|
||||
}
|
||||
|
||||
Future<void> enablePatchHistoryStatus(bool value) async {
|
||||
await _prefs.setBool('patchHistoryEnabled', value);
|
||||
}
|
||||
|
||||
Future<void> setKeystorePassword(String password) async {
|
||||
await _prefs.setString('keystorePassword', password);
|
||||
}
|
||||
|
@ -51,6 +51,11 @@ class HomeView extends StatelessWidget {
|
||||
const SizedBox(height: 10),
|
||||
LatestCommitCard(model: model, parentContext: context),
|
||||
const SizedBox(height: 23),
|
||||
Visibility(
|
||||
visible: model.isPatchHistoryEnabled(),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
I18nText(
|
||||
'homeView.patchHistorySubtitle',
|
||||
child: Text(
|
||||
@ -61,6 +66,10 @@ class HomeView extends StatelessWidget {
|
||||
const SizedBox(height: 10),
|
||||
PatchHistoryCard(),
|
||||
const SizedBox(height: 10),
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
I18nText(
|
||||
'homeView.patchedSubtitle',
|
||||
child: Text(
|
||||
|
@ -112,6 +112,10 @@ class HomeViewModel extends BaseViewModel {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
bool isPatchHistoryEnabled() {
|
||||
return _managerAPI.isPatchHistoryEnabled();
|
||||
}
|
||||
|
||||
Future<bool> hasManagerUpdates() async {
|
||||
String currentVersion = await _managerAPI.getCurrentManagerVersion();
|
||||
|
||||
|
@ -147,7 +147,11 @@ class InstallerViewModel extends BaseViewModel {
|
||||
_patches,
|
||||
);
|
||||
_app.appliedPatches = _patches.map((p) => p.name).toList();
|
||||
if (_managerAPI.isPatchHistoryEnabled()) {
|
||||
await _managerAPI.setLastPatchedApp(_app, _patcherAPI.outFile!);
|
||||
} else {
|
||||
_app.patchedFilePath = _patcherAPI.outFile!.path;
|
||||
}
|
||||
locator<HomeViewModel>().initialize(context);
|
||||
} on Exception catch (e) {
|
||||
update(
|
||||
|
@ -131,6 +131,18 @@ class SettingsViewModel extends BaseViewModel {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
bool isPatchHistoryEnabled() {
|
||||
return _managerAPI.isPatchHistoryEnabled();
|
||||
}
|
||||
|
||||
void usePatchHistory(bool value) {
|
||||
_managerAPI.enablePatchHistoryStatus(value);
|
||||
if (!value) {
|
||||
_managerAPI.deleteLastPatchedApp();
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
bool isVersionCompatibilityCheckEnabled() {
|
||||
return _managerAPI.isVersionCompatibilityCheckEnabled();
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import 'package:revanced_manager/ui/views/settings/settingsFragment/settings_man
|
||||
import 'package:revanced_manager/ui/views/settings/settingsFragment/settings_manage_sources.dart';
|
||||
import 'package:revanced_manager/ui/widgets/settingsView/settings_auto_update_patches.dart';
|
||||
import 'package:revanced_manager/ui/widgets/settingsView/settings_enable_patches_selection.dart';
|
||||
import 'package:revanced_manager/ui/widgets/settingsView/settings_patch_history.dart';
|
||||
import 'package:revanced_manager/ui/widgets/settingsView/settings_require_suggested_app_version.dart';
|
||||
import 'package:revanced_manager/ui/widgets/settingsView/settings_section.dart';
|
||||
import 'package:revanced_manager/ui/widgets/settingsView/settings_universal_patches.dart';
|
||||
@ -24,6 +25,7 @@ class SAdvancedSection extends StatelessWidget {
|
||||
SRequireSuggestedAppVersion(),
|
||||
SVersionCompatibilityCheck(),
|
||||
SUniversalPatches(),
|
||||
SPatchHistory(),
|
||||
SManageSourcesUI(),
|
||||
SManageApiUrlUI(),
|
||||
],
|
||||
|
40
lib/ui/widgets/settingsView/settings_patch_history.dart
Normal file
40
lib/ui/widgets/settingsView/settings_patch_history.dart
Normal file
@ -0,0 +1,40 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_i18n/widgets/I18nText.dart';
|
||||
import 'package:revanced_manager/ui/views/settings/settings_viewmodel.dart';
|
||||
|
||||
class SPatchHistory extends StatefulWidget {
|
||||
const SPatchHistory({super.key});
|
||||
|
||||
@override
|
||||
State<SPatchHistory> createState() =>
|
||||
_SPatchHistoryState();
|
||||
}
|
||||
|
||||
final _settingsViewModel = SettingsViewModel();
|
||||
|
||||
class _SPatchHistoryState
|
||||
extends State<SPatchHistory> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SwitchListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 20.0),
|
||||
title: I18nText(
|
||||
'settingsView.patchHistoryLabel',
|
||||
child: const Text(
|
||||
'',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
subtitle: I18nText('settingsView.patchHistoryHint'),
|
||||
value: _settingsViewModel.isPatchHistoryEnabled(),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_settingsViewModel.usePatchHistory(value);
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user