| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 package org.chromium.chrome.browser.payments.ui; | 5 package org.chromium.chrome.browser.payments.ui; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.text.TextUtils; | 8 import android.text.TextUtils; |
| 9 | 9 |
| 10 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; | 10 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; |
| 11 import org.chromium.chrome.browser.payments.AutofillAddress; | 11 import org.chromium.chrome.browser.payments.AutofillAddress; |
| 12 import org.chromium.chrome.browser.payments.AutofillContact; | 12 import org.chromium.chrome.browser.payments.AutofillContact; |
| 13 import org.chromium.chrome.browser.payments.ContactEditor; | 13 import org.chromium.chrome.browser.payments.ContactEditor; |
| 14 import org.chromium.chrome.browser.payments.PaymentRequestImpl; | 14 import org.chromium.chrome.browser.payments.PaymentRequestImpl; |
| 15 import org.chromium.chrome.browser.payments.PaymentRequestJourneyLogger; | |
| 16 | 15 |
| 17 import java.util.ArrayList; | 16 import java.util.ArrayList; |
| 18 import java.util.Collection; | 17 import java.util.Collection; |
| 19 import java.util.Collections; | 18 import java.util.Collections; |
| 20 import java.util.Comparator; | 19 import java.util.Comparator; |
| 21 import java.util.List; | 20 import java.util.List; |
| 22 | 21 |
| 23 import javax.annotation.Nullable; | 22 import javax.annotation.Nullable; |
| 24 | 23 |
| 25 /** | 24 /** |
| 26 * The data to show in the contact details section where the user can select som
ething. | 25 * The data to show in the contact details section where the user can select som
ething. |
| 27 */ | 26 */ |
| 28 public class ContactDetailsSection extends SectionInformation { | 27 public class ContactDetailsSection extends SectionInformation { |
| 29 private final Context mContext; | 28 private final Context mContext; |
| 30 private final ContactEditor mContactEditor; | 29 private final ContactEditor mContactEditor; |
| 31 private final PaymentRequestJourneyLogger mJourneyLogger = new PaymentReques
tJourneyLogger(); | |
| 32 | 30 |
| 33 private List<AutofillProfile> mProfiles; | 31 private List<AutofillProfile> mProfiles; |
| 34 | 32 |
| 35 /** | 33 /** |
| 36 * Builds a Contact section from a list of AutofillProfile. | 34 * Builds a Contact section from a list of AutofillProfile. |
| 37 * | 35 * |
| 38 * @param context Context | 36 * @param context Context |
| 39 * @param unmodifiableProfiles The list of profiles to build from. | 37 * @param unmodifiableProfiles The list of profiles to build from. |
| 40 * @param mContactEditor The Contact Editor associated with this flow
. | 38 * @param mContactEditor The Contact Editor associated with this flow
. |
| 41 */ | 39 */ |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 isNewSuggestion = false; | 126 isNewSuggestion = false; |
| 129 break; | 127 break; |
| 130 } | 128 } |
| 131 } | 129 } |
| 132 if (isNewSuggestion) uniqueContacts.add(contact); | 130 if (isNewSuggestion) uniqueContacts.add(contact); |
| 133 | 131 |
| 134 // Limit the number of suggestions. | 132 // Limit the number of suggestions. |
| 135 if (uniqueContacts.size() == PaymentRequestImpl.SUGGESTIONS_LIMIT) b
reak; | 133 if (uniqueContacts.size() == PaymentRequestImpl.SUGGESTIONS_LIMIT) b
reak; |
| 136 } | 134 } |
| 137 | 135 |
| 138 // Log the number of suggested contact infos. | |
| 139 mJourneyLogger.setNumberOfSuggestionsShown( | |
| 140 PaymentRequestJourneyLogger.SECTION_CONTACT_INFO, uniqueContacts
.size()); | |
| 141 | |
| 142 // Automatically select the first address if it is complete. | 136 // Automatically select the first address if it is complete. |
| 143 int firstCompleteContactIndex = SectionInformation.NO_SELECTION; | 137 int firstCompleteContactIndex = SectionInformation.NO_SELECTION; |
| 144 if (!uniqueContacts.isEmpty() && uniqueContacts.get(0).isComplete()) { | 138 if (!uniqueContacts.isEmpty() && uniqueContacts.get(0).isComplete()) { |
| 145 firstCompleteContactIndex = 0; | 139 firstCompleteContactIndex = 0; |
| 146 } | 140 } |
| 147 | 141 |
| 148 updateItemsWithCollection(firstCompleteContactIndex, uniqueContacts); | 142 updateItemsWithCollection(firstCompleteContactIndex, uniqueContacts); |
| 149 } | 143 } |
| 150 | 144 |
| 151 @Nullable | 145 @Nullable |
| (...skipping 13 matching lines...) Expand all Loading... |
| 165 | 159 |
| 166 if (name != null || phone != null || email != null) { | 160 if (name != null || phone != null || email != null) { |
| 167 @ContactEditor.CompletionStatus | 161 @ContactEditor.CompletionStatus |
| 168 int completionStatus = mContactEditor.checkContactCompletionStatus(n
ame, phone, email); | 162 int completionStatus = mContactEditor.checkContactCompletionStatus(n
ame, phone, email); |
| 169 return new AutofillContact(mContext, profile, name, phone, email, co
mpletionStatus, | 163 return new AutofillContact(mContext, profile, name, phone, email, co
mpletionStatus, |
| 170 requestPayerName, requestPayerPhone, requestPayerEmail); | 164 requestPayerName, requestPayerPhone, requestPayerEmail); |
| 171 } | 165 } |
| 172 return null; | 166 return null; |
| 173 } | 167 } |
| 174 } | 168 } |
| OLD | NEW |