Chromium Code Reviews| Index: remoting/ios/app/host_view_controller.mm |
| diff --git a/remoting/ios/app/host_view_controller.mm b/remoting/ios/app/host_view_controller.mm |
| index 4cdfb8866aa1d892f5f0d2b8ecc82701844d8191..f46fee1bb98a9fbb5bf8e1c534d338b1d5b0d54d 100644 |
| --- a/remoting/ios/app/host_view_controller.mm |
| +++ b/remoting/ios/app/host_view_controller.mm |
| @@ -17,12 +17,14 @@ |
| #import "remoting/ios/client_keyboard.h" |
| #import "remoting/ios/session/remoting_client.h" |
| +#include "base/strings/sys_string_conversions.h" |
| #include "remoting/client/gesture_interpreter.h" |
| +#include "remoting/client/input/keyboard_interpreter.h" |
| static const CGFloat kFabInset = 15.f; |
| static const CGFloat kKeyboardAnimationTime = 0.3; |
|
Yuwei
2017/05/15 19:38:07
f?
|
| -@interface HostViewController () { |
| +@interface HostViewController ()<ClientKeyboardDelegate> { |
| RemotingClient* _client; |
| MDCFloatingButton* _floatingButton; |
| ClientGestures* _clientGestures; |
| @@ -133,6 +135,7 @@ static const CGFloat kKeyboardAnimationTime = 0.3; |
| - (void)showKeyboard { |
| if (!_clientKeyboard) { |
| _clientKeyboard = [[ClientKeyboard alloc] init]; |
| + _clientKeyboard.delegate = self; |
| [self.view addSubview:_clientKeyboard]; |
| // TODO(nicholss): need to pass some keyboard injection interface here. |
| } |
| @@ -147,15 +150,15 @@ static const CGFloat kKeyboardAnimationTime = 0.3; |
| - (void)keyboardWillShow:(NSNotification*)notification { |
| CGSize keyboardSize = |
| - [[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] |
| + [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] |
| CGRectValue] |
| .size; |
| if (_keyboardSize.height != keyboardSize.height) { |
| CGFloat deltaHeight = keyboardSize.height - _keyboardSize.height; |
| - [UIView animateWithDuration:0.3 |
| + [UIView animateWithDuration:kKeyboardAnimationTime |
| animations:^{ |
| CGRect f = self.view.frame; |
| - f.size.height += deltaHeight; |
| + f.size.height -= deltaHeight; |
| self.view.frame = f; |
| }]; |
| _keyboardSize = keyboardSize; |
| @@ -172,6 +175,17 @@ static const CGFloat kKeyboardAnimationTime = 0.3; |
| _keyboardSize = CGSizeZero; |
| } |
| +#pragma mark - ClientKeyboardDelegate |
| + |
| +- (void)clientKeyboardShouldSend:(NSString*)text { |
| + _client.keyboardInterpreter->HandleTextEvent(base::SysNSStringToUTF8(text), |
| + 0); |
| +} |
| + |
| +- (void)clientKeyboardShouldDelete { |
| + _client.keyboardInterpreter->HandleDeleteEvent(0); |
| +} |
| + |
| #pragma mark - Private |
| - (void)didTap:(id)sender { |