Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Side by Side Diff: ios/chrome/browser/ui/payments/contact_info_edit_mediator.mm

Issue 2956433002: [Payment Request] keyboardType, autoCapitalizationType, etc for text fields (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "ios/chrome/browser/ui/payments/contact_info_edit_mediator.h" 5 #import "ios/chrome/browser/ui/payments/contact_info_edit_mediator.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/sys_string_conversions.h" 8 #include "base/strings/sys_string_conversions.h"
9 #include "components/autofill/core/browser/autofill_country.h" 9 #include "components/autofill/core/browser/autofill_country.h"
10 #include "components/autofill/core/browser/autofill_profile.h" 10 #include "components/autofill/core/browser/autofill_profile.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 if (_paymentRequest->request_payer_name()) { 100 if (_paymentRequest->request_payer_name()) {
101 NSString* name = 101 NSString* name =
102 [self fieldValueFromProfile:self.profile fieldType:autofill::NAME_FULL]; 102 [self fieldValueFromProfile:self.profile fieldType:autofill::NAME_FULL];
103 EditorField* nameField = [[EditorField alloc] 103 EditorField* nameField = [[EditorField alloc]
104 initWithAutofillUIType:AutofillUITypeProfileFullName 104 initWithAutofillUIType:AutofillUITypeProfileFullName
105 fieldType:EditorFieldTypeTextField 105 fieldType:EditorFieldTypeTextField
106 label:l10n_util::GetNSString( 106 label:l10n_util::GetNSString(
107 IDS_PAYMENTS_NAME_FIELD_IN_CONTACT_DETAILS) 107 IDS_PAYMENTS_NAME_FIELD_IN_CONTACT_DETAILS)
108 value:name 108 value:name
109 required:YES]; 109 required:YES];
110 if (!_paymentRequest->request_payer_phone() &&
111 !_paymentRequest->request_payer_email()) {
112 nameField.returnKeyType = UIReturnKeyDone;
113 }
110 [self.fields addObject:nameField]; 114 [self.fields addObject:nameField];
111 } 115 }
112 116
113 if (_paymentRequest->request_payer_phone()) { 117 if (_paymentRequest->request_payer_phone()) {
114 NSString* phone = 118 NSString* phone =
115 self.profile 119 self.profile
116 ? base::SysUTF16ToNSString( 120 ? base::SysUTF16ToNSString(
117 payments::data_util::GetFormattedPhoneNumberForDisplay( 121 payments::data_util::GetFormattedPhoneNumberForDisplay(
118 *self.profile, 122 *self.profile,
119 GetApplicationContext()->GetApplicationLocale())) 123 GetApplicationContext()->GetApplicationLocale()))
120 : nil; 124 : nil;
121 EditorField* phoneField = [[EditorField alloc] 125 EditorField* phoneField = [[EditorField alloc]
122 initWithAutofillUIType:AutofillUITypeProfileHomePhoneWholeNumber 126 initWithAutofillUIType:AutofillUITypeProfileHomePhoneWholeNumber
123 fieldType:EditorFieldTypeTextField 127 fieldType:EditorFieldTypeTextField
124 label:l10n_util::GetNSString( 128 label:l10n_util::GetNSString(
125 IDS_PAYMENTS_PHONE_FIELD_IN_CONTACT_DETAILS) 129 IDS_PAYMENTS_PHONE_FIELD_IN_CONTACT_DETAILS)
126 value:phone 130 value:phone
127 required:YES]; 131 required:YES];
132 phoneField.keyboardType = UIKeyboardTypePhonePad;
133 if (!_paymentRequest->request_payer_email())
134 phoneField.returnKeyType = UIReturnKeyDone;
128 [self.fields addObject:phoneField]; 135 [self.fields addObject:phoneField];
129 } 136 }
130 137
131 if (_paymentRequest->request_payer_email()) { 138 if (_paymentRequest->request_payer_email()) {
132 NSString* email = [self fieldValueFromProfile:self.profile 139 NSString* email = [self fieldValueFromProfile:self.profile
133 fieldType:autofill::EMAIL_ADDRESS]; 140 fieldType:autofill::EMAIL_ADDRESS];
134 EditorField* emailField = [[EditorField alloc] 141 EditorField* emailField = [[EditorField alloc]
135 initWithAutofillUIType:AutofillUITypeProfileEmailAddress 142 initWithAutofillUIType:AutofillUITypeProfileEmailAddress
136 fieldType:EditorFieldTypeTextField 143 fieldType:EditorFieldTypeTextField
137 label:l10n_util::GetNSString( 144 label:l10n_util::GetNSString(
138 IDS_PAYMENTS_EMAIL_FIELD_IN_CONTACT_DETAILS) 145 IDS_PAYMENTS_EMAIL_FIELD_IN_CONTACT_DETAILS)
139 value:email 146 value:email
140 required:YES]; 147 required:YES];
148 emailField.keyboardType = UIKeyboardTypeEmailAddress;
149 emailField.autoCapitalizationType = UITextAutocapitalizationTypeNone;
150 emailField.returnKeyType = UIReturnKeyDone;
141 [self.fields addObject:emailField]; 151 [self.fields addObject:emailField];
142 } 152 }
143 153
144 DCHECK(self.fields.count > 0) << "The contact info editor shouldn't be " 154 DCHECK(self.fields.count > 0) << "The contact info editor shouldn't be "
145 "reachable if no contact information is " 155 "reachable if no contact information is "
146 "requested."; 156 "requested.";
147 return self.fields; 157 return self.fields;
148 } 158 }
149 159
150 // Takes in an autofill profile and an autofill field type and returns the 160 // Takes in an autofill profile and an autofill field type and returns the
151 // corresponding field value. Returns nil if |profile| is nullptr. 161 // corresponding field value. Returns nil if |profile| is nullptr.
152 - (NSString*)fieldValueFromProfile:(autofill::AutofillProfile*)profile 162 - (NSString*)fieldValueFromProfile:(autofill::AutofillProfile*)profile
153 fieldType:(autofill::ServerFieldType)fieldType { 163 fieldType:(autofill::ServerFieldType)fieldType {
154 return profile ? base::SysUTF16ToNSString(profile->GetInfo( 164 return profile ? base::SysUTF16ToNSString(profile->GetInfo(
155 autofill::AutofillType(fieldType), 165 autofill::AutofillType(fieldType),
156 GetApplicationContext()->GetApplicationLocale())) 166 GetApplicationContext()->GetApplicationLocale()))
157 : nil; 167 : nil;
158 } 168 }
159 169
160 @end 170 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/payments/address_edit_mediator.mm ('k') | ios/chrome/browser/ui/payments/credit_card_edit_mediator.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698