summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjdonnelly <jdonnelly@chromium.org>2015-10-07 07:30:29 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-07 14:31:16 +0000
commit4ddf102561f6ac382890477fedbaf05947a275b1 (patch)
tree46c708c1708dd8ead13928428f5c9e61386ac535
parentd3fda2269814ef8e0af4210adb4d30706f78cc8c (diff)
downloadchromium_src-4ddf102561f6ac382890477fedbaf05947a275b1.zip
chromium_src-4ddf102561f6ac382890477fedbaf05947a275b1.tar.gz
chromium_src-4ddf102561f6ac382890477fedbaf05947a275b1.tar.bz2
Improve the accessibility label of Autofill suggestions.
This change adds displayDescription (containing the secondary portion of full-form Autofill suggestions) and an "x of y" description to the accessibility label of suggestions shown in the keyboard accessory. BUG=532722,532723 Review URL: https://codereview.chromium.org/1383203003 Cr-Commit-Position: refs/heads/master@{#352837}
-rw-r--r--ios/chrome/app/strings/ios_strings.grd3
-rw-r--r--ios/chrome/browser/autofill/form_suggestion_label.h2
-rw-r--r--ios/chrome/browser/autofill/form_suggestion_label.mm15
-rw-r--r--ios/chrome/browser/autofill/form_suggestion_view.mm11
4 files changed, 25 insertions, 6 deletions
diff --git a/ios/chrome/app/strings/ios_strings.grd b/ios/chrome/app/strings/ios_strings.grd
index 022c1b6..2cde67e 100644
--- a/ios/chrome/app/strings/ios_strings.grd
+++ b/ios/chrome/app/strings/ios_strings.grd
@@ -139,6 +139,9 @@ all other OS specific variables will be false.
<message name="IDS_IOS_AUTOFILL_ACCNAME_PREVIOUS_FIELD" desc="The accessible name for the previous field button in the keyboard accessory shown when filling out forms. [Length: unlimited] [iOS only]">
Previous field
</message>
+ <message name="IDS_IOS_AUTOFILL_ACCNAME_SUGGESTION" desc="The accessible description of a suggestion shown in the Autofill keyboard acessory. [Length: unlimited] [iOS only]">
+ <ph name="VALUE">$1<ex>John Smith</ex></ph>, <ph name="ADDITIONAL_INFO">$2<ex>1234 Main St., Springfield, IL 62711</ex></ph>, <ph name="INDEX">$3<ex>1</ex></ph> of <ph name="NUM_SUGGESTIONS">$4<ex>5</ex></ph>
+ </message>
<message name="IDS_IOS_AUTOFILL_DIALOG_PLACEHOLDER_EXPIRY_MONTH" desc="The placeholder text for credit card expiration month in the payments card unmask dialog. [Length: 4em] [iOS only]">
MM
</message>
diff --git a/ios/chrome/browser/autofill/form_suggestion_label.h b/ios/chrome/browser/autofill/form_suggestion_label.h
index 44a784b..15eb877 100644
--- a/ios/chrome/browser/autofill/form_suggestion_label.h
+++ b/ios/chrome/browser/autofill/form_suggestion_label.h
@@ -21,6 +21,8 @@
// |suggestion| and width in |proposedFrame| is ignored.
- (id)initWithSuggestion:(FormSuggestion*)suggestion
proposedFrame:(CGRect)proposedFrame
+ index:(NSUInteger)index
+ numSuggestions:(NSUInteger)numSuggestions
client:(id<FormSuggestionViewClient>)client;
@end
diff --git a/ios/chrome/browser/autofill/form_suggestion_label.mm b/ios/chrome/browser/autofill/form_suggestion_label.mm
index 099a8e7..2b16079 100644
--- a/ios/chrome/browser/autofill/form_suggestion_label.mm
+++ b/ios/chrome/browser/autofill/form_suggestion_label.mm
@@ -8,12 +8,15 @@
#import <QuartzCore/QuartzCore.h>
+#include "base/strings/string_number_conversions.h"
#include "base/strings/sys_string_conversions.h"
#include "components/autofill/core/browser/credit_card.h"
#import "components/autofill/ios/browser/form_suggestion.h"
#import "ios/chrome/browser/autofill/form_suggestion_view_client.h"
#import "ios/chrome/browser/ui/uikit_ui_util.h"
#include "ios/chrome/browser/ui/ui_util.h"
+#include "ios/chrome/grit/ios_strings.h"
+#include "ui/base/l10n/l10n_util.h"
namespace {
@@ -86,6 +89,8 @@ UILabel* TextLabel(NSString* text, CGFloat alpha, BOOL bold) {
- (id)initWithSuggestion:(FormSuggestion*)suggestion
proposedFrame:(CGRect)proposedFrame
+ index:(NSUInteger)index
+ numSuggestions:(NSUInteger)numSuggestions
client:(id<FormSuggestionViewClient>)client {
// TODO(jimblackler): implement sizeThatFits: and layoutSubviews, and perform
// layout in those methods instead of in the designated initializer.
@@ -144,9 +149,15 @@ UILabel* TextLabel(NSString* text, CGFloat alpha, BOOL bold) {
[[self layer] setCornerRadius:kCornerRadius];
[self setClipsToBounds:YES];
- [self setIsAccessibilityElement:YES];
- [self setAccessibilityLabel:suggestion.value];
[self setUserInteractionEnabled:YES];
+ [self setIsAccessibilityElement:YES];
+ [self setAccessibilityLabel:l10n_util::GetNSStringF(
+ IDS_IOS_AUTOFILL_ACCNAME_SUGGESTION,
+ base::SysNSStringToUTF16(suggestion.value),
+ base::SysNSStringToUTF16(
+ suggestion.displayDescription),
+ base::IntToString16(index + 1),
+ base::IntToString16(numSuggestions))];
}
return self;
diff --git a/ios/chrome/browser/autofill/form_suggestion_view.mm b/ios/chrome/browser/autofill/form_suggestion_view.mm
index d0cbffd..e7d1716 100644
--- a/ios/chrome/browser/autofill/form_suggestion_view.mm
+++ b/ios/chrome/browser/autofill/form_suggestion_view.mm
@@ -6,6 +6,7 @@
#include "base/i18n/rtl.h"
#include "base/mac/scoped_nsobject.h"
+#import "components/autofill/ios/browser/form_suggestion.h"
#import "ios/chrome/browser/autofill/form_suggestion_label.h"
#import "ios/chrome/browser/autofill/form_suggestion_view_client.h"
@@ -49,10 +50,12 @@ const CGFloat kSuggestionHorizontalMargin = 6;
// the width.
CGRect proposedFrame =
CGRectMake(currentX, kSuggestionVerticalMargin, 0, labelHeight);
- base::scoped_nsobject<UIView> label(
- [[FormSuggestionLabel alloc] initWithSuggestion:suggestion
- proposedFrame:proposedFrame
- client:client]);
+ base::scoped_nsobject<UIView> label([[FormSuggestionLabel alloc]
+ initWithSuggestion:suggestion
+ proposedFrame:proposedFrame
+ index:idx
+ numSuggestions:[_suggestions count]
+ client:client]);
[self addSubview:label];
currentX +=
CGRectGetWidth([label frame]) + kSuggestionHorizontalMargin;