diff --git a/LIBCWTCH-GO.version b/LIBCWTCH-GO.version index f0e8a400..09a831fa 100644 --- a/LIBCWTCH-GO.version +++ b/LIBCWTCH-GO.version @@ -1 +1 @@ -v1.3.1-8-g4529984-2021-11-01-22-03 \ No newline at end of file +v1.3.1-14-g63e96f3-2021-11-02-04-31 \ No newline at end of file diff --git a/android/app/src/main/kotlin/im/cwtch/flwtch/FlwtchWorker.kt b/android/app/src/main/kotlin/im/cwtch/flwtch/FlwtchWorker.kt index 98bbeb79..3b06e434 100644 --- a/android/app/src/main/kotlin/im/cwtch/flwtch/FlwtchWorker.kt +++ b/android/app/src/main/kotlin/im/cwtch/flwtch/FlwtchWorker.kt @@ -315,7 +315,7 @@ class FlwtchWorker(context: Context, parameters: WorkerParameters) : "CreateServer" -> { val password = (a.get("Password") as? String) ?: "" val desc = (a.get("Description") as? String) ?: "" - val autostart = (a.get("Autostart") as? Byte) ?: "" + val autostart = (a.get("Autostart") as? Boolean) ?: false Cwtch.createServer(password, desc, autostart) } "DeleteServer" -> { @@ -332,10 +332,10 @@ class FlwtchWorker(context: Context, parameters: WorkerParameters) : } "StopServer" -> { val serverOnion = (a.get("ServerOnion") as? String) ?: "" - Cwtch.shutdownServer(serverOnion) + Cwtch.stopServer(serverOnion) } "StopServers" -> { - Cwtch.shutdownServers() + Cwtch.stopServers() } "DestroyServers" -> { Cwtch.destroyServers() diff --git a/lib/cwtch/gomobile.dart b/lib/cwtch/gomobile.dart index 03efe699..dcf868b1 100644 --- a/lib/cwtch/gomobile.dart +++ b/lib/cwtch/gomobile.dart @@ -222,7 +222,7 @@ class CwtchGomobile implements Cwtch { @override // ignore: non_constant_identifier_names void CreateServer(String password, String description, bool autostart) { - cwtchPlatform.invokeMethod("CreateServer", {"Password": password, "Description": description, "Autostart": autostart ? 1 : 0}); + cwtchPlatform.invokeMethod("CreateServer", {"Password": password, "Description": description, "Autostart": autostart}); } @override diff --git a/lib/views/serversview.dart b/lib/views/serversview.dart index e1bd89b4..dbec10cd 100644 --- a/lib/views/serversview.dart +++ b/lib/views/serversview.dart @@ -1,5 +1,6 @@ import 'package:cwtch/models/servers.dart'; import 'package:cwtch/views/addeditservers.dart'; +import 'package:cwtch/widgets/passwordfield.dart'; import 'package:cwtch/widgets/serverrow.dart'; import 'package:flutter/material.dart'; import 'package:cwtch/torstatus.dart'; @@ -7,7 +8,9 @@ import 'package:cwtch/widgets/tor_icon.dart'; import 'package:provider/provider.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import '../cwtch_icons_icons.dart'; import '../main.dart'; +import '../settings.dart'; /// class ServersView extends StatefulWidget { @@ -16,8 +19,11 @@ class ServersView extends StatefulWidget { } class _ServersView extends State { + final ctrlrPassword = TextEditingController(); + @override void dispose() { + ctrlrPassword.dispose(); super.dispose(); } @@ -26,6 +32,7 @@ class _ServersView extends State { return Scaffold( appBar: AppBar( title: Text("Servers you host"), //AppLocalizations.of(context)!.torNetworkStatus), + actions: getActions(), ), floatingActionButton: FloatingActionButton( onPressed: _pushAddServer, @@ -63,6 +70,73 @@ class _ServersView extends State { )); } + List getActions() { + List actions = new List.empty(growable: true); + + // Unlock Profiles + actions.add(IconButton( + icon: Icon(CwtchIcons.lock_open_24px), + color: Provider.of(context).servers.isEmpty ? Provider.of(context).theme.defaultButtonColor() : Provider.of(context).theme.mainTextColor(), + tooltip: AppLocalizations.of(context)!.tooltipUnlockProfiles, + onPressed: _modalUnlockServers, + )); + + return actions; + } + + void _modalUnlockServers() { + showModalBottomSheet( + context: context, + isScrollControlled: true, + builder: (BuildContext context) { + return Padding( + padding: MediaQuery.of(context).viewInsets, + child: RepaintBoundary( + child: Container( + height: 200, // bespoke value courtesy of the [TextField] docs + child: Center( + child: Padding( + padding: EdgeInsets.all(10.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ + Text("Enter password to unlock server"),//AppLocalizations.of(context)!.enterProfilePassword), + SizedBox( + height: 20, + ), + CwtchPasswordField( + autofocus: true, + controller: ctrlrPassword, + action: unlock, + validator: (value) {}, + ), + SizedBox( + height: 20, + ), + Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ + Spacer(), + Expanded( + child: ElevatedButton( + child: Text(AppLocalizations.of(context)!.unlock, semanticsLabel: AppLocalizations.of(context)!.unlock), + onPressed: () { + unlock(ctrlrPassword.value.text); + }, + )), + Spacer() + ]), + ], + ))), + ))); + }); + } + + void unlock(String password) { + Provider.of(context, listen: false).cwtch.LoadServers(password); + ctrlrPassword.text = ""; + Navigator.pop(context); + } + void _pushAddServer() { Navigator.of(context).push(MaterialPageRoute( builder: (BuildContext context) {