From f2e5d424276a3729c5e5f5950932f235d38155ae Mon Sep 17 00:00:00 2001 From: Gauthier Ambard Date: Thu, 9 Aug 2018 09:29:33 +0000 Subject: [PATCH] [iOS] Add accessibility for UnifiedConsent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This CL adds accessibility (larger fonts and VoiceOver) to the Unified Consent and the Consent Bump. Bug: 872277 Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet Change-Id: Ie6699132fe395b34717a8097d66ee97bf9406e13 Reviewed-on: https://chromium-review.googlesource.com/1167504 Reviewed-by: Jérôme Lebel Commit-Queue: Gauthier Ambard Cr-Commit-Position: refs/heads/master@{#581842} --- .../browser/ui/authentication/authentication_constants.h | 4 ++-- .../ui/authentication/authentication_constants.mm | 4 ++-- .../consent_bump_personalization_view_controller.mm | 4 ++-- .../identity_chooser/identity_chooser_header_item.mm | 4 ++++ .../unified_consent/identity_picker_view.mm | 9 +++++++++ .../unified_consent/unified_consent_view_controller.mm | 4 ++-- 6 files changed, 21 insertions(+), 8 deletions(-) diff --git a/ios/chrome/browser/ui/authentication/authentication_constants.h b/ios/chrome/browser/ui/authentication/authentication_constants.h index 11e2ce809b74cf..7b67c717e2d776 100644 --- a/ios/chrome/browser/ui/authentication/authentication_constants.h +++ b/ios/chrome/browser/ui/authentication/authentication_constants.h @@ -12,8 +12,8 @@ extern const CGFloat kAuthenticationHeaderImageHeight; extern const CGFloat kAuthenticationHeaderImageWidth; // Font sizes -extern const CGFloat kAuthenticationTitleFontSize; -extern const CGFloat kAuthenticationTextFontSize; +extern const UIFontTextStyle kAuthenticationTitleFontStyle; +extern const UIFontTextStyle kAuthenticationTextFontStyle; // Color displayed in the non-safe area. extern const int kAuthenticationHeaderBackgroundColor; diff --git a/ios/chrome/browser/ui/authentication/authentication_constants.mm b/ios/chrome/browser/ui/authentication/authentication_constants.mm index 3d7cace8d8f9d6..8257d4c4134eeb 100644 --- a/ios/chrome/browser/ui/authentication/authentication_constants.mm +++ b/ios/chrome/browser/ui/authentication/authentication_constants.mm @@ -11,8 +11,8 @@ const CGFloat kAuthenticationHeaderImageHeight = 88.; const CGFloat kAuthenticationHeaderImageWidth = 360.; -const CGFloat kAuthenticationTitleFontSize = 23.; -const CGFloat kAuthenticationTextFontSize = 12.; +const UIFontTextStyle kAuthenticationTitleFontStyle = UIFontTextStyleTitle2; +const UIFontTextStyle kAuthenticationTextFontStyle = UIFontTextStyleCaption1; const int kAuthenticationHeaderBackgroundColor = 0xf8f9fa; const CGFloat kAuthenticationHorizontalMargin = 16.; diff --git a/ios/chrome/browser/ui/authentication/consent_bump/consent_bump_personalization_view_controller.mm b/ios/chrome/browser/ui/authentication/consent_bump/consent_bump_personalization_view_controller.mm index 3a41b4a494a8d6..1a33e27e5a8920 100644 --- a/ios/chrome/browser/ui/authentication/consent_bump/consent_bump_personalization_view_controller.mm +++ b/ios/chrome/browser/ui/authentication/consent_bump/consent_bump_personalization_view_controller.mm @@ -86,7 +86,7 @@ - (void)viewDidLoad { l10n_util::GetNSString(IDS_IOS_CONSENT_BUMP_PERSONALIZATION_TITLE); title.textColor = [UIColor colorWithWhite:0 alpha:kAuthenticationTitleColorAlpha]; - title.font = [UIFont systemFontOfSize:kAuthenticationTitleFontSize]; + title.font = [UIFont preferredFontForTextStyle:kAuthenticationTitleFontStyle]; title.numberOfLines = 0; [container addSubview:title]; @@ -97,7 +97,7 @@ - (void)viewDidLoad { l10n_util::GetNSString(IDS_IOS_CONSENT_BUMP_PERSONALIZATION_MESSAGE); text.textColor = [UIColor colorWithWhite:0 alpha:kAuthenticationTextColorAlpha]; - text.font = [UIFont systemFontOfSize:kAuthenticationTextFontSize]; + text.font = [UIFont preferredFontForTextStyle:kAuthenticationTextFontStyle]; text.numberOfLines = 0; [container addSubview:text]; diff --git a/ios/chrome/browser/ui/authentication/unified_consent/identity_chooser/identity_chooser_header_item.mm b/ios/chrome/browser/ui/authentication/unified_consent/identity_chooser/identity_chooser_header_item.mm index 536c7545fdb007..a41ae4c13546c0 100644 --- a/ios/chrome/browser/ui/authentication/unified_consent/identity_chooser/identity_chooser_header_item.mm +++ b/ios/chrome/browser/ui/authentication/unified_consent/identity_chooser/identity_chooser_header_item.mm @@ -52,6 +52,10 @@ - (instancetype)initWithReuseIdentifier:(NSString*)reuseIdentifier { @"V:|-(TopMargin)-[label]", ]; ApplyVisualConstraintsWithMetrics(constraints, views, metrics); + + self.isAccessibilityElement = YES; + self.accessibilityLabel = + l10n_util::GetNSString(IDS_IOS_ACCOUNT_IDENTITY_CHOOSER_CHOOSE_ACCOUNT); } return self; } diff --git a/ios/chrome/browser/ui/authentication/unified_consent/identity_picker_view.mm b/ios/chrome/browser/ui/authentication/unified_consent/identity_picker_view.mm index f13ed8b9aa5f43..75ca9b075e3681 100644 --- a/ios/chrome/browser/ui/authentication/unified_consent/identity_picker_view.mm +++ b/ios/chrome/browser/ui/authentication/unified_consent/identity_picker_view.mm @@ -116,6 +116,10 @@ - (instancetype)initWithFrame:(CGRect)frame { AddSameCenterYConstraint(self, _arrowDownImageView); AddSameCenterConstraints(_checkmarkImageView, _arrowDownImageView); ApplyVisualConstraintsWithMetrics(constraints, views, metrics); + + // Accessibility. + self.isAccessibilityElement = YES; + self.accessibilityTraits = UIAccessibilityTraitButton; } return self; } @@ -127,6 +131,8 @@ - (void)setCanChangeIdentity:(BOOL)canChangeIdentity { self.enabled = canChangeIdentity; self.arrowDownImageView.hidden = !canChangeIdentity; self.checkmarkImageView.hidden = canChangeIdentity; + self.accessibilityTraits = canChangeIdentity ? UIAccessibilityTraitButton + : UIAccessibilityTraitStaticText; } - (void)setIdentityAvatar:(UIImage*)identityAvatar { @@ -137,8 +143,11 @@ - (void)setIdentityName:(NSString*)name email:(NSString*)email { DCHECK(email); if (!name.length) { [self.identityView setTitle:email subtitle:nil]; + self.accessibilityLabel = email; } else { [self.identityView setTitle:name subtitle:email]; + self.accessibilityLabel = + [NSString stringWithFormat:@"%@, %@", name, email]; } } diff --git a/ios/chrome/browser/ui/authentication/unified_consent/unified_consent_view_controller.mm b/ios/chrome/browser/ui/authentication/unified_consent/unified_consent_view_controller.mm index c80fa97bb61730..4954719687d6a1 100644 --- a/ios/chrome/browser/ui/authentication/unified_consent/unified_consent_view_controller.mm +++ b/ios/chrome/browser/ui/authentication/unified_consent/unified_consent_view_controller.mm @@ -193,7 +193,7 @@ - (void)viewDidLoad { _consentStringIds.push_back(IDS_IOS_ACCOUNT_UNIFIED_CONSENT_TITLE); title.textColor = [UIColor colorWithWhite:0 alpha:kAuthenticationTitleColorAlpha]; - title.font = [UIFont systemFontOfSize:kAuthenticationTitleFontSize]; + title.font = [UIFont preferredFontForTextStyle:kAuthenticationTitleFontStyle]; title.numberOfLines = 0; [container addSubview:title]; @@ -374,7 +374,7 @@ - (UILabel*)addLabelWithStringId:(int)stringId DCHECK(parentView); UILabel* label = [[UILabel alloc] initWithFrame:CGRectZero]; label.translatesAutoresizingMaskIntoConstraints = NO; - label.font = [UIFont systemFontOfSize:kAuthenticationTextFontSize]; + label.font = [UIFont preferredFontForTextStyle:kAuthenticationTextFontStyle]; label.text = l10n_util::GetNSString(stringId); _consentStringIds.push_back(stringId); label.textColor =