add various engine settings
This commit is contained in:
@@ -25,7 +25,9 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:weblibre/core/routing/routes.dart';
|
||||
import 'package:weblibre/features/settings/presentation/controllers/save_settings.dart';
|
||||
import 'package:weblibre/features/settings/presentation/widgets/sections.dart';
|
||||
import 'package:weblibre/features/user/data/models/engine_settings.dart';
|
||||
import 'package:weblibre/features/user/data/models/general_settings.dart';
|
||||
import 'package:weblibre/features/user/domain/repositories/engine_settings.dart';
|
||||
import 'package:weblibre/features/user/domain/repositories/general_settings.dart';
|
||||
|
||||
class AppearanceDisplaySettingsScreen extends StatelessWidget {
|
||||
@@ -44,6 +46,7 @@ class AppearanceDisplaySettingsScreen extends StatelessWidget {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12.0),
|
||||
children: const [
|
||||
_VisualSection(),
|
||||
_WebContentSection(),
|
||||
_TabBarSection(),
|
||||
_TabViewSection(),
|
||||
_GesturesSection(),
|
||||
@@ -402,3 +405,226 @@ class _DoubleBackCloseTabTile extends HookConsumerWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _WebContentSection extends StatelessWidget {
|
||||
const _WebContentSection();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const Column(
|
||||
children: [
|
||||
SettingSection(name: 'Web Content'),
|
||||
_WebFontsEnabledTile(),
|
||||
_AutomaticFontSizeAdjustmentTile(),
|
||||
_FontSizeFactorSlider(),
|
||||
_FontInflationTile(),
|
||||
_InputAutoZoomEnabledTile(),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _WebFontsEnabledTile extends HookConsumerWidget {
|
||||
const _WebFontsEnabledTile();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final webFontsEnabled = ref.watch(
|
||||
engineSettingsWithDefaultsProvider.select((s) => s.webFontsEnabled),
|
||||
);
|
||||
|
||||
return SwitchListTile.adaptive(
|
||||
title: const Text('Web Fonts'),
|
||||
subtitle: const Text('Allow websites to use custom fonts'),
|
||||
secondary: const Icon(MdiIcons.formatFont),
|
||||
value: webFontsEnabled,
|
||||
onChanged: (value) async {
|
||||
await ref
|
||||
.read(saveEngineSettingsControllerProvider.notifier)
|
||||
.save(
|
||||
(currentSettings) =>
|
||||
currentSettings.copyWith.webFontsEnabled(value),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _AutomaticFontSizeAdjustmentTile extends HookConsumerWidget {
|
||||
const _AutomaticFontSizeAdjustmentTile();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final automaticFontSizeAdjustment = ref.watch(
|
||||
engineSettingsWithDefaultsProvider.select(
|
||||
(s) => s.automaticFontSizeAdjustment,
|
||||
),
|
||||
);
|
||||
|
||||
return SwitchListTile.adaptive(
|
||||
title: const Text('Automatic Font Size'),
|
||||
subtitle: const Text(
|
||||
'Automatically adjust font size based on system settings. Disable to manually control font size factor and inflation.',
|
||||
),
|
||||
secondary: const Icon(MdiIcons.formatFontSizeIncrease),
|
||||
value: automaticFontSizeAdjustment,
|
||||
onChanged: (value) async {
|
||||
await ref
|
||||
.read(saveEngineSettingsControllerProvider.notifier)
|
||||
.save(
|
||||
(currentSettings) =>
|
||||
currentSettings.copyWith.automaticFontSizeAdjustment(value),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _FontSizeFactorSlider extends HookConsumerWidget {
|
||||
const _FontSizeFactorSlider();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final automaticFontSizeAdjustment = ref.watch(
|
||||
engineSettingsWithDefaultsProvider.select(
|
||||
(s) => s.automaticFontSizeAdjustment,
|
||||
),
|
||||
);
|
||||
final fontSizeFactor = ref.watch(
|
||||
engineSettingsWithDefaultsProvider.select((s) => s.fontSizeFactor),
|
||||
);
|
||||
final sliderValue = useState(fontSizeFactor);
|
||||
|
||||
useEffect(() {
|
||||
sliderValue.value = fontSizeFactor;
|
||||
return null;
|
||||
}, [fontSizeFactor]);
|
||||
|
||||
final sliderLabel = '${(sliderValue.value * 100).round()}%';
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ListTile(
|
||||
title: const Text('Font Size Factor'),
|
||||
subtitle: Text(
|
||||
automaticFontSizeAdjustment
|
||||
? 'Disabled while automatic font size is enabled'
|
||||
: 'Scale web page text size',
|
||||
),
|
||||
leading: const Icon(MdiIcons.formatSize),
|
||||
contentPadding: EdgeInsets.zero,
|
||||
enabled: !automaticFontSizeAdjustment,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
sliderLabel,
|
||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||
color: automaticFontSizeAdjustment
|
||||
? Theme.of(context).disabledColor
|
||||
: null,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Slider(
|
||||
min: 0.5,
|
||||
max: 3.0,
|
||||
divisions: 25,
|
||||
label: sliderLabel,
|
||||
value: sliderValue.value.clamp(0.5, 3.0),
|
||||
onChanged: automaticFontSizeAdjustment
|
||||
? null
|
||||
: (value) {
|
||||
sliderValue.value = value;
|
||||
},
|
||||
onChangeEnd: automaticFontSizeAdjustment
|
||||
? null
|
||||
: (value) async {
|
||||
final rounded =
|
||||
(value * 10).round() / 10;
|
||||
sliderValue.value = rounded;
|
||||
await ref
|
||||
.read(
|
||||
saveEngineSettingsControllerProvider.notifier,
|
||||
)
|
||||
.save(
|
||||
(currentSettings) => currentSettings.copyWith
|
||||
.fontSizeFactor(rounded),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _FontInflationTile extends HookConsumerWidget {
|
||||
const _FontInflationTile();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final automaticFontSizeAdjustment = ref.watch(
|
||||
engineSettingsWithDefaultsProvider.select(
|
||||
(s) => s.automaticFontSizeAdjustment,
|
||||
),
|
||||
);
|
||||
final fontInflationEnabled = ref.watch(
|
||||
engineSettingsWithDefaultsProvider.select((s) => s.fontInflationEnabled),
|
||||
);
|
||||
|
||||
return SwitchListTile.adaptive(
|
||||
title: const Text('Font Inflation'),
|
||||
subtitle: Text(
|
||||
automaticFontSizeAdjustment
|
||||
? 'Disabled while automatic font size is enabled'
|
||||
: 'Enlarge text on pages that lack a mobile viewport meta tag',
|
||||
),
|
||||
secondary: const Icon(MdiIcons.formatTextVariantOutline),
|
||||
value: fontInflationEnabled,
|
||||
onChanged: automaticFontSizeAdjustment
|
||||
? null
|
||||
: (value) async {
|
||||
await ref
|
||||
.read(saveEngineSettingsControllerProvider.notifier)
|
||||
.save(
|
||||
(currentSettings) =>
|
||||
currentSettings.copyWith.fontInflationEnabled(value),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _InputAutoZoomEnabledTile extends HookConsumerWidget {
|
||||
const _InputAutoZoomEnabledTile();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final inputAutoZoomEnabled = ref.watch(
|
||||
engineSettingsWithDefaultsProvider.select((s) => s.inputAutoZoomEnabled),
|
||||
);
|
||||
|
||||
return SwitchListTile.adaptive(
|
||||
title: const Text('Input Auto Zoom'),
|
||||
subtitle: const Text('Automatically zoom in when focusing text inputs'),
|
||||
secondary: const Icon(MdiIcons.formTextbox),
|
||||
value: inputAutoZoomEnabled,
|
||||
onChanged: (value) async {
|
||||
await ref
|
||||
.read(saveEngineSettingsControllerProvider.notifier)
|
||||
.save(
|
||||
(currentSettings) =>
|
||||
currentSettings.copyWith.inputAutoZoomEnabled(value),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,8 +29,10 @@ import 'package:weblibre/features/settings/presentation/controllers/save_setting
|
||||
import 'package:weblibre/features/settings/presentation/widgets/sections.dart';
|
||||
import 'package:weblibre/features/user/data/models/engine_settings.dart';
|
||||
import 'package:weblibre/features/user/data/models/general_settings.dart';
|
||||
import 'package:weblibre/features/user/domain/presentation/dialogs/quit_browser_dialog.dart';
|
||||
import 'package:weblibre/features/user/domain/repositories/engine_settings.dart';
|
||||
import 'package:weblibre/features/user/domain/repositories/general_settings.dart';
|
||||
import 'package:weblibre/utils/exit_app.dart';
|
||||
|
||||
class PrivacySecuritySettingsScreen extends StatelessWidget {
|
||||
const PrivacySecuritySettingsScreen({super.key});
|
||||
@@ -51,6 +53,7 @@ class PrivacySecuritySettingsScreen extends StatelessWidget {
|
||||
_TrackingProtectionSection(),
|
||||
_OpenLinkModulesSection(),
|
||||
_ConnectionSecuritySection(),
|
||||
_LocalNetworkAccessSection(),
|
||||
_DataManagementSection(),
|
||||
_AdvancedSection(),
|
||||
],
|
||||
@@ -200,6 +203,9 @@ class _AdvancedSection extends StatelessWidget {
|
||||
children: [
|
||||
SettingSection(name: 'Advanced'),
|
||||
_WebEngineHardeningTile(),
|
||||
_FissionEnabledTile(),
|
||||
_IsolatedProcessEnabledTile(),
|
||||
_AppZygoteProcessEnabledTile(),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -650,6 +656,9 @@ class _BounceTrackingProtectionTile extends HookConsumerWidget {
|
||||
: BounceTrackingProtectionMode.disabled,
|
||||
),
|
||||
);
|
||||
if (context.mounted) {
|
||||
await _showRestartDialog(context, ref);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -732,3 +741,217 @@ class _WebEngineHardeningTile extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _FissionEnabledTile extends HookConsumerWidget {
|
||||
const _FissionEnabledTile();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final fissionEnabled = ref.watch(
|
||||
engineSettingsWithDefaultsProvider.select((s) => s.fissionEnabled),
|
||||
);
|
||||
|
||||
return SwitchListTile.adaptive(
|
||||
title: const Text('Fission (Site Isolation)'),
|
||||
subtitle: const Text(
|
||||
'Isolates each site into a separate OS process for improved security. Requires app restart.',
|
||||
),
|
||||
secondary: const Icon(MdiIcons.shieldHalfFull),
|
||||
value: fissionEnabled,
|
||||
onChanged: (value) async {
|
||||
await ref
|
||||
.read(saveEngineSettingsControllerProvider.notifier)
|
||||
.save(
|
||||
(currentSettings) =>
|
||||
currentSettings.copyWith.fissionEnabled(value),
|
||||
);
|
||||
if (context.mounted) {
|
||||
await _showRestartDialog(context, ref);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _IsolatedProcessEnabledTile extends HookConsumerWidget {
|
||||
const _IsolatedProcessEnabledTile();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final isolatedProcessEnabled = ref.watch(
|
||||
engineSettingsWithDefaultsProvider.select(
|
||||
(s) => s.isolatedProcessEnabled,
|
||||
),
|
||||
);
|
||||
|
||||
return SwitchListTile.adaptive(
|
||||
title: const Text('Isolated Content Process'),
|
||||
subtitle: const Text(
|
||||
'Run web content in an isolated process. Requires app restart.',
|
||||
),
|
||||
secondary: const Icon(MdiIcons.shieldCheck),
|
||||
value: isolatedProcessEnabled,
|
||||
onChanged: (value) async {
|
||||
await ref
|
||||
.read(saveEngineSettingsControllerProvider.notifier)
|
||||
.save(
|
||||
(currentSettings) =>
|
||||
currentSettings.copyWith.isolatedProcessEnabled(value),
|
||||
);
|
||||
if (context.mounted) {
|
||||
await _showRestartDialog(context, ref);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _AppZygoteProcessEnabledTile extends HookConsumerWidget {
|
||||
const _AppZygoteProcessEnabledTile();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final appZygoteProcessEnabled = ref.watch(
|
||||
engineSettingsWithDefaultsProvider.select(
|
||||
(s) => s.appZygoteProcessEnabled,
|
||||
),
|
||||
);
|
||||
|
||||
return SwitchListTile.adaptive(
|
||||
title: const Text('App Zygote Process'),
|
||||
subtitle: const Text(
|
||||
'Preload content service via App Zygote for faster isolated process startup. Requires Android 10+ and app restart.',
|
||||
),
|
||||
secondary: const Icon(MdiIcons.rocketLaunch),
|
||||
value: appZygoteProcessEnabled,
|
||||
onChanged: (value) async {
|
||||
await ref
|
||||
.read(saveEngineSettingsControllerProvider.notifier)
|
||||
.save(
|
||||
(currentSettings) =>
|
||||
currentSettings.copyWith.appZygoteProcessEnabled(value),
|
||||
);
|
||||
if (context.mounted) {
|
||||
await _showRestartDialog(context, ref);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _showRestartDialog(BuildContext context, WidgetRef ref) async {
|
||||
final result = await showQuitBrowserDialog(context);
|
||||
if (result == true && context.mounted) {
|
||||
await exitApp(ProviderScope.containerOf(context));
|
||||
}
|
||||
}
|
||||
|
||||
class _LocalNetworkAccessSection extends StatelessWidget {
|
||||
const _LocalNetworkAccessSection();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const Column(
|
||||
children: [
|
||||
SettingSection(name: 'Local Network / Device Access Blocking'),
|
||||
_LnaEnabledTile(),
|
||||
_LnaBlockingTile(),
|
||||
_LnaBlockTrackersTile(),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _LnaEnabledTile extends HookConsumerWidget {
|
||||
const _LnaEnabledTile();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final lnaEnabled = ref.watch(
|
||||
engineSettingsWithDefaultsProvider.select((s) => s.lnaEnabled),
|
||||
);
|
||||
|
||||
return SwitchListTile.adaptive(
|
||||
title: const Text('Local Network Access'),
|
||||
subtitle: const Text(
|
||||
'Enable local network and device access blocking',
|
||||
),
|
||||
secondary: const Icon(MdiIcons.lanDisconnect),
|
||||
value: lnaEnabled ?? false,
|
||||
onChanged: (value) async {
|
||||
await ref
|
||||
.read(saveEngineSettingsControllerProvider.notifier)
|
||||
.save(
|
||||
(currentSettings) =>
|
||||
currentSettings.copyWith.lnaEnabled(value),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _LnaBlockingTile extends HookConsumerWidget {
|
||||
const _LnaBlockingTile();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final lnaEnabled = ref.watch(
|
||||
engineSettingsWithDefaultsProvider.select((s) => s.lnaEnabled),
|
||||
);
|
||||
final lnaBlocking = ref.watch(
|
||||
engineSettingsWithDefaultsProvider.select((s) => s.lnaBlocking),
|
||||
);
|
||||
|
||||
return SwitchListTile.adaptive(
|
||||
title: const Text('Block Local Network Requests'),
|
||||
subtitle: const Text(
|
||||
'Block web page requests to local network addresses',
|
||||
),
|
||||
secondary: const Icon(MdiIcons.shieldLockOpen),
|
||||
value: lnaBlocking ?? false,
|
||||
onChanged: lnaEnabled == true
|
||||
? (value) async {
|
||||
await ref
|
||||
.read(saveEngineSettingsControllerProvider.notifier)
|
||||
.save(
|
||||
(currentSettings) =>
|
||||
currentSettings.copyWith.lnaBlocking(value),
|
||||
);
|
||||
}
|
||||
: null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _LnaBlockTrackersTile extends HookConsumerWidget {
|
||||
const _LnaBlockTrackersTile();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final lnaEnabled = ref.watch(
|
||||
engineSettingsWithDefaultsProvider.select((s) => s.lnaEnabled),
|
||||
);
|
||||
final lnaBlockTrackers = ref.watch(
|
||||
engineSettingsWithDefaultsProvider.select((s) => s.lnaBlockTrackers),
|
||||
);
|
||||
|
||||
return SwitchListTile.adaptive(
|
||||
title: const Text('Block Local Network Trackers'),
|
||||
subtitle: const Text(
|
||||
'Block trackers from accessing local network resources',
|
||||
),
|
||||
secondary: const Icon(MdiIcons.shieldBug),
|
||||
value: lnaBlockTrackers ?? false,
|
||||
onChanged: lnaEnabled == true
|
||||
? (value) async {
|
||||
await ref
|
||||
.read(saveEngineSettingsControllerProvider.notifier)
|
||||
.save(
|
||||
(currentSettings) =>
|
||||
currentSettings.copyWith.lnaBlockTrackers(value),
|
||||
);
|
||||
}
|
||||
: null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user