| 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 "remoting/client/gesture_interpreter.h" | 21 #include "remoting/client/gesture_interpreter.h" |
| 22 #include "remoting/client/input/keyboard_interpreter.h" |
| 21 | 23 |
| 22 static const CGFloat kFabInset = 15.f; | 24 static const CGFloat kFabInset = 15.f; |
| 23 | 25 |
| 24 @interface HostViewController () { | 26 @interface HostViewController ()<ClientKeyboardDelegate> { |
| 25 RemotingClient* _client; | 27 RemotingClient* _client; |
| 26 MDCFloatingButton* _floatingButton; | 28 MDCFloatingButton* _floatingButton; |
| 27 ClientGestures* _clientGestures; | 29 ClientGestures* _clientGestures; |
| 28 ClientKeyboard* _clientKeyboard; | 30 ClientKeyboard* _clientKeyboard; |
| 29 CGSize _keyboardSize; | 31 CGSize _keyboardSize; |
| 30 } | 32 } |
| 31 @end | 33 @end |
| 32 | 34 |
| 33 @implementation HostViewController | 35 @implementation HostViewController |
| 34 | 36 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 - (BOOL)isKeyboardActive { | 127 - (BOOL)isKeyboardActive { |
| 126 if (_clientKeyboard) { | 128 if (_clientKeyboard) { |
| 127 return [_clientKeyboard isFirstResponder]; | 129 return [_clientKeyboard isFirstResponder]; |
| 128 } | 130 } |
| 129 return NO; | 131 return NO; |
| 130 } | 132 } |
| 131 | 133 |
| 132 - (void)showKeyboard { | 134 - (void)showKeyboard { |
| 133 if (!_clientKeyboard) { | 135 if (!_clientKeyboard) { |
| 134 _clientKeyboard = [[ClientKeyboard alloc] init]; | 136 _clientKeyboard = [[ClientKeyboard alloc] init]; |
| 137 _clientKeyboard.delegate = self; |
| 135 [self.view addSubview:_clientKeyboard]; | 138 [self.view addSubview:_clientKeyboard]; |
| 136 // TODO(nicholss): need to pass some keyboard injection interface here. | 139 // TODO(nicholss): need to pass some keyboard injection interface here. |
| 137 } | 140 } |
| 138 [_clientKeyboard becomeFirstResponder]; | 141 [_clientKeyboard becomeFirstResponder]; |
| 139 } | 142 } |
| 140 | 143 |
| 141 - (void)hideKeyboard { | 144 - (void)hideKeyboard { |
| 142 [_clientKeyboard resignFirstResponder]; | 145 [_clientKeyboard resignFirstResponder]; |
| 143 } | 146 } |
| 144 | 147 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 164 - (void)keyboardWillHide:(NSNotification*)notification { | 167 - (void)keyboardWillHide:(NSNotification*)notification { |
| 165 [UIView animateWithDuration:0.3 | 168 [UIView animateWithDuration:0.3 |
| 166 animations:^{ | 169 animations:^{ |
| 167 CGRect f = self.view.frame; | 170 CGRect f = self.view.frame; |
| 168 f.size.height += _keyboardSize.height; | 171 f.size.height += _keyboardSize.height; |
| 169 self.view.frame = f; | 172 self.view.frame = f; |
| 170 }]; | 173 }]; |
| 171 _keyboardSize = CGSizeZero; | 174 _keyboardSize = CGSizeZero; |
| 172 } | 175 } |
| 173 | 176 |
| 177 #pragma mark - ClientKeyboardDelegate |
| 178 |
| 179 - (void)clientKeyboardShouldSend:(NSString*)text { |
| 180 _client.keyboardInterpreter->HandleTextEvent(base::SysNSStringToUTF8(text), |
| 181 0); |
| 182 } |
| 183 |
| 184 - (void)clientKeyboardShouldDelete { |
| 185 _client.keyboardInterpreter->HandleDeleteEvent(0); |
| 186 } |
| 187 |
| 174 #pragma mark - Private | 188 #pragma mark - Private |
| 175 | 189 |
| 176 - (void)didTap:(id)sender { | 190 - (void)didTap:(id)sender { |
| 177 // TODO(nicholss): The FAB is being used to launch an alert window with | 191 // TODO(nicholss): The FAB is being used to launch an alert window with |
| 178 // more options. This is not ideal but it gets us an easy way to make a | 192 // more options. This is not ideal but it gets us an easy way to make a |
| 179 // modal window option selector. Replace this with a real menu later. | 193 // modal window option selector. Replace this with a real menu later. |
| 180 | 194 |
| 181 UIAlertController* alert = | 195 UIAlertController* alert = |
| 182 [UIAlertController alertControllerWithTitle:@"Remote Settings" | 196 [UIAlertController alertControllerWithTitle:@"Remote Settings" |
| 183 message:nil | 197 message:nil |
| (...skipping 21 matching lines...) Expand all Loading... |
| 205 [self dismissViewControllerAnimated:YES completion:nil]; | 219 [self dismissViewControllerAnimated:YES completion:nil]; |
| 206 }; | 220 }; |
| 207 [alert addAction:[UIAlertAction actionWithTitle:@"Disconnect" | 221 [alert addAction:[UIAlertAction actionWithTitle:@"Disconnect" |
| 208 style:UIAlertActionStyleCancel | 222 style:UIAlertActionStyleCancel |
| 209 handler:disconnectHandler]]; | 223 handler:disconnectHandler]]; |
| 210 | 224 |
| 211 [self presentViewController:alert animated:YES completion:nil]; | 225 [self presentViewController:alert animated:YES completion:nil]; |
| 212 } | 226 } |
| 213 | 227 |
| 214 @end | 228 @end |
| OLD | NEW |