Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #import "ios/chrome/browser/ui/settings/cells/native_app_item.h" | 5 #import "ios/chrome/browser/ui/settings/cells/native_app_item.h" |
| 6 | 6 |
| 7 #import <QuartzCore/QuartzCore.h> | 7 #import <QuartzCore/QuartzCore.h> |
| 8 | 8 |
| 9 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" | 9 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" |
| 10 #include "ios/chrome/grit/ios_strings.h" | 10 #include "ios/chrome/grit/ios_strings.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 | 66 |
| 67 @synthesize nameLabel = _nameLabel; | 67 @synthesize nameLabel = _nameLabel; |
| 68 @synthesize iconImageView = _iconImageView; | 68 @synthesize iconImageView = _iconImageView; |
| 69 @synthesize switchControl = _switchControl; | 69 @synthesize switchControl = _switchControl; |
| 70 @synthesize installButton = _installButton; | 70 @synthesize installButton = _installButton; |
| 71 | 71 |
| 72 - (instancetype)initWithFrame:(CGRect)frame { | 72 - (instancetype)initWithFrame:(CGRect)frame { |
| 73 self = [super initWithFrame:frame]; | 73 self = [super initWithFrame:frame]; |
| 74 if (self) { | 74 if (self) { |
| 75 UIView* contentView = self.contentView; | 75 UIView* contentView = self.contentView; |
| 76 self.isAccessibilityElement = YES; | |
| 76 | 77 |
| 77 _iconImageView = [[UIImageView alloc] init]; | 78 _iconImageView = [[UIImageView alloc] init]; |
| 78 _iconImageView.translatesAutoresizingMaskIntoConstraints = NO; | 79 _iconImageView.translatesAutoresizingMaskIntoConstraints = NO; |
| 79 _iconImageView.image = PlaceholderIcon(); | 80 _iconImageView.image = PlaceholderIcon(); |
| 80 _iconImageView.layer.cornerRadius = kIconCornerRadius; | 81 _iconImageView.layer.cornerRadius = kIconCornerRadius; |
| 81 _iconImageView.layer.masksToBounds = YES; | 82 _iconImageView.layer.masksToBounds = YES; |
| 82 self.layer.shouldRasterize = YES; | 83 self.layer.shouldRasterize = YES; |
| 83 self.layer.rasterizationScale = [[UIScreen mainScreen] scale]; | 84 self.layer.rasterizationScale = [[UIScreen mainScreen] scale]; |
| 84 [contentView addSubview:_iconImageView]; | 85 [contentView addSubview:_iconImageView]; |
| 85 | 86 |
| 86 _nameLabel = [[UILabel alloc] init]; | 87 _nameLabel = [[UILabel alloc] init]; |
| 87 _nameLabel.translatesAutoresizingMaskIntoConstraints = NO; | 88 _nameLabel.translatesAutoresizingMaskIntoConstraints = NO; |
| 88 [contentView addSubview:_nameLabel]; | 89 [contentView addSubview:_nameLabel]; |
| 89 | 90 |
| 90 _nameLabel.font = | 91 _nameLabel.font = |
| 91 [[MDFRobotoFontLoader sharedInstance] mediumFontOfSize:14]; | 92 [[MDFRobotoFontLoader sharedInstance] mediumFontOfSize:14]; |
| 92 _nameLabel.textColor = [[MDCPalette greyPalette] tint900]; | 93 _nameLabel.textColor = [[MDCPalette greyPalette] tint900]; |
| 93 | 94 |
| 94 _switchControl = [[UISwitch alloc] init]; | 95 _switchControl = [[UISwitch alloc] init]; |
| 95 _switchControl.onTintColor = [[MDCPalette cr_bluePalette] tint500]; | 96 _switchControl.onTintColor = [[MDCPalette cr_bluePalette] tint500]; |
| 96 | 97 |
| 97 _installButton = [[MDCFlatButton alloc] init]; | 98 _installButton = [[MDCFlatButton alloc] init]; |
| 98 _installButton.translatesAutoresizingMaskIntoConstraints = NO; | 99 _installButton.translatesAutoresizingMaskIntoConstraints = NO; |
| 99 _installButton.customTitleColor = [[MDCPalette cr_bluePalette] tint500]; | 100 _installButton.customTitleColor = [[MDCPalette cr_bluePalette] tint500]; |
| 100 [_installButton | 101 [_installButton |
| 101 setTitle:l10n_util::GetNSString(IDS_IOS_GOOGLE_APPS_INSTALL_BUTTON) | 102 setTitle:l10n_util::GetNSString(IDS_IOS_GOOGLE_APPS_INSTALL_BUTTON) |
| 102 forState:UIControlStateNormal]; | 103 forState:UIControlStateNormal]; |
| 103 [_installButton setTitle:@"" forState:UIControlStateDisabled]; | 104 [_installButton setTitle:@"" forState:UIControlStateDisabled]; |
| 104 _installButton.accessibilityHint = l10n_util::GetNSString( | 105 _installButton.accessibilityHint = l10n_util::GetNSString( |
|
lpromero
2017/01/06 09:41:27
If the parent view is accessibility element, the b
sczs
2017/01/06 21:59:08
This currently gets read by VoiceOver since [self.
| |
| 105 IDS_IOS_GOOGLE_APPS_INSTALL_BUTTON_ACCESSIBILITY_HINT); | 106 IDS_IOS_GOOGLE_APPS_INSTALL_BUTTON_ACCESSIBILITY_HINT); |
| 106 | 107 |
| 107 // Set up the constraints. | 108 // Set up the constraints. |
| 108 [NSLayoutConstraint activateConstraints:@[ | 109 [NSLayoutConstraint activateConstraints:@[ |
| 109 [_iconImageView.leadingAnchor | 110 [_iconImageView.leadingAnchor |
| 110 constraintEqualToAnchor:contentView.leadingAnchor | 111 constraintEqualToAnchor:contentView.leadingAnchor |
| 111 constant:kHorizontalPadding], | 112 constant:kHorizontalPadding], |
| 112 [_iconImageView.trailingAnchor | 113 [_iconImageView.trailingAnchor |
| 113 constraintEqualToAnchor:_nameLabel.leadingAnchor | 114 constraintEqualToAnchor:_nameLabel.leadingAnchor |
| 114 constant:-kHorizontalPadding], | 115 constant:-kHorizontalPadding], |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 164 CGRect accessoryViewFrame = UIAccessibilityConvertFrameToScreenCoordinates( | 165 CGRect accessoryViewFrame = UIAccessibilityConvertFrameToScreenCoordinates( |
| 165 [self.accessoryView frame], self); | 166 [self.accessoryView frame], self); |
| 166 return CGPointMake(CGRectGetMidX(accessoryViewFrame), | 167 return CGPointMake(CGRectGetMidX(accessoryViewFrame), |
| 167 CGRectGetMidY(accessoryViewFrame)); | 168 CGRectGetMidY(accessoryViewFrame)); |
| 168 } | 169 } |
| 169 | 170 |
| 170 - (NSString*)accessibilityHint { | 171 - (NSString*)accessibilityHint { |
| 171 return [self.accessoryView accessibilityHint]; | 172 return [self.accessoryView accessibilityHint]; |
| 172 } | 173 } |
| 173 | 174 |
| 174 - (UIAccessibilityTraits)accessibilityTraits { | |
| 175 // Remove the "button" accessibility trait from the switch. This matches | |
| 176 // native switch content views such as Settings > Airplane Mode. | |
| 177 return | |
| 178 [super accessibilityTraits] | | |
| 179 ([self.switchControl accessibilityTraits] & ~UIAccessibilityTraitButton); | |
| 180 } | |
| 181 | |
| 182 - (NSString*)accessibilityValue { | 175 - (NSString*)accessibilityValue { |
| 183 if (self.accessoryView == self.switchControl) { | 176 if (self.accessoryView == self.switchControl) { |
| 184 return (self.switchControl.on) | 177 if (self.switchControl.on) { |
| 185 ? l10n_util::GetNSString(IDS_IOS_SETTING_ON) | 178 return [NSString |
| 186 : l10n_util::GetNSString(IDS_IOS_SETTING_OFF); | 179 stringWithFormat:@"%@, %@", self.nameLabel.text, |
| 180 l10n_util::GetNSString(IDS_IOS_SETTING_ON)]; | |
| 181 } else { | |
| 182 return [NSString | |
| 183 stringWithFormat:@"%@, %@", self.nameLabel.text, | |
| 184 l10n_util::GetNSString(IDS_IOS_SETTING_OFF)]; | |
| 185 } | |
| 187 } | 186 } |
| 188 return [self.accessoryView accessibilityValue]; | 187 |
| 188 return [NSString stringWithFormat:@"%@, %@", self.nameLabel.text, | |
| 189 l10n_util::GetNSString( | |
| 190 IDS_IOS_GOOGLE_APPS_INSTALL_BUTTON)]; | |
| 189 } | 191 } |
| 190 | 192 |
| 191 @end | 193 @end |
| OLD | NEW |