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 IDS_IOS_GOOGLE_APPS_INSTALL_BUTTON_ACCESSIBILITY_HINT); | |
106 | 105 |
107 // Set up the constraints. | 106 // Set up the constraints. |
108 [NSLayoutConstraint activateConstraints:@[ | 107 [NSLayoutConstraint activateConstraints:@[ |
109 [_iconImageView.leadingAnchor | 108 [_iconImageView.leadingAnchor |
110 constraintEqualToAnchor:contentView.leadingAnchor | 109 constraintEqualToAnchor:contentView.leadingAnchor |
111 constant:kHorizontalPadding], | 110 constant:kHorizontalPadding], |
112 [_iconImageView.trailingAnchor | 111 [_iconImageView.trailingAnchor |
113 constraintEqualToAnchor:_nameLabel.leadingAnchor | 112 constraintEqualToAnchor:_nameLabel.leadingAnchor |
114 constant:-kHorizontalPadding], | 113 constant:-kHorizontalPadding], |
115 [_iconImageView.widthAnchor constraintEqualToConstant:kIconSize], | 114 [_iconImageView.widthAnchor constraintEqualToConstant:kIconSize], |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
164 CGRect accessoryViewFrame = UIAccessibilityConvertFrameToScreenCoordinates( | 163 CGRect accessoryViewFrame = UIAccessibilityConvertFrameToScreenCoordinates( |
165 [self.accessoryView frame], self); | 164 [self.accessoryView frame], self); |
166 return CGPointMake(CGRectGetMidX(accessoryViewFrame), | 165 return CGPointMake(CGRectGetMidX(accessoryViewFrame), |
167 CGRectGetMidY(accessoryViewFrame)); | 166 CGRectGetMidY(accessoryViewFrame)); |
168 } | 167 } |
169 | 168 |
170 - (NSString*)accessibilityHint { | 169 - (NSString*)accessibilityHint { |
171 return [self.accessoryView accessibilityHint]; | 170 return [self.accessoryView accessibilityHint]; |
172 } | 171 } |
173 | 172 |
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 { | 173 - (NSString*)accessibilityValue { |
183 if (self.accessoryView == self.switchControl) { | 174 if (self.accessoryView == self.switchControl) { |
184 return (self.switchControl.on) | 175 if (self.switchControl.on) { |
185 ? l10n_util::GetNSString(IDS_IOS_SETTING_ON) | 176 return [NSString |
186 : l10n_util::GetNSString(IDS_IOS_SETTING_OFF); | 177 stringWithFormat:@"%@, %@", self.nameLabel.text, |
178 l10n_util::GetNSString(IDS_IOS_SETTING_ON)]; | |
179 } else { | |
180 return [NSString | |
181 stringWithFormat:@"%@, %@", self.nameLabel.text, | |
182 l10n_util::GetNSString(IDS_IOS_SETTING_OFF)]; | |
183 } | |
187 } | 184 } |
188 return [self.accessoryView accessibilityValue]; | 185 |
186 return | |
187 [NSString stringWithFormat: | |
188 @"%@, %@", self.nameLabel.text, | |
189 l10n_util::GetNSString( | |
190 IDS_IOS_GOOGLE_APPS_INSTALL_BUTTON_ACCESSIBILITY_HINT)]; | |
lpromero
2017/01/05 23:00:58
The hint reads: "Double tap to install", so I real
sczs
2017/01/05 23:17:24
You're right, the "INSTALL" text wasn't being read
| |
189 } | 191 } |
190 | 192 |
191 @end | 193 @end |
OLD | NEW |