Merge pull request #5597 from dignow/fix/image_over_android_toolbar

fix, the session image covers android toolbar
This commit is contained in:
RustDesk 2023-09-04 15:07:05 +08:00 committed by GitHub
commit 227c9594db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 35 additions and 18 deletions

View File

@ -614,6 +614,7 @@ class OverlayDialogManager {
int _tagCount = 0; int _tagCount = 0;
OverlayEntry? _mobileActionsOverlayEntry; OverlayEntry? _mobileActionsOverlayEntry;
RxBool mobileActionsOverlayVisible = false.obs;
void setOverlayState(OverlayKeyState overlayKeyState) { void setOverlayState(OverlayKeyState overlayKeyState) {
_overlayKeyState = overlayKeyState; _overlayKeyState = overlayKeyState;
@ -780,12 +781,14 @@ class OverlayDialogManager {
}); });
overlayState.insert(overlay); overlayState.insert(overlay);
_mobileActionsOverlayEntry = overlay; _mobileActionsOverlayEntry = overlay;
mobileActionsOverlayVisible.value = true;
} }
void hideMobileActionsOverlay() { void hideMobileActionsOverlay() {
if (_mobileActionsOverlayEntry != null) { if (_mobileActionsOverlayEntry != null) {
_mobileActionsOverlayEntry!.remove(); _mobileActionsOverlayEntry!.remove();
_mobileActionsOverlayEntry = null; _mobileActionsOverlayEntry = null;
mobileActionsOverlayVisible.value = false;
return; return;
} }
} }

View File

@ -279,7 +279,10 @@ class _RemotePageState extends State<RemotePage>
_ffi.ffiModel.pi.isSet.isTrue && _ffi.ffiModel.pi.isSet.isTrue &&
_ffi.ffiModel.waitForFirstImage.isTrue _ffi.ffiModel.waitForFirstImage.isTrue
? emptyOverlay() ? emptyOverlay()
: Offstage(), : () {
_ffi.ffiModel.tryShowAndroidActionsOverlay();
return Offstage();
}(),
// Use Overlay to enable rebuild every time on menu button click. // Use Overlay to enable rebuild every time on menu button click.
_ffi.ffiModel.pi.isSet.isTrue _ffi.ffiModel.pi.isSet.isTrue
? Overlay(initialEntries: [ ? Overlay(initialEntries: [

View File

@ -101,6 +101,9 @@ class ToolbarState {
class _ToolbarTheme { class _ToolbarTheme {
static const Color blueColor = MyTheme.button; static const Color blueColor = MyTheme.button;
static const Color hoverBlueColor = MyTheme.accent; static const Color hoverBlueColor = MyTheme.accent;
static Color inactiveColor = Colors.grey[800]!;
static Color hoverInactiveColor = Colors.grey[850]!;
static const Color redColor = Colors.redAccent; static const Color redColor = Colors.redAccent;
static const Color hoverRedColor = Colors.red; static const Color hoverRedColor = Colors.red;
// kMinInteractiveDimension // kMinInteractiveDimension
@ -543,9 +546,9 @@ class _PinMenu extends StatelessWidget {
assetName: state.pin ? "assets/pinned.svg" : "assets/unpinned.svg", assetName: state.pin ? "assets/pinned.svg" : "assets/unpinned.svg",
tooltip: state.pin ? 'Unpin Toolbar' : 'Pin Toolbar', tooltip: state.pin ? 'Unpin Toolbar' : 'Pin Toolbar',
onPressed: state.switchPin, onPressed: state.switchPin,
color: state.pin ? _ToolbarTheme.blueColor : Colors.grey[800]!, color: state.pin ? _ToolbarTheme.blueColor : _ToolbarTheme.inactiveColor,
hoverColor: hoverColor:
state.pin ? _ToolbarTheme.hoverBlueColor : Colors.grey[850]!, state.pin ? _ToolbarTheme.hoverBlueColor : _ToolbarTheme.hoverInactiveColor,
), ),
); );
} }
@ -558,13 +561,15 @@ class _MobileActionMenu extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (!ffi.ffiModel.isPeerAndroid) return Offstage(); if (!ffi.ffiModel.isPeerAndroid) return Offstage();
return _IconMenuButton( return Obx(()=>_IconMenuButton(
assetName: 'assets/actions_mobile.svg', assetName: 'assets/actions_mobile.svg',
tooltip: 'Mobile Actions', tooltip: 'Mobile Actions',
onPressed: () => ffi.dialogManager.toggleMobileActionsOverlay(ffi: ffi), onPressed: () => ffi.dialogManager.toggleMobileActionsOverlay(ffi: ffi),
color: _ToolbarTheme.blueColor, color: ffi.dialogManager.mobileActionsOverlayVisible.isTrue
hoverColor: _ToolbarTheme.hoverBlueColor, ? _ToolbarTheme.blueColor : _ToolbarTheme.inactiveColor,
); hoverColor: ffi.dialogManager.mobileActionsOverlayVisible.isTrue
? _ToolbarTheme.hoverBlueColor : _ToolbarTheme.hoverInactiveColor,
));
} }
} }

