Polish the suggestion card in quick contact.
am: 18906c0323
* commit '18906c03230be7de5b8e8bf663312cbc9a7c3097':
Polish the suggestion card in quick contact.
diff --git a/res/drawable-hdpi/quantum_ic_assistant_grey600_24.png b/res/drawable-hdpi/quantum_ic_assistant_grey600_24.png
new file mode 100644
index 0000000..0647862
--- /dev/null
+++ b/res/drawable-hdpi/quantum_ic_assistant_grey600_24.png
Binary files differ
diff --git a/res/drawable-ldrtl-hdpi/quantum_ic_assistant_grey600_24.png b/res/drawable-ldrtl-hdpi/quantum_ic_assistant_grey600_24.png
new file mode 100644
index 0000000..0647862
--- /dev/null
+++ b/res/drawable-ldrtl-hdpi/quantum_ic_assistant_grey600_24.png
Binary files differ
diff --git a/res/drawable-ldrtl-mdpi/quantum_ic_assistant_grey600_24.png b/res/drawable-ldrtl-mdpi/quantum_ic_assistant_grey600_24.png
new file mode 100644
index 0000000..0647862
--- /dev/null
+++ b/res/drawable-ldrtl-mdpi/quantum_ic_assistant_grey600_24.png
Binary files differ
diff --git a/res/drawable-ldrtl-xhdpi/quantum_ic_assistant_grey600_24.png b/res/drawable-ldrtl-xhdpi/quantum_ic_assistant_grey600_24.png
new file mode 100644
index 0000000..0647862
--- /dev/null
+++ b/res/drawable-ldrtl-xhdpi/quantum_ic_assistant_grey600_24.png
Binary files differ
diff --git a/res/drawable-mdpi/quantum_ic_assistant_grey600_24.png b/res/drawable-mdpi/quantum_ic_assistant_grey600_24.png
new file mode 100644
index 0000000..0647862
--- /dev/null
+++ b/res/drawable-mdpi/quantum_ic_assistant_grey600_24.png
Binary files differ
diff --git a/res/drawable-xhdpi/quantum_ic_assistant_grey600_24.png b/res/drawable-xhdpi/quantum_ic_assistant_grey600_24.png
new file mode 100644
index 0000000..0647862
--- /dev/null
+++ b/res/drawable-xhdpi/quantum_ic_assistant_grey600_24.png
Binary files differ
diff --git a/res/drawable-xxhdpi/quantum_ic_assistant_grey600_24.png b/res/drawable-xxhdpi/quantum_ic_assistant_grey600_24.png
new file mode 100644
index 0000000..0647862
--- /dev/null
+++ b/res/drawable-xxhdpi/quantum_ic_assistant_grey600_24.png
Binary files differ
diff --git a/res/drawable-xxxhdpi/quantum_ic_assistant_grey600_24.png b/res/drawable-xxxhdpi/quantum_ic_assistant_grey600_24.png
new file mode 100644
index 0000000..0647862
--- /dev/null
+++ b/res/drawable-xxxhdpi/quantum_ic_assistant_grey600_24.png
Binary files differ
diff --git a/res/layout/quickcontact_collapsed_suggestion_card.xml b/res/layout/quickcontact_collapsed_suggestion_card.xml
new file mode 100644
index 0000000..dbd3eee
--- /dev/null
+++ b/res/layout/quickcontact_collapsed_suggestion_card.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:card_view="http://schemas.android.com/apk/res-auto"
+ style="@style/ExpandingEntryCardStyle"
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ android:visibility="gone"
+ android:id="@+id/collapsed_suggestion_card">
+
+ <LinearLayout
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ android:orientation="horizontal"
+ android:clickable="true"
+ android:id="@+id/collapsed_suggestion_header">
+
+ <ImageView
+ android:src="@drawable/quantum_ic_assistant_grey600_24"
+ 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"/>
+
+ <TextView
+ android:id="@+id/collapsed_suggestion_card_title"
+ android:textSize="@dimen/expanding_entry_card_title_text_size"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:textColor="@color/quickcontact_entry_header_text_color"
+ android:singleLine="true"
+ android:ellipsize="end"
+ android:paddingTop="@dimen/quickcontact_suggestion_card_image_spacing"
+ android:paddingBottom="@dimen/quickcontact_suggestion_card_image_spacing"/>
+
+ <ImageView
+ android:src="@drawable/ic_menu_expander_minimized_holo_light"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical|end"
+ android:layout_alignParentEnd="true"
+ android:paddingStart="@dimen/editor_round_button_padding_left"
+ android:paddingEnd="@dimen/editor_round_button_padding_right"
+ android:paddingTop="@dimen/editor_round_button_padding_top"
+ android:paddingBottom="@dimen/editor_round_button_padding_bottom"/>
+ </LinearLayout>>
+
+</android.support.v7.widget.CardView>
\ No newline at end of file
diff --git a/res/layout/quickcontact_content.xml b/res/layout/quickcontact_content.xml
index 9c4e644..a6a8abb 100644
--- a/res/layout/quickcontact_content.xml
+++ b/res/layout/quickcontact_content.xml
@@ -54,7 +54,8 @@
android:visibility="gone"
cardview:cardCornerRadius="@dimen/expanding_entry_card_card_corner_radius" />
- <include layout="@layout/quickcontact_suggestion_card" />
+ <include layout="@layout/quickcontact_collapsed_suggestion_card" />
+ <include layout="@layout/quickcontact_expand_suggestion_card" />
</LinearLayout>
diff --git a/res/layout/quickcontact_expand_suggestion_card.xml b/res/layout/quickcontact_expand_suggestion_card.xml
new file mode 100644
index 0000000..c2c32cd
--- /dev/null
+++ b/res/layout/quickcontact_expand_suggestion_card.xml
@@ -0,0 +1,137 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!--
+ Layout for the expand suggestion card in QuickContact.
+-->
+<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:card_view="http://schemas.android.com/apk/res-auto"
+ style="@style/ExpandingEntryCardStyle"
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ android:visibility="gone"
+ android:id="@+id/expand_suggestion_card">
+
+ <LinearLayout
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/expand_suggestion_card_title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textStyle="bold"
+ android:textColor="@color/quickcontact_entry_header_text_color"
+ android:singleLine="true"
+ android:ellipsize="end"
+ android:paddingTop="@dimen/quickcontact_suggestion_card_image_spacing"
+ android:paddingBottom="@dimen/quickcontact_suggestion_card_image_spacing"
+ android:paddingStart="@dimen/quickcontact_suggestion_card_image_spacing"/>
+
+ <TextView
+ android:id="@+id/expand_suggestion_card_help"
+ android:textSize="@dimen/expanding_entry_card_title_text_size"
+ android:text="@string/suggestion_card_help_message"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:textColor="@color/quickcontact_entry_header_text_color"
+ android:paddingBottom="@dimen/quickcontact_suggestion_card_image_spacing"
+ android:paddingStart="@dimen/quickcontact_suggestion_card_image_spacing"
+ android:paddingEnd="@dimen/quickcontact_suggestion_card_image_spacing"/>
+
+ <TextView
+ android:id="@+id/expand_suggestion_card_this_contact"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:text="@string/suggestion_card_this_contact_title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:textColor="@color/quickcontact_entry_sub_header_text_color"
+ android:singleLine="true"
+ android:ellipsize="end"
+ android:paddingStart="@dimen/quickcontact_suggestion_card_image_spacing"/>
+
+ <LinearLayout
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ android:layout_marginTop="@dimen/quickcontact_suggestion_card_layout_margin"
+ android:layout_marginBottom="@dimen/quickcontact_suggestion_card_layout_margin"
+ android:orientation="horizontal">
+
+ <ImageView
+ android:id="@+id/suggestion_icon"
+ android:layout_width="@dimen/quickcontact_suggestion_card_icon_height"
+ android:layout_height="@dimen/quickcontact_suggestion_card_icon_width"
+ android:layout_gravity="center_vertical"
+ android:layout_marginStart="@dimen/quickcontact_suggestion_card_image_spacing"
+ android:scaleType="fitCenter" />
+
+ <TextView
+ android:id="@+id/suggestion_for_name"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textColor="@color/quickcontact_entry_header_text_color"
+ android:singleLine="true"
+ android:ellipsize="end"
+ android:layout_marginStart="@dimen/expanding_entry_card_item_image_spacing"
+ android:layout_marginEnd="@dimen/expanding_entry_card_item_image_spacing"/>
+
+ </LinearLayout>
+
+ <TextView
+ android:id="@+id/expand_suggestion_card_duplicates_title"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:text="@string/suggestion_card_duplicates_title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:textColor="@color/quickcontact_entry_sub_header_text_color"
+ android:singleLine="true"
+ android:ellipsize="end"
+ android:paddingStart="@dimen/quickcontact_suggestion_card_image_spacing"/>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:id="@+id/suggestion_list"
+ android:animateLayoutChanges="true"
+ android:orientation="vertical" />
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical|end"
+ android:orientation="horizontal">
+
+ <Button
+ android:id="@+id/cancel_button"
+ style="?android:attr/buttonBarButtonStyle"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/quickcontact_suggestion_cancel_button"/>
+
+ <Button
+ android:id="@+id/link_button"
+ style="?android:attr/buttonBarButtonStyle"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/quickcontact_suggestion_link_button"
+ android:paddingEnd="@dimen/quickcontact_suggestion_card_image_spacing"/>
+ </LinearLayout>
+ </LinearLayout>
+</android.support.v7.widget.CardView>
\ No newline at end of file
diff --git a/res/layout/quickcontact_suggestion_card.xml b/res/layout/quickcontact_suggestion_card.xml
deleted file mode 100644
index 1419bc8..0000000
--- a/res/layout/quickcontact_suggestion_card.xml
+++ /dev/null
@@ -1,137 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<!--
- Layout for the suggestion card in QuickContact.
--->
-<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:card_view="http://schemas.android.com/apk/res-auto"
- style="@style/ExpandingEntryCardStyle"
- android:layout_height="wrap_content"
- android:layout_width="match_parent"
- android:visibility="gone"
- android:id="@+id/suggestion_card_view">
-
- <LinearLayout
- android:layout_height="wrap_content"
- android:layout_width="match_parent"
- android:orientation="vertical">
-
- <LinearLayout
- android:layout_height="wrap_content"
- android:layout_width="match_parent"
- android:layout_marginTop="@dimen/quickcontact_suggestion_card_layout_margin"
- android:layout_marginBottom="@dimen/quickcontact_suggestion_card_layout_margin"
- android:orientation="horizontal">
-
- <ImageView
- android:id="@+id/suggestion_icon"
- android:layout_width="@dimen/quickcontact_suggestion_card_icon_height"
- android:layout_height="@dimen/quickcontact_suggestion_card_icon_width"
- android:layout_gravity="center_vertical"
- android:layout_marginStart="@dimen/quickcontact_suggestion_card_image_spacing"
- android:scaleType="fitCenter" />
-
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:layout_gravity="center_vertical"
- android:layout_weight="1"
- android:layout_toEndOf="@+id/line_vertical_separator"
- android:layout_marginStart="@dimen/expanding_entry_card_item_image_spacing"
- android:layout_marginEnd="@dimen/expanding_entry_card_item_image_spacing">
-
- <TextView
- android:id="@+id/suggestion_for_name"
- android:textSize="@dimen/expanding_entry_card_title_text_size"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textColor="@color/quickcontact_entry_header_text_color"
- android:singleLine="true"
- android:ellipsize="end"
- android:textAlignment="viewStart"/>
-
- <TextView
- android:id="@+id/suggestion_number"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textAlignment="viewStart"
- android:singleLine="true"
- android:ellipsize="end"
- android:textColor="@color/quickcontact_entry_sub_header_text_color" />
-
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:id="@+id/suggestion_summary"
- android:textAlignment="viewStart"
- android:singleLine="true"
- android:ellipsize="end"
- android:textColor="@color/quickcontact_entry_sub_header_text_color" />
- </LinearLayout>
-
- <View
- android:id="@+id/line_vertical_separator"
- android:layout_width="@dimen/divider_line_height"
- android:layout_height="match_parent"
- android:layout_toEndOf="@+id/expand_suggestion_button"
- android:background="@color/divider_line_color_light"/>
-
- <ImageView
- android:id="@+id/expand_suggestion_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center_vertical|end"
- android:layout_alignParentEnd="true"
- android:paddingStart="@dimen/editor_round_button_padding_left"
- android:paddingEnd="@dimen/editor_round_button_padding_right"
- android:paddingTop="@dimen/editor_round_button_padding_top"
- android:paddingBottom="@dimen/editor_round_button_padding_bottom"/>
-
- </LinearLayout>
-
- <View
- android:id="@+id/title_separator"
- android:layout_width="match_parent"
- android:layout_height="@dimen/divider_line_height"
- android:paddingTop="@dimen/editor_round_button_padding_top"
- android:background="@color/divider_line_color_light"/>
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:id="@+id/suggestion_list"
- android:animateLayoutChanges="true"
- android:orientation="vertical" />
-
- <View
- android:id="@+id/title_separator2"
- android:layout_width="match_parent"
- android:layout_height="@dimen/divider_line_height"
- android:background="@color/divider_line_color_light"
- android:visibility="gone"/>
-
- <Button
- android:id="@+id/link_button"
- style="?android:attr/buttonBarButtonStyle"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/quickcontact_suggestion_link_button"
- android:textColor="@color/quickcontact_entry_sub_header_text_color"
- android:paddingStart="@dimen/quickcontact_suggestion_card_image_spacing"/>
- </LinearLayout>
-</android.support.v7.widget.CardView>
\ No newline at end of file
diff --git a/res/layout/quickcontact_suggestion_contact_item.xml b/res/layout/quickcontact_suggestion_contact_item.xml
index 76792f8..e7c5af6 100644
--- a/res/layout/quickcontact_suggestion_contact_item.xml
+++ b/res/layout/quickcontact_suggestion_contact_item.xml
@@ -30,6 +30,7 @@
android:layout_gravity="center_vertical" />
<LinearLayout
+ android:id="@+id/suggestion_contact_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/expanding_entry_card_item_image_spacing"
@@ -41,22 +42,20 @@
android:id="@+id/aggregation_suggestion_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:textSize="@dimen/expanding_entry_card_title_text_size"
- android:textColor="@color/quickcontact_entry_sub_header_text_color"
android:layout_marginTop="@dimen/quickcontact_suggestion_card_layout_margin"
android:singleLine="true"
android:ellipsize="end"
- android:textAppearance="?android:attr/textAppearanceMedium" />
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textColor="@color/quickcontact_entry_header_text_color" />
<TextView
- android:id="@+id/aggregation_suggestion_account_type"
+ android:id="@+id/aggregation_suggestion_account_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_marginBottom="@dimen/quickcontact_suggestion_card_layout_margin"
android:singleLine="true"
- android:ellipsize="end"
- android:textColor="@color/quickcontact_entry_sub_header_text_color" />
+ android:ellipsize="end" />
</LinearLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 4454306..e440ab5 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -768,12 +768,21 @@
<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>
<!-- Button used in quick contact suggestion card to link selected contacts. [CHAR LIMIT=30]-->
- <string name="quickcontact_suggestion_link_button">Link</string>
+ <string name="quickcontact_suggestion_link_button">LINK CONTACTS</string>
+
+ <!-- Button used in quick contact suggestion card to collapse suggestion card. [CHAR LIMIT=30]-->
+ <string name="quickcontact_suggestion_cancel_button">CANCEL</string>
+
+ <!-- Suggestion card title in quick contact UI [CHAR LIMIT=100] -->
+ <plurals name="quickcontact_suggestion_card_title">
+ <item quantity="one">1 Duplicate Detected</item>
+ <item quantity="other"><xliff:g id="count">%d</xliff:g> Duplicates Detected</item>
+ </plurals>
<!-- Suggestions number in quick contact suggestion card [CHAR LIMIT=60] -->
<plurals name="quickcontact_suggestions_number">
- <item quantity="one">1 suggested contact</item>
- <item quantity="other"><xliff:g id="count">%d</xliff:g> suggested contacts</item>
+ <item quantity="one">1 linked contact</item>
+ <item quantity="other"><xliff:g id="count">%d</xliff:g> linked contacts</item>
</plurals>
<!-- Account type number for suggestions in quick contact suggestion card [CHAR LIMIT=30]-->
@@ -787,4 +796,13 @@
<!-- 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>
+
+ <!-- "Duplicates" title showing in suggestion card in Quick contact. [CHAR LIMIT=30]-->
+ <string name="suggestion_card_duplicates_title">Duplicates</string>
+
+ <!-- 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/quickcontact/QuickContactActivity.java b/src/com/android/contacts/quickcontact/QuickContactActivity.java
index 2f37387..d501e77 100644
--- a/src/com/android/contacts/quickcontact/QuickContactActivity.java
+++ b/src/com/android/contacts/quickcontact/QuickContactActivity.java
@@ -200,6 +200,8 @@
private static final String KEY_THEME_COLOR = "theme_color";
private static final String KEY_IS_SUGGESTION_LIST_COLLAPSED = "is_suggestion_list_collapsed";
private static final String KEY_SELECTED_SUGGESTION_CONTACTS = "selected_suggestion_contacts";
+ private static final String KEY_PREVIOUS_CONTACT_ID = "previous_contact_id";
+ private static final String KEY_SUGGESTIONS_AUTO_SELECTED = "suggestions_auto_seleted";
private static final int ANIMATION_STATUS_BAR_COLOR_CHANGE_DURATION = 150;
private static final int REQUEST_CODE_CONTACT_EDITOR_ACTIVITY = 1;
@@ -245,17 +247,19 @@
private ExpandingEntryCardView mAboutCard;
// Suggestion card.
- private CardView mSuggestionCardView;
+ private CardView mCollapsedSuggestionCardView;
+ private CardView mExpandSuggestionCardView;
+ private View mCollapasedSuggestionHeader;
+ private TextView mCollapsedSuggestionCardTitle;
+ private TextView mExpandSuggestionCardTitle;
private ImageView mSuggestionSummaryPhoto;
private TextView mSuggestionForName;
- private TextView mSuggestionNumber;
- private TextView mSuggestionSummary;
- private ImageView mSuggestionExpansionButton;
private LinearLayout mSuggestionList;
- private View mSuggestionSeparator;
+ private Button mSuggestionsCancelButton;
private Button mSuggestionsLinkButton;
private boolean mIsSuggestionListCollapsed;
- private long mPreviousSuggestionForContactId = 0;
+ private boolean mSuggestionsShouldAutoSelected = true;
+ private long mPreviousContactId = 0;
private MultiShrinkScroller mScroller;
private SelectAccountDialogFragmentListener mSelectAccountFragmentListener;
@@ -483,36 +487,34 @@
@Override
public void onAggregationSuggestionChange() {
mSuggestions = mAggregationSuggestionEngine.getSuggestions();
- mSuggestionCardView.setVisibility(View.GONE);
+ mCollapsedSuggestionCardView.setVisibility(View.GONE);
+ mExpandSuggestionCardView.setVisibility(View.GONE);
mSuggestionList.removeAllViews();
final String suggestionForName = mContactData.getDisplayName();
final int suggestionNumber = mSuggestions.size();
- final String suggestionSummary = getSuggestionAccountSummary(mSuggestions);
if (suggestionNumber <= 0) {
mSelectedAggregationIds.clear();
return;
}
- mSuggestionCardView.setVisibility(View.VISIBLE);
-
- // Take the first suggestion 's photo as the summary photo.
- // TODO: take all suggestions' photos.
- final Suggestion firstSuggestion = mSuggestions.get(0);
- if (firstSuggestion.photo != null) {
+ final byte[] photoBytes = mContactData.getThumbnailPhotoBinaryData();
+ if (photoBytes != null) {
mSuggestionSummaryPhoto.setImageBitmap(BitmapFactory.decodeByteArray(
- firstSuggestion.photo, 0, firstSuggestion.photo.length));
+ photoBytes, 0, photoBytes.length));
} else {
mSuggestionSummaryPhoto.setImageDrawable(
ContactPhotoManager.getDefaultAvatarDrawableForContact(
getResources(), false, null));
}
+ final String suggestionTitle = getResources().getQuantityString(
+ R.plurals.quickcontact_suggestion_card_title, suggestionNumber, suggestionNumber);
+ mCollapsedSuggestionCardTitle.setText(suggestionTitle);
+ mExpandSuggestionCardTitle.setText(suggestionTitle);
+
mSuggestionForName.setText(suggestionForName);
- mSuggestionNumber.setText(getResources().getQuantityString(
- R.plurals.quickcontact_suggestions_number, suggestionNumber, suggestionNumber));
- mSuggestionSummary.setText(suggestionSummary);
final Set<Long> suggestionContactIds = new HashSet<>();
for (Suggestion suggestion : mSuggestions) {
@@ -520,77 +522,31 @@
suggestionContactIds.add(suggestion.contactId);
}
+ if (mIsSuggestionListCollapsed) {
+ collapseSuggestionList();
+ } else {
+ expandSuggestionList();
+ }
+
// Remove contact Ids that are not suggestions.
final Set<Long> selectedSuggestionIds = com.google.common.collect.Sets.intersection(
mSelectedAggregationIds, suggestionContactIds);
mSelectedAggregationIds = new TreeSet<>(selectedSuggestionIds);
-
- mSuggestionExpansionButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (mIsSuggestionListCollapsed) {
- expandSuggestionList();
- } else {
- collapseSuggestionList();
- }
- }
- });
}
private void collapseSuggestionList() {
- mSuggestionList.setVisibility(View.GONE);
- mSuggestionSeparator.setVisibility(View.GONE);
- mSuggestionExpansionButton.setImageResource(
- R.drawable.ic_menu_expander_minimized_holo_light);
+ mCollapsedSuggestionCardView.setVisibility(View.VISIBLE);
+ mExpandSuggestionCardView.setVisibility(View.GONE);
mIsSuggestionListCollapsed = true;
}
private void expandSuggestionList() {
- mSuggestionList.setVisibility(View.VISIBLE);
- mSuggestionSeparator.setVisibility(View.VISIBLE);
- mSuggestionExpansionButton.setImageResource(
- R.drawable.ic_menu_expander_maximized_holo_light);
+ mCollapsedSuggestionCardView.setVisibility(View.GONE);
+ mExpandSuggestionCardView.setVisibility(View.VISIBLE);
mIsSuggestionListCollapsed = false;
}
- /**
- * Return summary like "Google(2),LinkedIn" for 3 suggestions.
- */
- private String getSuggestionAccountSummary(List<Suggestion> suggestions) {
- Map<String, Integer> accountTypeMap = new HashMap<String, Integer>();
- for (Suggestion suggestion : suggestions) {
- final com.android.contacts.editor.AggregationSuggestionEngine.RawContact rawContact =
- suggestion.rawContacts.get(0);
- final String displayAccountType = getDisplayAccountType(
- rawContact.accountType, rawContact.dataSet);
- if (accountTypeMap.containsKey(displayAccountType)) {
- int count = accountTypeMap.get(displayAccountType);
- count++;
- accountTypeMap.put(displayAccountType, count);
- } else {
- accountTypeMap.put(displayAccountType, 1);
- }
- }
- final Set<String> accountTypeWithNumber = new HashSet<>();
- for (String accountType : accountTypeMap.keySet()) {
- final String number = getResources().getQuantityString(
- R.plurals.quickcontact_suggestion_account_type_number,
- accountTypeMap.get(accountType),
- accountTypeMap.get(accountType));
- accountTypeWithNumber.add(getResources().getString(
- R.string.quickcontact_suggestion_account_type, accountType, number));
- }
- return TextUtils.join(",", accountTypeWithNumber);
- }
-
- private String getDisplayAccountType(String accountTypeString, String dataSet) {
- final AccountTypeManager accountTypeManager = AccountTypeManager.getInstance(this);
- final AccountType accountType = accountTypeManager.getAccountType(
- accountTypeString, dataSet);
- return accountType.getDisplayLabel(this).toString();
- }
-
- private View inflateSuggestionListView(Suggestion suggestion) {
+ private View inflateSuggestionListView(final Suggestion suggestion) {
final LayoutInflater layoutInflater = LayoutInflater.from(this);
final View suggestionView = layoutInflater.inflate(
R.layout.quickcontact_suggestion_contact_item, null);
@@ -608,17 +564,21 @@
final TextView name = (TextView) suggestionView.findViewById(R.id.aggregation_suggestion_name);
name.setText(suggestion.name);
- final TextView accountTypeView = (TextView) suggestionView.findViewById(
- R.id.aggregation_suggestion_account_type);
- final String accountTypeString = suggestion.rawContacts.get(0).accountType;
- final String dataSet = suggestion.rawContacts.get(0).dataSet;
- final String displayAccountType = getDisplayAccountType(accountTypeString, dataSet);
- if (!TextUtils.isEmpty(displayAccountType)) {
- accountTypeView.setText(displayAccountType);
+ final TextView accountNameView = (TextView) suggestionView.findViewById(
+ R.id.aggregation_suggestion_account_name);
+ final String accountName = suggestion.rawContacts.get(0).accountName;
+ if (!TextUtils.isEmpty(accountName)) {
+ accountNameView.setText("From " + accountName);
+ } else {
+ accountNameView.setVisibility(View.GONE);
}
final CheckBox checkbox = (CheckBox) suggestionView.findViewById(R.id.suggestion_checkbox);
- checkbox.setChecked(mSelectedAggregationIds.contains(suggestion.contactId));
+ checkbox.setChecked(mSuggestionsShouldAutoSelected ||
+ mSelectedAggregationIds.contains(suggestion.contactId));
+ if (checkbox.isChecked()) {
+ mSelectedAggregationIds.add(suggestion.contactId);
+ }
checkbox.setTag(suggestion.contactId);
checkbox.setOnClickListener(new OnClickListener() {
@Override
@@ -629,9 +589,11 @@
mSelectedAggregationIds.add(contactId);
} else {
mSelectedAggregationIds.remove(contactId);
+ mSuggestionsShouldAutoSelected = false;
}
}
});
+
return suggestionView;
}
@@ -908,18 +870,23 @@
mRecentCard = (ExpandingEntryCardView) findViewById(R.id.recent_card);
mAboutCard = (ExpandingEntryCardView) findViewById(R.id.about_card);
- mSuggestionCardView = (CardView) findViewById(R.id.suggestion_card_view);
+ mCollapsedSuggestionCardView = (CardView) findViewById(R.id.collapsed_suggestion_card);
+ mExpandSuggestionCardView = (CardView) findViewById(R.id.expand_suggestion_card);
+ mCollapasedSuggestionHeader = findViewById(R.id.collapsed_suggestion_header);
+ mCollapsedSuggestionCardTitle = (TextView) findViewById(
+ R.id.collapsed_suggestion_card_title);
+ mExpandSuggestionCardTitle = (TextView) findViewById(R.id.expand_suggestion_card_title);
mSuggestionSummaryPhoto = (ImageView) findViewById(R.id.suggestion_icon);
mSuggestionForName = (TextView) findViewById(R.id.suggestion_for_name);
- mSuggestionNumber = (TextView) findViewById(R.id.suggestion_number);
- mSuggestionSummary = (TextView) findViewById(R.id.suggestion_summary);
- mSuggestionExpansionButton = (ImageView) findViewById(R.id.expand_suggestion_button);
- mSuggestionSeparator = findViewById(R.id.title_separator2);
mSuggestionList = (LinearLayout) findViewById(R.id.suggestion_list);
+ mSuggestionsCancelButton= (Button) findViewById(R.id.cancel_button);
mSuggestionsLinkButton = (Button) findViewById(R.id.link_button);
if (savedInstanceState != null) {
mIsSuggestionListCollapsed = savedInstanceState.getBoolean(
KEY_IS_SUGGESTION_LIST_COLLAPSED, true);
+ mPreviousContactId = savedInstanceState.getLong(KEY_PREVIOUS_CONTACT_ID);
+ mSuggestionsShouldAutoSelected = savedInstanceState.getBoolean(
+ KEY_SUGGESTIONS_AUTO_SELECTED, true);
mSelectedAggregationIds = (TreeSet<Long>)
savedInstanceState.getSerializable(KEY_SELECTED_SUGGESTION_CONTACTS);
} else {
@@ -927,7 +894,25 @@
mSelectedAggregationIds.clear();
}
- mSuggestionExpansionButton.setClickable(true);
+ mCollapasedSuggestionHeader.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ mCollapsedSuggestionCardView.setVisibility(View.GONE);
+ mExpandSuggestionCardView.setVisibility(View.VISIBLE);
+ mIsSuggestionListCollapsed = false;
+ mSuggestionsShouldAutoSelected = true;
+ }
+ });
+
+ mSuggestionsCancelButton.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ mCollapsedSuggestionCardView.setVisibility(View.VISIBLE);
+ mExpandSuggestionCardView.setVisibility(View.GONE);
+ mIsSuggestionListCollapsed = true;
+ }
+ });
+
mSuggestionsLinkButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
@@ -1070,6 +1055,9 @@
savedInstanceState.putInt(KEY_THEME_COLOR, mColorFilterColor);
}
savedInstanceState.putBoolean(KEY_IS_SUGGESTION_LIST_COLLAPSED, mIsSuggestionListCollapsed);
+ savedInstanceState.putLong(KEY_PREVIOUS_CONTACT_ID, mPreviousContactId);
+ savedInstanceState.putBoolean(
+ KEY_SUGGESTIONS_AUTO_SELECTED, mSuggestionsShouldAutoSelected);
savedInstanceState.putSerializable(
KEY_SELECTED_SUGGESTION_CONTACTS, mSelectedAggregationIds);
}
@@ -1316,13 +1304,10 @@
private void populateSuggestionCard() {
// Initialize suggestion related view and data.
- if (mIsSuggestionListCollapsed) {
- collapseSuggestionList();
- } else {
- expandSuggestionList();
- }
- if (mPreviousSuggestionForContactId != mContactData.getId()) {
- mSuggestionCardView.setVisibility(View.GONE);
+ if (mPreviousContactId != mContactData.getId()) {
+ mCollapsedSuggestionCardView.setVisibility(View.GONE);
+ mExpandSuggestionCardView.setVisibility(View.GONE);
+ mIsSuggestionListCollapsed = true;
mSuggestionList.removeAllViews();
}
@@ -1335,12 +1320,12 @@
}
mAggregationSuggestionEngine.setContactId(mContactData.getId());
- if (mPreviousSuggestionForContactId != 0
- && mPreviousSuggestionForContactId != mContactData.getId()) {
+ if (mPreviousContactId != 0
+ && mPreviousContactId != mContactData.getId()) {
// Clear selected Ids when listing suggestions for new contact Id.
mSelectedAggregationIds.clear();
}
- mPreviousSuggestionForContactId = mContactData.getId();
+ mPreviousContactId = mContactData.getId();
// Trigger suggestion engine to compute suggestions.
final ContentValues values = new ContentValues();