From 26f32a0790fcd7e07933d77a4dac8c1c5131661f Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Wed, 12 Jan 2022 15:15:58 -0800 Subject: [PATCH] Update Translations + Error Reporting --- lib/l10n/intl_de.arb | 3 +- lib/l10n/intl_en.arb | 3 +- lib/l10n/intl_es.arb | 3 +- lib/l10n/intl_fr.arb | 3 +- lib/l10n/intl_it.arb | 3 +- lib/l10n/intl_pl.arb | 3 +- lib/l10n/intl_pt.arb | 3 +- lib/l10n/intl_ru.arb | 3 +- lib/views/torstatusview.dart | 53 ++++++++++++++++++++++++++++++++---- lib/widgets/textfield.dart | 6 ++++ 10 files changed, 69 insertions(+), 14 deletions(-) diff --git a/lib/l10n/intl_de.arb b/lib/l10n/intl_de.arb index d225aa56..05071e96 100644 --- a/lib/l10n/intl_de.arb +++ b/lib/l10n/intl_de.arb @@ -1,6 +1,7 @@ { "@@locale": "de", - "@@last_modified": "2022-01-12T22:53:15+01:00", + "@@last_modified": "2022-01-12T23:54:51+01:00", + "torSettingsErrorSettingPort": "Port Number must be between 1 and 65535", "torSettingsUseCustomTorServiceConfigurastionDescription": "Override the default tor configuration. Warning: This could be dangerous. Only turn this on if you know what you are doing.", "torSettingsUseCustomTorServiceConfiguration": "Use a Custom Tor Service Configuration (torrc)", "torSettingsCustomControlPortDescription": "Use a custom port for control connections to the Tor proxy", diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index 2d63548b..ff0be443 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -1,6 +1,7 @@ { "@@locale": "en", - "@@last_modified": "2022-01-12T22:53:15+01:00", + "@@last_modified": "2022-01-12T23:54:51+01:00", + "torSettingsErrorSettingPort": "Port Number must be between 1 and 65535", "settingTheme": "Use Light Themes", "torSettingsUseCustomTorServiceConfiguration": "Use a Custom Tor Service Configuration (torrc)", "torSettingsUseCustomTorServiceConfigurastionDescription": "Override the default tor configuration. Warning: This could be dangerous. Only turn this on if you know what you are doing.", diff --git a/lib/l10n/intl_es.arb b/lib/l10n/intl_es.arb index 300ee131..9c928936 100644 --- a/lib/l10n/intl_es.arb +++ b/lib/l10n/intl_es.arb @@ -1,6 +1,7 @@ { "@@locale": "es", - "@@last_modified": "2022-01-12T22:53:15+01:00", + "@@last_modified": "2022-01-12T23:54:51+01:00", + "torSettingsErrorSettingPort": "Port Number must be between 1 and 65535", "torSettingsUseCustomTorServiceConfigurastionDescription": "Override the default tor configuration. Warning: This could be dangerous. Only turn this on if you know what you are doing.", "torSettingsUseCustomTorServiceConfiguration": "Use a Custom Tor Service Configuration (torrc)", "torSettingsCustomControlPortDescription": "Use a custom port for control connections to the Tor proxy", diff --git a/lib/l10n/intl_fr.arb b/lib/l10n/intl_fr.arb index 9164448d..3e90f9fd 100644 --- a/lib/l10n/intl_fr.arb +++ b/lib/l10n/intl_fr.arb @@ -1,6 +1,7 @@ { "@@locale": "fr", - "@@last_modified": "2022-01-12T22:53:15+01:00", + "@@last_modified": "2022-01-12T23:54:51+01:00", + "torSettingsErrorSettingPort": "Port Number must be between 1 and 65535", "torSettingsUseCustomTorServiceConfigurastionDescription": "Override the default tor configuration. Warning: This could be dangerous. Only turn this on if you know what you are doing.", "torSettingsUseCustomTorServiceConfiguration": "Use a Custom Tor Service Configuration (torrc)", "torSettingsCustomControlPortDescription": "Use a custom port for control connections to the Tor proxy", diff --git a/lib/l10n/intl_it.arb b/lib/l10n/intl_it.arb index e60052ad..b392a0ff 100644 --- a/lib/l10n/intl_it.arb +++ b/lib/l10n/intl_it.arb @@ -1,6 +1,7 @@ { "@@locale": "it", - "@@last_modified": "2022-01-12T22:53:15+01:00", + "@@last_modified": "2022-01-12T23:54:51+01:00", + "torSettingsErrorSettingPort": "Port Number must be between 1 and 65535", "torSettingsUseCustomTorServiceConfigurastionDescription": "Override the default tor configuration. Warning: This could be dangerous. Only turn this on if you know what you are doing.", "torSettingsUseCustomTorServiceConfiguration": "Use a Custom Tor Service Configuration (torrc)", "torSettingsCustomControlPortDescription": "Use a custom port for control connections to the Tor proxy", diff --git a/lib/l10n/intl_pl.arb b/lib/l10n/intl_pl.arb index 52487b41..80ebcac5 100644 --- a/lib/l10n/intl_pl.arb +++ b/lib/l10n/intl_pl.arb @@ -1,6 +1,7 @@ { "@@locale": "pl", - "@@last_modified": "2022-01-12T22:53:15+01:00", + "@@last_modified": "2022-01-12T23:54:51+01:00", + "torSettingsErrorSettingPort": "Port Number must be between 1 and 65535", "torSettingsUseCustomTorServiceConfigurastionDescription": "Override the default tor configuration. Warning: This could be dangerous. Only turn this on if you know what you are doing.", "torSettingsUseCustomTorServiceConfiguration": "Use a Custom Tor Service Configuration (torrc)", "torSettingsCustomControlPortDescription": "Use a custom port for control connections to the Tor proxy", diff --git a/lib/l10n/intl_pt.arb b/lib/l10n/intl_pt.arb index ac96f461..31ce6b76 100644 --- a/lib/l10n/intl_pt.arb +++ b/lib/l10n/intl_pt.arb @@ -1,6 +1,7 @@ { "@@locale": "pt", - "@@last_modified": "2022-01-12T22:53:15+01:00", + "@@last_modified": "2022-01-12T23:54:51+01:00", + "torSettingsErrorSettingPort": "Port Number must be between 1 and 65535", "torSettingsUseCustomTorServiceConfigurastionDescription": "Override the default tor configuration. Warning: This could be dangerous. Only turn this on if you know what you are doing.", "torSettingsUseCustomTorServiceConfiguration": "Use a Custom Tor Service Configuration (torrc)", "torSettingsCustomControlPortDescription": "Use a custom port for control connections to the Tor proxy", diff --git a/lib/l10n/intl_ru.arb b/lib/l10n/intl_ru.arb index 255c4b12..dc524e28 100644 --- a/lib/l10n/intl_ru.arb +++ b/lib/l10n/intl_ru.arb @@ -1,6 +1,7 @@ { "@@locale": "ru", - "@@last_modified": "2022-01-12T22:53:15+01:00", + "@@last_modified": "2022-01-12T23:54:51+01:00", + "torSettingsErrorSettingPort": "Port Number must be between 1 and 65535", "msgAddToAccept": "Добавьте учетную запись в контакты, чтобы принять этот файл.", "btnSendFile": "Отправить файл", "msgConfirmSend": "Вы уверены, что хотите отправить?", diff --git a/lib/views/torstatusview.dart b/lib/views/torstatusview.dart index c94a8a42..1a63899c 100644 --- a/lib/views/torstatusview.dart +++ b/lib/views/torstatusview.dart @@ -96,13 +96,33 @@ class _TorStatusView extends State { subtitle: Text(AppLocalizations.of(context)!.torSettingsCustomSocksPortDescription), leading: Icon(CwtchIcons.swap_horiz_24px, color: settings.current().mainTextColor), trailing: Container( - width: 100, + width: 300, child: CwtchTextField( + number: true, controller: torSocksPortController, + validator: (value) { + try { + var port = int.parse(value); + if (port > 0 && port < 65536) { + return null; + } else { + return AppLocalizations.of( + context)! + .torSettingsErrorSettingPort; + } + }catch (e) { + return AppLocalizations.of( + context)! + .torSettingsErrorSettingPort; + } + }, onChanged: (String socksPort) { try { - settings.socksPort = int.parse(socksPort); - saveSettings(context); + var port = int.parse(socksPort); + if (port > 0 && port < 65536) { + settings.socksPort = int.parse(socksPort); + saveSettings(context); + } } catch (e) {} }, ))), @@ -111,13 +131,34 @@ class _TorStatusView extends State { subtitle: Text(AppLocalizations.of(context)!.torSettingsCustomControlPortDescription), leading: Icon(CwtchIcons.swap_horiz_24px, color: settings.current().mainTextColor), trailing: Container( - width: 100, + width: 300, child: CwtchTextField( + number: true, controller: torControlPortController, + validator: (value) { + try { + var port = int.parse(value); + if (port > 0 && port < 65536) { + return null; + } else { + return AppLocalizations.of( + context)! + .torSettingsErrorSettingPort; + } + }catch (e) { + return AppLocalizations.of( + context)! + .torSettingsErrorSettingPort; + } + }, onChanged: (String controlPort) { try { - settings.controlPort = int.parse(controlPort); - saveSettings(context); + var port = int.parse(controlPort); + if (port > 0 && port < 65536) { + settings.controlPort = + int.parse(controlPort); + saveSettings(context); + } } catch (e) {} }, ))), diff --git a/lib/widgets/textfield.dart b/lib/widgets/textfield.dart index ca98ca57..9f5ff620 100644 --- a/lib/widgets/textfield.dart +++ b/lib/widgets/textfield.dart @@ -44,17 +44,22 @@ class _CwtchTextFieldState extends State { validator: widget.validator, onChanged: widget.onChanged, autofocus: widget.autofocus, + autovalidateMode: AutovalidateMode.onUserInteraction, textAlign: widget.number ? TextAlign.end : TextAlign.start, keyboardType: widget.multiLine ? TextInputType.multiline : widget.number ? TextInputType.number : TextInputType.text, + inputFormatters: widget.number ? [ + FilteringTextInputFormatter.digitsOnly + ] : null, maxLines: widget.multiLine ? null : 1, scrollController: _scrollController, enableIMEPersonalizedLearning: false, focusNode: _focusNode, decoration: InputDecoration( + errorMaxLines: 2, hintText: widget.hintText, floatingLabelBehavior: FloatingLabelBehavior.never, filled: true, @@ -64,6 +69,7 @@ class _CwtchTextFieldState extends State { errorStyle: TextStyle( color: theme.current().textfieldErrorColor, fontWeight: FontWeight.bold, + overflow: TextOverflow.visible ), fillColor: theme.current().textfieldBackgroundColor, contentPadding: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0),