diff --git a/VoidLink/HostCardView.m b/VoidLink/HostCardView.m index 85235946..b12b5855 100644 --- a/VoidLink/HostCardView.m +++ b/VoidLink/HostCardView.m @@ -325,7 +325,6 @@ static const float REFRESH_CYCLE = 2.0f; if (@available(iOS 13.0, *)) { UIImageSymbolConfiguration *config = [UIImageSymbolConfiguration configurationWithPointSize:buttonHeight*0.263]; [self.launchButton setImage:[UIImage systemImageNamed:@"play.fill" withConfiguration:config] forState:UIControlStateNormal]; - } else { // Fallback on earlier versions } diff --git a/VoidLink/Input/StreamView.m b/VoidLink/Input/StreamView.m index f88a3316..61e5a1f0 100644 --- a/VoidLink/Input/StreamView.m +++ b/VoidLink/Input/StreamView.m @@ -249,12 +249,30 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5; - (void)keyboardWillShow:(NSNotification *)notification{ // NSLog(@"keyboard will show markmark %f", CACurrentMediaTime()); if(settings.liftStreamViewForKeyboard && !isInputingText){ + isInputingText = true; + NSDictionary *userInfo = notification.userInfo; // Get the keyboard size from the notification CGRect keyboardFrame = [userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue]; - // NSLog(@"keyboard will show markmark, lowest height %f", keyboardToggleRecognizer.lowestTouchPointHeight); - if(keyboardFrame.size.height < CGRectGetHeight([[UIScreen mainScreen] bounds]) * 0.25) return; // return in case of abnormal keyboard height - HeightViewLiftedTo = keyboardFrame.size.height - keyboardToggleRecognizer.lowestTouchPointHeight + CGRectGetHeight([[UIScreen mainScreen] bounds]) * 0.1; // lift the StreamView to the height of lowest touch point of multi-finger tap gesture, while reserving the view of 1/10 screen height for remote typing. + CGFloat screenHeight = CGRectGetHeight([[UIScreen mainScreen] bounds]); + CGFloat keyboardHeight = keyboardFrame.size.height; + CGFloat toolbarHeight = settings.showKeyboardToolbar ? GenericUtils.legacyToolbarHeight : 0; + + if(keyboardHeight < screenHeight * 0.33333333333 + toolbarHeight + || keyboardHeight > screenHeight*0.8 + toolbarHeight){ + keyboardHeight = screenHeight*0.5 + toolbarHeight; + // [self toggleKeyboard]; + /* + if(keyboardToggleRecognizer.lowestTouchPointHeight < screenHeight/2){ + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), + dispatch_get_main_queue(), ^{ + [self toggleKeyboard]; + }); + return; // return in case of abnormal keyboard height + }*/ + } + + HeightViewLiftedTo = keyboardHeight - keyboardToggleRecognizer.lowestTouchPointHeight + CGRectGetHeight([[UIScreen mainScreen] bounds]) * 0.15; // lift the StreamView to the height of lowest touch point of multi-finger tap gesture, while reserving the view of 1/10 screen height for remote typing. if(HeightViewLiftedTo < 0) HeightViewLiftedTo = 0; // set HeightViewLiftedTo to 0 if it is high enough and not going to be covered by keyboard. CGRect liftedStreamFrame = self.frame; liftedStreamFrame.origin.y -= HeightViewLiftedTo; @@ -263,7 +281,6 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5; // Also lift Metal video view if using Metal rendering backend [self liftMetalVideoViewIfNeeded:HeightViewLiftedTo]; - isInputingText = true; [self refreshKeyboardToggleRecognizer:settings.keyboardToggleFingers.intValue]; [keyboardToggleTip removeFromSuperview]; } @@ -353,6 +370,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5; if (isInputingText) { Log(LOG_D, @"Closing the keyboard"); [keyInputField resignFirstResponder]; + [keyboardToggleTip removeFromSuperview]; } else { Log(LOG_D, @"Opening the keyboard"); // Prepare the textbox used to capture keyboard events. @@ -361,21 +379,33 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5; #if !TARGET_OS_TV // Prepare the toolbar above the keyboard for more options if(settings.showKeyboardToolbar){ - UIToolbar *customToolbarView = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, 44)]; - UIBarButtonItem *doneBarButton = [self createButtonWithImageNamed:@"DoneIcon.png" backgroundColor:[UIColor clearColor] target:self action:@selector(toolbarButtonClicked:) keyCode:0x00 isToggleable:NO]; - UIBarButtonItem *windowsBarButton = [self createButtonWithImageNamed:@"WindowsIcon.png" backgroundColor:[UIColor blackColor] target:self action:@selector(toolbarButtonClicked:) keyCode:0x5B isToggleable:YES]; - UIBarButtonItem *tabBarButton = [self createButtonWithImageNamed:@"TabIcon.png" backgroundColor:[UIColor blackColor] target:self action:@selector(toolbarButtonClicked:) keyCode:0x09 isToggleable:NO]; - UIBarButtonItem *shiftBarButton = [self createButtonWithImageNamed:@"ShiftIcon.png" backgroundColor:[UIColor blackColor] target:self action:@selector(toolbarButtonClicked:) keyCode:0xA0 isToggleable:YES]; - UIBarButtonItem *escapeBarButton = [self createButtonWithImageNamed:@"EscapeIcon.png" backgroundColor:[UIColor blackColor] target:self action:@selector(toolbarButtonClicked:) keyCode:0x1B isToggleable:NO]; - UIBarButtonItem *controlBarButton = [self createButtonWithImageNamed:@"ControlIcon.png" backgroundColor:[UIColor blackColor] target:self action:@selector(toolbarButtonClicked:) keyCode:0x11 isToggleable:YES]; - UIBarButtonItem *altBarButton = [self createButtonWithImageNamed:@"AltIcon.png" backgroundColor:[UIColor blackColor] target:self action:@selector(toolbarButtonClicked:) keyCode:0x12 isToggleable:YES]; - UIBarButtonItem *deleteBarButton = [self createButtonWithImageNamed:@"DeleteIcon.png" backgroundColor:[UIColor blackColor] target:self action:@selector(toolbarButtonClicked:) keyCode:0x2E isToggleable:NO]; + UIToolbar *customToolbarView = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, GenericUtils.legacyToolbarHeight)]; + UIBarButtonItem *doneBarButton = [self createButtonWithImageNamed:@"DoneIcon.png" backgroundColor:[UIColor clearColor] target:self action:@selector(toolbarButtonClicked:) keyCode:0x00 isToggleable:NO isDoneButton:true]; + UIBarButtonItem *windowsBarButton = [self createButtonWithImageNamed:@"WindowsIcon.png" backgroundColor:[UIColor blackColor] target:self action:@selector(toolbarButtonClicked:) keyCode:0x5B isToggleable:YES isDoneButton:false]; + UIBarButtonItem *tabBarButton = [self createButtonWithImageNamed:@"TabIcon.png" backgroundColor:[UIColor blackColor] target:self action:@selector(toolbarButtonClicked:) keyCode:0x09 isToggleable:NO isDoneButton:false]; + UIBarButtonItem *shiftBarButton = [self createButtonWithImageNamed:@"ShiftIcon.png" backgroundColor:[UIColor blackColor] target:self action:@selector(toolbarButtonClicked:) keyCode:0xA0 isToggleable:YES isDoneButton:false]; + UIBarButtonItem *escapeBarButton = [self createButtonWithImageNamed:@"EscapeIcon.png" backgroundColor:[UIColor blackColor] target:self action:@selector(toolbarButtonClicked:) keyCode:0x1B isToggleable:NO isDoneButton:false]; + UIBarButtonItem *controlBarButton = [self createButtonWithImageNamed:@"ControlIcon.png" backgroundColor:[UIColor blackColor] target:self action:@selector(toolbarButtonClicked:) keyCode:0x11 isToggleable:YES isDoneButton:false]; + UIBarButtonItem *altBarButton = [self createButtonWithImageNamed:@"AltIcon.png" backgroundColor:[UIColor blackColor] target:self action:@selector(toolbarButtonClicked:) keyCode:0x12 isToggleable:YES isDoneButton:false]; + UIBarButtonItem *deleteBarButton = [self createButtonWithImageNamed:@"DeleteIcon.png" backgroundColor:[UIColor blackColor] target:self action:@selector(toolbarButtonClicked:) keyCode:0x2E isToggleable:NO isDoneButton:false]; UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]; - [customToolbarView setItems:[NSArray arrayWithObjects:doneBarButton, windowsBarButton, escapeBarButton, tabBarButton, shiftBarButton, controlBarButton, altBarButton, deleteBarButton, flexibleSpace, nil]]; - if (@available(iOS 26.0, *)) { - for(UIBarButtonItem *button in customToolbarView.items){ - button.hidesSharedBackground = true; + if (GenericUtils.liquidGlassEnabled) { + if (@available(iOS 26.0, *)) { + for(UIBarButtonItem *button in customToolbarView.items){ + button.hidesSharedBackground = true; + } + // customToolbarView.barTintColor = UIColor.systemGrayColor; + customToolbarView.backgroundColor = [UIColor.blackColor colorWithAlphaComponent:0.3]; + customToolbarView.layer.cornerRadius = customToolbarView.bounds.size.height/2; + customToolbarView.layer.masksToBounds = true; + + UIVisualEffectView *glassView = + [[UIVisualEffectView alloc] initWithEffect:[UIGlassEffect effectWithStyle:UIGlassEffectStyleClear]]; + glassView.frame = customToolbarView.bounds; + glassView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + [customToolbarView addSubview:glassView]; + [customToolbarView sendSubviewToBack:glassView]; } } keyInputField.inputAccessoryView = customToolbarView; @@ -913,15 +943,21 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5; else if(![_onScreenControls handleTouchDownEvent:targetTouches]) [touchHandler touchesBegan:targetTouches withEvent:event]; } -- (UIBarButtonItem *)createButtonWithImageNamed:(NSString *)imageName backgroundColor:(UIColor *)backgroundColor target:(id)target action:(SEL)action keyCode:(NSInteger)keyCode isToggleable:(BOOL)isToggleable { +- (UIBarButtonItem *)createButtonWithImageNamed:(NSString *)imageName backgroundColor:(UIColor *)backgroundColor target:(id)target action:(SEL)action keyCode:(NSInteger)keyCode isToggleable:(BOOL)isToggleable isDoneButton:(bool)isDoneButton { UIImage *image = [UIImage imageNamed:imageName]; + + UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; + // [button setTitle:@"666" forState:UIControlStateNormal]; [button setImage:image forState:UIControlStateNormal]; - button.frame = CGRectMake(0, 0, 30, 30); + + button.frame = GenericUtils.liquidGlassEnabled ? CGRectMake(0, 0, 30, 30) : CGRectMake(0, 0, 30, 30); button.imageView.contentMode = UIViewContentModeScaleAspectFit; button.imageView.backgroundColor = backgroundColor; button.imageView.layer.cornerRadius = 10.0; - button.imageEdgeInsets = UIEdgeInsetsMake(6, 6, 6, 6); + button.imageEdgeInsets = (GenericUtils.liquidGlassEnabled + ? (isDoneButton ? UIEdgeInsetsMake(16, 16, 16, 16) : UIEdgeInsetsMake(27.5, 27.5, 27.5, 27.5)) + : UIEdgeInsetsMake(6, 6, 6, 6)); [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside]; objc_setAssociatedObject(button, "keyCode", @(keyCode), OBJC_ASSOCIATION_RETAIN_NONATOMIC); objc_setAssociatedObject(button, "isToggleable", @(isToggleable), OBJC_ASSOCIATION_RETAIN_NONATOMIC); @@ -937,7 +973,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5; isOn = !isOn; // Update the button's appearance based on its new state if (isOn) { - sender.imageView.backgroundColor = [UIColor lightGrayColor]; + sender.imageView.backgroundColor = GenericUtils.liquidGlassEnabled ? [UIColor.systemGrayColor colorWithAlphaComponent:0.5] : [UIColor lightGrayColor]; } else { sender.imageView.backgroundColor = [UIColor blackColor]; } diff --git a/VoidLink/Utility/GenericUtils.swift b/VoidLink/Utility/GenericUtils.swift index 754592a2..41ce9b1a 100644 --- a/VoidLink/Utility/GenericUtils.swift +++ b/VoidLink/Utility/GenericUtils.swift @@ -62,6 +62,10 @@ import Foundation @objc static let menuSeparatorWidth: CGFloat = 0.7 @objc static let menuSectionSeparatorWidth: CGFloat = 0.7 + @objc static var legacyToolbarHeight: CGFloat { + return 44 + } + @objc static var hostViewNavigationBarHeight: CGFloat { switch UIDevice.current.userInterfaceIdiom { case .phone: