diff --git a/lib/cwtch/gomobile.dart b/lib/cwtch/gomobile.dart index e5b4ea70..17d55b9e 100644 --- a/lib/cwtch/gomobile.dart +++ b/lib/cwtch/gomobile.dart @@ -410,6 +410,5 @@ class CwtchGomobile implements Cwtch { @override void AttemptReconnection(String profile, String onion) { cwtchPlatform.invokeMethod("PeerWithOnion", {"ProfileOnion": profile, "onion": onion}); - } } diff --git a/lib/licenses.dart b/lib/licenses.dart index 6c0e9903..14520467 100644 --- a/lib/licenses.dart +++ b/lib/licenses.dart @@ -167,7 +167,7 @@ SOFTWARE.'''); THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.'''); - + yield LicenseEntryWithLineBreaks(["connectivity_plus"], ''' * Copyright (c) 2013-2020, The PurpleI2P Project * diff --git a/lib/main.dart b/lib/main.dart index 4f3ac855..8b73312c 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -32,7 +32,6 @@ import 'themes/opaque.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:connectivity_plus/connectivity_plus.dart'; - import 'package:intl/intl.dart' as intl; var globalSettings = Settings(Locale("en", ''), CwtchDark()); @@ -95,39 +94,15 @@ class FlwtchState extends State with WindowListener { shutdownLinuxMethodChannel.setMethodCallHandler(shutdownDirect); print("initState: creating cwtchnotifier, ffi"); if (Platform.isAndroid) { - var cwtchNotifier = new CwtchNotifier( - profs, - globalSettings, - globalErrorHandler, - globalTorStatus, - NullNotificationsManager(), - globalAppState, - globalServersList, - this); + var cwtchNotifier = new CwtchNotifier(profs, globalSettings, globalErrorHandler, globalTorStatus, NullNotificationsManager(), globalAppState, globalServersList, this); cwtch = CwtchGomobile(cwtchNotifier); } else if (Platform.isLinux) { var cwtchNotifier = - new CwtchNotifier( - profs, - globalSettings, - globalErrorHandler, - globalTorStatus, - newDesktopNotificationsManager(_notificationSelectConvo), - globalAppState, - globalServersList, - this); + new CwtchNotifier(profs, globalSettings, globalErrorHandler, globalTorStatus, newDesktopNotificationsManager(_notificationSelectConvo), globalAppState, globalServersList, this); cwtch = CwtchFfi(cwtchNotifier); } else { var cwtchNotifier = - new CwtchNotifier( - profs, - globalSettings, - globalErrorHandler, - globalTorStatus, - newDesktopNotificationsManager(_notificationSelectConvo), - globalAppState, - globalServersList, - this); + new CwtchNotifier(profs, globalSettings, globalErrorHandler, globalTorStatus, newDesktopNotificationsManager(_notificationSelectConvo), globalAppState, globalServersList, this); cwtch = CwtchFfi(cwtchNotifier); } startConnectivityListener(); @@ -139,7 +114,7 @@ class FlwtchState extends State with WindowListener { // connectivity listening is an optional enhancement feature that tries to listen for OS events about the network // and if it detects coming back online, restarts the ACN/tor // gracefully fails and NOPs, as it's not a required functionality - startConnectivityListener() async { + startConnectivityListener() async { try { connectivityStream = await Connectivity().onConnectivityChanged.listen((ConnectivityResult result) { // Got a new connectivity status! diff --git a/lib/settings.dart b/lib/settings.dart index 74eb7af8..6877e12d 100644 --- a/lib/settings.dart +++ b/lib/settings.dart @@ -66,6 +66,7 @@ class Settings extends ChangeNotifier { bool _useTorCache = false; String _torCacheDir = ""; bool _useSemanticDebugger = false; + double _fontScaling = 1.0; String get torCacheDir => _torCacheDir; @@ -129,6 +130,9 @@ class Settings extends ChangeNotifier { // Set Locale and notify listeners switchLocaleByCode(settings["Locale"]); + // Decide whether to enable Experiments + _fontScaling = double.parse(settings["FontScaling"].toString()); + blockUnknownConnections = settings["BlockUnknownConnections"] ?? false; streamerMode = settings["StreamerMode"] ?? false; @@ -180,6 +184,14 @@ class Settings extends ChangeNotifier { } } + /// Handle Font Scaling + set fontScaling(double newFontScaling) { + this._fontScaling = newFontScaling; + notifyListeners(); + } + + double get fontScaling => _fontScaling; + /// Switch the Locale of the App switchLocale(Locale newLocale) { locale = newLocale; @@ -454,7 +466,8 @@ class Settings extends ChangeNotifier { "CustomAuth": _customTorAuth, "UseTorCache": _useTorCache, "TorCacheDir": _torCacheDir, - "BlodeuweddPath": _blodeuweddPath + "BlodeuweddPath": _blodeuweddPath, + "FontScaling": _fontScaling }; } } diff --git a/lib/third_party/connectivity_plus/connectivity_plus/lib/connectivity_plus.dart b/lib/third_party/connectivity_plus/connectivity_plus/lib/connectivity_plus.dart index dfba08c3..120a9afd 100644 --- a/lib/third_party/connectivity_plus/connectivity_plus/lib/connectivity_plus.dart +++ b/lib/third_party/connectivity_plus/connectivity_plus/lib/connectivity_plus.dart @@ -7,8 +7,7 @@ import 'dart:async'; import 'package:connectivity_plus_platform_interface/connectivity_plus_platform_interface.dart'; // Export enums from the platform_interface so plugin users can use them directly. -export 'package:connectivity_plus_platform_interface/connectivity_plus_platform_interface.dart' - show ConnectivityResult; +export 'package:connectivity_plus_platform_interface/connectivity_plus_platform_interface.dart' show ConnectivityResult; export 'src/connectivity_plus_linux.dart'; diff --git a/lib/third_party/connectivity_plus/connectivity_plus_platform_interface/lib/connectivity_plus_platform_interface.dart b/lib/third_party/connectivity_plus/connectivity_plus_platform_interface/lib/connectivity_plus_platform_interface.dart index 76d98666..dfc51b8b 100644 --- a/lib/third_party/connectivity_plus/connectivity_plus_platform_interface/lib/connectivity_plus_platform_interface.dart +++ b/lib/third_party/connectivity_plus/connectivity_plus_platform_interface/lib/connectivity_plus_platform_interface.dart @@ -45,7 +45,6 @@ abstract class ConnectivityPlatform extends PlatformInterface { /// Returns a Stream of ConnectivityResults changes. Stream get onConnectivityChanged { - throw UnimplementedError( - 'get onConnectivityChanged has not been implemented.'); + throw UnimplementedError('get onConnectivityChanged has not been implemented.'); } } diff --git a/lib/third_party/connectivity_plus/connectivity_plus_platform_interface/lib/method_channel_connectivity.dart b/lib/third_party/connectivity_plus/connectivity_plus_platform_interface/lib/method_channel_connectivity.dart index 1c053d91..8a5b560c 100644 --- a/lib/third_party/connectivity_plus/connectivity_plus_platform_interface/lib/method_channel_connectivity.dart +++ b/lib/third_party/connectivity_plus/connectivity_plus_platform_interface/lib/method_channel_connectivity.dart @@ -14,30 +14,23 @@ import 'src/utils.dart'; class MethodChannelConnectivity extends ConnectivityPlatform { /// The method channel used to interact with the native platform. @visibleForTesting - MethodChannel methodChannel = - const MethodChannel('dev.fluttercommunity.plus/connectivity'); + MethodChannel methodChannel = const MethodChannel('dev.fluttercommunity.plus/connectivity'); /// The event channel used to receive ConnectivityResult changes from the native platform. @visibleForTesting - EventChannel eventChannel = - const EventChannel('dev.fluttercommunity.plus/connectivity_status'); + EventChannel eventChannel = const EventChannel('dev.fluttercommunity.plus/connectivity_status'); Stream? _onConnectivityChanged; /// Fires whenever the connectivity state changes. @override Stream get onConnectivityChanged { - _onConnectivityChanged ??= eventChannel - .receiveBroadcastStream() - .map((dynamic result) => result.toString()) - .map(parseConnectivityResult); + _onConnectivityChanged ??= eventChannel.receiveBroadcastStream().map((dynamic result) => result.toString()).map(parseConnectivityResult); return _onConnectivityChanged!; } @override Future checkConnectivity() { - return methodChannel - .invokeMethod('check') - .then((value) => parseConnectivityResult(value ?? '')); + return methodChannel.invokeMethod('check').then((value) => parseConnectivityResult(value ?? '')); } } diff --git a/lib/third_party/connectivity_plus/connectivity_plus_platform_interface/lib/src/enums.dart b/lib/third_party/connectivity_plus/connectivity_plus_platform_interface/lib/src/enums.dart index 53410c07..1860de43 100644 --- a/lib/third_party/connectivity_plus/connectivity_plus_platform_interface/lib/src/enums.dart +++ b/lib/third_party/connectivity_plus/connectivity_plus_platform_interface/lib/src/enums.dart @@ -1,6 +1,5 @@ /// Connection status check result. enum ConnectivityResult { - /// WiFi: Device connected via Wi-Fi wifi, diff --git a/lib/third_party/nm/src/network_manager_client.dart b/lib/third_party/nm/src/network_manager_client.dart index 222c94bf..42731b73 100644 --- a/lib/third_party/nm/src/network_manager_client.dart +++ b/lib/third_party/nm/src/network_manager_client.dart @@ -59,12 +59,10 @@ NetworkManagerConnectivityState _decodeConnectivityState(int value) { class _NetworkManagerInterface { final Map properties; - final propertiesChangedStreamController = - StreamController>.broadcast(); + final propertiesChangedStreamController = StreamController>.broadcast(); /// Stream of property names as their values change. - Stream> get propertiesChanged => - propertiesChangedStreamController.stream; + Stream> get propertiesChanged => propertiesChangedStreamController.stream; _NetworkManagerInterface(this.properties); @@ -77,8 +75,7 @@ class _NetworkManagerInterface { class _NetworkManagerObject extends DBusRemoteObject { final interfaces = {}; - void updateInterfaces( - Map> interfacesAndProperties) { + void updateInterfaces(Map> interfacesAndProperties) { interfacesAndProperties.forEach((interfaceName, properties) { interfaces[interfaceName] = _NetworkManagerInterface(properties); }); @@ -100,8 +97,7 @@ class _NetworkManagerObject extends DBusRemoteObject { } } - void updateProperties( - String interfaceName, Map changedProperties) { + void updateProperties(String interfaceName, Map changedProperties) { var interface = interfaces[interfaceName]; if (interface != null) { interface.updateProperties(changedProperties); @@ -210,10 +206,7 @@ class _NetworkManagerObject extends DBusRemoteObject { if (value.signature != DBusSignature('as')) { return null; } - return (value as DBusArray) - .children - .map((e) => (e as DBusString).value) - .toList(); + return (value as DBusArray).children.map((e) => (e as DBusString).value).toList(); } /// Gets a cached object path property, or returns null if not present or not the correct type. @@ -229,8 +222,7 @@ class _NetworkManagerObject extends DBusRemoteObject { } /// Gets a cached object path array property, or returns null if not present or not the correct type. - List? getObjectPathArrayProperty( - String interface, String name) { + List? getObjectPathArrayProperty(String interface, String name) { var value = getCachedProperty(interface, name); if (value == null) { return null; @@ -238,15 +230,11 @@ class _NetworkManagerObject extends DBusRemoteObject { if (value.signature != DBusSignature('ao')) { return null; } - return (value as DBusArray) - .children - .map((e) => (e as DBusObjectPath)) - .toList(); + return (value as DBusArray).children.map((e) => (e as DBusObjectPath)).toList(); } /// Gets a cached list of data property, or returns null if not present or not the correct type. - List>? getDataListProperty( - String interface, String name) { + List>? getDataListProperty(String interface, String name) { var value = getCachedProperty(interface, name); if (value == null) { return null; @@ -261,22 +249,16 @@ class _NetworkManagerObject extends DBusRemoteObject { )); } - return (value as DBusArray) - .children - .map((value) => convertData(value)) - .toList(); + return (value as DBusArray).children.map((value) => convertData(value)).toList(); } - _NetworkManagerObject(DBusClient client, DBusObjectPath path, - Map> interfacesAndProperties) - : super(client, name: 'org.freedesktop.NetworkManager', path: path) { + _NetworkManagerObject(DBusClient client, DBusObjectPath path, Map> interfacesAndProperties) : super(client, name: 'org.freedesktop.NetworkManager', path: path) { updateInterfaces(interfacesAndProperties); } } /// A client that connects to NetworkManager. class NetworkManagerClient { - /// The bus this client is connected to. final DBusClient _bus; final bool _closeBus; @@ -302,10 +284,7 @@ class NetworkManagerClient { } /// Stream of property names as their values change. - Stream> get propertiesChanged => - _manager?.interfaces[_managerInterfaceName] - ?.propertiesChangedStreamController.stream ?? - Stream>.empty(); + Stream> get propertiesChanged => _manager?.interfaces[_managerInterfaceName]?.propertiesChangedStreamController.stream ?? Stream>.empty(); /// Connects to the NetworkManager D-Bus objects. /// Must be called before accessing methods and properties. @@ -333,8 +312,7 @@ class NetworkManagerClient { if (object != null) { object.updateInterfaces(signal.interfacesAndProperties); } else { - object = _NetworkManagerObject( - _bus, signal.changedPath, signal.interfacesAndProperties); + object = _NetworkManagerObject(_bus, signal.changedPath, signal.interfacesAndProperties); _objects[signal.changedPath] = object; } } else if (signal is DBusObjectManagerInterfacesRemovedSignal) { @@ -351,8 +329,7 @@ class NetworkManagerClient { } else if (signal is DBusPropertiesChangedSignal) { var object = _objects[signal.path]; if (object != null) { - object.updateProperties( - signal.propertiesInterface, signal.changedProperties); + object.updateProperties(signal.propertiesInterface, signal.changedProperties); } } }); @@ -360,8 +337,7 @@ class NetworkManagerClient { // Find all the objects exported. var objects = await _root.getManagedObjects(); objects.forEach((objectPath, interfacesAndProperties) { - _objects[objectPath] = - _NetworkManagerObject(_bus, objectPath, interfacesAndProperties); + _objects[objectPath] = _NetworkManagerObject(_bus, objectPath, interfacesAndProperties); }); } @@ -376,8 +352,7 @@ class NetworkManagerClient { /// True is NetworkManager is still starting up. bool get startup { - return _manager?.getBooleanProperty(_managerInterfaceName, 'Startup') ?? - false; + return _manager?.getBooleanProperty(_managerInterfaceName, 'Startup') ?? false; } /// The version of NetworkManager running. @@ -387,20 +362,17 @@ class NetworkManagerClient { /// The result of the last connectivity check. NetworkManagerConnectivityState get connectivity { - var value = - _manager?.getUint32Property(_managerInterfaceName, 'Connectivity') ?? 0; + var value = _manager?.getUint32Property(_managerInterfaceName, 'Connectivity') ?? 0; return _decodeConnectivityState(value); } /// The overall networking state. NetworkManagerState get state { - var value = - _manager?.getUint32Property(_managerInterfaceName, 'State') ?? 0; + var value = _manager?.getUint32Property(_managerInterfaceName, 'State') ?? 0; return _decodeState(value); } - _NetworkManagerObject? get _manager => - _objects[DBusObjectPath('/org/freedesktop/NetworkManager')]; + _NetworkManagerObject? get _manager => _objects[DBusObjectPath('/org/freedesktop/NetworkManager')]; /// Terminates all active connections. If a client remains unclosed, the Dart process may not terminate. Future close() async { @@ -412,4 +384,4 @@ class NetworkManagerClient { await _bus.close(); } } -} \ No newline at end of file +} diff --git a/lib/views/globalsettingsview.dart b/lib/views/globalsettingsview.dart index 2fafbd7e..8310427e 100644 --- a/lib/views/globalsettingsview.dart +++ b/lib/views/globalsettingsview.dart @@ -216,6 +216,27 @@ class _GlobalSettingsViewState extends State { ), ); }).toList())))), + ListTile( + title: Text(AppLocalizations.of(context)!.defaultScalingText, style: TextStyle(color: settings.current().mainTextColor)), + subtitle: Text(AppLocalizations.of(context)!.defaultScalingText), + trailing: Container( + width: MediaQuery.of(context).size.width / 4, + child: Slider( + onChanged: (double value) { + settings.fontScaling = value; + // Save Settings... + saveSettings(context); + }, + min: -1.0, + divisions: 10, + max: 2.0, + activeColor: settings.current().defaultButtonColor, + thumbColor: settings.current().mainTextColor, + overlayColor: MaterialStateProperty.all(settings.current().mainTextColor), + inactiveColor: settings.theme.defaultButtonDisabledColor, + value: settings.fontScaling)), + leading: Icon(Icons.format_size, color: settings.current().mainTextColor), + ), SwitchListTile( title: Text(AppLocalizations.of(context)!.streamerModeLabel, style: TextStyle(color: settings.current().mainTextColor)), subtitle: Text(AppLocalizations.of(context)!.descriptionStreamerMode), diff --git a/lib/widgets/messagelist.dart b/lib/widgets/messagelist.dart index c8e0e7df..257afc22 100644 --- a/lib/widgets/messagelist.dart +++ b/lib/widgets/messagelist.dart @@ -46,15 +46,21 @@ class _MessageListState extends State { // With the message cache in place this is no longer necessary bool loadMessages = true; - var reconnectButton = Visibility(visible: isP2P, child: Padding(padding: EdgeInsets.all(2), child: Tooltip( - message: AppLocalizations.of(context)!.retryConnectionTooltip, - child:ElevatedButton( - style: ButtonStyle(padding: MaterialStateProperty.all(EdgeInsets.all(20))), - child: Text(AppLocalizations.of(context)!.retryConnection), - onPressed: () { - Provider.of(context, listen: false).cwtch.AttemptReconnection(Provider.of(context,listen: false).onion, Provider.of(context, listen: false).onion); - }, - )))); + var reconnectButton = Visibility( + visible: isP2P, + child: Padding( + padding: EdgeInsets.all(2), + child: Tooltip( + message: AppLocalizations.of(context)!.retryConnectionTooltip, + child: ElevatedButton( + style: ButtonStyle(padding: MaterialStateProperty.all(EdgeInsets.all(20))), + child: Text(AppLocalizations.of(context)!.retryConnection), + onPressed: () { + Provider.of(context, listen: false) + .cwtch + .AttemptReconnection(Provider.of(context, listen: false).onion, Provider.of(context, listen: false).onion); + }, + )))); return RepaintBoundary( child: Container( @@ -70,8 +76,14 @@ class _MessageListState extends State { child: showSyncing ? Text(AppLocalizations.of(context)!.serverNotSynced, textAlign: TextAlign.center) : showOfflineWarning - ? Column(crossAxisAlignment: CrossAxisAlignment.center, children: [Text(Provider.of(context).isGroup ? AppLocalizations.of(context)!.serverConnectivityDisconnected : AppLocalizations.of(context)!.peerOfflineMessage, - textAlign: TextAlign.center), reconnectButton]) + ? Column(crossAxisAlignment: CrossAxisAlignment.center, children: [ + Text( + Provider.of(context).isGroup + ? AppLocalizations.of(context)!.serverConnectivityDisconnected + : AppLocalizations.of(context)!.peerOfflineMessage, + textAlign: TextAlign.center), + reconnectButton + ]) // Only show the ephemeral status for peer conversations, not for groups... : (showEphemeralWarning ? Text(AppLocalizations.of(context)!.chatHistoryDefault, textAlign: TextAlign.center)