View File

@ -266,7 +266,10 @@ class _RemotePageState extends State<RemotePage> {
gFFI.ffiModel.pi.isSet.isTrue && gFFI.ffiModel.pi.isSet.isTrue &&
gFFI.ffiModel.waitForFirstImage.isTrue gFFI.ffiModel.waitForFirstImage.isTrue
? emptyOverlay() ? emptyOverlay()
: Offstage(), : () {
gFFI.ffiModel.tryShowAndroidActionsOverlay();
return Offstage();
}(),
_bottomWidget(), _bottomWidget(),
gFFI.ffiModel.pi.isSet.isFalse ? emptyOverlay() : Offstage(), gFFI.ffiModel.pi.isSet.isFalse ? emptyOverlay() : Offstage(),
], ],

View File

@ -554,23 +554,13 @@ class FfiModel with ChangeNotifier {
} }
final connType = parent.target?.connType; final connType = parent.target?.connType;
if (isPeerAndroid) { if (isPeerAndroid) {
_touchMode = true; _touchMode = true;
if (connType == ConnType.defaultConn &&
parent.target != null &&
parent.target!.ffiModel.permissions['keyboard'] != false) {
Timer(
const Duration(milliseconds: 100),
() => parent.target!.dialogManager
.showMobileActionsOverlay(ffi: parent.target!));
}
} else { } else {
_touchMode = await bind.sessionGetOption( _touchMode = await bind.sessionGetOption(
sessionId: sessionId, arg: 'touch-mode') != sessionId: sessionId, arg: 'touch-mode') !=
''; '';
} }
if (connType == ConnType.fileTransfer) { if (connType == ConnType.fileTransfer) {
parent.target?.fileModel.onReady(); parent.target?.fileModel.onReady();
} else if (connType == ConnType.defaultConn) { } else if (connType == ConnType.defaultConn) {
@ -616,6 +606,19 @@ class FfiModel with ChangeNotifier {
notifyListeners(); notifyListeners();
} }
tryShowAndroidActionsOverlay({int delayMSecs = 10}) {
if (isPeerAndroid) {
if (parent.target?.connType == ConnType.defaultConn &&
parent.target != null &&
parent.target!.ffiModel.permissions['keyboard'] != false) {
Timer(
Duration(milliseconds: delayMSecs),
() => parent.target!.dialogManager
.showMobileActionsOverlay(ffi: parent.target!));
}
}
}
handleResolutions(String id, dynamic resolutions) { handleResolutions(String id, dynamic resolutions) {
try { try {
final List<dynamic> dynamicArray = jsonDecode(resolutions as String); final List<dynamic> dynamicArray = jsonDecode(resolutions as String);