Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(553)

Side by Side Diff: remoting/client/ios/app/remoting_view_controller.mm

Issue 2846603002: Updating Pin Entry View and creating Connection Status View. (Closed)
Patch Set: Use viewWillLayoutSubviews. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/client/ios/app/remoting_view_controller.h" 9 #import "remoting/client/ios/app/remoting_view_controller.h"
10 10
11 #import "base/mac/bind_objc_block.h" 11 #import "base/mac/bind_objc_block.h"
12 #import "ios/third_party/material_components_ios/src/components/AnimationTiming/ src/MaterialAnimationTiming.h" 12 #import "ios/third_party/material_components_ios/src/components/AnimationTiming/ src/MaterialAnimationTiming.h"
13 #import "ios/third_party/material_components_ios/src/components/AppBar/src/Mater ialAppBar.h" 13 #import "ios/third_party/material_components_ios/src/components/AppBar/src/Mater ialAppBar.h"
14 #import "ios/third_party/material_components_ios/src/components/Dialogs/src/Mate rialDialogs.h" 14 #import "ios/third_party/material_components_ios/src/components/Dialogs/src/Mate rialDialogs.h"
15 #import "ios/third_party/material_components_ios/src/components/Snackbar/src/Mat erialSnackbar.h" 15 #import "ios/third_party/material_components_ios/src/components/Snackbar/src/Mat erialSnackbar.h"
16 #import "remoting/client/ios/app/client_connection_view_controller.h"
16 #import "remoting/client/ios/app/host_collection_view_controller.h" 17 #import "remoting/client/ios/app/host_collection_view_controller.h"
17 #import "remoting/client/ios/app/host_view_controller.h" 18 #import "remoting/client/ios/app/host_view_controller.h"
18 #import "remoting/client/ios/app/pin_entry_view_controller.h"
19 #import "remoting/client/ios/app/remoting_settings_view_controller.h" 19 #import "remoting/client/ios/app/remoting_settings_view_controller.h"
20 #import "remoting/client/ios/domain/client_session_details.h"
20 #import "remoting/client/ios/facade/remoting_service.h" 21 #import "remoting/client/ios/facade/remoting_service.h"
21 #import "remoting/client/ios/session/remoting_client.h" 22 #import "remoting/client/ios/session/remoting_client.h"
22 23
23 #include "base/strings/sys_string_conversions.h" 24 #include "base/strings/sys_string_conversions.h"
24 #include "remoting/base/oauth_token_getter.h" 25 #include "remoting/base/oauth_token_getter.h"
25 #include "remoting/client/connect_to_host_info.h" 26 #include "remoting/client/connect_to_host_info.h"
26 27
27 static CGFloat kHostInset = 5.f; 28 static CGFloat kHostInset = 5.f;
28 29
29 @interface RemotingViewController ()<HostCollectionViewControllerDelegate, 30 @interface RemotingViewController ()<HostCollectionViewControllerDelegate,
31 ClientConnectionViewControllerDelegate,
30 UIViewControllerAnimatedTransitioning, 32 UIViewControllerAnimatedTransitioning,
31 UIViewControllerTransitioningDelegate> { 33 UIViewControllerTransitioningDelegate> {
32 bool _isAuthenticated; 34 bool _isAuthenticated;
33 MDCDialogTransitionController* _dialogTransitionController; 35 MDCDialogTransitionController* _dialogTransitionController;
34 MDCAppBar* _appBar; 36 MDCAppBar* _appBar;
35 HostCollectionViewController* _collectionViewController; 37 HostCollectionViewController* _collectionViewController;
36 RemotingService* _remotingService; 38 RemotingService* _remotingService;
39 RemotingClient* _client;
37 } 40 }
38 @end 41 @end
39 42
40 // TODO(nicholss): Localize this file. 43 // TODO(nicholss): Localize this file.
41 // TODO(nicholss): This file is not finished with integration, the app flow is 44 // TODO(nicholss): This file is not finished with integration, the app flow is
42 // still pending development. 45 // still pending development.
43 46
44 @implementation RemotingViewController 47 @implementation RemotingViewController
45 48
46 - (instancetype)init { 49 - (instancetype)init {
(...skipping 28 matching lines...) Expand all
75 target:self 78 target:self
76 action:@selector(didSelectSettings)]; 79 action:@selector(didSelectSettings)];
77 self.navigationItem.leftBarButtonItem = menuButton; 80 self.navigationItem.leftBarButtonItem = menuButton;
78 81
79 UIBarButtonItem* refreshButton = 82 UIBarButtonItem* refreshButton =
80 [[UIBarButtonItem alloc] initWithTitle:@"Refresh" 83 [[UIBarButtonItem alloc] initWithTitle:@"Refresh"
81 style:UIBarButtonItemStyleDone 84 style:UIBarButtonItemStyleDone
82 target:self 85 target:self
83 action:@selector(didSelectRefresh)]; 86 action:@selector(didSelectRefresh)];
84 self.navigationItem.rightBarButtonItem = refreshButton; 87 self.navigationItem.rightBarButtonItem = refreshButton;
88
89 [[NSNotificationCenter defaultCenter]
90 addObserver:self
91 selector:@selector(hostSessionStatusChanged:)
92 name:kHostSessionStatusChanged
93 object:nil];
85 } 94 }
86 return self; 95 return self;
87 } 96 }
88 97
89 #pragma mark - UIViewController 98 #pragma mark - UIViewController
90 99
91 - (void)viewDidLoad { 100 - (void)viewDidLoad {
92 [super viewDidLoad]; 101 [super viewDidLoad];
93 [_appBar addSubviewsToParent]; 102 [_appBar addSubviewsToParent];
94 [self presentStatus]; 103 [self presentStatus];
(...skipping 30 matching lines...) Expand all
125 } 134 }
126 135
127 #pragma mark - RemotingHostListDelegate 136 #pragma mark - RemotingHostListDelegate
128 137
129 // TODO(nicholss): these need to be a stats change like "none, loading, 138 // TODO(nicholss): these need to be a stats change like "none, loading,
130 // updated"... 139 // updated"...
131 - (void)hostListUpdated { 140 - (void)hostListUpdated {
132 [_collectionViewController.collectionView reloadData]; 141 [_collectionViewController.collectionView reloadData];
133 } 142 }
134 143
144 #pragma mark - ClientConnectionViewControllerDelegate
145
146 - (void)clientConnected {
147 HostViewController* hostViewController =
148 [[HostViewController alloc] initWithClient:_client];
149 [self presentViewController:hostViewController animated:YES completion:nil];
150 }
151
152 - (NSString*)getConnectingHostName {
153 if (_client) {
154 return _client.hostInfo.hostName;
155 }
156 return nil;
157 }
158
135 #pragma mark - HostCollectionViewControllerDelegate 159 #pragma mark - HostCollectionViewControllerDelegate
136 160
137 - (void)didSelectCell:(HostCollectionViewCell*)cell 161 - (void)didSelectCell:(HostCollectionViewCell*)cell
138 completion:(void (^)())completionBlock { 162 completion:(void (^)())completionBlock {
139 RemotingClient* client = [[RemotingClient alloc] init]; 163 _client = [[RemotingClient alloc] init];
140 164
141 [_remotingService 165 [_remotingService
142 callbackWithAccessToken:base::BindBlockArc(^( 166 callbackWithAccessToken:base::BindBlockArc(^(
143 remoting::OAuthTokenGetter::Status status, 167 remoting::OAuthTokenGetter::Status status,
144 const std::string& user_email, 168 const std::string& user_email,
145 const std::string& access_token) { 169 const std::string& access_token) {
146 // TODO(nicholss): Check status. 170 // TODO(nicholss): Check status.
147 HostInfo* hostInfo = cell.hostInfo; 171 HostInfo* hostInfo = cell.hostInfo;
148 DCHECK(hostInfo); 172 [_client connectToHost:hostInfo
149 DCHECK(hostInfo.jabberId); 173 username:base::SysUTF8ToNSString(user_email)
150 DCHECK(hostInfo.hostId); 174 accessToken:base::SysUTF8ToNSString(access_token)];
151 DCHECK(hostInfo.publicKey);
152
153 remoting::ConnectToHostInfo info;
154 info.username = user_email;
155 info.auth_token = access_token;
156 info.host_jid = base::SysNSStringToUTF8(hostInfo.jabberId);
157 info.host_id = base::SysNSStringToUTF8(hostInfo.hostId);
158 info.host_pubkey = base::SysNSStringToUTF8(hostInfo.publicKey);
159 // TODO(nicholss): If iOS supports pairing, pull the stored data and
160 // insert it here.
161 info.pairing_id = "";
162 info.pairing_secret = "";
163
164 // TODO(nicholss): I am not sure about the following fields yet.
165 // info.capabilities =
166 // info.flags =
167 // info.host_version =
168 // info.host_os =
169 // info.host_os_version =
170 [client connectToHost:info];
171 })]; 175 })];
172 176
173 HostViewController* hostViewController = 177 ClientConnectionViewController* clientConnectionViewController =
174 [[HostViewController alloc] initWithClient:client]; 178 [[ClientConnectionViewController alloc] init];
175 179 clientConnectionViewController.delegate = self;
176 // TODO(nicholss): Add feedback on status of request. 180 [self presentViewController:clientConnectionViewController
177 [self presentViewController:hostViewController animated:YES completion:nil]; 181 animated:YES
178 182 completion:nil];
179 completionBlock(); 183 completionBlock();
180 } 184 }
181 185
182 - (NSInteger)getHostCount { 186 - (NSInteger)getHostCount {
183 NSArray<HostInfo*>* hosts = [_remotingService getHosts]; 187 NSArray<HostInfo*>* hosts = [_remotingService getHosts];
184 return [hosts count]; 188 return [hosts count];
185 } 189 }
186 190
187 - (HostInfo*)getHostAtIndexPath:(NSIndexPath*)path { 191 - (HostInfo*)getHostAtIndexPath:(NSIndexPath*)path {
188 NSArray<HostInfo*>* hosts = [_remotingService getHosts]; 192 NSArray<HostInfo*>* hosts = [_remotingService getHosts];
(...skipping 21 matching lines...) Expand all
210 (id<UIViewControllerContextTransitioning>)transitionContext { 214 (id<UIViewControllerContextTransitioning>)transitionContext {
211 } 215 }
212 216
213 - (NSTimeInterval)transitionDuration: 217 - (NSTimeInterval)transitionDuration:
214 (id<UIViewControllerContextTransitioning>)transitionContext { 218 (id<UIViewControllerContextTransitioning>)transitionContext {
215 return 0.2; 219 return 0.2;
216 } 220 }
217 221
218 #pragma mark - Private 222 #pragma mark - Private
219 223
224 - (void)hostSessionStatusChanged:(NSNotification*)notification {
225 NSLog(@"hostSessionStatusChanged: %@", [notification userInfo]);
226 }
227
220 - (void)closeViewController { 228 - (void)closeViewController {
221 [self dismissViewControllerAnimated:true completion:nil]; 229 [self dismissViewControllerAnimated:true completion:nil];
222 } 230 }
223 231
224 - (void)didSelectRefresh { 232 - (void)didSelectRefresh {
225 // TODO(nicholss) implement this. 233 // TODO(nicholss) implement this.
226 NSLog(@"Should refresh..."); 234 NSLog(@"Should refresh...");
227 _dialogTransitionController = [[MDCDialogTransitionController alloc] init]; 235 _dialogTransitionController = [[MDCDialogTransitionController alloc] init];
228 PinEntryViewController* vc =
229 [[PinEntryViewController alloc] initWithCallback:nil];
230 vc.modalPresentationStyle = UIModalPresentationCustom;
231 vc.transitioningDelegate = _dialogTransitionController;
232 [self presentViewController:vc animated:YES completion:nil];
233 } 236 }
234 237
235 - (void)didSelectSettings { 238 - (void)didSelectSettings {
236 RemotingSettingsViewController* settingsVC = 239 RemotingSettingsViewController* settingsViewController =
237 [RemotingSettingsViewController new]; 240 [[RemotingSettingsViewController alloc] init];
238 [self presentViewController:settingsVC animated:YES completion:nil]; 241 [self presentViewController:settingsViewController
242 animated:YES
243 completion:nil];
239 } 244 }
240 245
241 - (void)presentStatus { 246 - (void)presentStatus {
242 MDCSnackbarMessage* message = [[MDCSnackbarMessage alloc] init]; 247 MDCSnackbarMessage* message = [[MDCSnackbarMessage alloc] init];
243 if (_isAuthenticated) { 248 if (_isAuthenticated) {
244 UserInfo* user = [_remotingService getUser]; 249 UserInfo* user = [_remotingService getUser];
245 message.text = [NSString 250 message.text = [NSString
246 stringWithFormat:@"Currently signed in as %@.", [user userEmail]]; 251 stringWithFormat:@"Currently signed in as %@.", [user userEmail]];
247 [MDCSnackbarManager showMessage:message]; 252 [MDCSnackbarManager showMessage:message];
248 } 253 }
249 } 254 }
250 255
251 @end 256 @end
OLDNEW
« no previous file with comments | « remoting/client/ios/app/pin_entry_view_controller.mm ('k') | remoting/client/ios/domain/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698