| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #if !defined(__has_feature) || !__has_feature(objc_arc) | 5 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 6 #error "This file requires ARC support." | 6 #error "This file requires ARC support." |
| 7 #endif | 7 #endif |
| 8 | 8 |
| 9 #import "remoting/ios/app/host_view_controller.h" | 9 #import "remoting/ios/app/host_view_controller.h" |
| 10 | 10 |
| 11 #include <memory> | 11 #include <memory> |
| 12 | 12 |
| 13 #import <GLKit/GLKit.h> | 13 #import <GLKit/GLKit.h> |
| 14 | 14 |
| 15 #import "ios/third_party/material_components_ios/src/components/Buttons/src/Mate
rialButtons.h" | 15 #import "ios/third_party/material_components_ios/src/components/Buttons/src/Mate
rialButtons.h" |
| 16 #import "remoting/ios/client_gestures.h" | 16 #import "remoting/ios/client_gestures.h" |
| 17 #import "remoting/ios/client_keyboard.h" | 17 #import "remoting/ios/client_keyboard.h" |
| 18 #import "remoting/ios/session/remoting_client.h" | 18 #import "remoting/ios/session/remoting_client.h" |
| 19 | 19 |
| 20 #include "base/strings/sys_string_conversions.h" | 20 #include "base/strings/sys_string_conversions.h" |
| 21 #include "remoting/client/gesture_interpreter.h" | 21 #include "remoting/client/gesture_interpreter.h" |
| 22 #include "remoting/client/input/keyboard_interpreter.h" | 22 #include "remoting/client/input/keyboard_interpreter.h" |
| 23 | 23 |
| 24 static const CGFloat kFabInset = 15.f; | 24 static const CGFloat kFabInset = 15.f; |
| 25 static const CGFloat kKeyboardAnimationTime = 0.3; | 25 static const CGFloat kKeyboardAnimationTime = 0.3; |
| 26 | 26 |
| 27 @interface HostViewController ()<ClientKeyboardDelegate> { | 27 @interface HostViewController ()<ClientKeyboardDelegate, |
| 28 ClientGesturesDelegate> { |
| 28 RemotingClient* _client; | 29 RemotingClient* _client; |
| 29 MDCFloatingButton* _floatingButton; | 30 MDCFloatingButton* _floatingButton; |
| 30 ClientGestures* _clientGestures; | 31 ClientGestures* _clientGestures; |
| 31 ClientKeyboard* _clientKeyboard; | 32 ClientKeyboard* _clientKeyboard; |
| 32 CGSize _keyboardSize; | 33 CGSize _keyboardSize; |
| 33 } | 34 } |
| 34 @end | 35 @end |
| 35 | 36 |
| 36 @implementation HostViewController | 37 @implementation HostViewController |
| 37 | 38 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 - (void)viewDidDisappear:(BOOL)animated { | 94 - (void)viewDidDisappear:(BOOL)animated { |
| 94 [super viewDidDisappear:animated]; | 95 [super viewDidDisappear:animated]; |
| 95 [(GLKView*)self.view deleteDrawable]; | 96 [(GLKView*)self.view deleteDrawable]; |
| 96 } | 97 } |
| 97 | 98 |
| 98 - (void)viewWillAppear:(BOOL)animated { | 99 - (void)viewWillAppear:(BOOL)animated { |
| 99 [super viewWillAppear:animated]; | 100 [super viewWillAppear:animated]; |
| 100 | 101 |
| 101 _clientGestures = | 102 _clientGestures = |
| 102 [[ClientGestures alloc] initWithView:self.view client:_client]; | 103 [[ClientGestures alloc] initWithView:self.view client:_client]; |
| 104 _clientGestures.delegate = self; |
| 103 [[NSNotificationCenter defaultCenter] | 105 [[NSNotificationCenter defaultCenter] |
| 104 addObserver:self | 106 addObserver:self |
| 105 selector:@selector(keyboardWillShow:) | 107 selector:@selector(keyboardWillShow:) |
| 106 name:UIKeyboardWillShowNotification | 108 name:UIKeyboardWillShowNotification |
| 107 object:nil]; | 109 object:nil]; |
| 108 | 110 |
| 109 [[NSNotificationCenter defaultCenter] | 111 [[NSNotificationCenter defaultCenter] |
| 110 addObserver:self | 112 addObserver:self |
| 111 selector:@selector(keyboardWillHide:) | 113 selector:@selector(keyboardWillHide:) |
| 112 name:UIKeyboardWillHideNotification | 114 name:UIKeyboardWillHideNotification |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 | 195 |
| 194 - (void)clientKeyboardShouldSend:(NSString*)text { | 196 - (void)clientKeyboardShouldSend:(NSString*)text { |
| 195 _client.keyboardInterpreter->HandleTextEvent(base::SysNSStringToUTF8(text), | 197 _client.keyboardInterpreter->HandleTextEvent(base::SysNSStringToUTF8(text), |
| 196 0); | 198 0); |
| 197 } | 199 } |
| 198 | 200 |
| 199 - (void)clientKeyboardShouldDelete { | 201 - (void)clientKeyboardShouldDelete { |
| 200 _client.keyboardInterpreter->HandleDeleteEvent(0); | 202 _client.keyboardInterpreter->HandleDeleteEvent(0); |
| 201 } | 203 } |
| 202 | 204 |
| 205 #pragma mark - ClientGesturesDelegate |
| 206 |
| 207 - (void)keyboardShouldShow { |
| 208 [self showKeyboard]; |
| 209 } |
| 210 |
| 211 - (void)keyboardShouldHide { |
| 212 [self hideKeyboard]; |
| 213 } |
| 214 |
| 203 #pragma mark - Private | 215 #pragma mark - Private |
| 204 | 216 |
| 205 - (void)didTap:(id)sender { | 217 - (void)didTap:(id)sender { |
| 206 // TODO(nicholss): The FAB is being used to launch an alert window with | 218 // TODO(nicholss): The FAB is being used to launch an alert window with |
| 207 // more options. This is not ideal but it gets us an easy way to make a | 219 // more options. This is not ideal but it gets us an easy way to make a |
| 208 // modal window option selector. Replace this with a real menu later. | 220 // modal window option selector. Replace this with a real menu later. |
| 209 | 221 |
| 210 UIAlertController* alert = [UIAlertController | 222 UIAlertController* alert = [UIAlertController |
| 211 alertControllerWithTitle:@"Remote Settings" | 223 alertControllerWithTitle:@"Remote Settings" |
| 212 message:nil | 224 message:nil |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 // Target the alert menu at the top middle of the FAB. | 275 // Target the alert menu at the top middle of the FAB. |
| 264 alert.popoverPresentationController.sourceRect = CGRectMake( | 276 alert.popoverPresentationController.sourceRect = CGRectMake( |
| 265 _floatingButton.center.x, _floatingButton.frame.origin.y, 1.0, 1.0); | 277 _floatingButton.center.x, _floatingButton.frame.origin.y, 1.0, 1.0); |
| 266 | 278 |
| 267 alert.popoverPresentationController.permittedArrowDirections = | 279 alert.popoverPresentationController.permittedArrowDirections = |
| 268 UIPopoverArrowDirectionDown; | 280 UIPopoverArrowDirectionDown; |
| 269 [self presentViewController:alert animated:YES completion:nil]; | 281 [self presentViewController:alert animated:YES completion:nil]; |
| 270 } | 282 } |
| 271 | 283 |
| 272 @end | 284 @end |
| OLD | NEW |