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

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

Issue 2479153002: Rename media constraints model and store. (Closed)
Patch Set: 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 @interface ARDSettingsViewController () { 15 @interface ARDSettingsViewController () {
16 ARDMediaConstraintsModel *_mediaConstraintsModel; 16 ARDSettingsModel *_settingsModel;
17 } 17 }
18 18
19 @end 19 @end
20 20
21 @implementation ARDSettingsViewController 21 @implementation ARDSettingsViewController
22 22
23 - (instancetype)initWithStyle:(UITableViewStyle)style 23 - (instancetype)initWithStyle:(UITableViewStyle)style
24 mediaConstraintsModel:(ARDMediaConstraintsModel *)mediaConstraintsModel { 24 settingsModel:(ARDSettingsModel *)settingsModel {
25 self = [super initWithStyle:style]; 25 self = [super initWithStyle:style];
26 if (self) { 26 if (self) {
27 _mediaConstraintsModel = mediaConstraintsModel; 27 _settingsModel = settingsModel;
28 } 28 }
29 return self; 29 return self;
30 } 30 }
31 31
32 #pragma mark - View lifecycle 32 #pragma mark - View lifecycle
33 33
34 - (void)viewDidLoad { 34 - (void)viewDidLoad {
35 [super viewDidLoad]; 35 [super viewDidLoad];
36 self.title = @"Settings"; 36 self.title = @"Settings";
37 [self addDoneBarButton]; 37 [self addDoneBarButton];
38 } 38 }
39 39
40 - (void)viewDidAppear:(BOOL)animated { 40 - (void)viewDidAppear:(BOOL)animated {
41 [super viewDidAppear:animated]; 41 [super viewDidAppear:animated];
42 [self selectCurrentlyStoredOrDefaultMediaConstraints]; 42 [self selectCurrentlyStoredOrDefaultMediaConstraints];
43 } 43 }
44 44
45 #pragma mark - Data source 45 #pragma mark - Data source
46 46
47 - (NSArray<NSString *> *)mediaConstraintsArray { 47 - (NSArray<NSString *> *)mediaConstraintsArray {
48 return _mediaConstraintsModel.availableVideoResoultionsMediaConstraints; 48 return _settingsModel.availableVideoResoultionsMediaConstraints;
49 } 49 }
50 50
51 #pragma mark - 51 #pragma mark -
52 52
53 - (void)addDoneBarButton { 53 - (void)addDoneBarButton {
54 UIBarButtonItem *barItem = 54 UIBarButtonItem *barItem =
55 [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItem Done 55 [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItem Done
56 target:self 56 target:self
57 action:@selector(dismissModa lly:)]; 57 action:@selector(dismissModa lly:)];
58 self.navigationItem.leftBarButtonItem = barItem; 58 self.navigationItem.leftBarButtonItem = barItem;
59 } 59 }
60 60
61 - (void)selectCurrentlyStoredOrDefaultMediaConstraints { 61 - (void)selectCurrentlyStoredOrDefaultMediaConstraints {
62 NSString *currentSelection = [_mediaConstraintsModel currentVideoResoultionCon straintFromStore]; 62 NSString *currentSelection = [_settingsModel currentVideoResoultionConstraintF romStore];
63 63
64 NSUInteger indexOfSelection = [[self mediaConstraintsArray] indexOfObject:curr entSelection]; 64 NSUInteger indexOfSelection = [[self mediaConstraintsArray] indexOfObject:curr entSelection];
65 NSIndexPath *pathToBeSelected = [NSIndexPath indexPathForRow:indexOfSelection inSection:0]; 65 NSIndexPath *pathToBeSelected = [NSIndexPath indexPathForRow:indexOfSelection inSection:0];
66 [self.tableView selectRowAtIndexPath:pathToBeSelected 66 [self.tableView selectRowAtIndexPath:pathToBeSelected
67 animated:NO 67 animated:NO
68 scrollPosition:UITableViewScrollPositionNone]; 68 scrollPosition:UITableViewScrollPositionNone];
69 // Manully invoke the delegate method because the previous invocation will not . 69 // Manully invoke the delegate method because the previous invocation will not .
70 [self tableView:self.tableView didSelectRowAtIndexPath:pathToBeSelected]; 70 [self tableView:self.tableView didSelectRowAtIndexPath:pathToBeSelected];
71 } 71 }
72 72
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 cell.textLabel.text = self.mediaConstraintsArray[indexPath.row]; 140 cell.textLabel.text = self.mediaConstraintsArray[indexPath.row];
141 return cell; 141 return cell;
142 } 142 }
143 143
144 - (void)tableView:(UITableView *)tableView 144 - (void)tableView:(UITableView *)tableView
145 didSelectMediaConstraintsCellAtIndexPath:(NSIndexPath *)indexPath { 145 didSelectMediaConstraintsCellAtIndexPath:(NSIndexPath *)indexPath {
146 UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; 146 UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
147 cell.accessoryType = UITableViewCellAccessoryCheckmark; 147 cell.accessoryType = UITableViewCellAccessoryCheckmark;
148 148
149 NSString *mediaConstraintsString = self.mediaConstraintsArray[indexPath.row]; 149 NSString *mediaConstraintsString = self.mediaConstraintsArray[indexPath.row];
150 [_mediaConstraintsModel storeVideoResoultionConstraint:mediaConstraintsString] ; 150 [_settingsModel storeVideoResoultionConstraint:mediaConstraintsString];
151 } 151 }
152 152
153 - (NSIndexPath *)tableView:(UITableView *)tableView 153 - (NSIndexPath *)tableView:(UITableView *)tableView
154 willDeselectMediaConstraintsRowAtIndexPath:(NSIndexPath *)indexPath { 154 willDeselectMediaConstraintsRowAtIndexPath:(NSIndexPath *)indexPath {
155 NSIndexPath *oldSelection = [tableView indexPathForSelectedRow]; 155 NSIndexPath *oldSelection = [tableView indexPathForSelectedRow];
156 UITableViewCell *cell = [tableView cellForRowAtIndexPath:oldSelection]; 156 UITableViewCell *cell = [tableView cellForRowAtIndexPath:oldSelection];
157 cell.accessoryType = UITableViewCellAccessoryNone; 157 cell.accessoryType = UITableViewCellAccessoryNone;
158 return indexPath; 158 return indexPath;
159 } 159 }
160 160
161 @end 161 @end
162 NS_ASSUME_NONNULL_END 162 NS_ASSUME_NONNULL_END
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698