diff --git a/flutter/android/app/src/main/kotlin/com/carriez/flutter_hbb/InputService.kt b/flutter/android/app/src/main/kotlin/com/carriez/flutter_hbb/InputService.kt index fa6a348c1..2db376230 100644 --- a/flutter/android/app/src/main/kotlin/com/carriez/flutter_hbb/InputService.kt +++ b/flutter/android/app/src/main/kotlin/com/carriez/flutter_hbb/InputService.kt @@ -1,5 +1,11 @@ package com.carriez.flutter_hbb +/** + * Handle remote input and dispatch android gesture + * + * Inspired by [droidVNC-NG] https://github.com/bk138/droidVNC-NG + */ + import android.accessibilityservice.AccessibilityService import android.accessibilityservice.GestureDescription import android.content.Context diff --git a/flutter/android/app/src/main/kotlin/com/carriez/flutter_hbb/MainActivity.kt b/flutter/android/app/src/main/kotlin/com/carriez/flutter_hbb/MainActivity.kt index bb4e85c89..3cc105bfa 100644 --- a/flutter/android/app/src/main/kotlin/com/carriez/flutter_hbb/MainActivity.kt +++ b/flutter/android/app/src/main/kotlin/com/carriez/flutter_hbb/MainActivity.kt @@ -1,5 +1,12 @@ package com.carriez.flutter_hbb +/** + * Handle events from flutter + * Request MediaProjection permission + * + * Inspired by [droidVNC-NG] https://github.com/bk138/droidVNC-NG + */ + import android.app.Activity import android.content.ComponentName import android.content.Context diff --git a/flutter/android/app/src/main/kotlin/com/carriez/flutter_hbb/MainService.kt b/flutter/android/app/src/main/kotlin/com/carriez/flutter_hbb/MainService.kt index dc86cea45..a71541cd8 100644 --- a/flutter/android/app/src/main/kotlin/com/carriez/flutter_hbb/MainService.kt +++ b/flutter/android/app/src/main/kotlin/com/carriez/flutter_hbb/MainService.kt @@ -1,8 +1,11 @@ +package com.carriez.flutter_hbb + /** * Capture screen,get video and audio,send to rust. - * Handle notification + * Dispatch notifications + * + * Inspired by [droidVNC-NG] https://github.com/bk138/droidVNC-NG */ -package com.carriez.flutter_hbb import android.Manifest import android.annotation.SuppressLint diff --git a/flutter/lib/models/model.dart b/flutter/lib/models/model.dart index 313ab3fc1..fd3f97ec6 100644 --- a/flutter/lib/models/model.dart +++ b/flutter/lib/models/model.dart @@ -168,6 +168,7 @@ class FfiModel with ChangeNotifier { } void handleSwitchDisplay(Map evt) { + final oldOrientation = _display.width > _display.height; var old = _pi.currentDisplay; _pi.currentDisplay = int.parse(evt['display']); _display.x = double.parse(evt['x']); @@ -176,6 +177,11 @@ class FfiModel with ChangeNotifier { _display.height = int.parse(evt['height']); if (old != _pi.currentDisplay) FFI.cursorModel.updateDisplayOrigin(_display.x, _display.y); + + // remote is mobile, and orientation changed + if ((_display.width > _display.height) != oldOrientation) { + FFI.canvasModel.updateViewStyle(); + } notifyListeners(); } diff --git a/flutter/lib/pages/remote_page.dart b/flutter/lib/pages/remote_page.dart index e86c94cfd..9feef9577 100644 --- a/flutter/lib/pages/remote_page.dart +++ b/flutter/lib/pages/remote_page.dart @@ -33,6 +33,7 @@ class _RemotePageState extends State { String _value = ''; double _scale = 1; double _mouseScrollIntegral = 0; // mouse scroll speed controller + Orientation? _currentOrientation; var _more = true; var _fn = false; @@ -258,12 +259,22 @@ class _RemotePageState extends State { color: Colors.black, child: isDesktop ? getBodyForDesktopWithListener(keyboard) - : SafeArea( - child: Container( + : SafeArea(child: + OrientationBuilder(builder: (ctx, orientation) { + if (_currentOrientation != orientation) { + debugPrint("on orientation changed"); + Timer(Duration(milliseconds: 200), () { + resetMobileActionsOverlay(); + _currentOrientation = orientation; + FFI.canvasModel.updateViewStyle(); + }); + } + return Container( color: MyTheme.canvasColor, child: _isPhysicalMouse ? getBodyForMobile() - : getBodyForMobileWithGesture()))); + : getBodyForMobileWithGesture()); + }))); }) ], ))), diff --git a/flutter/lib/widgets/overlay.dart b/flutter/lib/widgets/overlay.dart index a90492f51..276c175f9 100644 --- a/flutter/lib/widgets/overlay.dart +++ b/flutter/lib/widgets/overlay.dart @@ -228,6 +228,12 @@ class DraggableMobileActions extends StatelessWidget { } } +resetMobileActionsOverlay() { + if (mobileActionsOverlayEntry == null) return; + hideMobileActionsOverlay(); + showMobileActionsOverlay(); +} + showMobileActionsOverlay() { if (mobileActionsOverlayEntry != null) return; if (globalKey.currentContext == null ||