Fix the account selector and linked accounts titles
Bug 24988734
Bug 23589603
Change-Id: I1032decbd7aee04efd0b61aaf39a14a54b69be6b
diff --git a/res/drawable-hdpi/ic_link_grey600_drawable_24dp.png b/res/drawable-hdpi/ic_link_grey600_drawable_24dp.png
new file mode 100644
index 0000000..31fcce2
--- /dev/null
+++ b/res/drawable-hdpi/ic_link_grey600_drawable_24dp.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_link_grey600_drawable_24dp.png b/res/drawable-mdpi/ic_link_grey600_drawable_24dp.png
new file mode 100644
index 0000000..65997eb
--- /dev/null
+++ b/res/drawable-mdpi/ic_link_grey600_drawable_24dp.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_link_grey600_drawable_24dp.png b/res/drawable-xhdpi/ic_link_grey600_drawable_24dp.png
new file mode 100644
index 0000000..9f37410
--- /dev/null
+++ b/res/drawable-xhdpi/ic_link_grey600_drawable_24dp.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_link_grey600_drawable_24dp.png b/res/drawable-xxhdpi/ic_link_grey600_drawable_24dp.png
new file mode 100644
index 0000000..140daef
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_link_grey600_drawable_24dp.png
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_link_grey600_drawable_24dp.png b/res/drawable-xxxhdpi/ic_link_grey600_drawable_24dp.png
new file mode 100644
index 0000000..6fe9b8c
--- /dev/null
+++ b/res/drawable-xxxhdpi/ic_link_grey600_drawable_24dp.png
Binary files differ
diff --git a/res/layout/editor_all_rawcontacts_accounts_selector.xml b/res/layout/editor_all_rawcontacts_accounts_selector.xml
index 3b92c9f..e400f3b 100644
--- a/res/layout/editor_all_rawcontacts_accounts_selector.xml
+++ b/res/layout/editor_all_rawcontacts_accounts_selector.xml
@@ -28,42 +28,22 @@
android:visibility="gone" >
<ImageView
- android:id="@+id/primary_account_icon"
- android:src="@drawable/ic_account_circle_black_24dp"
+ android:src="@drawable/ic_link_grey600_drawable_24dp"
android:layout_width="@dimen/detail_network_icon_size"
android:layout_height="@dimen/detail_network_icon_size"
android:layout_margin="16dip"
android:layout_gravity="center_vertical"/>
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="vertical"
+ <TextView
+ android:id="@+id/rawcontacts_accounts_summary"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:textSize="16sp"
+ android:singleLine="true"
+ android:textColor="@color/primary_text_color"
android:layout_gravity="center_vertical"
- android:layout_weight="1">
-
- <TextView
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:text="@string/compact_editor_linked_contacts_title"
- android:textSize="16sp"
- android:singleLine="true"
- android:textColor="@color/primary_text_color"
- android:layout_gravity="center_vertical"
- android:gravity="center_vertical"
- android:ellipsize="end" />
-
- <TextView
- android:id="@+id/rawcontacts_accounts_summary"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:textSize="16sp"
- android:singleLine="true"
- android:textColor="@color/primary_text_color"
- android:layout_gravity="center_vertical"
- android:gravity="center_vertical"
- android:ellipsize="end" />
- </LinearLayout>
+ android:gravity="center_vertical"
+ android:ellipsize="end" />
<ImageView
android:src="@drawable/ic_menu_expander_minimized_holo_light"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index e440ab5..3102bf8 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -764,6 +764,12 @@
<!-- Toast message displayed when the editor fails to load for a contacts. [CHAR LIMIT=NONE] -->
<string name="compact_editor_failed_to_load">Failed to open editor.</string>
+ <!-- Label for the account selector to indicate which account a contact will be saved to. [CHAR LIMIT=30] -->
+ <string name="compact_editor_account_selector_title">Saving to</string>
+
+ <!-- Label for the linked contacts selector which indicates the number of raw contacts which have been linked together into the aggregate being viewed. [CHAR LIMIT=40] -->
+ <string name="compact_editor_linked_contacts_selector_title">Linked contacts (<xliff:g id="count">%d</xliff:g>)</string>
+
<!-- Quick contact display name with phonetic name -->
<string name="quick_contact_display_name_with_phonetic"><xliff:g id="display_name">%s</xliff:g> (<xliff:g id="phonetic_name">%s</xliff:g>)</string>
@@ -794,9 +800,6 @@
<!-- Account type with number in quick contact suggestion card [CHAR LIMIT=30]-->
<string name="quickcontact_suggestion_account_type"><xliff:g id="account_type">%s</xliff:g><xliff:g id="account_type_number">%s</xliff:g></string>
- <!-- Linked contacts title showing in contact editor UI. [CHAR LIMIT=30]-->
- <string name="compact_editor_linked_contacts_title">Linked contacts</string>
-
<!-- "This contact" title showing in suggestion card in Quick contact. [CHAR LIMIT=30]-->
<string name="suggestion_card_this_contact_title">This contact</string>
@@ -805,4 +808,5 @@
<!-- Help message showing in suggestion card in Quick contact. [CHAR LIMIT=500]-->
<string name="suggestion_card_help_message">Clean up duplicate contacts to see all info in one place. For more details on a contact tap on the avatar. You can always change the profile photo or separate contacts at anytime.</string>
+
</resources>
diff --git a/src/com/android/contacts/editor/CompactRawContactsEditorView.java b/src/com/android/contacts/editor/CompactRawContactsEditorView.java
index 386a6b3..e02e35a 100644
--- a/src/com/android/contacts/editor/CompactRawContactsEditorView.java
+++ b/src/com/android/contacts/editor/CompactRawContactsEditorView.java
@@ -72,8 +72,6 @@
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.TreeSet;
@@ -158,18 +156,17 @@
: mInflater.inflate(R.layout.account_selector_list_item, parent, false);
final RawContactDelta rawContactDelta = mRawContactDeltas.get(position);
- final String accountName = rawContactDelta.getAccountName();
- final AccountType accountType = rawContactDelta.getRawContactAccountType(mContext);
final TextView text1 = (TextView) resultView.findViewById(android.R.id.text1);
+ final AccountType accountType = rawContactDelta.getRawContactAccountType(mContext);
text1.setText(accountType.getDisplayLabel(mContext));
- // For email addresses, we don't want to truncate at end, which might cut off the domain
- // name.
final TextView text2 = (TextView) resultView.findViewById(android.R.id.text2);
+ final String accountName = rawContactDelta.getAccountName();
if (TextUtils.isEmpty(accountName)) {
text2.setVisibility(View.GONE);
} else {
+ // Truncate email addresses in the middle so we don't lose the domain
text2.setText(accountName);
text2.setEllipsize(TextUtils.TruncateAt.MIDDLE);
}
@@ -399,7 +396,6 @@
// Raw contacts selector
private View mRawContactContainer;
private TextView mRawContactSummary;
- private ImageView mPrimaryAccountIcon;
private CompactPhotoEditorView mPhotoView;
private ViewGroup mKindSectionViews;
@@ -450,7 +446,6 @@
// Raw contacts selector
mRawContactContainer = findViewById(R.id.all_rawcontacts_accounts_container);
mRawContactSummary = (TextView) findViewById(R.id.rawcontacts_accounts_summary);
- mPrimaryAccountIcon = (ImageView) findViewById(R.id.primary_account_icon);
mPhotoView = (CompactPhotoEditorView) findViewById(R.id.photo_editor);
mKindSectionViews = (LinearLayout) findViewById(R.id.kind_section_views);
@@ -819,7 +814,10 @@
mAccountHeaderName.setVisibility(View.VISIBLE);
mAccountHeaderName.setText(accountInfo.first);
}
- mAccountHeaderType.setText(accountInfo.second);
+
+ final String selectorTitle = getResources().getString(
+ R.string.compact_editor_account_selector_title);
+ mAccountHeaderType.setText(selectorTitle);
final AccountType primaryAccountType = mPrimaryRawContactDelta.getRawContactAccountType(
getContext());
@@ -827,7 +825,7 @@
mAccountHeaderContainer.setContentDescription(
EditorUiUtils.getAccountInfoContentDescription(
- accountInfo.first, accountInfo.second));
+ accountInfo.first, selectorTitle));
}
private void addAccountSelector(Pair<String,String> accountInfo) {
@@ -840,11 +838,14 @@
mAccountSelectorName.setVisibility(View.VISIBLE);
mAccountSelectorName.setText(accountInfo.first);
}
- mAccountSelectorType.setText(accountInfo.second);
+
+ final String selectorTitle = getResources().getString(
+ R.string.compact_editor_account_selector_title);
+ mAccountSelectorType.setText(selectorTitle);
mAccountSelectorContainer.setContentDescription(
EditorUiUtils.getAccountInfoContentDescription(
- accountInfo.first, accountInfo.second));
+ accountInfo.first, selectorTitle));
mAccountSelector.setOnClickListener(new View.OnClickListener() {
@Override
@@ -883,15 +884,9 @@
Collections.sort(rawContactDeltas, new RawContactDeltaComparator(getContext()));
- final String accountsSummary = getRawContactsAccountsSummary(
- getContext(), rawContactDeltas);
+ final String accountsSummary = getResources().getString(
+ R.string.compact_editor_linked_contacts_selector_title, rawContactDeltas.size());
mRawContactSummary.setText(accountsSummary);
- mRawContactContainer.setContentDescription(accountsSummary);
- if (mPrimaryRawContactDelta != null) {
- final AccountType primaryAccountType = mPrimaryRawContactDelta.getRawContactAccountType(
- getContext());
- mPrimaryAccountIcon.setImageDrawable(primaryAccountType.getDisplayIcon(getContext()));
- }
mRawContactContainer.setOnClickListener(new View.OnClickListener() {
@Override
@@ -930,38 +925,6 @@
});
}
- private static String getRawContactsAccountsSummary(
- Context context, RawContactDeltaList rawContactDeltas) {
- final LinkedHashMap<String, Integer> accountTypeNumber = new LinkedHashMap<>();
- for (RawContactDelta rawContactDelta : rawContactDeltas) {
- if (rawContactDelta.isVisible()) {
- final AccountType accountType = rawContactDelta.getRawContactAccountType(context);
- final String accountTypeLabel = accountType.getDisplayLabel(context).toString();
- if (accountTypeNumber.containsKey(accountTypeLabel)) {
- int number = accountTypeNumber.get(accountTypeLabel);
- number++;
- accountTypeNumber.put(accountTypeLabel, number);
- } else {
- accountTypeNumber.put(accountTypeLabel, 1);
- }
- }
- }
-
- final LinkedHashSet<String> linkedAccounts = new LinkedHashSet<>();
- for (String accountTypeLabel : accountTypeNumber.keySet()) {
- final String number = context.getResources().getQuantityString(
- R.plurals.quickcontact_suggestion_account_type_number,
- accountTypeNumber.get(accountTypeLabel),
- accountTypeNumber.get(accountTypeLabel));
- final String accountWithNumber = context.getResources().getString(
- R.string.quickcontact_suggestion_account_type,
- accountTypeLabel,
- number);
- linkedAccounts.add(accountWithNumber);
- }
- return TextUtils.join(",", linkedAccounts);
- }
-
private void addPhotoView() {
// Get the kind section data and values delta that we will display in the photo view
final KindSectionDataList kindSectionDataList =