Skip to content

Commit

Permalink
[iOS] Add accessibility for UnifiedConsent
Browse files Browse the repository at this point in the history
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 <jlebel@chromium.org>
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#581842}
  • Loading branch information
Gauthier Ambard authored and Commit Bot committed Aug 9, 2018
1 parent 8519a6f commit f2e5d42
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand All @@ -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];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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 {
Expand All @@ -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];
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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 =
Expand Down

0 comments on commit f2e5d42

Please sign in to comment.