| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #if !defined(__has_feature) || !__has_feature(objc_arc) | |
| 6 #error "This file requires ARC support." | |
| 7 #endif | |
| 8 | |
| 9 #import "remoting/ios/ui/pin_entry_view_controller.h" | |
| 10 | |
| 11 #import "remoting/ios/utility.h" | |
| 12 | |
| 13 @implementation PinEntryViewController | |
| 14 | |
| 15 @synthesize delegate = _delegate; | |
| 16 @synthesize shouldPrompt = _shouldPrompt; | |
| 17 @synthesize pairingSupported = _pairingSupported; | |
| 18 | |
| 19 // Override UIViewController | |
| 20 - (id)initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil { | |
| 21 // NibName is the * part of your *.xib file | |
| 22 | |
| 23 if ([Utility isPad]) { | |
| 24 self = [super initWithNibName:@"pin_entry_view_controller_ipad" bundle:nil]; | |
| 25 } else { | |
| 26 self = | |
| 27 [super initWithNibName:@"pin_entry_view_controller_iphone" bundle:nil]; | |
| 28 } | |
| 29 if (self) { | |
| 30 // Custom initialization | |
| 31 } | |
| 32 return self; | |
| 33 } | |
| 34 | |
| 35 // Override UIViewController | |
| 36 // Controls are not created immediately, properties must be set before the form | |
| 37 // is displayed | |
| 38 - (void)viewWillAppear:(BOOL)animated { | |
| 39 _host.text = _hostName; | |
| 40 | |
| 41 [_switchAskAgain setOn:!_shouldPrompt]; | |
| 42 | |
| 43 // TODO (aboone) The switch is being hidden in all cases, this functionality | |
| 44 // is not scheduled for QA yet. | |
| 45 // if (!_pairingSupported) { | |
| 46 _switchAskAgain.hidden = YES; | |
| 47 _shouldSavePin.hidden = YES; | |
| 48 _switchAskAgain.enabled = NO; | |
| 49 //} | |
| 50 [_hostPin becomeFirstResponder]; | |
| 51 } | |
| 52 | |
| 53 // @protocol UITextFieldDelegate, called when the 'enter' key is pressed | |
| 54 - (BOOL)textFieldShouldReturn:(UITextField*)textField { | |
| 55 [textField resignFirstResponder]; | |
| 56 if (textField == _hostPin) | |
| 57 [self buttonConnectClicked:self]; | |
| 58 return YES; | |
| 59 } | |
| 60 | |
| 61 - (IBAction)buttonCancelClicked:(id)sender { | |
| 62 [_delegate cancelledConnectToHostWithPin:self]; | |
| 63 } | |
| 64 | |
| 65 - (IBAction)buttonConnectClicked:(id)sender { | |
| 66 [_delegate connectToHostWithPin:self | |
| 67 hostPin:_hostPin.text | |
| 68 shouldPrompt:!_switchAskAgain.isOn]; | |
| 69 } | |
| 70 | |
| 71 @end | |
| OLD | NEW |