[H/W] Add trailing text for H/W addresses
Adds a new UILabel in AutofillProfileCell to store information about
profile's record type.
Feature off: https://screenshot.googleplex.com/QJeNfdaEggsqn3e.png
iPhone: https://screenshot.googleplex.com/4VS3cio9NiKM6it.png
iPad: https://screenshot.googleplex.com/5SRKAJLYNPPKRkt.png
Bug: 411012711
Change-Id: I317bfccb1cfed53f702146a291b6ce81f1d71d8e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6459602
Commit-Queue: Julia Sobiech <jsobiech@google.com>
Reviewed-by: Gauthier Ambard <gambard@chromium.org>
Reviewed-by: Vidhan Jain <vidhanj@google.com>
Cr-Commit-Position: refs/heads/main@{#1453846}
diff --git a/ios/chrome/app/strings/ios_strings.grd b/ios/chrome/app/strings/ios_strings.grd
index bfda4f4..5fb43dcb 100644
--- a/ios/chrome/app/strings/ios_strings.grd
+++ b/ios/chrome/app/strings/ios_strings.grd
@@ -4814,6 +4814,12 @@
<message name="IDS_IOS_PRIVACY_SAFE_BROWSING_TITLE" desc="Title for Privacy Safe Browsing table view.">
Safe Browsing
</message>
+ <message name="IDS_IOS_PROFILE_RECORD_TYPE_HOME" desc="Title for a profile with a Home record type.">
+ Home
+ </message>
+ <message name="IDS_IOS_PROFILE_RECORD_TYPE_WORK" desc="Title for a profile with a Work record type.">
+ Work
+ </message>
<message name="IDS_IOS_PROGRESS_BAR_ACCESSIBILITY" desc="Text read by voice over to inform the user about the progress of the page load. [Read by Text To Speech].">
Page load progress bar, <ph name="EMAIL">$1<ex>20%</ex></ph> loaded.
</message>
diff --git a/ios/chrome/app/strings/ios_strings_grd/IDS_IOS_PROFILE_RECORD_TYPE_HOME.png.sha1 b/ios/chrome/app/strings/ios_strings_grd/IDS_IOS_PROFILE_RECORD_TYPE_HOME.png.sha1
new file mode 100644
index 0000000..24912f2
--- /dev/null
+++ b/ios/chrome/app/strings/ios_strings_grd/IDS_IOS_PROFILE_RECORD_TYPE_HOME.png.sha1
@@ -0,0 +1 @@
+d54666a10911b38f3ed473e2c25be99e3a769400
\ No newline at end of file
diff --git a/ios/chrome/app/strings/ios_strings_grd/IDS_IOS_PROFILE_RECORD_TYPE_WORK.png.sha1 b/ios/chrome/app/strings/ios_strings_grd/IDS_IOS_PROFILE_RECORD_TYPE_WORK.png.sha1
new file mode 100644
index 0000000..24912f2
--- /dev/null
+++ b/ios/chrome/app/strings/ios_strings_grd/IDS_IOS_PROFILE_RECORD_TYPE_WORK.png.sha1
@@ -0,0 +1 @@
+d54666a10911b38f3ed473e2c25be99e3a769400
\ No newline at end of file
diff --git a/ios/chrome/browser/settings/ui_bundled/autofill/autofill_profile_table_view_controller.mm b/ios/chrome/browser/settings/ui_bundled/autofill/autofill_profile_table_view_controller.mm
index 408e1ff..38c26cb 100644
--- a/ios/chrome/browser/settings/ui_bundled/autofill/autofill_profile_table_view_controller.mm
+++ b/ios/chrome/browser/settings/ui_bundled/autofill/autofill_profile_table_view_controller.mm
@@ -296,6 +296,21 @@
[[AutofillProfileItem alloc] initWithType:ItemTypeAddress];
item.title = title;
item.detailText = subTitle;
+
+ if (base::FeatureList::IsEnabled(
+ autofill::features::kAutofillEnableSupportForHomeAndWork)) {
+ autofill::AutofillProfile::RecordType recordType =
+ autofillProfile.record_type();
+ if (recordType == autofill::AutofillProfile::RecordType::kAccountHome) {
+ item.trailingDetailText =
+ l10n_util::GetNSString(IDS_IOS_PROFILE_RECORD_TYPE_HOME);
+ } else if (recordType ==
+ autofill::AutofillProfile::RecordType::kAccountWork) {
+ item.trailingDetailText =
+ l10n_util::GetNSString(IDS_IOS_PROFILE_RECORD_TYPE_WORK);
+ }
+ }
+
item.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
item.accessibilityIdentifier = title;
item.GUID = guid;
diff --git a/ios/chrome/browser/settings/ui_bundled/autofill/cells/autofill_profile_item.h b/ios/chrome/browser/settings/ui_bundled/autofill/cells/autofill_profile_item.h
index c9530bb..a334fd56 100644
--- a/ios/chrome/browser/settings/ui_bundled/autofill/cells/autofill_profile_item.h
+++ b/ios/chrome/browser/settings/ui_bundled/autofill/cells/autofill_profile_item.h
@@ -23,6 +23,9 @@
// multiline (no limit).
@property(nonatomic, copy) NSString* detailText;
+// Trailing detail text to be displayed.
+@property(nonatomic, copy) NSString* trailingDetailText;
+
// The GUID used by the PersonalDataManager to identify profiles.
@property(nonatomic, assign) std::string GUID;
@@ -47,9 +50,13 @@
@property(nonatomic, readonly, strong) UILabel* textLabel;
// The cell detail text.
@property(nonatomic, readonly, strong) UILabel* detailTextLabel;
+
// YES, if the cloud off icon representing local profile is shown.
@property(nonatomic, assign) BOOL localProfileIconShown;
+// Sets the visibility of trailingDetailTextLabel.
+- (void)setTrailingDetailText:(NSString*)trailingText;
+
@end
#endif // IOS_CHROME_BROWSER_SETTINGS_UI_BUNDLED_AUTOFILL_CELLS_AUTOFILL_PROFILE_ITEM_H_
diff --git a/ios/chrome/browser/settings/ui_bundled/autofill/cells/autofill_profile_item.mm b/ios/chrome/browser/settings/ui_bundled/autofill/cells/autofill_profile_item.mm
index 887dc5f..79942c46c 100644
--- a/ios/chrome/browser/settings/ui_bundled/autofill/cells/autofill_profile_item.mm
+++ b/ios/chrome/browser/settings/ui_bundled/autofill/cells/autofill_profile_item.mm
@@ -40,12 +40,16 @@
cell.textLabel.text = self.title;
cell.detailTextLabel.text = self.detailText;
+ [cell setTrailingDetailText:_trailingDetailText];
cell.localProfileIconShown = self.localProfileIconShown;
}
@end
-@implementation AutofillProfileCell
+@implementation AutofillProfileCell {
+ // The cell trailing detail text
+ UILabel* _trailingDetailTextLabel;
+}
// These properties overrides the ones from UITableViewCell, so this @synthesize
// cannot be removed.
@@ -80,6 +84,13 @@
_detailTextLabel.adjustsFontForContentSizeCategory = YES;
_detailTextLabel.textColor = [UIColor colorNamed:kTextSecondaryColor];
+ _trailingDetailTextLabel = [[UILabel alloc] init];
+ _trailingDetailTextLabel.font =
+ [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
+ _trailingDetailTextLabel.textColor =
+ [UIColor colorNamed:kTextSecondaryColor];
+ _trailingDetailTextLabel.hidden = YES;
+
UIStackView* verticalStack = [[UIStackView alloc]
initWithArrangedSubviews:@[ _textLabel, _detailTextLabel ]];
verticalStack.translatesAutoresizingMaskIntoConstraints = NO;
@@ -89,8 +100,10 @@
verticalStack.alignment = UIStackViewAlignmentLeading;
[self.contentView addSubview:verticalStack];
- UIStackView* horizontalStack = [[UIStackView alloc]
- initWithArrangedSubviews:@[ verticalStack, _imageView ]];
+ UIStackView* horizontalStack =
+ [[UIStackView alloc] initWithArrangedSubviews:@[
+ verticalStack, _trailingDetailTextLabel, _imageView
+ ]];
horizontalStack.translatesAutoresizingMaskIntoConstraints = NO;
horizontalStack.axis = UILayoutConstraintAxisHorizontal;
horizontalStack.spacing = kTableViewSubViewHorizontalSpacing;
@@ -125,12 +138,18 @@
return self;
}
+- (void)setTrailingDetailText:(NSString*)trailingText {
+ _trailingDetailTextLabel.text = trailingText;
+ _trailingDetailTextLabel.hidden = (trailingText.length == 0);
+}
+
#pragma mark - UITableViewCell
- (void)prepareForReuse {
[super prepareForReuse];
self.textLabel.text = nil;
self.detailTextLabel.text = nil;
+ [self setTrailingDetailText:nil];
self.localProfileIconShown = NO;
}
@@ -142,6 +161,11 @@
label =
[NSString stringWithFormat:@"%@, %@", label, self.detailTextLabel.text];
}
+
+ if (_trailingDetailTextLabel.text.length > 0) {
+ label = [NSString
+ stringWithFormat:@"%@, %@", label, _trailingDetailTextLabel.text];
+ }
if (self.localProfileIconShown) {
label = [NSString
stringWithFormat:@"%@, %@", label,