Merge "Changes in comments" into ub-contactsdialer-a-dev
diff --git a/res/drawable-hdpi/ic_person_black_128dp.png b/res/drawable-hdpi/ic_person_black_128dp.png
new file mode 100644
index 0000000..93b7886
--- /dev/null
+++ b/res/drawable-hdpi/ic_person_black_128dp.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_star_black_128dp.png b/res/drawable-hdpi/ic_star_black_128dp.png
new file mode 100644
index 0000000..a0cb1c1
--- /dev/null
+++ b/res/drawable-hdpi/ic_star_black_128dp.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_person_black_128dp.png b/res/drawable-mdpi/ic_person_black_128dp.png
new file mode 100644
index 0000000..4da7118
--- /dev/null
+++ b/res/drawable-mdpi/ic_person_black_128dp.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_star_black_128dp.png b/res/drawable-mdpi/ic_star_black_128dp.png
new file mode 100644
index 0000000..1ba2792
--- /dev/null
+++ b/res/drawable-mdpi/ic_star_black_128dp.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_person_black_128dp.png b/res/drawable-xhdpi/ic_person_black_128dp.png
new file mode 100644
index 0000000..04445b6
--- /dev/null
+++ b/res/drawable-xhdpi/ic_person_black_128dp.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_star_black_128dp.png b/res/drawable-xhdpi/ic_star_black_128dp.png
new file mode 100644
index 0000000..842ce10
--- /dev/null
+++ b/res/drawable-xhdpi/ic_star_black_128dp.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_person_black_128dp.png b/res/drawable-xxhdpi/ic_person_black_128dp.png
new file mode 100644
index 0000000..3c40711
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_person_black_128dp.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_star_black_128dp.png b/res/drawable-xxhdpi/ic_star_black_128dp.png
new file mode 100644
index 0000000..f7d0eb0
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_star_black_128dp.png
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_person_black_128dp.png b/res/drawable-xxxhdpi/ic_person_black_128dp.png
new file mode 100644
index 0000000..1d94d5f
--- /dev/null
+++ b/res/drawable-xxxhdpi/ic_person_black_128dp.png
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_star_black_128dp.png b/res/drawable-xxxhdpi/ic_star_black_128dp.png
new file mode 100644
index 0000000..49f9e8b
--- /dev/null
+++ b/res/drawable-xxxhdpi/ic_star_black_128dp.png
Binary files differ
diff --git a/res/layout-land/contacts_unavailable_fragment_content.xml b/res/layout-land/contacts_unavailable_fragment_content.xml
new file mode 100644
index 0000000..05e4919
--- /dev/null
+++ b/res/layout-land/contacts_unavailable_fragment_content.xml
@@ -0,0 +1,93 @@
+<?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.
+-->
+
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="horizontal"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center_horizontal">
+
+ <LinearLayout
+ android:orientation="vertical"
+ android:layout_marginLeft="44dip"
+ android:layout_marginRight="44dip"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"/>
+
+ <LinearLayout
+ android:orientation="vertical"
+ android:layout_marginLeft="48dip"
+ android:layout_marginRight="48dip"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent">
+ <ImageView
+ android:id="@+id/empty_image"
+ android:layout_height="128dp"
+ android:layout_width="128dp"
+ android:layout_marginTop="56dip"
+ android:alpha="0.38"
+ android:gravity="center_horizontal"/>
+
+ <TextView
+ android:id="@+id/message"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="6dip"
+ android:textAppearance="?android:attr/textAppearanceLarge"
+ android:textColor="?android:attr/textColorSecondary"
+ android:textIsSelectable="false"/>
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:orientation="vertical"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent">
+
+ <Button
+ android:id="@+id/add_account_button"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="72dip"
+ android:layout_marginBottom="20dip"
+ android:textColor="@android:color/white"
+ android:text="@string/contacts_unavailable_add_account" />
+
+ <Button
+ android:id="@+id/import_contacts_button"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="15dip"
+ android:textColor="@android:color/white"
+ android:text="@string/contacts_unavailable_import_contacts" />
+
+ <ProgressBar
+ android:id="@+id/progress"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:layout_marginBottom="15dip" />
+ </LinearLayout>
+
+ <LinearLayout
+ android:orientation="vertical"
+ android:layout_marginLeft="44dip"
+ android:layout_marginRight="44dip"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"/>
+
+</LinearLayout>
diff --git a/res/layout/contact_tile_list.xml b/res/layout/contact_tile_list.xml
index e941617..8b172d1 100644
--- a/res/layout/contact_tile_list.xml
+++ b/res/layout/contact_tile_list.xml
@@ -39,7 +39,11 @@
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:layout_marginTop="@dimen/empty_message_top_margin"
- android:textColor="?android:attr/textColorSecondary"
+ android:textColor="@android:color/black"
+ android:drawableTop="@drawable/ic_star_black_128dp"
+ android:drawablePadding="4dp"
+ android:alpha="0.38"
+ android:paddingTop="10dp"
android:textAppearance="?android:attr/textAppearanceLarge"/>
</FrameLayout>
diff --git a/res/layout/contacts_unavailable_fragment_content.xml b/res/layout/contacts_unavailable_fragment_content.xml
index 4f54801..32636b4 100644
--- a/res/layout/contacts_unavailable_fragment_content.xml
+++ b/res/layout/contacts_unavailable_fragment_content.xml
@@ -20,43 +20,38 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
+
+ <ImageView
+ android:id="@+id/empty_image"
+ android:layout_height="128dp"
+ android:layout_width="128dp"
+ android:layout_marginTop="56dip"
+ android:alpha="0.38"
+ android:gravity="center_horizontal" />
+
<TextView
android:id="@+id/message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginTop="48dip"
+ android:layout_marginTop="6dip"
android:textAppearance="?android:attr/textAppearanceLarge"
- android:textColor="?android:attr/textColorSecondary" />
-
- <TextView
- android:id="@+id/secondary_message"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textColor="?android:attr/textColorSecondary"
- android:layout_gravity="center_horizontal"
- android:layout_marginBottom="@dimen/no_accounts_message_margin" />
+ android:textColor="?android:attr/textColorSecondary"/>
<LinearLayout
android:orientation="vertical"
android:layout_marginLeft="48dip"
android:layout_marginRight="48dip"
- android:layout_marginStart="48dip"
- android:layout_marginEnd="48dip"
+
android:layout_width="wrap_content"
android:layout_height="match_parent">
- <Button
- android:id="@+id/create_contact_button"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginBottom="15dip"
- android:text="@string/contacts_unavailable_create_contact" />
<Button
android:id="@+id/add_account_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:layout_marginTop="24dip"
android:layout_marginBottom="15dip"
+ android:textColor="@android:color/white"
android:text="@string/contacts_unavailable_add_account" />
<Button
@@ -64,6 +59,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="15dip"
+ android:textColor="@android:color/white"
android:text="@string/contacts_unavailable_import_contacts" />
<ProgressBar
diff --git a/res/values/integers.xml b/res/values/integers.xml
index 0de1de1..86a8e26 100644
--- a/res/values/integers.xml
+++ b/res/values/integers.xml
@@ -24,4 +24,7 @@
<!-- Number of lines the QuickContact title can have -->
<integer name="quickcontact_title_lines">1</integer>
+ <!-- Max suggestions limit showing in quick contact suggestion card [CHAR LIMIT=30]-->
+ <integer name="quickcontact_suggestions_limit">10</integer>
+
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 1104a24..6e1b9ee 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -255,7 +255,7 @@
<string name="removePhoto">Remove photo</string>
<!-- The text displayed when the contacts list is empty while displaying all contacts [CHAR LIMIT=NONE] -->
- <string name="noContacts">No contacts.</string>
+ <string name="noContacts">No contacts</string>
<!-- The text displayed when the groups list is empty while displaying all groups [CHAR LIMIT=NONE] -->
<string name="noGroups">No groups.</string>
@@ -544,7 +544,7 @@
<!-- Button shown on the main contacts screen when there are no contacts on the device.
Navigates to account setup [CHAR LIMIT=128] -->
- <string name="contacts_unavailable_add_account">Sign in to an account</string>
+ <string name="contacts_unavailable_add_account">Add account</string>
<!-- Button shown on the main contacts screen when there are no contacts on the device.
Initiates a contact import dialog [CHAR LIMIT=128] -->
@@ -777,7 +777,7 @@
<!-- Button used in quick contact suggestion card to merge selected contacts. [CHAR LIMIT=30]-->
<string name="quickcontact_suggestion_merge_button">Merge</string>
- <!-- Suggestions number in quick contact suggestion card [CHAR LIMIT=30] -->
+ <!-- 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>
diff --git a/src/com/android/contacts/activities/PeopleActivity.java b/src/com/android/contacts/activities/PeopleActivity.java
index 26add9d..473ed5c 100644
--- a/src/com/android/contacts/activities/PeopleActivity.java
+++ b/src/com/android/contacts/activities/PeopleActivity.java
@@ -627,11 +627,11 @@
if (mContactsUnavailableFragment != null) {
switch (getTabPositionForTextDirection(tab)) {
case TabState.FAVORITES:
- mContactsUnavailableFragment.setMessageText(
- R.string.listTotalAllContactsZeroStarred, -1);
+ mContactsUnavailableFragment.setTabInfo(
+ R.string.listTotalAllContactsZeroStarred, TabState.FAVORITES);
break;
case TabState.ALL:
- mContactsUnavailableFragment.setMessageText(R.string.noContacts, -1);
+ mContactsUnavailableFragment.setTabInfo(R.string.noContacts, TabState.ALL);
break;
}
// When using the mContactsUnavailableFragment the ViewPager doesn't contain two views.
diff --git a/src/com/android/contacts/editor/CompactContactEditorFragment.java b/src/com/android/contacts/editor/CompactContactEditorFragment.java
index e98a8de..031805b 100644
--- a/src/com/android/contacts/editor/CompactContactEditorFragment.java
+++ b/src/com/android/contacts/editor/CompactContactEditorFragment.java
@@ -365,6 +365,11 @@
}
}
+ @Override
+ public void onEditorsBound() {
+ getLoaderManager().initLoader(LOADER_GROUPS, null, mGroupsLoaderListener);
+ }
+
private CompactRawContactsEditorView getContent() {
return (CompactRawContactsEditorView) mContent;
}
diff --git a/src/com/android/contacts/editor/CompactRawContactsEditorView.java b/src/com/android/contacts/editor/CompactRawContactsEditorView.java
index 9d81276..e71c814 100644
--- a/src/com/android/contacts/editor/CompactRawContactsEditorView.java
+++ b/src/com/android/contacts/editor/CompactRawContactsEditorView.java
@@ -109,6 +109,11 @@
* Invoked when no editors could be bound for the contact.
*/
public void onBindEditorsFailed();
+
+ /**
+ * Invoked after editors have been bound for the contact.
+ */
+ public void onEditorsBound();
}
/** Used to sort entire kind sections. */
@@ -360,8 +365,7 @@
@Override
public void onClick(View view) {
if (view.getId() == R.id.more_fields) {
- showMoreFields();
- updateMoreFieldsButton();
+ showAllFields();
}
}
@@ -391,8 +395,8 @@
final SavedState savedState = (SavedState) state;
super.onRestoreInstanceState(savedState.getSuperState());
mIsExpanded = savedState.mIsExpanded;
- if (mIsExpanded && !mKindSectionDataMap.isEmpty()) {
- showMoreFields();
+ if (mIsExpanded) {
+ showAllFields();
}
}
@@ -445,20 +449,17 @@
GroupMembership.CONTENT_ITEM_TYPE);
for (CompactKindSectionView kindSectionView : kindSectionViews) {
kindSectionView.setGroupMetaData(groupMetaData);
+ if (mIsExpanded) {
+ kindSectionView.setHideWhenEmpty(false);
+ kindSectionView.updateEmptyEditors(/* shouldAnimate =*/ true);
+ }
}
-
- // Groups metadata may be set after we restore expansion state so just do it again
- if (mIsExpanded) {
- showMoreFields();
- }
- updateMoreFieldsButton();
}
public void setState(RawContactDeltaList rawContactDeltas,
MaterialColorMapUtils.MaterialPalette materialPalette, ViewIdGenerator viewIdGenerator,
long photoId, boolean hasNewContact, boolean isUserProfile,
AccountWithDataSet primaryAccount) {
- // Clear previous state and reset views
mKindSectionDataMap.clear();
mKindSectionViews.removeAllViews();
mMoreFields.setVisibility(View.VISIBLE);
@@ -488,13 +489,15 @@
}
// Setup the view
- setId(mViewIdGenerator.getId(rawContactDeltas.get(0), /* dataKind =*/ null,
- /* valuesDelta =*/ null, ViewIdGenerator.NO_VIEW_INDEX));
addAccountInfo();
addPhotoView();
addKindSectionViews();
- updateMoreFieldsButton();
+ if (mIsExpanded) {
+ showAllFields();
+ }
+
+ if (mListener != null) mListener.onEditorsBound();
}
private void parseRawContactDeltas(RawContactDeltaList rawContactDeltas,
@@ -836,7 +839,7 @@
return kindSectionView;
}
- private void showMoreFields() {
+ private void showAllFields() {
// Stop hiding empty editors and allow the user to enter values for all kinds now
for (int i = 0; i < mKindSectionViews.getChildCount(); i++) {
final CompactKindSectionView kindSectionView =
@@ -845,19 +848,7 @@
kindSectionView.updateEmptyEditors(/* shouldAnimate =*/ true);
}
mIsExpanded = true;
- }
- private void updateMoreFieldsButton() {
- // If any kind section views are hidden then show the link
- for (int i = 0; i < mKindSectionViews.getChildCount(); i++) {
- final CompactKindSectionView kindSectionView =
- (CompactKindSectionView) mKindSectionViews.getChildAt(i);
- if (kindSectionView.getVisibility() == View.GONE) {
- // Show the more fields button
- mMoreFields.setVisibility(View.VISIBLE);
- return;
- }
- }
// Hide the more fields button
mMoreFields.setVisibility(View.GONE);
}
diff --git a/src/com/android/contacts/editor/ContactEditorBaseFragment.java b/src/com/android/contacts/editor/ContactEditorBaseFragment.java
index 5b341a0..2c3b6c9 100644
--- a/src/com/android/contacts/editor/ContactEditorBaseFragment.java
+++ b/src/com/android/contacts/editor/ContactEditorBaseFragment.java
@@ -95,7 +95,7 @@
static final String TAG = "ContactEditor";
- protected static final int LOADER_DATA = 1;
+ protected static final int LOADER_CONTACT = 1;
protected static final int LOADER_GROUPS = 2;
private static final List<String> VALID_INTENT_ACTIONS = new ArrayList<String>() {{
@@ -366,7 +366,7 @@
/**
* The contact data loader listener.
*/
- protected final LoaderManager.LoaderCallbacks<Contact> mDataLoaderListener =
+ protected final LoaderManager.LoaderCallbacks<Contact> mContactLoaderListener =
new LoaderManager.LoaderCallbacks<Contact>() {
protected long mLoaderStartTime;
@@ -405,9 +405,9 @@
};
/**
- * The group meta data loader listener.
+ * The groups meta data loader listener.
*/
- protected final LoaderManager.LoaderCallbacks<Cursor> mGroupLoaderListener =
+ protected final LoaderManager.LoaderCallbacks<Cursor> mGroupsLoaderListener =
new LoaderManager.LoaderCallbacks<Cursor>() {
@Override
@@ -507,11 +507,11 @@
// database.
if (Intent.ACTION_EDIT.equals(mAction) ||
ContactEditorBaseActivity.ACTION_EDIT.equals(mAction)) {
- // Either...
+ // Either
// 1) orientation change but load never finished.
- // or
- // 2) not an orientation change. data needs to be loaded for first time.
- getLoaderManager().initLoader(LOADER_DATA, null, mDataLoaderListener);
+ // 2) not an orientation change so data needs to be loaded for first time.
+ getLoaderManager().initLoader(LOADER_CONTACT, null, mContactLoaderListener);
+ getLoaderManager().initLoader(LOADER_GROUPS, null, mGroupsLoaderListener);
}
} else {
// Orientation change, we already have mState, it was loaded by onCreate
@@ -560,12 +560,6 @@
}
@Override
- public void onStart() {
- getLoaderManager().initLoader(LOADER_GROUPS, null, mGroupLoaderListener);
- super.onStart();
- }
-
- @Override
public void onSaveInstanceState(Bundle outState) {
outState.putString(KEY_ACTION, mAction);
outState.putParcelable(KEY_URI, mLookupUri);
@@ -898,7 +892,7 @@
// If we are about to close the editor - there is no need to refresh the data
if (saveMode == SaveMode.CLOSE || saveMode == SaveMode.COMPACT
|| saveMode == SaveMode.SPLIT) {
- getLoaderManager().destroyLoader(LOADER_DATA);
+ getLoaderManager().destroyLoader(LOADER_CONTACT);
}
mStatus = Status.SAVING;
@@ -1360,7 +1354,7 @@
mState = new RawContactDeltaList();
load(Intent.ACTION_EDIT, contactLookupUri, null);
mStatus = Status.LOADING;
- getLoaderManager().restartLoader(LOADER_DATA, null, mDataLoaderListener);
+ getLoaderManager().restartLoader(LOADER_CONTACT, null, mContactLoaderListener);
}
break;
diff --git a/src/com/android/contacts/editor/ContactEditorFragment.java b/src/com/android/contacts/editor/ContactEditorFragment.java
index ccbf615..5d84f53 100644
--- a/src/com/android/contacts/editor/ContactEditorFragment.java
+++ b/src/com/android/contacts/editor/ContactEditorFragment.java
@@ -115,6 +115,12 @@
}
@Override
+ public void onStart() {
+ getLoaderManager().initLoader(LOADER_GROUPS, null, mGroupsLoaderListener);
+ super.onStart();
+ }
+
+ @Override
public void onExternalEditorRequest(AccountWithDataSet account, Uri uri) {
if (mListener != null) {
mListener.onCustomEditContactActivityRequested(account, uri, null, false);
diff --git a/src/com/android/contacts/list/ContactsUnavailableFragment.java b/src/com/android/contacts/list/ContactsUnavailableFragment.java
index c1b2c41..bd811b2 100644
--- a/src/com/android/contacts/list/ContactsUnavailableFragment.java
+++ b/src/com/android/contacts/list/ContactsUnavailableFragment.java
@@ -16,18 +16,21 @@
package com.android.contacts.list;
import android.app.Fragment;
-import android.content.Context;
+import android.graphics.PorterDuff;
import android.os.Bundle;
import android.provider.ContactsContract.ProviderStatus;
+import android.support.v4.content.ContextCompat;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
+import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
+import com.android.contacts.activities.ActionBarAdapter.TabState;
import com.android.contacts.R;
/**
@@ -37,14 +40,13 @@
public class ContactsUnavailableFragment extends Fragment implements OnClickListener {
private View mView;
+ private ImageView mImageView;
private TextView mMessageView;
- private TextView mSecondaryMessageView;
- private Button mCreateContactButton;
private Button mAddAccountButton;
private Button mImportContactsButton;
private ProgressBar mProgress;
private int mNoContactsMsgResId = -1;
- private int mNSecNoContactsMsgResId = -1;
+ private int mLastTab = -1;
private OnContactsUnavailableActionListener mListener;
@@ -59,14 +61,18 @@
public View onCreateView(
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mView = inflater.inflate(R.layout.contacts_unavailable_fragment, null);
+
+ mImageView = (ImageView) mView.findViewById(R.id.empty_image);
+
mMessageView = (TextView) mView.findViewById(R.id.message);
- mSecondaryMessageView = (TextView) mView.findViewById(R.id.secondary_message);
- mCreateContactButton = (Button) mView.findViewById(R.id.create_contact_button);
- mCreateContactButton.setOnClickListener(this);
mAddAccountButton = (Button) mView.findViewById(R.id.add_account_button);
mAddAccountButton.setOnClickListener(this);
+ mAddAccountButton.getBackground().setColorFilter(ContextCompat.getColor(getContext(), R
+ .color.primary_color), PorterDuff.Mode.MULTIPLY);
mImportContactsButton = (Button) mView.findViewById(R.id.import_contacts_button);
mImportContactsButton.setOnClickListener(this);
+ mImportContactsButton.getBackground().setColorFilter(ContextCompat.getColor(getContext(),
+ R.color.primary_color), PorterDuff.Mode.MULTIPLY);
mProgress = (ProgressBar) mView.findViewById(R.id.progress);
if (mProviderStatus != null) {
@@ -89,10 +95,11 @@
}
switch (providerStatus) {
case ProviderStatus.STATUS_EMPTY:
- setMessageText(mNoContactsMsgResId, mNSecNoContactsMsgResId);
- mCreateContactButton.setVisibility(View.VISIBLE);
- mAddAccountButton.setVisibility(View.VISIBLE);
- mImportContactsButton.setVisibility(View.VISIBLE);
+ setTabInfo(mNoContactsMsgResId, mLastTab);
+ if (mLastTab == TabState.ALL) {
+ mAddAccountButton.setVisibility(View.VISIBLE);
+ mImportContactsButton.setVisibility(View.VISIBLE);
+ }
mProgress.setVisibility(View.GONE);
break;
@@ -100,7 +107,6 @@
mMessageView.setText(R.string.upgrade_in_progress);
mMessageView.setGravity(Gravity.CENTER_HORIZONTAL);
mMessageView.setVisibility(View.VISIBLE);
- mCreateContactButton.setVisibility(View.GONE);
mAddAccountButton.setVisibility(View.GONE);
mImportContactsButton.setVisibility(View.GONE);
mProgress.setVisibility(View.VISIBLE);
@@ -114,9 +120,6 @@
return;
}
switch (v.getId()) {
- case R.id.create_contact_button:
- mListener.onCreateNewContactAction();
- break;
case R.id.add_account_button:
mListener.onAddAccountAction();
break;
@@ -130,24 +133,26 @@
*
* @param resId - String resource ID of the message , -1 means view will not be visible
*/
- public void setMessageText(int resId, int secResId) {
+ public void setTabInfo(int resId, int callerTab) {
mNoContactsMsgResId = resId;
- mNSecNoContactsMsgResId = secResId;
+ mLastTab = callerTab;
if ((mMessageView != null) && (mProviderStatus != null) &&
(mProviderStatus.equals(ProviderStatus.STATUS_EMPTY))) {
if (resId != -1) {
mMessageView.setText(mNoContactsMsgResId);
mMessageView.setGravity(Gravity.CENTER_HORIZONTAL);
mMessageView.setVisibility(View.VISIBLE);
- if (secResId != -1) {
- mSecondaryMessageView.setText(mNSecNoContactsMsgResId);
- mSecondaryMessageView.setGravity(Gravity.CENTER_HORIZONTAL);
- mSecondaryMessageView.setVisibility(View.VISIBLE);
- } else {
- mSecondaryMessageView.setVisibility(View.INVISIBLE);
+ if (callerTab == TabState.FAVORITES) {
+ mImageView.setImageResource(R.drawable.ic_star_black_128dp);
+ mAddAccountButton.setVisibility(View.GONE);
+ mImportContactsButton.setVisibility(View.GONE);
+ mProgress.setVisibility(View.GONE);
+ } else if (callerTab == TabState.ALL) {
+ mImageView.setImageResource(R.drawable.ic_person_black_128dp);
+ mAddAccountButton.setVisibility(View.VISIBLE);
+ mImportContactsButton.setVisibility(View.VISIBLE);
}
} else {
- mSecondaryMessageView.setVisibility(View.GONE);
mMessageView.setVisibility(View.GONE);
}
}
diff --git a/src/com/android/contacts/quickcontact/QuickContactActivity.java b/src/com/android/contacts/quickcontact/QuickContactActivity.java
index 3ac9472..39cf0ec 100644
--- a/src/com/android/contacts/quickcontact/QuickContactActivity.java
+++ b/src/com/android/contacts/quickcontact/QuickContactActivity.java
@@ -255,6 +255,7 @@
private View mSuggestionSeparator;
private Button mSuggestionsMergeButton;
private boolean mIsSuggestionListCollapsed;
+ private long mPreviousSuggestionForContactId = 0;
private MultiShrinkScroller mScroller;
private SelectAccountDialogFragmentListener mSelectAccountFragmentListener;
@@ -489,44 +490,51 @@
final int suggestionNumber = mSuggestions.size();
final String suggestionSummary = getSuggestionAccountSummary(mSuggestions);
- if (suggestionNumber > 0) {
- 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) {
- mSuggestionSummaryPhoto.setImageBitmap(BitmapFactory.decodeByteArray(
- firstSuggestion.photo, 0, firstSuggestion.photo.length));
- } else {
- mSuggestionSummaryPhoto.setImageDrawable(
- ContactPhotoManager.getDefaultAvatarDrawableForContact(
- getResources(), false, null));
- }
-
- mSuggestionForName.setText(suggestionForName);
- mSuggestionNumber.setText(getResources().getQuantityString(
- R.plurals.quickcontact_suggestions_number, suggestionNumber, suggestionNumber));
- mSuggestionSummary.setText(suggestionSummary);
-
- for (Suggestion suggestion : mSuggestions) {
- mSuggestionList.addView(inflateSuggestionListView(suggestion));
- }
-
- mSuggestionExpansionButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (mIsSuggestionListCollapsed) {
- expandSuggestionList();
- } else {
- collapseSuggestionList();
- }
- }
- });
-
- } else {
- mSuggestionCardView.setVisibility(View.GONE);
+ 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) {
+ mSuggestionSummaryPhoto.setImageBitmap(BitmapFactory.decodeByteArray(
+ firstSuggestion.photo, 0, firstSuggestion.photo.length));
+ } else {
+ mSuggestionSummaryPhoto.setImageDrawable(
+ ContactPhotoManager.getDefaultAvatarDrawableForContact(
+ getResources(), false, null));
+ }
+
+ 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) {
+ mSuggestionList.addView(inflateSuggestionListView(suggestion));
+ suggestionContactIds.add(suggestion.contactId);
+ }
+
+ // 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() {
@@ -563,7 +571,7 @@
}
}
- Set<String> accountTypeWithNumber = new HashSet<>();
+ final Set<String> accountTypeWithNumber = new HashSet<>();
for (String accountType : accountTypeMap.keySet()) {
final String number = getResources().getQuantityString(
R.plurals.quickcontact_suggestion_account_type_number,
@@ -927,9 +935,8 @@
if (!mSelectedAggregationIds.contains(mContactData.getId())) {
mSelectedAggregationIds.add(mContactData.getId());
}
- TreeSet<Long> mergedContactIds = new TreeSet<Long>(mSelectedAggregationIds);
- mSelectedAggregationIds.clear(); // Clear selected ids for merged contact.
- JoinContactsDialogFragment.start(QuickContactActivity.this, mergedContactIds);
+ JoinContactsDialogFragment.start(
+ QuickContactActivity.this, mSelectedAggregationIds);
}
});
@@ -1320,11 +1327,18 @@
if (mAggregationSuggestionEngine == null) {
mAggregationSuggestionEngine = new AggregationSuggestionEngine(this);
mAggregationSuggestionEngine.setListener(this);
- mAggregationSuggestionEngine.setSuggestionsLimit(10);
+ mAggregationSuggestionEngine.setSuggestionsLimit(getResources().getInteger(
+ R.integer.quickcontact_suggestions_limit));
mAggregationSuggestionEngine.start();
}
mAggregationSuggestionEngine.setContactId(mContactData.getId());
+ if (mPreviousSuggestionForContactId != 0
+ && mPreviousSuggestionForContactId != mContactData.getId()) {
+ // Clear selected Ids when listing suggestions for new contact Id.
+ mSelectedAggregationIds.clear();
+ }
+ mPreviousSuggestionForContactId = mContactData.getId();
// Trigger suggestion engine to compute suggestions.
final ContentValues values = new ContentValues();