2022-11-12 16:55:33 +01:00
|
|
|
import 'package:flutter/material.dart';
|
2024-02-12 00:22:25 +01:00
|
|
|
import 'package:revanced_manager/gen/strings.g.dart';
|
2023-04-18 11:38:10 +02:00
|
|
|
import 'package:revanced_manager/ui/views/settings/settingsFragment/settings_manage_keystore_password.dart';
|
2023-04-18 22:02:43 +02:00
|
|
|
import 'package:revanced_manager/ui/views/settings/settings_viewmodel.dart';
|
2022-11-12 16:55:33 +01:00
|
|
|
import 'package:revanced_manager/ui/widgets/settingsView/settings_section.dart';
|
|
|
|
|
|
|
|
final _settingsViewModel = SettingsViewModel();
|
|
|
|
|
|
|
|
class SExportSection extends StatelessWidget {
|
|
|
|
const SExportSection({super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return SettingsSection(
|
2024-02-12 00:22:25 +01:00
|
|
|
title: t.settingsView.exportSectionTitle,
|
2022-11-12 16:55:33 +01:00
|
|
|
children: <Widget>[
|
|
|
|
ListTile(
|
|
|
|
contentPadding: const EdgeInsets.symmetric(horizontal: 20.0),
|
2024-02-12 00:22:25 +01:00
|
|
|
title: Text(
|
|
|
|
t.settingsView.exportPatchesLabel,
|
|
|
|
style: const TextStyle(
|
|
|
|
fontSize: 20,
|
|
|
|
fontWeight: FontWeight.w500,
|
2022-11-12 16:55:33 +01:00
|
|
|
),
|
|
|
|
),
|
2024-02-12 00:22:25 +01:00
|
|
|
subtitle: Text(t.settingsView.exportPatchesHint),
|
2022-11-12 16:55:33 +01:00
|
|
|
onTap: () => _settingsViewModel.exportPatches(),
|
|
|
|
),
|
|
|
|
ListTile(
|
|
|
|
contentPadding: const EdgeInsets.symmetric(horizontal: 20.0),
|
2024-02-12 00:22:25 +01:00
|
|
|
title: Text(
|
|
|
|
t.settingsView.importPatchesLabel,
|
|
|
|
style: const TextStyle(
|
|
|
|
fontSize: 20,
|
|
|
|
fontWeight: FontWeight.w500,
|
2022-11-12 16:55:33 +01:00
|
|
|
),
|
|
|
|
),
|
2024-02-12 00:22:25 +01:00
|
|
|
subtitle: Text(t.settingsView.importPatchesHint),
|
2023-08-15 11:05:27 +02:00
|
|
|
onTap: () => _settingsViewModel.importPatches(context),
|
2022-11-12 16:55:33 +01:00
|
|
|
),
|
2023-04-18 11:38:10 +02:00
|
|
|
ListTile(
|
|
|
|
contentPadding: const EdgeInsets.symmetric(horizontal: 20.0),
|
2024-02-12 00:22:25 +01:00
|
|
|
title: Text(
|
|
|
|
t.settingsView.resetStoredPatchesLabel,
|
|
|
|
style: const TextStyle(
|
|
|
|
fontSize: 20,
|
|
|
|
fontWeight: FontWeight.w500,
|
2023-04-18 11:38:10 +02:00
|
|
|
),
|
|
|
|
),
|
2024-02-12 00:22:25 +01:00
|
|
|
subtitle: Text(t.settingsView.resetStoredPatchesHint),
|
2023-10-15 11:56:02 +02:00
|
|
|
onTap: () => _showResetDialog(
|
|
|
|
context,
|
2024-02-12 00:22:25 +01:00
|
|
|
t.settingsView.resetStoredPatchesDialogTitle,
|
|
|
|
t.settingsView.resetStoredPatchesDialogText,
|
2023-10-15 11:56:02 +02:00
|
|
|
_settingsViewModel.resetSelectedPatches,
|
|
|
|
),
|
2023-04-18 11:38:10 +02:00
|
|
|
),
|
|
|
|
ListTile(
|
|
|
|
contentPadding: const EdgeInsets.symmetric(horizontal: 20.0),
|
2024-02-12 00:22:25 +01:00
|
|
|
title: Text(
|
|
|
|
t.settingsView.resetStoredOptionsLabel,
|
|
|
|
style: const TextStyle(
|
|
|
|
fontSize: 20,
|
|
|
|
fontWeight: FontWeight.w500,
|
2023-04-18 11:38:10 +02:00
|
|
|
),
|
|
|
|
),
|
2024-02-12 00:22:25 +01:00
|
|
|
subtitle: Text(t.settingsView.resetStoredOptionsHint),
|
2023-10-15 11:56:02 +02:00
|
|
|
onTap: () => _showResetDialog(
|
|
|
|
context,
|
2024-02-12 00:22:25 +01:00
|
|
|
t.settingsView.resetStoredOptionsDialogTitle,
|
|
|
|
t.settingsView.resetStoredOptionsDialogText,
|
2023-10-15 11:56:02 +02:00
|
|
|
_settingsViewModel.resetAllOptions,
|
|
|
|
),
|
2023-04-18 11:38:10 +02:00
|
|
|
),
|
2022-11-12 16:55:33 +01:00
|
|
|
ListTile(
|
|
|
|
contentPadding: const EdgeInsets.symmetric(horizontal: 20.0),
|
2024-02-12 00:22:25 +01:00
|
|
|
title: Text(
|
|
|
|
t.settingsView.exportKeystoreLabel,
|
|
|
|
style: const TextStyle(
|
|
|
|
fontSize: 20,
|
|
|
|
fontWeight: FontWeight.w500,
|
2022-11-12 16:55:33 +01:00
|
|
|
),
|
|
|
|
),
|
2024-02-12 00:22:25 +01:00
|
|
|
subtitle: Text(t.settingsView.exportKeystoreHint),
|
2023-10-15 11:56:02 +02:00
|
|
|
onTap: () => _settingsViewModel.exportKeystore(),
|
2023-10-12 02:00:39 +02:00
|
|
|
),
|
|
|
|
ListTile(
|
|
|
|
contentPadding: const EdgeInsets.symmetric(horizontal: 20.0),
|
2024-02-12 00:22:25 +01:00
|
|
|
title: Text(
|
|
|
|
t.settingsView.importKeystoreLabel,
|
|
|
|
style: const TextStyle(
|
|
|
|
fontSize: 20,
|
|
|
|
fontWeight: FontWeight.w500,
|
2023-10-12 02:00:39 +02:00
|
|
|
),
|
|
|
|
),
|
2024-02-12 00:22:25 +01:00
|
|
|
subtitle: Text(t.settingsView.importKeystoreHint),
|
2023-10-15 11:56:02 +02:00
|
|
|
onTap: () async {
|
|
|
|
await _settingsViewModel.importKeystore();
|
|
|
|
final sManageKeystorePassword = SManageKeystorePassword();
|
|
|
|
if (context.mounted) {
|
|
|
|
sManageKeystorePassword.showKeystoreDialog(context);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
),
|
|
|
|
ListTile(
|
|
|
|
contentPadding: const EdgeInsets.symmetric(horizontal: 20.0),
|
2024-02-12 00:22:25 +01:00
|
|
|
title: Text(
|
|
|
|
t.settingsView.regenerateKeystoreLabel,
|
|
|
|
style: const TextStyle(
|
|
|
|
fontSize: 20,
|
|
|
|
fontWeight: FontWeight.w500,
|
2023-10-15 11:56:02 +02:00
|
|
|
),
|
2023-10-12 02:00:39 +02:00
|
|
|
),
|
2024-02-12 00:22:25 +01:00
|
|
|
subtitle: Text(t.settingsView.regenerateKeystoreHint),
|
2023-10-15 11:56:02 +02:00
|
|
|
onTap: () => _showDeleteKeystoreDialog(context),
|
2022-11-12 16:55:33 +01:00
|
|
|
),
|
2023-10-15 11:56:02 +02:00
|
|
|
// SManageKeystorePasswordUI(),
|
2022-11-12 16:55:33 +01:00
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
2023-07-08 06:01:10 +02:00
|
|
|
|
2023-10-12 02:00:39 +02:00
|
|
|
Future<void> _showResetDialog(
|
|
|
|
context,
|
|
|
|
dialogTitle,
|
|
|
|
dialogText,
|
|
|
|
dialogAction,
|
|
|
|
) {
|
2023-07-08 06:01:10 +02:00
|
|
|
return showDialog(
|
|
|
|
context: context,
|
|
|
|
builder: (context) => AlertDialog(
|
2024-02-12 00:22:25 +01:00
|
|
|
title: Text(dialogTitle),
|
|
|
|
content: Text(dialogText),
|
2023-07-08 06:01:10 +02:00
|
|
|
actions: <Widget>[
|
2023-12-22 14:34:03 +01:00
|
|
|
TextButton(
|
2023-07-08 06:01:10 +02:00
|
|
|
onPressed: () => Navigator.of(context).pop(),
|
2024-02-12 00:22:25 +01:00
|
|
|
child: Text(t.noButton),
|
2023-07-08 06:01:10 +02:00
|
|
|
),
|
2023-12-22 14:34:03 +01:00
|
|
|
FilledButton(
|
2023-07-08 06:01:10 +02:00
|
|
|
onPressed: () => {
|
|
|
|
Navigator.of(context).pop(),
|
2023-10-12 02:00:39 +02:00
|
|
|
dialogAction(),
|
2023-07-08 06:01:10 +02:00
|
|
|
},
|
2024-02-12 00:22:25 +01:00
|
|
|
child: Text(t.yesButton),
|
2023-08-06 09:39:46 +02:00
|
|
|
),
|
2023-07-08 06:01:10 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2023-10-15 11:56:02 +02:00
|
|
|
|
|
|
|
Future<void> _showDeleteKeystoreDialog(context) {
|
|
|
|
return showDialog(
|
|
|
|
context: context,
|
|
|
|
builder: (context) => AlertDialog(
|
2024-02-12 00:22:25 +01:00
|
|
|
title: Text(t.settingsView.regenerateKeystoreDialogTitle),
|
|
|
|
content: Text(t.settingsView.regenerateKeystoreDialogText),
|
2023-10-15 11:56:02 +02:00
|
|
|
actions: <Widget>[
|
2023-12-22 14:34:03 +01:00
|
|
|
TextButton(
|
2023-10-15 11:56:02 +02:00
|
|
|
onPressed: () => Navigator.of(context).pop(),
|
2024-02-12 00:22:25 +01:00
|
|
|
child: Text(t.noButton),
|
2023-10-15 11:56:02 +02:00
|
|
|
),
|
2023-12-22 14:34:03 +01:00
|
|
|
FilledButton(
|
2023-10-15 11:56:02 +02:00
|
|
|
onPressed: () => {
|
|
|
|
Navigator.of(context).pop(),
|
|
|
|
_settingsViewModel.deleteKeystore(),
|
|
|
|
},
|
2024-02-12 00:22:25 +01:00
|
|
|
child: Text(t.yesButton),
|
2023-10-15 11:56:02 +02:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2022-11-12 16:55:33 +01:00
|
|
|
}
|