Skip to content

Commit

Permalink
refactor: Apply changes from suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAabedKhan committed Oct 23, 2024
1 parent 8021b9f commit 94a728f
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
12 changes: 6 additions & 6 deletions assets/i18n/strings.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,12 @@
"deleteTempDirLabel": "Delete temporary files",
"deleteTempDirHint": "Delete unused temporary files",
"deletedTempDir": "Temporary files deleted",
"exportManagerSettingsLabel": "Export manager settings",
"exportManagerSettingsHint": "Export manager settings to a JSON file",
"exportedManagerSettings": "Manager settings exported",
"importManagerSettingsLabel": "Import manager settings",
"importManagerSettingsHint": "Import manager settings from a JSON file",
"importedManagerSettings": "Manager settings imported",
"exportSettingsLabel": "Export settings",
"exportSettingsHint": "Export settings to a JSON file",
"exportedSettings": "Settings exported",
"importSettingsLabel": "Import settings",
"importSettingsHint": "Import settings from a JSON file",
"importedSettings": "Settings imported",
"exportPatchesLabel": "Export patch selection",
"exportPatchesHint": "Export patch selection to a JSON file",
"exportedPatches": "Patch selection exported",
Expand Down
1 change: 1 addition & 0 deletions docs/2_4_settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Learn how to configure ReVanced Manager.
- 🔑 Keystore used to sign patched apps
- 📄 Remembered selection of patches for each app
- ⚙️ Remembered patch options
- 🛠️ Remembered settings

> ℹ️ Note
> These can be used to backup and restore or reset settings to default in case of issues.
Expand Down
4 changes: 2 additions & 2 deletions lib/services/manager_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ class ManagerAPI {
return jsonDecode(string);
}

String exportManagerSettings() {
String exportSettings() {
final Map<String, dynamic> settings = _prefs
.getKeys()
.fold<Map<String, dynamic>>({}, (Map<String, dynamic> map, String key) {
Expand All @@ -827,7 +827,7 @@ class ManagerAPI {
return jsonEncode(settings);
}

Future<void> importManagerSettings(String settings) async {
Future<void> importSettings(String settings) async {
final Map<String, dynamic> settingsMap = jsonDecode(settings);
settingsMap.forEach((key, value) {
if (value is bool) {
Expand Down
12 changes: 6 additions & 6 deletions lib/ui/views/settings/settings_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,9 @@ class SettingsViewModel extends BaseViewModel {
notifyListeners();
}

Future<void> exportManagerSettings() async {
Future<void> exportSettings() async {
try {
final String settings = _managerAPI.exportManagerSettings();
final String settings = _managerAPI.exportSettings();
final Directory tempDir = await getTemporaryDirectory();
final String filePath = '${tempDir.path}/manager_settings.json';
final File file = File(filePath);
Expand All @@ -237,7 +237,7 @@ class SettingsViewModel extends BaseViewModel {
),
);
if (result != null) {
_toast.showBottom(t.settingsView.exportedManagerSettings);
_toast.showBottom(t.settingsView.exportedSettings);
}
} on Exception catch (e) {
if (kDebugMode) {
Expand All @@ -246,7 +246,7 @@ class SettingsViewModel extends BaseViewModel {
}
}

Future<void> importManagerSettings() async {
Future<void> importSettings() async {
try {
final String? result = await FlutterFileDialog.pickFile(
params: const OpenFileDialogParams(
Expand All @@ -257,8 +257,8 @@ class SettingsViewModel extends BaseViewModel {
final File inFile = File(result);
final String settings = inFile.readAsStringSync();
inFile.delete();
_managerAPI.importManagerSettings(settings);
_toast.showBottom(t.settingsView.importedManagerSettings);
_managerAPI.importSettings(settings);
_toast.showBottom(t.settingsView.importedSettings);
_toast.showBottom(t.settingsView.restartAppForChanges);
}
} on Exception catch (e) {
Expand Down
12 changes: 6 additions & 6 deletions lib/ui/widgets/settingsView/settings_export_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,26 @@ class SExportSection extends StatelessWidget {
ListTile(
contentPadding: const EdgeInsets.symmetric(horizontal: 20.0),
title: Text(
t.settingsView.exportManagerSettingsLabel,
t.settingsView.exportSettingsLabel,
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
),
),
subtitle: Text(t.settingsView.exportManagerSettingsHint),
onTap: () => _settingsViewModel.exportManagerSettings(),
subtitle: Text(t.settingsView.exportSettingsHint),
onTap: () => _settingsViewModel.exportSettings(),
),
ListTile(
contentPadding: const EdgeInsets.symmetric(horizontal: 20.0),
title: Text(
t.settingsView.importManagerSettingsLabel,
t.settingsView.importSettingsLabel,
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
),
),
subtitle: Text(t.settingsView.importManagerSettingsHint),
onTap: () => _settingsViewModel.importManagerSettings(),
subtitle: Text(t.settingsView.importSettingsHint),
onTap: () => _settingsViewModel.importSettings(),
),
ListTile(
contentPadding: const EdgeInsets.symmetric(horizontal: 20.0),
Expand Down

0 comments on commit 94a728f

Please sign in to comment.