| OLD | NEW |
| 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 "ARDSettingsModel.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 () <UITextFieldDelegate> { |
| 22 ARDSettingsModel *_settingsModel; | 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 settingsModel:(ARDSettingsModel *)settingsModel { | 30 settingsModel:(ARDSettingsModel *)settingsModel { |
| 31 self = [super initWithStyle:style]; | 31 self = [super initWithStyle:style]; |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 - (UITableViewCell *)bitrateTableViewCellForTableView:(UITableView *)tableView | 193 - (UITableViewCell *)bitrateTableViewCellForTableView:(UITableView *)tableView |
| 194 atIndexPath:(NSIndexPath *)indexPath { | 194 atIndexPath:(NSIndexPath *)indexPath { |
| 195 NSString *dequeueIdentifier = @"ARDSettingsBitrateCellIdentifier"; | 195 NSString *dequeueIdentifier = @"ARDSettingsBitrateCellIdentifier"; |
| 196 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:dequeueId
entifier]; | 196 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:dequeueId
entifier]; |
| 197 if (!cell) { | 197 if (!cell) { |
| 198 cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault | 198 cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault |
| 199 reuseIdentifier:dequeueIdentifier]; | 199 reuseIdentifier:dequeueIdentifier]; |
| 200 | 200 |
| 201 UITextField *textField = [[UITextField alloc] | 201 UITextField *textField = [[UITextField alloc] |
| 202 initWithFrame:CGRectMake(10, 0, cell.bounds.size.width - 20, cell.bounds
.size.height)]; | 202 initWithFrame:CGRectMake(10, 0, cell.bounds.size.width - 20, cell.bounds
.size.height)]; |
| 203 NSString *currentMaxBitrate = [_settingsModel currentMaxBitrateSettingFromSt
ore].stringValue; |
| 204 textField.text = currentMaxBitrate; |
| 203 textField.placeholder = @"Enter max bit rate (kbps)"; | 205 textField.placeholder = @"Enter max bit rate (kbps)"; |
| 204 textField.keyboardType = UIKeyboardTypeNumberPad; | 206 textField.keyboardType = UIKeyboardTypeNumberPad; |
| 207 textField.delegate = self; |
| 205 | 208 |
| 206 // Numerical keyboards have no return button, we need to add one manually. | 209 // Numerical keyboards have no return button, we need to add one manually. |
| 207 UIToolbar *numberToolbar = | 210 UIToolbar *numberToolbar = |
| 208 [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.
width, 50)]; | 211 [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.
width, 50)]; |
| 209 numberToolbar.items = @[ | 212 numberToolbar.items = @[ |
| 210 [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItem
FlexibleSpace | 213 [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItem
FlexibleSpace |
| 211 target:nil | 214 target:nil |
| 212 action:nil], | 215 action:nil], |
| 213 [[UIBarButtonItem alloc] initWithTitle:@"Apply" | 216 [[UIBarButtonItem alloc] initWithTitle:@"Apply" |
| 214 style:UIBarButtonItemStyleDone | 217 style:UIBarButtonItemStyleDone |
| 215 target:self | 218 target:self |
| 216 action:@selector(numberTextFieldDidEndEdit
ing:)] | 219 action:@selector(numberTextFieldDidEndEdit
ing:)] |
| 217 ]; | 220 ]; |
| 218 [numberToolbar sizeToFit]; | 221 [numberToolbar sizeToFit]; |
| 219 | 222 |
| 220 textField.inputAccessoryView = numberToolbar; | 223 textField.inputAccessoryView = numberToolbar; |
| 221 [cell addSubview:textField]; | 224 [cell addSubview:textField]; |
| 222 } | 225 } |
| 223 return cell; | 226 return cell; |
| 224 } | 227 } |
| 225 | 228 |
| 226 - (void)numberTextFieldDidEndEditing:(id)sender { | 229 - (void)numberTextFieldDidEndEditing:(id)sender { |
| 227 [self.view endEditing:YES]; | 230 [self.view endEditing:YES]; |
| 228 } | 231 } |
| 229 | 232 |
| 233 - (void)textFieldDidEndEditing:(UITextField *)textField { |
| 234 NSNumber *bitrateNumber = nil; |
| 235 |
| 236 if (textField.text.length != 0) { |
| 237 bitrateNumber = [NSNumber numberWithInteger:textField.text.intValue]; |
| 238 } |
| 239 |
| 240 [_settingsModel storeMaxBitrateSetting:bitrateNumber]; |
| 241 } |
| 242 |
| 230 @end | 243 @end |
| 231 NS_ASSUME_NONNULL_END | 244 NS_ASSUME_NONNULL_END |
| OLD | NEW |