Commit 2ae6201b authored by Finnur Thorarinsson's avatar Finnur Thorarinsson Committed by Commit Bot

Contacts Picker: Show fewer phone numbers/emails by default.

The UX design calls for showing only one number/email
on-screen, and have the rest show only in details view
(a view that will appear in an upcoming CL).

Bug: 860467
Change-Id: Ifaccdbd89b0fc5041cef7c05e288469032f5e78b
Reviewed-on: https://chromium-review.googlesource.com/c/1393368Reviewed-by: default avatarTheresa <twellington@chromium.org>
Commit-Queue: Finnur Thorarinsson <finnur@chromium.org>
Cr-Commit-Position: refs/heads/master@{#619621}
parent bac20b94
......@@ -4,9 +4,12 @@
package org.chromium.chrome.browser.contacts_picker;
import android.content.res.Resources;
import android.support.annotation.Nullable;
import android.util.JsonWriter;
import org.chromium.chrome.R;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
......@@ -80,9 +83,13 @@ public class ContactDetails implements Comparable<ContactDetails> {
/**
* Accessor for the list of contact details (emails and phone numbers). Returned as strings
* separated by newline).
* @param longVersion Whether to get all the details (for emails and phone numbers) or only what
* will fit in the allotted space on the dialog.
* @param resources The resources to use for fetching the string. Must be provided if
* longVersion is false, otherwise it can be null.
* @return A string containing all the contact details registered for this contact.
*/
public String getContactDetailsAsString() {
public String getContactDetailsAsString(boolean longVersion, @Nullable Resources resources) {
int count = 0;
StringBuilder builder = new StringBuilder();
if (mEmails != null) {
......@@ -91,6 +98,12 @@ public class ContactDetails implements Comparable<ContactDetails> {
builder.append("\n");
}
builder.append(email);
if (!longVersion && mEmails.size() > 1) {
int size = mEmails.size() - 1;
builder.append(resources.getQuantityString(
R.plurals.contacts_picker_more_details, size, size));
break;
}
}
}
if (mPhoneNumbers != null) {
......@@ -99,6 +112,12 @@ public class ContactDetails implements Comparable<ContactDetails> {
builder.append("\n");
}
builder.append(phoneNumber);
if (!longVersion && mPhoneNumbers.size() > 1) {
int size = mPhoneNumbers.size() - 1;
builder.append(resources.getQuantityString(
R.plurals.contacts_picker_more_details, size, size));
break;
}
}
}
......
......@@ -129,7 +129,11 @@ public class ContactView extends SelectableItemView<ContactDetails> {
String displayName = contactDetails.getDisplayName();
mDisplayName.setText(displayName);
mDetailsView.setText(contactDetails.getContactDetailsAsString());
String details = contactDetails.getContactDetailsAsString(
/*longVersion=*/false, mContext.getResources());
mDetailsView.setText(details);
mDetailsView.setVisibility(details.isEmpty() ? View.GONE : View.VISIBLE);
if (icon == null) {
icon = mCategoryView.getIconGenerator().generateIconForText(
contactDetails.getDisplayNameAbbreviation());
......
......@@ -73,7 +73,8 @@ public class PickerAdapter extends Adapter<ContactViewHolder>
String query_lower = query.toLowerCase(Locale.getDefault());
for (ContactDetails contact : mContactDetails) {
if (contact.getDisplayName().toLowerCase(Locale.getDefault()).contains(query_lower)
|| contact.getContactDetailsAsString()
|| contact.getContactDetailsAsString(
/*longVersion=*/true, /*resources=*/null)
.toLowerCase(Locale.getDefault())
.contains(query_lower)) {
mSearchResults.add(count);
......
......@@ -3527,6 +3527,11 @@ However, you aren’t invisible. Going private doesn’t hide your browsing from
<message name="IDS_CONTACTS_PICKER_SELECT_CONTACT" desc="The label at the top of the dialog that allows users to select a single contact from their device and share the details with a web page.">
Select a contact
</message>
<message name="IDS_CONTACTS_PICKER_MORE_DETAILS" desc="Label describing that the user has one or more telephone/emails (used for either). The leading space is a word separator, for those languages that use space as a separator.">
{DETAIL_COUNT, plural,
=1 { (+ 1 more)}
other { (+ # more)}}
</message>
<!-- Photo Picker strings -->
<message name="IDS_DECODER_DESCRIPTION" desc="The title for the image decoder utility service.">
......
f128a8aeb58975274245413412bf1acf75b812f8
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment