Skip to content

Commit

Permalink
[iOS][Autofill][SavePrompts] Use i18n strings for address save/update…
Browse files Browse the repository at this point in the history
…/edit prompts on iOS

The strings have been added to the components/autofill_strings.grdp.

Bug: 1167062
Change-Id: I9b5071b9d4f8c3cb10166e9425806b1c66980719
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2903117
Reviewed-by: Chris Lu <thegreenfrog@chromium.org>
Commit-Queue: Vidhan Jain <vidhanj@google.com>
Cr-Commit-Position: refs/heads/master@{#885045}
  • Loading branch information
Vidhan Jain authored and Chromium LUCI CQ committed May 20, 2021
1 parent c2e8eda commit d8dd5da
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 14 deletions.
1 change: 1 addition & 0 deletions ios/chrome/browser/ui/infobars/modals/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ source_set("modals") {
":public",
"//base",
"//components/autofill/core/common:features",
"//components/strings",
"//components/translate/core/browser",
"//ios/chrome/app/strings:ios_strings_grit",
"//ios/chrome/browser/infobars:public",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
// Informs the consumer of the data.
- (void)setupModalViewControllerWithData:(NSDictionary*)data;

// Informs the consumer if the edit is done for updating the profile.
- (void)setIsEditForUpdate:(BOOL)isEditForUpdate;

@end

#endif // IOS_CHROME_BROWSER_UI_INFOBARS_MODALS_INFOBAR_EDIT_ADDRESS_PROFILE_MODAL_CONSUMER_H_
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "base/metrics/user_metrics_action.h"
#include "base/stl_util.h"
#include "components/autofill/core/common/autofill_features.h"
#include "components/strings/grit/components_strings.h"
#include "ios/chrome/browser/infobars/infobar_metrics_recorder.h"
#import "ios/chrome/browser/ui/autofill/autofill_ui_type.h"
#import "ios/chrome/browser/ui/autofill/autofill_ui_type_util.h"
Expand Down Expand Up @@ -54,6 +55,9 @@ @interface InfobarEditAddressProfileTableViewController () <UITextFieldDelegate>
// All the data to be displayed in the edit dialog.
@property(nonatomic, strong) NSMutableDictionary* profileData;

// Yes, if the edit is done for updating the profile.
@property(nonatomic, assign) BOOL isEditForUpdate;

@end

@implementation InfobarEditAddressProfileTableViewController
Expand Down Expand Up @@ -93,8 +97,13 @@ - (void)viewDidLoad {
self.navigationItem.leftBarButtonItem = cancelButton;
self.navigationController.navigationBar.prefersLargeTitles = NO;

// TODO(crbug.com/1167062): Replace with proper localized string.
self.navigationItem.title = @"Test Edit Address";
if (self.isEditForUpdate) {
self.navigationItem.title =
l10n_util::GetNSString(IDS_IOS_AUTOFILL_UPDATE_ADDRESS_PROMPT_TITLE);
} else {
self.navigationItem.title =
l10n_util::GetNSString(IDS_IOS_AUTOFILL_SAVE_ADDRESS_PROMPT_TITLE);
}

self.tableView.allowsSelectionDuringEditing = YES;

Expand Down Expand Up @@ -132,8 +141,13 @@ - (void)loadModel {
TableViewTextButtonItem* saveButton =
[[TableViewTextButtonItem alloc] initWithType:ItemTypeSaveButton];
saveButton.textAlignment = NSTextAlignmentNatural;
// TODO(crbug.com/1167062): Replace with proper localized string.
saveButton.buttonText = @"Test Save";
if (self.isEditForUpdate) {
saveButton.buttonText = l10n_util::GetNSString(
IDS_AUTOFILL_UPDATE_ADDRESS_PROMPT_OK_BUTTON_LABEL);
} else {
saveButton.buttonText = l10n_util::GetNSString(
IDS_AUTOFILL_SAVE_ADDRESS_PROMPT_OK_BUTTON_LABEL);
}
saveButton.disableButtonIntrinsicWidth = YES;
[model addItem:saveButton toSectionWithIdentifier:SectionIdentifierButton];
}
Expand Down Expand Up @@ -169,6 +183,10 @@ - (void)setupModalViewControllerWithData:(NSDictionary*)data {
[self.tableView reloadData];
}

- (void)setIsEditForUpdate:(BOOL)isEditForUpdate {
_isEditForUpdate = isEditForUpdate;
}

#pragma mark - UITableViewDelegate

- (CGFloat)tableView:(UITableView*)tableView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "base/mac/foundation_util.h"
#include "base/metrics/user_metrics.h"
#include "base/metrics/user_metrics_action.h"
#include "components/strings/grit/components_strings.h"
#include "ios/chrome/browser/infobars/infobar_metrics_recorder.h"
#import "ios/chrome/browser/ui/autofill/autofill_ui_type.h"
#import "ios/chrome/browser/ui/autofill/autofill_ui_type_util.h"
Expand Down Expand Up @@ -126,11 +127,12 @@ - (void)viewDidLoad {

self.navigationController.navigationBar.prefersLargeTitles = NO;

// TODO(crbug.com/1167062): Replace with proper localized string.
if (self.isUpdateModal) {
self.navigationItem.title = @"Update Address";
self.navigationItem.title =
l10n_util::GetNSString(IDS_IOS_AUTOFILL_UPDATE_ADDRESS_PROMPT_TITLE);
} else {
self.navigationItem.title = @"Save Address";
self.navigationItem.title =
l10n_util::GetNSString(IDS_IOS_AUTOFILL_SAVE_ADDRESS_PROMPT_TITLE);
}

[self loadModel];
Expand Down Expand Up @@ -277,8 +279,11 @@ - (void)loadUpdateAddressModal {
[model addSectionWithIdentifier:SectionIdentifierUpdateModalNewFields];

if (showOld) {
// TODO(crbug.com/1167062): Use i18n strings.
[model setHeader:[self updateHeaderWithText:@"New"]
[model setHeader:
[self
updateHeaderWithText:
l10n_util::GetNSString(
IDS_AUTOFILL_UPDATE_ADDRESS_PROMPT_NEW_VALUES_SECTION_LABEL)]
forSectionWithIdentifier:SectionIdentifierUpdateModalNewFields];
}
for (NSNumber* type in self.profileDataDiff) {
Expand All @@ -295,8 +300,11 @@ - (void)loadUpdateAddressModal {
// Old
[model addSectionWithIdentifier:SectionIdentifierUpdateModalOldFields];

// TODO(crbug.com/1167062): Use i18n strings.
[model setHeader:[self updateHeaderWithText:@"Old"]
[model setHeader:
[self
updateHeaderWithText:
l10n_util::GetNSString(
IDS_AUTOFILL_UPDATE_ADDRESS_PROMPT_OLD_VALUES_SECTION_LABEL)]
forSectionWithIdentifier:SectionIdentifierUpdateModalOldFields];
for (NSNumber* type in self.profileDataDiff) {
if ([self.profileDataDiff[type][1] length] > 0) {
Expand Down Expand Up @@ -357,11 +365,12 @@ - (TableViewTextButtonItem*)saveUpdateButton {
initWithType:ItemTypeAddressProfileSaveUpdateButton];
saveUpdateButton.textAlignment = NSTextAlignmentNatural;

// TODO(crbug.com/1167062): Use i18n strings.
if (self.isUpdateModal) {
saveUpdateButton.buttonText = @"Update";
saveUpdateButton.buttonText = l10n_util::GetNSString(
IDS_AUTOFILL_UPDATE_ADDRESS_PROMPT_OK_BUTTON_LABEL);
} else {
saveUpdateButton.buttonText = @"Save";
saveUpdateButton.buttonText = l10n_util::GetNSString(
IDS_AUTOFILL_SAVE_ADDRESS_PROMPT_OK_BUTTON_LABEL);
}

saveUpdateButton.enabled = !self.currentAddressProfileSaved;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ - (void)setEditAddressConsumer:
if (!_editAddressConsumer || !config)
return;

[_editAddressConsumer setIsEditForUpdate:config->IsUpdateModal()];

[_editAddressConsumer
setupModalViewControllerWithData:config->GetProfileInfo()];
}
Expand Down

0 comments on commit d8dd5da

Please sign in to comment.