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

Side by Side Diff: webrtc/examples/objc/AppRTCMobile/ios/ARDSettingsViewController.m

Issue 2479153002: Rename media constraints model and store. (Closed)
Patch Set: Rebase master Created 4 years, 1 month 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 /* 1 /*
2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #import "ARDSettingsViewController.h" 11 #import "ARDSettingsViewController.h"
12 #import "ARDMediaConstraintsModel.h" 12 #import "ARDSettingsModel.h"
13 13
14 NS_ASSUME_NONNULL_BEGIN 14 NS_ASSUME_NONNULL_BEGIN
15 15
16 typedef NS_ENUM(int, ARDSettingsSections) { 16 typedef NS_ENUM(int, ARDSettingsSections) {
17 ARDSettingsSectionMediaConstraints = 0, 17 ARDSettingsSectionMediaConstraints = 0,
18 ARDSettingsSectionBitRate 18 ARDSettingsSectionBitRate
19 }; 19 };
20 20
21 @interface ARDSettingsViewController () { 21 @interface ARDSettingsViewController () {
22 ARDMediaConstraintsModel *_mediaConstraintsModel; 22 ARDSettingsModel *_settingsModel;
23 } 23 }
24 24
25 @end 25 @end
26 26
27 @implementation ARDSettingsViewController 27 @implementation ARDSettingsViewController
28 28
29 - (instancetype)initWithStyle:(UITableViewStyle)style 29 - (instancetype)initWithStyle:(UITableViewStyle)style
30 mediaConstraintsModel:(ARDMediaConstraintsModel *)mediaConstraintsModel { 30 settingsModel:(ARDSettingsModel *)settingsModel {
31 self = [super initWithStyle:style]; 31 self = [super initWithStyle:style];
32 if (self) { 32 if (self) {
33 _mediaConstraintsModel = mediaConstraintsModel; 33 _settingsModel = settingsModel;
34 } 34 }
35 return self; 35 return self;
36 } 36 }
37 37
38 #pragma mark - View lifecycle 38 #pragma mark - View lifecycle
39 39
40 - (void)viewDidLoad { 40 - (void)viewDidLoad {
41 [super viewDidLoad]; 41 [super viewDidLoad];
42 self.title = @"Settings"; 42 self.title = @"Settings";
43 [self addDoneBarButton]; 43 [self addDoneBarButton];
44 } 44 }
45 45
46 - (void)viewDidAppear:(BOOL)animated { 46 - (void)viewDidAppear:(BOOL)animated {
47 [super viewDidAppear:animated]; 47 [super viewDidAppear:animated];
48 [self selectCurrentlyStoredOrDefaultMediaConstraints]; 48 [self selectCurrentlyStoredOrDefaultMediaConstraints];
49 } 49 }
50 50
51 #pragma mark - Data source 51 #pragma mark - Data source
52 52
53 - (NSArray<NSString *> *)mediaConstraintsArray { 53 - (NSArray<NSString *> *)mediaConstraintsArray {
54 return _mediaConstraintsModel.availableVideoResoultionsMediaConstraints; 54 return _settingsModel.availableVideoResoultionsMediaConstraints;
55 } 55 }
56 56
57 #pragma mark - 57 #pragma mark -
58 58
59 - (void)addDoneBarButton { 59 - (void)addDoneBarButton {
60 UIBarButtonItem *barItem = 60 UIBarButtonItem *barItem =
61 [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItem Done 61 [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItem Done
62 target:self 62 target:self
63 action:@selector(dismissModa lly:)]; 63 action:@selector(dismissModa lly:)];
64 self.navigationItem.leftBarButtonItem = barItem; 64 self.navigationItem.leftBarButtonItem = barItem;
65 } 65 }
66 66
67 - (void)selectCurrentlyStoredOrDefaultMediaConstraints { 67 - (void)selectCurrentlyStoredOrDefaultMediaConstraints {
68 NSString *currentSelection = [_mediaConstraintsModel currentVideoResoultionCon straintFromStore]; 68 NSString *currentSelection = [_settingsModel currentVideoResoultionConstraintF romStore];
69 69
70 NSUInteger indexOfSelection = [[self mediaConstraintsArray] indexOfObject:curr entSelection]; 70 NSUInteger indexOfSelection = [[self mediaConstraintsArray] indexOfObject:curr entSelection];
71 NSIndexPath *pathToBeSelected = [NSIndexPath indexPathForRow:indexOfSelection inSection:0]; 71 NSIndexPath *pathToBeSelected = [NSIndexPath indexPathForRow:indexOfSelection inSection:0];
72 [self.tableView selectRowAtIndexPath:pathToBeSelected 72 [self.tableView selectRowAtIndexPath:pathToBeSelected
73 animated:NO 73 animated:NO
74 scrollPosition:UITableViewScrollPositionNone]; 74 scrollPosition:UITableViewScrollPositionNone];
75 // Manully invoke the delegate method because the previous invocation will not . 75 // Manully invoke the delegate method because the previous invocation will not .
76 [self tableView:self.tableView didSelectRowAtIndexPath:pathToBeSelected]; 76 [self tableView:self.tableView didSelectRowAtIndexPath:pathToBeSelected];
77 } 77 }
78 78
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 cell.textLabel.text = self.mediaConstraintsArray[indexPath.row]; 170 cell.textLabel.text = self.mediaConstraintsArray[indexPath.row];
171 return cell; 171 return cell;
172 } 172 }
173 173
174 - (void)tableView:(UITableView *)tableView 174 - (void)tableView:(UITableView *)tableView
175 didSelectMediaConstraintsCellAtIndexPath:(NSIndexPath *)indexPath { 175 didSelectMediaConstraintsCellAtIndexPath:(NSIndexPath *)indexPath {
176 UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; 176 UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
177 cell.accessoryType = UITableViewCellAccessoryCheckmark; 177 cell.accessoryType = UITableViewCellAccessoryCheckmark;
178 178
179 NSString *mediaConstraintsString = self.mediaConstraintsArray[indexPath.row]; 179 NSString *mediaConstraintsString = self.mediaConstraintsArray[indexPath.row];
180 [_mediaConstraintsModel storeVideoResoultionConstraint:mediaConstraintsString] ; 180 [_settingsModel storeVideoResoultionConstraint:mediaConstraintsString];
181 } 181 }
182 182
183 - (NSIndexPath *)tableView:(UITableView *)tableView 183 - (NSIndexPath *)tableView:(UITableView *)tableView
184 willDeselectMediaConstraintsRowAtIndexPath:(NSIndexPath *)indexPath { 184 willDeselectMediaConstraintsRowAtIndexPath:(NSIndexPath *)indexPath {
185 NSIndexPath *oldSelection = [tableView indexPathForSelectedRow]; 185 NSIndexPath *oldSelection = [tableView indexPathForSelectedRow];
186 UITableViewCell *cell = [tableView cellForRowAtIndexPath:oldSelection]; 186 UITableViewCell *cell = [tableView cellForRowAtIndexPath:oldSelection];
187 cell.accessoryType = UITableViewCellAccessoryNone; 187 cell.accessoryType = UITableViewCellAccessoryNone;
188 return indexPath; 188 return indexPath;
189 } 189 }
190 190
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 } 222 }
223 return cell; 223 return cell;
224 } 224 }
225 225
226 - (void)numberTextFieldDidEndEditing:(id)sender { 226 - (void)numberTextFieldDidEndEditing:(id)sender {
227 [self.view endEditing:YES]; 227 [self.view endEditing:YES];
228 } 228 }
229 229
230 @end 230 @end
231 NS_ASSUME_NONNULL_END 231 NS_ASSUME_NONNULL_END
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698