Skip to content

Commit b3b0503

Browse files
committed
revert(settings): restore proxy autodetect settings
Works on Android with kotlin native http client.
1 parent aa63d57 commit b3b0503

File tree

1 file changed

+43
-28
lines changed

1 file changed

+43
-28
lines changed

lib/features/settings/view/settings_page.dart

Lines changed: 43 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,9 @@ class _SettingsPageState extends State<SettingsPage> {
615615
port = parts.elementAtOrNull(1);
616616
}
617617

618+
// On these platforms, uses native http client for now and the proxy settings are not configurable.
619+
final proxyAutomated = isAndroid || isMacOS || isIOS;
620+
618621
final tr = context.t.settingsPage.advancedSection;
619622

620623
return [
@@ -629,35 +632,47 @@ class _SettingsPageState extends State<SettingsPage> {
629632
),
630633

631634
// Proxy settings, enable or disable.
632-
SectionSwitchListTile(
633-
secondary: Icon(MdiIcons.networkOutline),
634-
title: Text(tr.useProxy),
635-
value: netClientUseProxy,
636-
onChanged: (v) {
637-
context.read<SettingsBloc>().add(SettingsValueChanged(SettingsKeys.netClientUseProxy, v));
638-
showSnackBar(context: context, message: context.t.general.affectAfterRestart);
639-
},
640-
),
641-
SectionSwitchListTile(
642-
secondary: const Icon(Symbols.network_manage),
643-
title: Text(tr.proxySettings.useDetectProxy.title),
644-
subtitle: Text(tr.proxySettings.useDetectProxy.detail),
645-
value: useDetectedProxy,
646-
onChanged: netClientUseProxy
647-
? (v) async =>
648-
context.read<SettingsBloc>().add(SettingsValueChanged(SettingsKeys.useDetectedProxyWhenStartup, v))
649-
: null,
650-
),
651-
SectionListTile(
652-
enabled: netClientUseProxy && !useDetectedProxy,
653-
leading: const Icon(Icons.network_locked_outlined),
654-
title: Text(tr.proxySettings.title),
655-
onTap: () async => showDialog<void>(
656-
context: context,
657-
builder: (context) => RootPage(DialogPaths.setupProxy, ProxySettingsDialog(host: host, port: port)),
658-
barrierDismissible: false,
635+
if (proxyAutomated)
636+
SectionListTile(
637+
leading: Icon(MdiIcons.networkOutline),
638+
title: Text(tr.useProxy),
639+
subtitle: Text(tr.proxySettings.automatedOnPlatform),
640+
enabled: false,
641+
)
642+
else
643+
SectionSwitchListTile(
644+
secondary: Icon(MdiIcons.networkOutline),
645+
title: Text(tr.useProxy),
646+
value: netClientUseProxy,
647+
onChanged: (v) {
648+
context.read<SettingsBloc>().add(SettingsValueChanged(SettingsKeys.netClientUseProxy, v));
649+
showSnackBar(context: context, message: context.t.general.affectAfterRestart);
650+
},
651+
),
652+
653+
if (!proxyAutomated)
654+
SectionSwitchListTile(
655+
secondary: const Icon(Symbols.network_manage),
656+
title: Text(tr.proxySettings.useDetectProxy.title),
657+
subtitle: Text(tr.proxySettings.useDetectProxy.detail),
658+
value: useDetectedProxy,
659+
onChanged: netClientUseProxy && !proxyAutomated
660+
? (v) async =>
661+
context.read<SettingsBloc>().add(SettingsValueChanged(SettingsKeys.useDetectedProxyWhenStartup, v))
662+
: null,
663+
),
664+
665+
if (!proxyAutomated)
666+
SectionListTile(
667+
enabled: netClientUseProxy && !useDetectedProxy && !proxyAutomated,
668+
leading: const Icon(Icons.network_locked_outlined),
669+
title: Text(tr.proxySettings.title),
670+
onTap: () async => showDialog<void>(
671+
context: context,
672+
builder: (context) => RootPage(DialogPaths.setupProxy, ProxySettingsDialog(host: host, port: port)),
673+
barrierDismissible: false,
674+
),
659675
),
660-
),
661676

662677
// Export data.
663678
SectionListTile(

0 commit comments

Comments
 (0)