Merge "Temporary fix for crash on rotation in search mode"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index e27445f..7fb7f37 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -298,6 +298,24 @@
android:targetActivity=".activities.PeopleActivity"
/>
+ <!-- Backwards compatibility: "Contacts" from Honeycomb -->
+ <activity-alias android:name=".activities.ContactsFrontDoor"
+ android:targetActivity=".activities.PeopleActivity"
+ android:exported="true"
+ />
+
+ <!-- Backwards compatibility: "Contacts" from Gingerbread and earlier -->
+ <activity-alias android:name="DialtactsContactsEntryActivity"
+ android:targetActivity=".activities.PeopleActivity"
+ android:exported="true"
+ />
+
+ <!-- Backwards compatibility: "Phone" from Gingerbread and earlier -->
+ <activity-alias android:name="DialtactsActivity"
+ android:targetActivity=".activities.DialtactsActivity"
+ android:exported="true"
+ />
+
<!-- An activity for joining contacts -->
<activity android:name=".activities.JoinContactActivity"
android:theme="@style/JoinContactActivityTheme"
diff --git a/res/layout/contact_tile_single.xml b/res/layout/contact_tile_frequent.xml
similarity index 95%
rename from res/layout/contact_tile_single.xml
rename to res/layout/contact_tile_frequent.xml
index 7147f3c..4ba7396 100644
--- a/res/layout/contact_tile_single.xml
+++ b/res/layout/contact_tile_frequent.xml
@@ -36,8 +36,8 @@
android:textAppearance="?android:attr/textAppearanceMedium"
android:paddingTop="24dip" />
- <ImageView
- android:id="@+id/contact_tile_image"
+ <QuickContactBadge
+ android:id="@+id/contact_tile_quick"
android:layout_width="64dip"
android:layout_height="64dip"
android:scaleType="centerCrop" />
diff --git a/res/layout/contact_tile_square.xml b/res/layout/contact_tile_square.xml
deleted file mode 100644
index ca79cef..0000000
--- a/res/layout/contact_tile_square.xml
+++ /dev/null
@@ -1,57 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 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.
--->
-<view
- xmlns:android="http://schemas.android.com/apk/res/android"
- class="com.android.contacts.list.ContactTileSquareView"
- android:focusable="true"
- android:padding="1px"
- android:background="@drawable/list_selector" >
-
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
-
- <ImageView
- android:id="@+id/contact_tile_image"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:scaleType="centerCrop" />
-
- <View
- android:id="@+id/contact_tile_background"
- android:layout_width="match_parent"
- android:layout_height="48dip"
- android:layout_alignParentBottom="true"
- android:layout_alignParentLeft="true"
- android:alpha="0.5"
- android:background="@android:color/black" />
-
- <TextView
- android:id="@+id/contact_tile_name"
- android:layout_width="match_parent"
- android:layout_height="48dip"
- android:layout_alignParentBottom="true"
- android:layout_alignParentLeft="true"
- android:gravity="center_vertical"
- android:paddingLeft="8dip"
- android:singleLine="true"
- android:ellipsize="end"
- android:textColor="@android:color/white"
- android:textAppearance="?android:attr/textAppearanceMedium" />
-
- </RelativeLayout>
-
-</view>
diff --git a/res/layout/contact_tile_single.xml b/res/layout/contact_tile_starred.xml
similarity index 60%
copy from res/layout/contact_tile_single.xml
copy to res/layout/contact_tile_starred.xml
index 7147f3c..6cdf213 100644
--- a/res/layout/contact_tile_single.xml
+++ b/res/layout/contact_tile_starred.xml
@@ -15,33 +15,27 @@
-->
<view
xmlns:android="http://schemas.android.com/apk/res/android"
- class="com.android.contacts.list.ContactTileView"
- android:focusable="true"
- android:background="@drawable/list_selector"
- android:paddingRight="16dip"
- android:paddingLeft="16dip" >
+ class="com.android.contacts.list.ContactTileStarredView"
+ style="@style/ContactTileStarred" >
- <LinearLayout
+ <RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
- <TextView
- android:id="@+id/contact_tile_name"
- android:layout_width="0dip"
- android:layout_height="fill_parent"
- android:layout_weight="1"
- android:textSize="18sp"
- android:singleLine="true"
- android:ellipsize="end"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:paddingTop="24dip" />
-
<ImageView
android:id="@+id/contact_tile_image"
- android:layout_width="64dip"
- android:layout_height="64dip"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
android:scaleType="centerCrop" />
- </LinearLayout>
+ <View
+ android:id="@+id/contact_tile_background"
+ style="@style/ContactTileStarredTextBackground" />
+
+ <TextView
+ android:id="@+id/contact_tile_name"
+ style="@style/ContactTileStarredText" />
+
+ </RelativeLayout>
</view>
diff --git a/res/layout/contact_tile_starred_quick_contact.xml b/res/layout/contact_tile_starred_quick_contact.xml
new file mode 100644
index 0000000..241ab54
--- /dev/null
+++ b/res/layout/contact_tile_starred_quick_contact.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 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.
+-->
+<view
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ class="com.android.contacts.list.ContactTileStarredView"
+ style="@style/ContactTileStarred" >
+
+ <RelativeLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" >
+
+ <QuickContactBadge
+ android:id="@+id/contact_tile_quick"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:scaleType="centerCrop" />
+
+ <View
+ android:id="@+id/contact_tile_background"
+ style="@style/ContactTileStarredTextBackground" />
+
+ <TextView
+ android:id="@+id/contact_tile_name"
+ style="@style/ContactTileStarredText" />
+
+ </RelativeLayout>
+
+</view>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index e4b7a86..01f0e62 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -328,4 +328,32 @@
<item name="android:background">@drawable/btn_dial</item>
<item name="android:soundEffectsEnabled">false</item>
</style>
+
+ <style name="ContactTileStarred">
+ <item name="android:focusable">true</item>
+ <item name="android:padding">1px</item>
+ <item name="android:background">@drawable/list_selector</item>
+ </style>
+
+ <style name="ContactTileStarredText">
+ <item name="android:layout_width">match_parent</item>
+ <item name="android:layout_height">48dip</item>
+ <item name="android:layout_alignParentBottom">true</item>
+ <item name="android:layout_alignParentLeft">true</item>
+ <item name="android:gravity">center_vertical</item>
+ <item name="android:paddingLeft">8dip</item>
+ <item name="android:singleLine">true</item>
+ <item name="android:ellipsize">end</item>
+ <item name="android:textColor">@android:color/white</item>
+ <item name="android:textAppearance">?android:attr/textAppearanceMedium</item>
+ </style>
+
+ <style name="ContactTileStarredTextBackground">
+ <item name="android:layout_width">match_parent</item>
+ <item name="android:layout_height">48dip</item>
+ <item name="android:layout_alignParentBottom">true</item>
+ <item name="android:layout_alignParentLeft">true</item>
+ <item name="android:alpha">0.5</item>
+ <item name="android:background">@android:color/black</item>
+ </style>
</resources>
diff --git a/src/com/android/contacts/CallDetailActivity.java b/src/com/android/contacts/CallDetailActivity.java
index a1d2bb7..d08b76a 100644
--- a/src/com/android/contacts/CallDetailActivity.java
+++ b/src/com/android/contacts/CallDetailActivity.java
@@ -304,8 +304,8 @@
setListAdapter(adapter);
}
mPhoneCallDetailsHelper.setPhoneCallDetails(mPhoneCallDetailsViews,
- new PhoneCallDetails(mNumber, numberText, callType, date, nameText,
- numberType, numberLabel), false);
+ new PhoneCallDetails(mNumber, numberText, new int[]{ callType }, date,
+ nameText, numberType, numberLabel), false);
loadContactPhotos(photoId);
} else {
diff --git a/src/com/android/contacts/ContactLoader.java b/src/com/android/contacts/ContactLoader.java
index 2ec1cbf..7ed9d86 100644
--- a/src/com/android/contacts/ContactLoader.java
+++ b/src/com/android/contacts/ContactLoader.java
@@ -413,7 +413,6 @@
RawContacts.SYNC3,
RawContacts.SYNC4,
RawContacts.DELETED,
- RawContacts.IS_RESTRICTED,
RawContacts.NAME_VERIFIED,
Contacts.Entity.DATA_ID,
@@ -481,46 +480,45 @@
public final static int SYNC3 = 22;
public final static int SYNC4 = 23;
public final static int DELETED = 24;
- public final static int IS_RESTRICTED = 25;
- public final static int NAME_VERIFIED = 26;
+ public final static int NAME_VERIFIED = 25;
- public final static int DATA_ID = 27;
- public final static int DATA1 = 28;
- public final static int DATA2 = 29;
- public final static int DATA3 = 30;
- public final static int DATA4 = 31;
- public final static int DATA5 = 32;
- public final static int DATA6 = 33;
- public final static int DATA7 = 34;
- public final static int DATA8 = 35;
- public final static int DATA9 = 36;
- public final static int DATA10 = 37;
- public final static int DATA11 = 38;
- public final static int DATA12 = 39;
- public final static int DATA13 = 40;
- public final static int DATA14 = 41;
- public final static int DATA15 = 42;
- public final static int DATA_SYNC1 = 43;
- public final static int DATA_SYNC2 = 44;
- public final static int DATA_SYNC3 = 45;
- public final static int DATA_SYNC4 = 46;
- public final static int DATA_VERSION = 47;
- public final static int IS_PRIMARY = 48;
- public final static int IS_SUPERPRIMARY = 49;
- public final static int MIMETYPE = 50;
- public final static int RES_PACKAGE = 51;
+ public final static int DATA_ID = 26;
+ public final static int DATA1 = 27;
+ public final static int DATA2 = 28;
+ public final static int DATA3 = 29;
+ public final static int DATA4 = 30;
+ public final static int DATA5 = 31;
+ public final static int DATA6 = 32;
+ public final static int DATA7 = 33;
+ public final static int DATA8 = 34;
+ public final static int DATA9 = 35;
+ public final static int DATA10 = 36;
+ public final static int DATA11 = 37;
+ public final static int DATA12 = 38;
+ public final static int DATA13 = 39;
+ public final static int DATA14 = 40;
+ public final static int DATA15 = 41;
+ public final static int DATA_SYNC1 = 42;
+ public final static int DATA_SYNC2 = 43;
+ public final static int DATA_SYNC3 = 44;
+ public final static int DATA_SYNC4 = 45;
+ public final static int DATA_VERSION = 46;
+ public final static int IS_PRIMARY = 47;
+ public final static int IS_SUPERPRIMARY = 48;
+ public final static int MIMETYPE = 49;
+ public final static int RES_PACKAGE = 50;
- public final static int GROUP_SOURCE_ID = 52;
+ public final static int GROUP_SOURCE_ID = 51;
- public final static int PRESENCE = 53;
- public final static int CHAT_CAPABILITY = 54;
- public final static int STATUS = 55;
- public final static int STATUS_RES_PACKAGE = 56;
- public final static int STATUS_ICON = 57;
- public final static int STATUS_LABEL = 58;
- public final static int STATUS_TIMESTAMP = 59;
+ public final static int PRESENCE = 52;
+ public final static int CHAT_CAPABILITY = 53;
+ public final static int STATUS = 54;
+ public final static int STATUS_RES_PACKAGE = 55;
+ public final static int STATUS_ICON = 56;
+ public final static int STATUS_LABEL = 57;
+ public final static int STATUS_TIMESTAMP = 58;
- public final static int PHOTO_URI = 60;
+ public final static int PHOTO_URI = 59;
}
private static class DirectoryQuery {
@@ -764,7 +762,6 @@
cursorColumnToContentValues(cursor, cv, ContactQuery.DELETED);
cursorColumnToContentValues(cursor, cv, ContactQuery.CONTACT_ID);
cursorColumnToContentValues(cursor, cv, ContactQuery.STARRED);
- cursorColumnToContentValues(cursor, cv, ContactQuery.IS_RESTRICTED);
cursorColumnToContentValues(cursor, cv, ContactQuery.NAME_VERIFIED);
return cv;
diff --git a/src/com/android/contacts/GroupMemberLoader.java b/src/com/android/contacts/GroupMemberLoader.java
index 0633bf8..8f08ccd 100644
--- a/src/com/android/contacts/GroupMemberLoader.java
+++ b/src/com/android/contacts/GroupMemberLoader.java
@@ -82,8 +82,6 @@
Uri uri = Data.CONTENT_URI;
uri = uri.buildUpon().appendQueryParameter(ContactsContract.DIRECTORY_PARAM_KEY,
String.valueOf(Directory.DEFAULT)).build();
- // TODO: Bring back dataRestriction
- // uri = applyDataRestriction(uri);
return uri;
}
diff --git a/src/com/android/contacts/PhoneCallDetails.java b/src/com/android/contacts/PhoneCallDetails.java
index c5c37df..7b02a88 100644
--- a/src/com/android/contacts/PhoneCallDetails.java
+++ b/src/com/android/contacts/PhoneCallDetails.java
@@ -27,8 +27,12 @@
public final CharSequence number;
/** The formatted version of {@link #number}. */
public final CharSequence formattedNumber;
- /** The type of call, as defined in the call log table, e.g., {@link Calls#INCOMING_TYPE}. */
- public final int callType;
+ /**
+ * The type of calls, as defined in the call log table, e.g., {@link Calls#INCOMING_TYPE}.
+ * <p>
+ * There might be multiple types if this represents a set of entries grouped together.
+ */
+ public final int[] callTypes;
/** The date of the call, in milliseconds since the epoch. */
public final long date;
/** The name of the contact, or the empty string. */
@@ -39,17 +43,17 @@
public final CharSequence numberLabel;
/** Create the details for a call with a number not associated with a contact. */
- public PhoneCallDetails(CharSequence number, CharSequence formattedNumber, int callType,
+ public PhoneCallDetails(CharSequence number, CharSequence formattedNumber, int[] callTypes,
long date) {
- this(number, formattedNumber, callType, date, "", 0, "");
+ this(number, formattedNumber, callTypes, date, "", 0, "");
}
/** Create the details for a call with a number associated with a contact. */
- public PhoneCallDetails(CharSequence number, CharSequence formattedNumber, int callType,
+ public PhoneCallDetails(CharSequence number, CharSequence formattedNumber, int[] callTypes,
long date, CharSequence name, int numberType, CharSequence numberLabel) {
this.number = number;
this.formattedNumber = formattedNumber;
- this.callType = callType;
+ this.callTypes = callTypes;
this.date = date;
this.name = name;
this.numberType = numberType;
diff --git a/src/com/android/contacts/PhoneCallDetailsHelper.java b/src/com/android/contacts/PhoneCallDetailsHelper.java
index 4605799..7f73b04 100644
--- a/src/com/android/contacts/PhoneCallDetailsHelper.java
+++ b/src/com/android/contacts/PhoneCallDetailsHelper.java
@@ -86,58 +86,22 @@
public void setPhoneCallDetails(PhoneCallDetailsViews views, PhoneCallDetails details,
boolean useIcons) {
if (useIcons) {
- final Drawable callTypeDrawable;
- switch (details.callType) {
- case Calls.INCOMING_TYPE:
- callTypeDrawable = mIncomingDrawable;
- break;
-
- case Calls.OUTGOING_TYPE:
- callTypeDrawable = mOutgoingDrawable;
- break;
-
- case Calls.MISSED_TYPE:
- callTypeDrawable = mMissedDrawable;
- break;
-
- case Calls.VOICEMAIL_TYPE:
- callTypeDrawable = mVoicemailDrawable;
- break;
-
- default:
- throw new IllegalArgumentException("invalid call type: " + details.callType);
- }
- ImageView callTypeImage = new ImageView(mContext);
- callTypeImage.setImageDrawable(callTypeDrawable);
views.callTypeIcons.removeAllViews();
- views.callTypeIcons.addView(callTypeImage);
-
+ int count = details.callTypes.length;
+ for (int callType : details.callTypes) {
+ ImageView callTypeImage = new ImageView(mContext);
+ callTypeImage.setImageDrawable(getCallTypeDrawable(callType));
+ views.callTypeIcons.addView(callTypeImage);
+ }
views.callTypeIcons.setVisibility(View.VISIBLE);
views.callTypeText.setVisibility(View.GONE);
views.callTypeSeparator.setVisibility(View.GONE);
} else {
String callTypeName;
- switch (details.callType) {
- case Calls.INCOMING_TYPE:
- callTypeName = mIncomingName;
- break;
-
- case Calls.OUTGOING_TYPE:
- callTypeName = mOutgoingName;
- break;
-
- case Calls.MISSED_TYPE:
- callTypeName = mMissedName;
- break;
-
- case Calls.VOICEMAIL_TYPE:
- callTypeName = mVoicemailName;
- break;
-
- default:
- throw new IllegalArgumentException("invalid call type: " + details.callType);
- }
- views.callTypeText.setText(callTypeName);
+ // Use the name of the first call type.
+ // TODO: We should update this to handle the text for multiple calls as well.
+ int callType = details.callTypes[0];
+ views.callTypeText.setText(getCallTypeText(callType));
views.callTypeIcons.removeAllViews();
views.callTypeText.setVisibility(View.VISIBLE);
@@ -167,7 +131,7 @@
} else {
nameText = details.name;
CharSequence displayNumber = getDisplayNumber(details.number, details.formattedNumber);
- if (details.callType != 0 && numberFormattedLabel != null) {
+ if (numberFormattedLabel != null) {
numberText = FormatUtils.applyStyleToSpan(Typeface.BOLD,
numberFormattedLabel + " " + displayNumber, 0,
numberFormattedLabel.length(),
@@ -191,6 +155,46 @@
}
}
+ /** Returns the text used to represent the given call type. */
+ private String getCallTypeText(int callType) {
+ switch (callType) {
+ case Calls.INCOMING_TYPE:
+ return mIncomingName;
+
+ case Calls.OUTGOING_TYPE:
+ return mOutgoingName;
+
+ case Calls.MISSED_TYPE:
+ return mMissedName;
+
+ case Calls.VOICEMAIL_TYPE:
+ return mVoicemailName;
+
+ default:
+ throw new IllegalArgumentException("invalid call type: " + callType);
+ }
+ }
+
+ /** Returns the drawable of the icon associated with the given call type. */
+ private Drawable getCallTypeDrawable(int callType) {
+ switch (callType) {
+ case Calls.INCOMING_TYPE:
+ return mIncomingDrawable;
+
+ case Calls.OUTGOING_TYPE:
+ return mOutgoingDrawable;
+
+ case Calls.MISSED_TYPE:
+ return mMissedDrawable;
+
+ case Calls.VOICEMAIL_TYPE:
+ return mVoicemailDrawable;
+
+ default:
+ throw new IllegalArgumentException("invalid call type: " + callType);
+ }
+ }
+
private CharSequence getDisplayNumber(CharSequence number, CharSequence formattedNumber) {
if (TextUtils.isEmpty(number)) {
return "";
diff --git a/src/com/android/contacts/activities/ContactDetailActivity.java b/src/com/android/contacts/activities/ContactDetailActivity.java
index 47568b8..7456967 100644
--- a/src/com/android/contacts/activities/ContactDetailActivity.java
+++ b/src/com/android/contacts/activities/ContactDetailActivity.java
@@ -218,7 +218,7 @@
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
// First check if the {@link ContactLoaderFragment} can handle the key
- if (mLoaderFragment.handleKeyDown(keyCode)) return true;
+ if (mLoaderFragment != null && mLoaderFragment.handleKeyDown(keyCode)) return true;
// Otherwise find the correct fragment to handle the event
FragmentKeyListener mCurrentFragment;
@@ -232,7 +232,7 @@
default:
throw new IllegalStateException("Invalid current item for ViewPager");
}
- if (mCurrentFragment.handleKeyDown(keyCode)) return true;
+ if (mCurrentFragment != null && mCurrentFragment.handleKeyDown(keyCode)) return true;
// In the last case, give the key event to the superclass.
return super.onKeyDown(keyCode, event);
diff --git a/src/com/android/contacts/activities/DialtactsActivity.java b/src/com/android/contacts/activities/DialtactsActivity.java
index e345db7..0fa745d 100644
--- a/src/com/android/contacts/activities/DialtactsActivity.java
+++ b/src/com/android/contacts/activities/DialtactsActivity.java
@@ -333,6 +333,7 @@
mCallLogFragment.onVisibilityChanged(currentPosition == TAB_INDEX_CALL_LOG);
} else if (fragment instanceof StrequentContactListFragment) {
mStrequentFragment = (StrequentContactListFragment) fragment;
+ mStrequentFragment.setQuickContact(false);
mStrequentFragment.setListener(mStrequentListener);
} else if (fragment instanceof PhoneNumberPickerFragment) {
mSearchFragment = (PhoneNumberPickerFragment) fragment;
diff --git a/src/com/android/contacts/activities/PeopleActivity.java b/src/com/android/contacts/activities/PeopleActivity.java
index bf0b256..12a17f2 100644
--- a/src/com/android/contacts/activities/PeopleActivity.java
+++ b/src/com/android/contacts/activities/PeopleActivity.java
@@ -236,10 +236,12 @@
} else if (fragment instanceof GroupDetailFragment) {
mGroupDetailFragment = (GroupDetailFragment) fragment;
mGroupDetailFragment.setListener(mGroupDetailFragmentListener);
+ mGroupDetailFragment.setQuickContact(PhoneCapabilityTester.isUsingTwoPanes(this));
} else if (fragment instanceof StrequentContactListFragment) {
mFavoritesFragment = (StrequentContactListFragment) fragment;
mFavoritesFragment.setListener(mFavoritesFragmentListener);
mFavoritesFragment.setDisplayType(DisplayType.STARRED_ONLY);
+ mFavoritesFragment.setQuickContact(PhoneCapabilityTester.isUsingTwoPanes(this));
}
}
@@ -488,6 +490,10 @@
filter = ContactListFilter.createFilterWithType(
ContactListFilter.FILTER_TYPE_STARRED);
break;
+ case ContactsRequest.ACTION_VIEW_CONTACT:
+ if (PhoneCapabilityTester.isUsingTwoPanes(this)) {
+ getActionBar().setSelectedNavigationItem(TabState.ALL.ordinal());
+ }
}
mSearchMode = mRequest.isSearchMode();
diff --git a/src/com/android/contacts/calllog/CallLogFragment.java b/src/com/android/contacts/calllog/CallLogFragment.java
index 3bf757b..11f8965 100644
--- a/src/com/android/contacts/calllog/CallLogFragment.java
+++ b/src/com/android/contacts/calllog/CallLogFragment.java
@@ -583,7 +583,7 @@
@VisibleForTesting
@Override
public void bindStandAloneView(View view, Context context, Cursor cursor) {
- bindView(context, view, cursor);
+ bindView(view, cursor, 1);
}
@VisibleForTesting
@@ -599,7 +599,7 @@
@VisibleForTesting
@Override
public void bindChildView(View view, Context context, Cursor cursor) {
- bindView(context, view, cursor);
+ bindView(view, cursor, 1);
}
@VisibleForTesting
@@ -616,11 +616,7 @@
@Override
public void bindGroupView(View view, Context context, Cursor cursor, int groupSize,
boolean expanded) {
- final CallLogListItemViews views = (CallLogListItemViews) view.getTag();
- int groupIndicator = expanded
- ? com.android.internal.R.drawable.expander_ic_maximized
- : com.android.internal.R.drawable.expander_ic_minimized;
- bindView(context, view, cursor);
+ bindView(view, cursor, groupSize);
}
private void findAndCacheViews(View view) {
@@ -632,12 +628,18 @@
view.setTag(views);
}
- public void bindView(Context context, View view, Cursor c) {
+ /**
+ * Binds the views in the entry to the data in the call log.
+ *
+ * @param view the view corresponding to this entry
+ * @param c the cursor pointing to the entry in the call log
+ * @param count the number of entries in the current item, greater than 1 if it is a group
+ */
+ private void bindView(View view, Cursor c, int count) {
final CallLogListItemViews views = (CallLogListItemViews) view.getTag();
String number = c.getString(CallLogQuery.NUMBER);
long date = c.getLong(CallLogQuery.DATE);
- int callType = c.getInt(CallLogQuery.CALL_TYPE);
final String formattedNumber;
String countryIso = c.getString(CallLogQuery.COUNTRY_ISO);
// Store away the number so we can call it directly if you click on the call icon
@@ -694,11 +696,12 @@
views.callView.setVisibility(View.VISIBLE);
}
+ int[] callTypes = getCallTypes(c, count);
final PhoneCallDetails details;
if (TextUtils.isEmpty(name)) {
- details = new PhoneCallDetails(number, formattedNumber, callType, date);
+ details = new PhoneCallDetails(number, formattedNumber, callTypes, date);
} else {
- details = new PhoneCallDetails(number, formattedNumber, callType, date, name,
+ details = new PhoneCallDetails(number, formattedNumber, callTypes, date, name,
ntype, label);
}
mCallLogViewsHelper.setPhoneCallDetails(views, details , true);
@@ -715,6 +718,24 @@
}
}
+ /**
+ * Returns the call types for the given number of items in the cursor.
+ * <p>
+ * It uses the next {@code count} rows in the cursor to extract the types.
+ * <p>
+ * It position in the cursor is unchanged by this function.
+ */
+ private int[] getCallTypes(Cursor cursor, int count) {
+ int position = cursor.getPosition();
+ int[] callTypes = new int[count];
+ for (int index = 0; index < count; ++index) {
+ callTypes[index] = cursor.getInt(CallLogQuery.CALL_TYPE);
+ cursor.moveToNext();
+ }
+ cursor.moveToPosition(position);
+ return callTypes;
+ }
+
private void bindQuickContact(QuickContactBadge view, long photoId, long contactId,
String lookupKey) {
view.assignContactUri(getContactUri(contactId, lookupKey));
diff --git a/src/com/android/contacts/calllog/CallLogListItemHelper.java b/src/com/android/contacts/calllog/CallLogListItemHelper.java
index 462b0b3..e4630e9 100644
--- a/src/com/android/contacts/calllog/CallLogListItemHelper.java
+++ b/src/com/android/contacts/calllog/CallLogListItemHelper.java
@@ -61,8 +61,9 @@
boolean useIcons) {
mPhoneCallDetailsHelper.setPhoneCallDetails(views.phoneCallDetailsViews, details, useIcons);
if (views.callView != null) {
+ // The type of icon, call or play, is determined by the first call in the group.
views.callView.setImageDrawable(
- details.callType == Calls.VOICEMAIL_TYPE ? mPlayDrawable : mCallDrawable);
+ details.callTypes[0] == Calls.VOICEMAIL_TYPE ? mPlayDrawable : mCallDrawable);
views.callView.setVisibility(
canPlaceCallsTo(details.number) ? View.VISIBLE : View.INVISIBLE);
}
diff --git a/src/com/android/contacts/detail/ContactLoaderFragment.java b/src/com/android/contacts/detail/ContactLoaderFragment.java
index 5504473..b7cb2b7 100644
--- a/src/com/android/contacts/detail/ContactLoaderFragment.java
+++ b/src/com/android/contacts/detail/ContactLoaderFragment.java
@@ -98,8 +98,6 @@
private ContactLoader.Result mContactData;
- private boolean mAllRestricted;
-
public ContactLoaderFragment() {
}
@@ -189,16 +187,6 @@
mContactData = null;
}
- mAllRestricted = true;
-
- for (Entity entity: mContactData.getEntities()) {
- final ContentValues entValues = entity.getEntityValues();
- // Mark when this contact has any unrestricted components
- Integer restricted = entValues.getAsInteger(RawContacts.IS_RESTRICTED);
- final boolean isRestricted = restricted != null && restricted != 0;
- if (!isRestricted) mAllRestricted = false;
- }
-
if (mListener != null) {
if (mContactData == null) {
mListener.onContactNotFound();
@@ -208,6 +196,7 @@
}
}
+ @Override
public void onLoaderReset(Loader<ContactLoader.Result> loader) {
mContactData = null;
if (mListener != null) {
@@ -259,7 +248,7 @@
}
public boolean isContactShareable() {
- return mContactData != null && !mContactData.isDirectoryEntry() && !mAllRestricted;
+ return mContactData != null && !mContactData.isDirectoryEntry();
}
@Override
@@ -281,7 +270,6 @@
return true;
}
case R.id.menu_share: {
- if (mAllRestricted) return false;
if (mContactData == null) return false;
final String lookupKey = mContactData.getLookupKey();
diff --git a/src/com/android/contacts/group/GroupDetailFragment.java b/src/com/android/contacts/group/GroupDetailFragment.java
index fe2605e..9e668bb 100644
--- a/src/com/android/contacts/group/GroupDetailFragment.java
+++ b/src/com/android/contacts/group/GroupDetailFragment.java
@@ -105,6 +105,7 @@
mAdapter = new ContactTileAdapter(activity, mContactTileListener, columnCount,
DisplayType.GROUP_MEMBERS);
+
configurePhotoLoader();
}
@@ -130,6 +131,10 @@
startGroupMetadataLoader();
}
+ public void setQuickContact(boolean enableQuickContact) {
+ mAdapter.setQuickContact(enableQuickContact);
+ }
+
private void configureAdapter(long groupId) {
mGroupId = groupId;
mMemberListView.setAdapter(mAdapter);
diff --git a/src/com/android/contacts/list/ContactEntryListAdapter.java b/src/com/android/contacts/list/ContactEntryListAdapter.java
index 06e31e3..a03ddee 100644
--- a/src/com/android/contacts/list/ContactEntryListAdapter.java
+++ b/src/com/android/contacts/list/ContactEntryListAdapter.java
@@ -20,7 +20,6 @@
import com.android.contacts.widget.IndexerListAdapter;
import com.android.contacts.widget.TextWithHighlightingFactory;
-import android.app.Activity;
import android.content.Context;
import android.content.CursorLoader;
import android.database.Cursor;
@@ -61,7 +60,6 @@
private int mDisplayOrder;
private int mSortOrder;
private boolean mNameHighlightingEnabled;
- private boolean mDataRestrictedByCallingPackage;
private boolean mDisplayPhotos;
private boolean mQuickContactEnabled;
@@ -278,43 +276,6 @@
mIncludeProfile = includeProfile;
}
- public boolean isDataRestrictedByCallingPackage() {
- return mDataRestrictedByCallingPackage;
- }
-
- public void setDataRestrictedByCallingPackage(boolean flag) {
- mDataRestrictedByCallingPackage = flag;
- }
-
- /**
- * Adds a parameter to the URI that ensures that only unrestricted data
- * is included in the list, if {@link #isDataRestrictedByCallingPackage()} is true.
- */
- protected Uri applyDataRestriction(Uri uri) {
- if (!mDataRestrictedByCallingPackage) {
- return uri;
- }
-
- return applyDataRestriction(uri.buildUpon()).build();
- }
-
- /**
- * See {@link #applyDataRestriction(Uri)}.
- */
- protected Uri.Builder applyDataRestriction(Uri.Builder builder) {
- if (!mDataRestrictedByCallingPackage) {
- return builder;
- }
-
- String callingPackage = ((Activity)getContext()).getCallingPackage();
- if (!TextUtils.isEmpty(callingPackage)) {
- return builder.appendQueryParameter(
- ContactsContract.REQUESTING_PACKAGE_PARAM_KEY, callingPackage);
- }
-
- return builder;
- }
-
public void configureDirectoryLoader(DirectoryListLoader loader) {
loader.setDirectorySearchMode(mDirectorySearchMode);
loader.setLocalInvisibleDirectoryEnabled(LOCAL_INVISIBLE_DIRECTORY_ENABLED);
diff --git a/src/com/android/contacts/list/ContactPickerFragment.java b/src/com/android/contacts/list/ContactPickerFragment.java
index 6bfca57..5d0f692 100644
--- a/src/com/android/contacts/list/ContactPickerFragment.java
+++ b/src/com/android/contacts/list/ContactPickerFragment.java
@@ -170,7 +170,6 @@
super.configureAdapter();
ContactEntryListAdapter adapter = getAdapter();
- adapter.setDataRestrictedByCallingPackage(true);
// If "Create new contact" is shown, don't display the empty list UI
adapter.setEmptyListEnabled(!isCreateContactEnabled());
diff --git a/src/com/android/contacts/list/ContactTileAdapter.java b/src/com/android/contacts/list/ContactTileAdapter.java
index 5d5e6cb..20c639e 100644
--- a/src/com/android/contacts/list/ContactTileAdapter.java
+++ b/src/com/android/contacts/list/ContactTileAdapter.java
@@ -65,6 +65,7 @@
private int mPhotoUriIndex;
private int mNameIndex;
private int mStarredIndex;
+ private boolean mIsQuickContact = false;
/**
* Configures the adapter to filter and display contacts using different view types.
@@ -72,27 +73,23 @@
*/
public enum DisplayType {
/**
- * Displays a mixed view type where Starred Contacts
- * are in a regular {@link ContactTileView} layout and
- * frequent contacts are in a small {@link ContactTileView} layout.
+ * Displays a mixed view type of starred and frequent contacts
*/
STREQUENT,
/**
- * Display only starred contacts in
- * regular {@link ContactTileView} layout.
+ * Display only starred contacts
*/
STARRED_ONLY,
/**
- * Display only most frequently contacted in a
- * single {@link ContactTileView} layout.
+ * Display only most frequently contacted
*/
FREQUENT_ONLY,
/**
- * Display all contacts from a group in the cursor in a
- * regular {@link ContactTileView} layout. Use {@link GroupMemberLoader}
+ * Display all contacts from a group in the cursor
+ * Use {@link GroupMemberLoader}
* when passing {@link Cursor} into loadFromCusor method.
*/
GROUP_MEMBERS
@@ -120,6 +117,10 @@
mDisplayType = displayType;
}
+ public void setQuickContact(boolean enableQuickContact) {
+ mIsQuickContact = enableQuickContact;
+ }
+
/**
* Sets the column indices for expected {@link Cursor}
* based on {@link DisplayType}.
@@ -292,7 +293,7 @@
int columnCount = -1;
switch (itemViewType) {
- case ViewTypes.SQUARE:
+ case ViewTypes.STARRED:
if (contactTileRowView == null) {
// Creating new row if needed
contactTileRowView = new ContactTileRow(mContext, layoutResId, true);
@@ -300,7 +301,7 @@
columnCount = mColumnCount;
break;
- case ViewTypes.SINGLE_ROW:
+ case ViewTypes.FREQUENT:
if (contactTileRowView == null) {
// Creating new row if needed
contactTileRowView = new ContactTileRow(mContext, layoutResId, false);
@@ -327,10 +328,14 @@
private int getLayoutResourceId(int viewType) {
switch (viewType) {
- case ViewTypes.SQUARE:
- return R.layout.contact_tile_square;
- case ViewTypes.SINGLE_ROW:
- return R.layout.contact_tile_single;
+ case ViewTypes.STARRED:
+ if (mIsQuickContact) {
+ return R.layout.contact_tile_starred_quick_contact;
+ } else {
+ return R.layout.contact_tile_starred;
+ }
+ case ViewTypes.FREQUENT:
+ return R.layout.contact_tile_frequent;
default:
throw new IllegalArgumentException("Received unrecognized viewType " + viewType);
}
@@ -343,8 +348,8 @@
/**
* Returns view type based on {@link DisplayType}.
* {@link DisplayType#STARRED_ONLY} and {@link DisplayType#GROUP_MEMBERS}
- * are {@link ViewTypes#SQUARE}.
- * {@link DisplayType#FREQUENT_ONLY} is {@link ViewTypes#SINGLE_ROW}.
+ * are {@link ViewTypes#STARRED}.
+ * {@link DisplayType#FREQUENT_ONLY} is {@link ViewTypes#FREQUENT}.
* {@link DisplayType#STREQUENT} mixes both {@link ViewTypes}
* and also adds in {@link ViewTypes#DIVIDER}.
*/
@@ -353,17 +358,17 @@
switch (mDisplayType) {
case STREQUENT:
if (position < mDividerRowIndex) {
- return ViewTypes.SQUARE;
+ return ViewTypes.STARRED;
} else if (position == mDividerRowIndex) {
return ViewTypes.DIVIDER;
} else {
- return ViewTypes.SINGLE_ROW;
+ return ViewTypes.FREQUENT;
}
case STARRED_ONLY:
case GROUP_MEMBERS:
- return ViewTypes.SQUARE;
+ return ViewTypes.STARRED;
case FREQUENT_ONLY:
- return ViewTypes.SINGLE_ROW;
+ return ViewTypes.FREQUENT;
default:
throw new IllegalStateException(
"Received unrecognized DisplayType " + mDisplayType);
@@ -400,7 +405,7 @@
if (getChildCount() <= tileIndex) {
if (mIsContactTileSquare) {
- contactTile = (ContactTileSquareView) inflate(mContext, mLayoutResId, null);
+ contactTile = (ContactTileStarredView) inflate(mContext, mLayoutResId, null);
} else {
contactTile = (ContactTileView) inflate(mContext, mLayoutResId, null);
}
@@ -433,9 +438,9 @@
private static class ViewTypes {
public static final int COUNT = 3;
- public static final int SQUARE = 0;
+ public static final int STARRED = 0;
public static final int DIVIDER = 1;
- public static final int SINGLE_ROW = 2;
+ public static final int FREQUENT = 2;
}
public interface Listener {
diff --git a/src/com/android/contacts/list/ContactTileSquareView.java b/src/com/android/contacts/list/ContactTileStarredView.java
similarity index 80%
rename from src/com/android/contacts/list/ContactTileSquareView.java
rename to src/com/android/contacts/list/ContactTileStarredView.java
index 7716481..3c0ba42 100644
--- a/src/com/android/contacts/list/ContactTileSquareView.java
+++ b/src/com/android/contacts/list/ContactTileStarredView.java
@@ -19,13 +19,13 @@
import android.util.AttributeSet;
/**
- * A ContactTileSquare displays the contact's picture overlayed with their name
+ * A {@link ContactTileStarredView} displays the contact's picture overlayed with their name
* in a perfect square.
*/
-public class ContactTileSquareView extends ContactTileView {
- private final static String TAG = ContactTileSquareView.class.getSimpleName();
+public class ContactTileStarredView extends ContactTileView {
+ private final static String TAG = ContactTileStarredView.class.getSimpleName();
- public ContactTileSquareView(Context context, AttributeSet attrs) {
+ public ContactTileStarredView(Context context, AttributeSet attrs) {
super(context, attrs);
}
diff --git a/src/com/android/contacts/list/ContactTileView.java b/src/com/android/contacts/list/ContactTileView.java
index ad711cf..279dc93 100644
--- a/src/com/android/contacts/list/ContactTileView.java
+++ b/src/com/android/contacts/list/ContactTileView.java
@@ -26,6 +26,7 @@
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
+import android.widget.QuickContactBadge;
import android.widget.TextView;
/**
@@ -36,6 +37,7 @@
private Uri mLookupUri;
private ImageView mPhoto;
+ private QuickContactBadge mQuickContact;
private TextView mName;
private ContactPhotoManager mPhotoManager = null;
@@ -47,6 +49,8 @@
protected void onFinishInflate() {
super.onFinishInflate();
mName = (TextView) findViewById(R.id.contact_tile_name);
+
+ mQuickContact = (QuickContactBadge) findViewById(R.id.contact_tile_quick);
mPhoto = (ImageView) findViewById(R.id.contact_tile_image);
}
@@ -62,11 +66,23 @@
if (entry != null) {
mName.setText(entry.name);
mLookupUri = entry.lookupKey;
- mPhoto.setImageBitmap(null);
+
+ if (mQuickContact != null) {
+ mQuickContact.assignContactUri(mLookupUri);
+ mQuickContact.setImageBitmap(null);
+ } else {
+ mPhoto.setImageBitmap(null);
+ }
+
setVisibility(View.VISIBLE);
if (mPhotoManager != null) {
- mPhotoManager.loadPhoto(mPhoto, entry.photoUri);
+ if (mQuickContact != null){
+ mPhotoManager.loadPhoto(mQuickContact, entry.photoUri);
+ } else {
+ mPhotoManager.loadPhoto(mPhoto, entry.photoUri);
+ }
+
} else {
Log.w(TAG, "contactPhotoManager not set");
}
diff --git a/src/com/android/contacts/list/DefaultContactListAdapter.java b/src/com/android/contacts/list/DefaultContactListAdapter.java
index 7f96906..30ba3b0 100644
--- a/src/com/android/contacts/list/DefaultContactListAdapter.java
+++ b/src/com/android/contacts/list/DefaultContactListAdapter.java
@@ -82,7 +82,6 @@
}
builder.appendQueryParameter(SearchSnippetColumns.SNIPPET_ARGS_PARAM_KEY,
SNIPPET_ARGS);
- applyDataRestriction(builder);
loader.setUri(builder.build());
loader.setProjection(FILTER_PROJECTION);
}
@@ -129,7 +128,6 @@
ContactsContract.DIRECTORY_PARAM_KEY, String.valueOf(Directory.DEFAULT))
.build();
}
- uri = applyDataRestriction(uri);
// Include the user's personal profile.
if (shouldIncludeProfile()) {
diff --git a/src/com/android/contacts/list/EmailAddressListAdapter.java b/src/com/android/contacts/list/EmailAddressListAdapter.java
index eae02b5..e1c8ea2 100644
--- a/src/com/android/contacts/list/EmailAddressListAdapter.java
+++ b/src/com/android/contacts/list/EmailAddressListAdapter.java
@@ -22,10 +22,9 @@
import android.net.Uri;
import android.net.Uri.Builder;
import android.provider.ContactsContract;
+import android.provider.ContactsContract.CommonDataKinds.Email;
import android.provider.ContactsContract.ContactCounts;
import android.provider.ContactsContract.Data;
-import android.provider.ContactsContract.CommonDataKinds.Email;
-import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
@@ -75,7 +74,6 @@
}
builder.appendQueryParameter(ContactsContract.DIRECTORY_PARAM_KEY,
String.valueOf(directoryId));
- applyDataRestriction(builder);
loader.setUri(builder.build());
loader.setProjection(EMAILS_PROJECTION);
diff --git a/src/com/android/contacts/list/PhoneNumberListAdapter.java b/src/com/android/contacts/list/PhoneNumberListAdapter.java
index aabeebc..21a7846 100644
--- a/src/com/android/contacts/list/PhoneNumberListAdapter.java
+++ b/src/com/android/contacts/list/PhoneNumberListAdapter.java
@@ -90,7 +90,6 @@
builder.appendQueryParameter(ContactsContract.DIRECTORY_PARAM_KEY,
String.valueOf(directoryId));
- applyDataRestriction(builder);
uri = builder.build();
// TODO a projection that includes the search snippet
loader.setProjection(PHONES_PROJECTION);
@@ -101,7 +100,6 @@
if (isSectionHeaderDisplayEnabled()) {
uri = buildSectionIndexerUri(uri);
}
- uri = applyDataRestriction(uri);
loader.setProjection(PHONES_PROJECTION);
}
diff --git a/src/com/android/contacts/list/PostalAddressListAdapter.java b/src/com/android/contacts/list/PostalAddressListAdapter.java
index 86d465a..5642045 100644
--- a/src/com/android/contacts/list/PostalAddressListAdapter.java
+++ b/src/com/android/contacts/list/PostalAddressListAdapter.java
@@ -63,7 +63,6 @@
@Override
public void configureLoader(CursorLoader loader, long directoryId) {
Uri uri = buildSectionIndexerUri(StructuredPostal.CONTENT_URI);
- uri = applyDataRestriction(uri);
loader.setUri(uri);
loader.setProjection(POSTALS_PROJECTION);
diff --git a/src/com/android/contacts/list/StrequentContactListFragment.java b/src/com/android/contacts/list/StrequentContactListFragment.java
index 18edaea..00b3072 100644
--- a/src/com/android/contacts/list/StrequentContactListFragment.java
+++ b/src/com/android/contacts/list/StrequentContactListFragment.java
@@ -85,6 +85,10 @@
mAdapter.setDisplayType(displayType);
}
+ public void setQuickContact(boolean enableQuickContact) {
+ mAdapter.setQuickContact(enableQuickContact);
+ }
+
/**
* The listener for the strequent meta data loader.
*/
diff --git a/tests/src/com/android/contacts/ContactLoaderTest.java b/tests/src/com/android/contacts/ContactLoaderTest.java
index 0e0e2b0..d923bfa 100644
--- a/tests/src/com/android/contacts/ContactLoaderTest.java
+++ b/tests/src/com/android/contacts/ContactLoaderTest.java
@@ -279,8 +279,7 @@
RawContacts.ACCOUNT_NAME, RawContacts.ACCOUNT_TYPE, RawContacts.DIRTY,
RawContacts.VERSION, RawContacts.SOURCE_ID, RawContacts.SYNC1,
RawContacts.SYNC2, RawContacts.SYNC3, RawContacts.SYNC4,
- RawContacts.DELETED, RawContacts.IS_RESTRICTED,
- RawContacts.NAME_VERIFIED,
+ RawContacts.DELETED, RawContacts.NAME_VERIFIED,
Contacts.Entity.DATA_ID,
diff --git a/tests/src/com/android/contacts/PhoneCallDetailsHelperTest.java b/tests/src/com/android/contacts/PhoneCallDetailsHelperTest.java
index 8b8baae..353c2ec 100644
--- a/tests/src/com/android/contacts/PhoneCallDetailsHelperTest.java
+++ b/tests/src/com/android/contacts/PhoneCallDetailsHelperTest.java
@@ -131,16 +131,16 @@
}
public void testSetPhoneCallDetails_CallTypeIcons() {
- setPhoneCallDetailsWithCallType(Calls.INCOMING_TYPE, true);
+ setPhoneCallDetailsWithCallTypeIcons(Calls.INCOMING_TYPE);
assertCallTypeIconsEquals(TEST_INCOMING_DRAWABLE);
- setPhoneCallDetailsWithCallType(Calls.OUTGOING_TYPE, true);
+ setPhoneCallDetailsWithCallTypeIcons(Calls.OUTGOING_TYPE);
assertCallTypeIconsEquals(TEST_OUTGOING_DRAWABLE);
- setPhoneCallDetailsWithCallType(Calls.MISSED_TYPE, true);
+ setPhoneCallDetailsWithCallTypeIcons(Calls.MISSED_TYPE);
assertCallTypeIconsEquals(TEST_MISSED_DRAWABLE);
- setPhoneCallDetailsWithCallType(Calls.VOICEMAIL_TYPE, true);
+ setPhoneCallDetailsWithCallTypeIcons(Calls.VOICEMAIL_TYPE);
assertCallTypeIconsEquals(TEST_VOICEMAIL_DRAWABLE);
}
@@ -148,16 +148,16 @@
LocaleTestUtils localeTestUtils = new LocaleTestUtils(getContext());
localeTestUtils.setLocale(Locale.US);
try {
- setPhoneCallDetailsWithCallType(Calls.INCOMING_TYPE, false);
+ setPhoneCallDetailsWithCallTypeText(Calls.INCOMING_TYPE);
assertCallTypeTextEquals("Incoming call");
- setPhoneCallDetailsWithCallType(Calls.OUTGOING_TYPE, false);
+ setPhoneCallDetailsWithCallTypeText(Calls.OUTGOING_TYPE);
assertCallTypeTextEquals("Outgoing call");
- setPhoneCallDetailsWithCallType(Calls.MISSED_TYPE, false);
+ setPhoneCallDetailsWithCallTypeText(Calls.MISSED_TYPE);
assertCallTypeTextEquals("Missed call");
- setPhoneCallDetailsWithCallType(Calls.VOICEMAIL_TYPE, false);
+ setPhoneCallDetailsWithCallTypeText(Calls.VOICEMAIL_TYPE);
assertCallTypeTextEquals("Voicemail");
} finally {
localeTestUtils.restoreLocale();
@@ -203,21 +203,32 @@
/** Sets the phone call details with default values and the given number. */
private void setPhoneCallDetailsWithNumber(String number, String formattedNumber) {
mHelper.setPhoneCallDetails(mViews,
- new PhoneCallDetails(number, formattedNumber, Calls.INCOMING_TYPE, TEST_DATE),
+ new PhoneCallDetails(number, formattedNumber, new int[]{ Calls.INCOMING_TYPE },
+ TEST_DATE),
false);
}
/** Sets the phone call details with default values and the given date. */
private void setPhoneCallDetailsWithDate(long date) {
mHelper.setPhoneCallDetails(mViews,
- new PhoneCallDetails(TEST_NUMBER, TEST_FORMATTED_NUMBER, Calls.INCOMING_TYPE, date),
+ new PhoneCallDetails(TEST_NUMBER, TEST_FORMATTED_NUMBER,
+ new int[]{ Calls.INCOMING_TYPE }, date),
false);
}
- /** Sets the phone call details with default values and the given call type. */
- private void setPhoneCallDetailsWithCallType(int callType, boolean useIcons) {
+ /** Sets the phone call details with default values and the given call types using icons. */
+ private void setPhoneCallDetailsWithCallTypeIcons(int... callTypes) {
+ setPhoneCallDetailsWithCallTypes(true, callTypes);
+ }
+
+ /** Sets the phone call details with default values and the given call types using text. */
+ private void setPhoneCallDetailsWithCallTypeText(int... callTypes) {
+ setPhoneCallDetailsWithCallTypes(false, callTypes);
+ }
+
+ private void setPhoneCallDetailsWithCallTypes(boolean useIcons, int... callTypes) {
mHelper.setPhoneCallDetails(mViews,
- new PhoneCallDetails(TEST_NUMBER, TEST_FORMATTED_NUMBER, callType, TEST_DATE),
+ new PhoneCallDetails(TEST_NUMBER, TEST_FORMATTED_NUMBER, callTypes, TEST_DATE),
useIcons);
}
}
diff --git a/tests/src/com/android/contacts/calllog/CallLogListItemHelperTest.java b/tests/src/com/android/contacts/calllog/CallLogListItemHelperTest.java
index 2665c13..a8714b4 100644
--- a/tests/src/com/android/contacts/calllog/CallLogListItemHelperTest.java
+++ b/tests/src/com/android/contacts/calllog/CallLogListItemHelperTest.java
@@ -86,35 +86,35 @@
super.tearDown();
}
- public void testSetContactNumberOnly() {
+ public void testSetPhoneCallDetails() {
setPhoneCallDetailsWithNumber("12125551234", "1-212-555-1234");
assertEquals(View.VISIBLE, mViews.callView.getVisibility());
assertEquals(TEST_CALL_DRAWABLE, mViews.callView.getDrawable());
}
- public void testSetContactNumberOnly_Unknown() {
+ public void testSetPhoneCallDetails_Unknown() {
setPhoneCallDetailsWithNumber(CallerInfo.UNKNOWN_NUMBER, CallerInfo.UNKNOWN_NUMBER);
assertEquals(View.INVISIBLE, mViews.callView.getVisibility());
}
- public void testSetContactNumberOnly_Private() {
+ public void testSetPhoneCallDetails_Private() {
setPhoneCallDetailsWithNumber(CallerInfo.PRIVATE_NUMBER, CallerInfo.PRIVATE_NUMBER);
assertEquals(View.INVISIBLE, mViews.callView.getVisibility());
}
- public void testSetContactNumberOnly_Payphone() {
+ public void testSetPhoneCallDetails_Payphone() {
setPhoneCallDetailsWithNumber(CallerInfo.PAYPHONE_NUMBER, CallerInfo.PAYPHONE_NUMBER);
assertEquals(View.INVISIBLE, mViews.callView.getVisibility());
}
- public void testSetContactNumberOnly_VoicemailNumber() {
+ public void testSetPhoneCallDetails_VoicemailNumber() {
setPhoneCallDetailsWithNumber(TEST_VOICEMAIL_NUMBER, TEST_VOICEMAIL_NUMBER);
assertEquals(View.VISIBLE, mViews.callView.getVisibility());
assertEquals(TEST_CALL_DRAWABLE, mViews.callView.getDrawable());
}
- public void testSetContactNumberOnly_Voicemail() {
- setPhoneCallDetailsWithType(Calls.VOICEMAIL_TYPE);
+ public void testSetPhoneCallDetails_Voicemail() {
+ setPhoneCallDetailsWithTypes(Calls.VOICEMAIL_TYPE);
assertEquals(View.VISIBLE, mViews.callView.getVisibility());
assertEquals(TEST_PLAY_DRAWABLE, mViews.callView.getDrawable());
}
@@ -122,13 +122,14 @@
/** Sets the details of a phone call using the specified phone number. */
private void setPhoneCallDetailsWithNumber(String number, String formattedNumber) {
mHelper.setPhoneCallDetails(mViews,
- new PhoneCallDetails(number, formattedNumber, Calls.INCOMING_TYPE, TEST_DATE),
+ new PhoneCallDetails(number, formattedNumber, new int[]{ Calls.INCOMING_TYPE },
+ TEST_DATE),
true);
}
/** Sets the details of a phone call using the specified call type. */
- private void setPhoneCallDetailsWithType(int type) {
+ private void setPhoneCallDetailsWithTypes(int... types) {
mHelper.setPhoneCallDetails(mViews,
- new PhoneCallDetails(TEST_NUMBER, TEST_FORMATTED_NUMBER, type, TEST_DATE), true);
+ new PhoneCallDetails(TEST_NUMBER, TEST_FORMATTED_NUMBER, types, TEST_DATE), true);
}
}