diff --git a/flutter_hbb/assets/insecure.png b/flutter_hbb/assets/insecure.png new file mode 100644 index 000000000..0c954468d Binary files /dev/null and b/flutter_hbb/assets/insecure.png differ diff --git a/flutter_hbb/assets/insecure_relay.png b/flutter_hbb/assets/insecure_relay.png new file mode 100644 index 000000000..878d57467 Binary files /dev/null and b/flutter_hbb/assets/insecure_relay.png differ diff --git a/flutter_hbb/assets/linux.png b/flutter_hbb/assets/linux.png index 198131142..456e58675 100644 Binary files a/flutter_hbb/assets/linux.png and b/flutter_hbb/assets/linux.png differ diff --git a/flutter_hbb/assets/mac.png b/flutter_hbb/assets/mac.png index e0d71d8d3..4be16f369 100644 Binary files a/flutter_hbb/assets/mac.png and b/flutter_hbb/assets/mac.png differ diff --git a/flutter_hbb/assets/secure.png b/flutter_hbb/assets/secure.png new file mode 100644 index 000000000..01dcb2a8a Binary files /dev/null and b/flutter_hbb/assets/secure.png differ diff --git a/flutter_hbb/assets/secure_relay.png b/flutter_hbb/assets/secure_relay.png new file mode 100644 index 000000000..4119f05ba Binary files /dev/null and b/flutter_hbb/assets/secure_relay.png differ diff --git a/flutter_hbb/assets/win.png b/flutter_hbb/assets/win.png index 155f4e75d..5ce86a257 100644 Binary files a/flutter_hbb/assets/win.png and b/flutter_hbb/assets/win.png differ diff --git a/flutter_hbb/lib/common.dart b/flutter_hbb/lib/common.dart index 3751a8d68..c84260b1e 100644 --- a/flutter_hbb/lib/common.dart +++ b/flutter_hbb/lib/common.dart @@ -64,12 +64,13 @@ Future showAlertDialog(BuildContext context, BuildAlertDailog build, return res; } -void msgbox(String type, String title, String text, BuildContext context, - [bool hasCancel]) { +Future msgbox( + String type, String title, String text, BuildContext context, + [bool hasCancel]) async { if (hasCancel == null) { hasCancel = type != 'error'; } - showAlertDialog( + return await showAlertDialog( context, (_) => Tuple3(Text(title), Text(text), [ hasCancel diff --git a/flutter_hbb/lib/home_page.dart b/flutter_hbb/lib/home_page.dart index 1de6ee6af..bba97dc5c 100644 --- a/flutter_hbb/lib/home_page.dart +++ b/flutter_hbb/lib/home_page.dart @@ -168,7 +168,7 @@ class _HomePageState extends State { if (platform == 'mac os') platform = 'mac'; else if (platform != 'linux') platform = 'win'; - return Image.asset('assets/$platform.png', width: 36, height: 36); + return Image.asset('assets/$platform.png', width: 24, height: 24); } Widget getPeers() { diff --git a/flutter_hbb/lib/model.dart b/flutter_hbb/lib/model.dart index 3bea25c8c..65ecd32b2 100644 --- a/flutter_hbb/lib/model.dart +++ b/flutter_hbb/lib/model.dart @@ -33,9 +33,13 @@ class FfiModel with ChangeNotifier { bool _waitForImage; bool _initialized = false; final _permissions = Map(); + bool _secure; + bool _direct; get permissions => _permissions; get initialized => _initialized; + get secure => _secure; + get direct => _direct; get pi => _pi; FfiModel() { @@ -61,9 +65,32 @@ class FfiModel with ChangeNotifier { _pi = PeerInfo(); _display = Display(); _waitForImage = false; + _secure = null; + _direct = null; clearPermissions(); } + void setConnectionType(bool secure, bool direct) { + _secure = secure; + _direct = direct; + } + + Image getConnectionImage() { + String icon; + if (secure == true && direct == true) { + icon = 'secure'; + } else if (secure == false && direct == true) { + icon = 'insecure'; + } else if (secure == false && direct == false) { + icon = 'insecure_relay'; + } else if (secure == true && direct == false) { + icon = 'secure_relay'; + } + return icon == null + ? null + : Image.asset('assets/$icon.png', width: 48, height: 48); + } + void clearPermissions() { _permissions.clear(); } @@ -71,7 +98,10 @@ class FfiModel with ChangeNotifier { void update( String id, BuildContext context, - void Function(Map evt, String id, BuildContext context) + void Function( + Map evt, + String id, + ) handleMsgbox) { var pos; for (;;) { @@ -79,9 +109,12 @@ class FfiModel with ChangeNotifier { if (evt == null) break; var name = evt['name']; if (name == 'msgbox') { - handleMsgbox(evt, id, context); + handleMsgbox(evt, id); } else if (name == 'peer_info') { handlePeerInfo(evt, context); + } else if (name == 'connection_ready') { + FFI.ffiModel.setConnectionType( + evt['secure'] == 'true', evt['direct'] == 'true'); } else if (name == 'switch_display') { handleSwitchDisplay(evt); } else if (name == 'cursor_data') { diff --git a/flutter_hbb/lib/remote_page.dart b/flutter_hbb/lib/remote_page.dart index e91ac3bfe..163db41ba 100644 --- a/flutter_hbb/lib/remote_page.dart +++ b/flutter_hbb/lib/remote_page.dart @@ -86,7 +86,7 @@ class _RemotePageState extends State { FFI.ffiModel.update(widget.id, context, handleMsgbox); } - void handleMsgbox(Map evt, String id, BuildContext context) { + void handleMsgbox(Map evt, String id) { var type = evt['type']; var title = evt['title']; var text = evt['text']; @@ -95,25 +95,29 @@ class _RemotePageState extends State { } else if (type == 'input-password') { enterPasswordDialog(id, context); } else { - msgbox(type, title, text, context); - final hasRetry = type == "error" && - title == "Connection Error" && - text.toLowerCase().indexOf("offline") < 0 && - text.toLowerCase().indexOf("exist") < 0 && - text.toLowerCase().indexOf("handshake") < 0 && - text.toLowerCase().indexOf("failed") < 0 && - text.toLowerCase().indexOf("resolve") < 0 && - text.toLowerCase().indexOf("manually") < 0; - if (hasRetry) { - _timer?.cancel(); - _timer = Timer(Duration(seconds: _reconnects), () { - FFI.reconnect(); - showLoading('Connecting...', context); - }); - _reconnects *= 2; - } else { - _reconnects = 1; - } + showMsgBox(type, title, text); + } + } + + Future showMsgBox(String type, String title, String text) async { + await msgbox(type, title, text, context); + final hasRetry = type == "error" && + title == "Connection Error" && + text.toLowerCase().indexOf("offline") < 0 && + text.toLowerCase().indexOf("exist") < 0 && + text.toLowerCase().indexOf("handshake") < 0 && + text.toLowerCase().indexOf("failed") < 0 && + text.toLowerCase().indexOf("resolve") < 0 && + text.toLowerCase().indexOf("manually") < 0; + if (hasRetry) { + _timer?.cancel(); + _timer = Timer(Duration(seconds: _reconnects), () { + FFI.reconnect(); + showLoading('Connecting...', context); + }); + _reconnects *= 2; + } else { + _reconnects = 1; } } @@ -330,7 +334,7 @@ class _RemotePageState extends State { minWidth: 0, //wraps child's width height: 0, child: FlatButton( - splashColor: Colors.black, + splashColor: MyTheme.accent, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(5.0), ), @@ -620,6 +624,9 @@ void showOptions(BuildContext context) { if (quality == '') quality = 'balanced'; var displays = []; final pi = FFI.ffiModel.pi; + final image = FFI.ffiModel.getConnectionImage(); + if (image != null) + displays.add(Padding(padding: const EdgeInsets.only(top: 8), child: image)); if (pi.displays.length > 1) { final cur = pi.currentDisplay; final children = []; @@ -647,6 +654,8 @@ void showOptions(BuildContext context) { spacing: 8, children: children, ))); + } + if (displays.isNotEmpty) { displays.add(Divider(color: MyTheme.border)); } showAlertDialog(context, (setState) {