Merge "Restart default directory loader after yenta search deletes" into ub-contactsdialer-i-dev
diff --git a/res/layout/contact_tile_frequent.xml b/res/layout/contact_tile_frequent.xml
deleted file mode 100644
index 6fd38fc..0000000
--- a/res/layout/contact_tile_frequent.xml
+++ /dev/null
@@ -1,51 +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.ContactTileFrequentView"
- android:focusable="true"
- android:background="?android:attr/selectableItemBackground">
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:gravity="center_vertical"
- android:paddingTop="?list_item_padding_top"
- android:paddingBottom="?list_item_padding_bottom">
-
- <com.android.contacts.widget.LayoutSuppressingImageView
- android:id="@+id/contact_tile_image"
- android:layout_width="?list_item_photo_size"
- android:layout_height="?list_item_photo_size"
- android:scaleType="centerCrop"
- android:layout_marginEnd="?list_item_gap_between_image_and_text"/>
-
- <TextView
- android:id="@+id/contact_tile_name"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:textColor="@android:color/black"
- android:textSize="@dimen/contact_browser_list_item_text_size"
- android:singleLine="true"
- android:fadingEdge="horizontal"
- android:fadingEdgeLength="3dip"
- android:ellipsize="marquee"
- android:textAlignment="viewStart" />
-
- </LinearLayout>
-
-</view>
diff --git a/res/layout/contact_tile_frequent_phone.xml b/res/layout/contact_tile_frequent_phone.xml
deleted file mode 100644
index 8fcdd31..0000000
--- a/res/layout/contact_tile_frequent_phone.xml
+++ /dev/null
@@ -1,106 +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.
--->
-
-<!-- Layout parameters are set programmatically. -->
-<view
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/contact_tile_frequent_phone"
- class="com.android.contacts.list.ContactTilePhoneFrequentView"
- android:focusable="true"
- android:background="?android:attr/selectableItemBackground"
- android:nextFocusLeft="@+id/contact_tile_quick">
-
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
-
- <com.android.contacts.widget.LayoutSuppressingQuickContactBadge
- android:id="@id/contact_tile_quick"
- android:layout_width="64dip"
- android:layout_height="64dip"
- android:layout_alignParentLeft="true"
- android:layout_alignParentStart="true"
- android:nextFocusRight="@id/contact_tile_frequent_phone"
- android:scaleType="centerCrop"
- android:focusable="true" />
-
- <TextView
- android:id="@+id/contact_tile_name"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginLeft="8dip"
- android:layout_marginStart="8dip"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:layout_marginTop="8dip"
- android:layout_toRightOf="@id/contact_tile_quick"
- android:layout_toEndOf="@id/contact_tile_quick"
- android:singleLine="true"
- android:fadingEdge="horizontal"
- android:fadingEdgeLength="3dip"
- android:ellipsize="marquee"
- android:textAlignment="viewStart" />
-
- <LinearLayout
- android:orientation="horizontal"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_below="@id/contact_tile_name"
- android:layout_toRightOf="@id/contact_tile_quick"
- android:layout_toEndOf="@id/contact_tile_quick"
- android:gravity="center_vertical">
-
- <TextView
- android:id="@+id/contact_tile_phone_number"
- android:layout_width="0dip"
- android:layout_height="wrap_content"
- android:layout_weight="?attr/list_item_data_width_weight"
- android:textSize="14sp"
- android:ellipsize="marquee"
- android:textColor="@color/dialtacts_secondary_text_color"
- android:layout_marginLeft="8dip"
- android:layout_marginStart="8dip"
- android:singleLine="true"
- android:layout_gravity="bottom"
- android:textDirection="ltr"
- android:textAlignment="viewStart" />
-
- <TextView
- android:id="@+id/contact_tile_phone_type"
- android:layout_width="0dip"
- android:layout_height="wrap_content"
- android:layout_weight="?attr/list_item_label_width_weight"
- android:textSize="12sp"
- android:ellipsize="marquee"
- android:singleLine="true"
- android:textAllCaps="true"
- android:textColor="@color/dialtacts_secondary_text_color"
- android:layout_marginLeft="8dip"
- android:layout_marginStart="8dip"
- android:gravity="end"
- android:layout_gravity="bottom" />
-
- </LinearLayout>
-
- <View
- android:id="@+id/contact_tile_horizontal_divider"
- android:layout_width="match_parent"
- android:layout_height="1px"
- android:background="?android:attr/listDivider"
- android:layout_below="@id/contact_tile_quick" />
-
- </RelativeLayout>
-
-</view>
diff --git a/res/layout/contact_tile_starred.xml b/res/layout/contact_tile_starred.xml
deleted file mode 100644
index 10716cb..0000000
--- a/res/layout/contact_tile_starred.xml
+++ /dev/null
@@ -1,54 +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"
- xmlns:ex="http://schemas.android.com/apk/res-auto"
- class="com.android.contacts.list.ContactTileStarredView"
- android:focusable="true"
- android:background="?android:attr/selectableItemBackground">
-
- <LinearLayout
- android:id="@+id/contact_tile_push_state"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"
- android:paddingTop="24dp">
- <view
- android:id="@+id/contact_tile_container"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- ex:direction="widthToHeight"
- ex:ratio="1.0"
- class="com.android.contacts.widget.ProportionalLayout" >
- <ImageView
- android:id="@+id/contact_tile_image"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
- </view>
- <TextView
- android:id="@+id/contact_tile_name"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingTop="7dp"
- android:textColor="#202020"
- android:textSize="@dimen/contact_browser_list_item_text_size"
- android:singleLine="true"
- android:fadingEdge="horizontal"
- android:fadingEdgeLength="3dip"
- android:ellipsize="marquee"
- android:textAlignment="center"/>
- </LinearLayout>
-</view>
diff --git a/res/layout/contact_tile_starred_quick_contact.xml b/res/layout/contact_tile_starred_quick_contact.xml
deleted file mode 100644
index 2579034..0000000
--- a/res/layout/contact_tile_starred_quick_contact.xml
+++ /dev/null
@@ -1,82 +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"
- android:paddingBottom="1dip"
- android:paddingRight="1dip"
- android:paddingEnd="1dip"
- android:background="@null"
- class="com.android.contacts.list.ContactTileStarredView" >
-
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
-
- <com.android.contacts.widget.LayoutSuppressingImageView
- android:id="@+id/contact_tile_image"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:scaleType="centerCrop" />
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="@dimen/contact_tile_shadowbox_height"
- android:orientation="vertical"
- android:background="@color/contact_tile_shadow_box_color"
- android:layout_alignParentBottom="true"
- android:gravity="center_vertical"
- android:paddingLeft="8dip"
- android:paddingRight="8dip"
- android:paddingStart="8dip"
- android:paddingEnd="8dip">
-
- <TextView
- android:id="@+id/contact_tile_name"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textColor="@android:color/white"
- android:textSize="16sp"
- android:singleLine="true"
- android:fadingEdge="horizontal"
- android:fadingEdgeLength="3dip"
- android:ellipsize="marquee"
- android:textAlignment="viewStart" />
-
- <TextView
- android:id="@+id/contact_tile_status"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textColor="@color/people_contact_tile_status_color"
- android:singleLine="true"
- android:drawablePadding="4dip"
- android:fadingEdge="horizontal"
- android:fadingEdgeLength="3dip"
- android:layout_marginTop="-3dip"
- android:ellipsize="marquee" />
-
- </LinearLayout>
-
- <QuickContactBadge
- android:id="@+id/contact_tile_quick"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:focusable="true"
- android:background="@null" />
-
- </RelativeLayout>
-
-</view>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 61994da..d5f2da3 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -117,12 +117,6 @@
<!-- Secondary text color in the Phone app -->
<color name="dialtacts_secondary_text_color">#737373</color>
- <!-- Color of the semi-transparent shadow box on contact tiles -->
- <color name="contact_tile_shadow_box_color">#7F000000</color>
-
- <!-- Color of the status message for starred contacts in the People app -->
- <color name="people_contact_tile_status_color">#CCCCCC</color>
-
<color name="shortcut_overlay_text_background">#7f000000</color>
<color name="textColorIconOverlay">#fff</color>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 44f86d9..b33975f 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -257,13 +257,6 @@
<!-- Horizontal whitespace (both padding and margin) before the first tile and after the last tile -->
<dimen name="contact_tile_start_end_whitespace">16dip</dimen>
- <!-- ContactTile Layouts -->
- <!--
- Use sp instead of dip so that the shadowbox heights can all scale uniformly
- when the font size is scaled for accessibility purposes
- -->
- <dimen name="contact_tile_shadowbox_height">48sp</dimen>
-
<!-- For contact filter setting screens -->
<dimen name="contact_filter_left_margin">8dp</dimen>
<dimen name="contact_filter_right_margin">16dip</dimen>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 31c0f6b..a1875ca 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -75,8 +75,6 @@
<item name="list_item_header_text_color">@color/people_app_theme_color</item>
<item name="list_item_header_text_size">14sp</item>
<item name="list_item_header_height">30dip</item>
- <item name="list_item_data_width_weight">5</item>
- <item name="list_item_label_width_weight">3</item>
<item name="list_item_header_text_indent">8dip</item>
<item name="contact_browser_list_padding_left">0dip</item>
<item name="contact_browser_list_padding_right">0dip</item>
@@ -146,8 +144,6 @@
<item name="list_item_header_text_color">@color/people_app_theme_color</item>
<item name="list_item_header_text_size">14sp</item>
<item name="list_item_header_height">30dip</item>
- <item name="list_item_data_width_weight">5</item>
- <item name="list_item_label_width_weight">3</item>
<item name="list_item_header_text_indent">8dip</item>
<item name="contact_browser_list_padding_left">0dip</item>
<item name="contact_browser_list_padding_right">0dip</item>
diff --git a/src/com/android/contacts/list/ContactEntry.java b/src/com/android/contacts/list/ContactEntry.java
deleted file mode 100644
index 18a44ca..0000000
--- a/src/com/android/contacts/list/ContactEntry.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2013 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.
- */
-
-package com.android.contacts.list;
-
-import android.graphics.drawable.Drawable;
-import android.net.Uri;
-import android.provider.ContactsContract.PinnedPositions;
-import android.text.TextUtils;
-
-import com.android.contacts.preference.ContactsPreferences;
-
-/**
- * Class to hold contact information
- */
-public class ContactEntry {
-
- private static final int UNSET_DISPLAY_ORDER_PREFERENCE = -1;
-
- /**
- * Primary name for a Contact
- */
- public String namePrimary;
- /**
- * Alternative name for a Contact, e.g. last name first
- */
- public String nameAlternative;
- /**
- * The user's preference on name display order, last name first or first time first.
- * {@see ContactsPreferences}
- */
- public int nameDisplayOrder = UNSET_DISPLAY_ORDER_PREFERENCE;
-
- public String status;
- public String phoneLabel;
- public String phoneNumber;
- public Uri photoUri;
- public Uri lookupUri;
- public String lookupKey;
- public Drawable presenceIcon;
- public long id;
- public int pinned = PinnedPositions.UNPINNED;
- public boolean isFavorite = false;
- public boolean isDefaultNumber = false;
-
- public static final ContactEntry BLANK_ENTRY = new ContactEntry();
-
- public String getPreferredDisplayName() {
- if (nameDisplayOrder == UNSET_DISPLAY_ORDER_PREFERENCE
- || nameDisplayOrder == ContactsPreferences.DISPLAY_ORDER_PRIMARY
- || TextUtils.isEmpty(nameAlternative)) {
- return namePrimary;
- }
- return nameAlternative;
- }
-}
\ No newline at end of file
diff --git a/src/com/android/contacts/list/ContactTileAdapter.java b/src/com/android/contacts/list/ContactTileAdapter.java
deleted file mode 100644
index c184e38..0000000
--- a/src/com/android/contacts/list/ContactTileAdapter.java
+++ /dev/null
@@ -1,632 +0,0 @@
-/*
- * 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.
- */
-package com.android.contacts.list;
-
-import android.content.ContentUris;
-import android.content.Context;
-import android.content.res.Resources;
-import android.database.Cursor;
-import android.graphics.drawable.Drawable;
-import android.net.Uri;
-import android.provider.ContactsContract.Contacts;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.BaseAdapter;
-import android.widget.FrameLayout;
-import android.widget.TextView;
-
-import com.android.contacts.ContactPhotoManager;
-import com.android.contacts.ContactPresenceIconUtil;
-import com.android.contacts.ContactStatusUtil;
-import com.android.contacts.ContactTileLoaderFactory;
-import com.android.contacts.MoreContactUtils;
-import com.android.contacts.R;
-import com.android.contacts.util.ViewUtil;
-
-import java.util.ArrayList;
-
-/**
- * Arranges contacts favorites according to provided {@link DisplayType}.
- * Also allows for a configurable number of columns and {@link DisplayType}
- */
-public class ContactTileAdapter extends BaseAdapter {
- private static final String TAG = ContactTileAdapter.class.getSimpleName();
-
- private DisplayType mDisplayType;
- private ContactTileView.Listener mListener;
- private Context mContext;
- private Resources mResources;
- protected Cursor mContactCursor = null;
- private ContactPhotoManager mPhotoManager;
- protected int mNumFrequents;
-
- /**
- * Index of the first NON starred contact in the {@link Cursor}
- * Only valid when {@link DisplayType#STREQUENT} is true
- */
- private int mDividerPosition;
- protected int mColumnCount;
- private int mStarredIndex;
-
- protected int mIdIndex;
- protected int mLookupIndex;
- protected int mPhotoUriIndex;
- protected int mNameIndex;
- protected int mPresenceIndex;
- protected int mStatusIndex;
-
- private boolean mIsQuickContactEnabled = false;
- private final int mPaddingInPixels;
- private final int mWhitespaceStartEnd;
-
- /**
- * Configures the adapter to filter and display contacts using different view types.
- * TODO: Create Uris to support getting Starred_only and Frequent_only cursors.
- */
- public enum DisplayType {
- /**
- * Displays a mixed view type of starred and frequent contacts
- */
- STREQUENT,
-
- /**
- * Display only starred contacts
- */
- STARRED_ONLY,
-
- /**
- * Display only most frequently contacted
- */
- FREQUENT_ONLY,
-
- /**
- * Display all contacts from a group in the cursor
- */
- GROUP_MEMBERS
- }
-
- public ContactTileAdapter(Context context, ContactTileView.Listener listener, int numCols,
- DisplayType displayType) {
- mListener = listener;
- mContext = context;
- mResources = context.getResources();
- mColumnCount = (displayType == DisplayType.FREQUENT_ONLY ? 1 : numCols);
- mDisplayType = displayType;
- mNumFrequents = 0;
-
- // Converting padding in dips to padding in pixels
- mPaddingInPixels = mContext.getResources()
- .getDimensionPixelSize(R.dimen.contact_tile_divider_padding);
- mWhitespaceStartEnd = mContext.getResources()
- .getDimensionPixelSize(R.dimen.contact_tile_start_end_whitespace);
-
- bindColumnIndices();
- }
-
- public void setPhotoLoader(ContactPhotoManager photoLoader) {
- mPhotoManager = photoLoader;
- }
-
- public void setColumnCount(int columnCount) {
- mColumnCount = columnCount;
- }
-
- public void setDisplayType(DisplayType displayType) {
- mDisplayType = displayType;
- }
-
- public void enableQuickContact(boolean enableQuickContact) {
- mIsQuickContactEnabled = enableQuickContact;
- }
-
- /**
- * Sets the column indices for expected {@link Cursor}
- * based on {@link DisplayType}.
- */
- protected void bindColumnIndices() {
- mIdIndex = ContactTileLoaderFactory.CONTACT_ID;
- mLookupIndex = ContactTileLoaderFactory.LOOKUP_KEY;
- mPhotoUriIndex = ContactTileLoaderFactory.PHOTO_URI;
- mNameIndex = ContactTileLoaderFactory.DISPLAY_NAME;
- mStarredIndex = ContactTileLoaderFactory.STARRED;
- mPresenceIndex = ContactTileLoaderFactory.CONTACT_PRESENCE;
- mStatusIndex = ContactTileLoaderFactory.CONTACT_STATUS;
- }
-
- private static boolean cursorIsValid(Cursor cursor) {
- return cursor != null && !cursor.isClosed();
- }
-
- /**
- * Gets the number of frequents from the passed in cursor.
- *
- * This methods is needed so the GroupMemberTileAdapter can override this.
- *
- * @param cursor The cursor to get number of frequents from.
- */
- protected void saveNumFrequentsFromCursor(Cursor cursor) {
-
- // count the number of frequents
- switch (mDisplayType) {
- case STARRED_ONLY:
- mNumFrequents = 0;
- break;
- case STREQUENT:
- mNumFrequents = cursorIsValid(cursor) ?
- cursor.getCount() - mDividerPosition : 0;
- break;
- case FREQUENT_ONLY:
- mNumFrequents = cursorIsValid(cursor) ? cursor.getCount() : 0;
- break;
- default:
- throw new IllegalArgumentException("Unrecognized DisplayType " + mDisplayType);
- }
- }
-
- /**
- * Creates {@link ContactTileView}s for each item in {@link Cursor}.
- *
- * Else use {@link ContactTileLoaderFactory}
- */
- public void setContactCursor(Cursor cursor) {
- mContactCursor = cursor;
- mDividerPosition = getDividerPosition(cursor);
-
- saveNumFrequentsFromCursor(cursor);
-
- // cause a refresh of any views that rely on this data
- notifyDataSetChanged();
- }
-
- /**
- * Iterates over the {@link Cursor}
- * Returns position of the first NON Starred Contact
- * Returns -1 if {@link DisplayType#STARRED_ONLY}
- * Returns 0 if {@link DisplayType#FREQUENT_ONLY}
- */
- protected int getDividerPosition(Cursor cursor) {
- switch (mDisplayType) {
- case STREQUENT:
- if (!cursorIsValid(cursor)) {
- return 0;
- }
- cursor.moveToPosition(-1);
- while (cursor.moveToNext()) {
- if (cursor.getInt(mStarredIndex) == 0) {
- return cursor.getPosition();
- }
- }
-
- // There are not NON Starred contacts in cursor
- // Set divider positon to end
- return cursor.getCount();
- case STARRED_ONLY:
- // There is no divider
- return -1;
- case FREQUENT_ONLY:
- // Divider is first
- return 0;
- default:
- throw new IllegalStateException("Unrecognized DisplayType " + mDisplayType);
- }
- }
-
- protected ContactEntry createContactEntryFromCursor(Cursor cursor, int position) {
- // If the loader was canceled we will be given a null cursor.
- // In that case, show an empty list of contacts.
- if (!cursorIsValid(cursor) || cursor.getCount() <= position) {
- return null;
- }
-
- cursor.moveToPosition(position);
- long id = cursor.getLong(mIdIndex);
- String photoUri = cursor.getString(mPhotoUriIndex);
- String lookupKey = cursor.getString(mLookupIndex);
-
- ContactEntry contact = new ContactEntry();
- String name = cursor.getString(mNameIndex);
- contact.namePrimary = (name != null) ? name : mResources.getString(R.string.missing_name);
- contact.status = cursor.getString(mStatusIndex);
- contact.photoUri = (photoUri != null ? Uri.parse(photoUri) : null);
- contact.lookupKey = lookupKey;
- contact.lookupUri = ContentUris.withAppendedId(
- Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI, lookupKey), id);
- contact.isFavorite = cursor.getInt(mStarredIndex) > 0;
-
- // Set presence icon and status message
- Drawable icon = null;
- int presence = 0;
- if (!cursor.isNull(mPresenceIndex)) {
- presence = cursor.getInt(mPresenceIndex);
- icon = ContactPresenceIconUtil.getPresenceIcon(mContext, presence);
- }
- contact.presenceIcon = icon;
-
- String statusMessage = null;
- if (mStatusIndex != 0 && !cursor.isNull(mStatusIndex)) {
- statusMessage = cursor.getString(mStatusIndex);
- }
- // If there is no status message from the contact, but there was a presence value,
- // then use the default status message string
- if (statusMessage == null && presence != 0) {
- statusMessage = ContactStatusUtil.getStatusString(mContext, presence);
- }
- contact.status = statusMessage;
-
- return contact;
- }
-
- /**
- * Returns the number of frequents that will be displayed in the list.
- */
- public int getNumFrequents() {
- return mNumFrequents;
- }
-
- @Override
- public int getCount() {
- if (!cursorIsValid(mContactCursor)) {
- return 0;
- }
-
- switch (mDisplayType) {
- case STARRED_ONLY:
- return getRowCount(mContactCursor.getCount());
- case STREQUENT:
- // Takes numbers of rows the Starred Contacts Occupy
- int starredRowCount = getRowCount(mDividerPosition);
-
- // Compute the frequent row count which is 1 plus the number of frequents
- // (to account for the divider) or 0 if there are no frequents.
- int frequentRowCount = mNumFrequents == 0 ? 0 : mNumFrequents + 1;
-
- // Return the number of starred plus frequent rows
- return starredRowCount + frequentRowCount;
- case FREQUENT_ONLY:
- // Number of frequent contacts
- return mContactCursor.getCount();
- default:
- throw new IllegalArgumentException("Unrecognized DisplayType " + mDisplayType);
- }
- }
-
- /**
- * Returns the number of rows required to show the provided number of entries
- * with the current number of columns.
- */
- protected int getRowCount(int entryCount) {
- return entryCount == 0 ? 0 : ((entryCount - 1) / mColumnCount) + 1;
- }
-
- public int getColumnCount() {
- return mColumnCount;
- }
-
- /**
- * Returns an ArrayList of the {@link ContactEntry}s that are to appear
- * on the row for the given position.
- */
- @Override
- public ArrayList<ContactEntry> getItem(int position) {
- ArrayList<ContactEntry> resultList = new ArrayList<ContactEntry>(mColumnCount);
- int contactIndex = position * mColumnCount;
-
- switch (mDisplayType) {
- case FREQUENT_ONLY:
- resultList.add(createContactEntryFromCursor(mContactCursor, position));
- break;
- case STARRED_ONLY:
- for (int columnCounter = 0; columnCounter < mColumnCount; columnCounter++) {
- resultList.add(createContactEntryFromCursor(mContactCursor, contactIndex));
- contactIndex++;
- }
- break;
- case STREQUENT:
- if (position < getRowCount(mDividerPosition)) {
- for (int columnCounter = 0; columnCounter < mColumnCount &&
- contactIndex != mDividerPosition; columnCounter++) {
- resultList.add(createContactEntryFromCursor(mContactCursor, contactIndex));
- contactIndex++;
- }
- } else {
- /*
- * Current position minus how many rows are before the divider and
- * Minus 1 for the divider itself provides the relative index of the frequent
- * contact being displayed. Then add the dividerPostion to give the offset
- * into the contacts cursor to get the absoulte index.
- */
- contactIndex = position - getRowCount(mDividerPosition) - 1 + mDividerPosition;
- resultList.add(createContactEntryFromCursor(mContactCursor, contactIndex));
- }
- break;
- default:
- throw new IllegalStateException("Unrecognized DisplayType " + mDisplayType);
- }
- return resultList;
- }
-
- @Override
- public long getItemId(int position) {
- // As we show several selectable items for each ListView row,
- // we can not determine a stable id. But as we don't rely on ListView's selection,
- // this should not be a problem.
- return position;
- }
-
- @Override
- public boolean areAllItemsEnabled() {
- return (mDisplayType != DisplayType.STREQUENT);
- }
-
- @Override
- public boolean isEnabled(int position) {
- return position != getRowCount(mDividerPosition);
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- int itemViewType = getItemViewType(position);
-
- if (itemViewType == ViewTypes.DIVIDER) {
- // Checking For Divider First so not to cast convertView
- final TextView textView = (TextView) (convertView == null ? getDivider() : convertView);
- setDividerPadding(textView, position == 0);
- return textView;
- }
-
- ContactTileRow contactTileRowView = (ContactTileRow) convertView;
- ArrayList<ContactEntry> contactList = getItem(position);
-
- if (contactTileRowView == null) {
- // Creating new row if needed
- contactTileRowView = new ContactTileRow(mContext, itemViewType);
- }
-
- contactTileRowView.configureRow(contactList, position == getCount() - 1);
- return contactTileRowView;
- }
-
- /**
- * Divider uses a list_seperator.xml along with text to denote
- * the most frequently contacted contacts.
- */
- private TextView getDivider() {
- return MoreContactUtils.createHeaderView(mContext, R.string.favoritesFrequentContacted);
- }
-
- private void setDividerPadding(TextView headerTextView, boolean isFirstRow) {
- MoreContactUtils.setHeaderViewBottomPadding(mContext, headerTextView, isFirstRow);
- }
-
- private int getLayoutResourceId(int viewType) {
- switch (viewType) {
- case ViewTypes.STARRED:
- return mIsQuickContactEnabled ?
- R.layout.contact_tile_starred_quick_contact : R.layout.contact_tile_starred;
- case ViewTypes.FREQUENT:
- return R.layout.contact_tile_frequent;
- default:
- throw new IllegalArgumentException("Unrecognized viewType " + viewType);
- }
- }
- @Override
- public int getViewTypeCount() {
- return ViewTypes.COUNT;
- }
-
- @Override
- public int getItemViewType(int position) {
- /*
- * Returns view type based on {@link DisplayType}.
- * {@link DisplayType#STARRED_ONLY} and {@link DisplayType#GROUP_MEMBERS}
- * 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}.
- */
- switch (mDisplayType) {
- case STREQUENT:
- if (position < getRowCount(mDividerPosition)) {
- return ViewTypes.STARRED;
- } else if (position == getRowCount(mDividerPosition)) {
- return ViewTypes.DIVIDER;
- } else {
- return ViewTypes.FREQUENT;
- }
- case STARRED_ONLY:
- return ViewTypes.STARRED;
- case FREQUENT_ONLY:
- return ViewTypes.FREQUENT;
- default:
- throw new IllegalStateException("Unrecognized DisplayType " + mDisplayType);
- }
- }
-
- /**
- * Returns the "frequent header" position. Only available when STREQUENT or
- * STREQUENT_PHONE_ONLY is used for its display type.
- */
- public int getFrequentHeaderPosition() {
- return getRowCount(mDividerPosition);
- }
-
- /**
- * Acts as a row item composed of {@link ContactTileView}
- *
- * TODO: FREQUENT doesn't really need it. Just let {@link #getView} return
- */
- private class ContactTileRow extends FrameLayout {
- private int mItemViewType;
- private int mLayoutResId;
-
- public ContactTileRow(Context context, int itemViewType) {
- super(context);
- mItemViewType = itemViewType;
- mLayoutResId = getLayoutResourceId(mItemViewType);
-
- // Remove row (but not children) from accessibility node tree.
- setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
- }
-
- /**
- * Configures the row to add {@link ContactEntry}s information to the views
- */
- public void configureRow(ArrayList<ContactEntry> list, boolean isLastRow) {
- int columnCount = mItemViewType == ViewTypes.FREQUENT ? 1 : mColumnCount;
-
- // Adding tiles to row and filling in contact information
- for (int columnCounter = 0; columnCounter < columnCount; columnCounter++) {
- ContactEntry entry =
- columnCounter < list.size() ? list.get(columnCounter) : null;
- addTileFromEntry(entry, columnCounter, isLastRow);
- }
- }
-
- private void addTileFromEntry(ContactEntry entry, int childIndex, boolean isLastRow) {
- final ContactTileView contactTile;
-
- if (getChildCount() <= childIndex) {
- contactTile = (ContactTileView) inflate(mContext, mLayoutResId, null);
- // Note: the layoutparam set here is only actually used for FREQUENT.
- // We override onMeasure() for STARRED and we don't care the layout param there.
- Resources resources = mContext.getResources();
- FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
- ViewGroup.LayoutParams.MATCH_PARENT,
- ViewGroup.LayoutParams.WRAP_CONTENT);
- params.setMargins(
- mWhitespaceStartEnd,
- 0,
- mWhitespaceStartEnd,
- 0);
- contactTile.setLayoutParams(params);
- contactTile.setPhotoManager(mPhotoManager);
- contactTile.setListener(mListener);
- addView(contactTile);
- } else {
- contactTile = (ContactTileView) getChildAt(childIndex);
- }
- contactTile.loadFromContact(entry);
-
- switch (mItemViewType) {
- case ViewTypes.STARRED:
- // Set padding between tiles. Divide mPaddingInPixels between left and right
- // tiles as evenly as possible.
- contactTile.setPaddingRelative(
- (mPaddingInPixels + 1) / 2, 0,
- mPaddingInPixels
- / 2, 0);
- break;
- case ViewTypes.FREQUENT:
- contactTile.setHorizontalDividerVisibility(
- isLastRow ? View.GONE : View.VISIBLE);
- break;
- default:
- break;
- }
- }
-
- @Override
- protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
- switch (mItemViewType) {
- case ViewTypes.STARRED:
- onLayoutForTiles();
- return;
- default:
- super.onLayout(changed, left, top, right, bottom);
- return;
- }
- }
-
- private void onLayoutForTiles() {
- final int count = getChildCount();
-
- // Amount of margin needed on the left is based on difference between offset and padding
- int childLeft = mWhitespaceStartEnd - (mPaddingInPixels + 1) / 2;
-
- // Just line up children horizontally.
- for (int i = 0; i < count; i++) {
- final int rtlAdjustedIndex = ViewUtil.isViewLayoutRtl(this) ? count - i - 1 : i;
- final View child = getChildAt(rtlAdjustedIndex);
-
- // Note MeasuredWidth includes the padding.
- final int childWidth = child.getMeasuredWidth();
- child.layout(childLeft, 0, childLeft + childWidth, child.getMeasuredHeight());
- childLeft += childWidth;
- }
- }
-
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- switch (mItemViewType) {
- case ViewTypes.STARRED:
- onMeasureForTiles(widthMeasureSpec);
- return;
- default:
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
- return;
- }
- }
-
- private void onMeasureForTiles(int widthMeasureSpec) {
- final int width = MeasureSpec.getSize(widthMeasureSpec);
-
- final int childCount = getChildCount();
- if (childCount == 0) {
- // Just in case...
- setMeasuredDimension(width, 0);
- return;
- }
-
- // 1. Calculate image size.
- // = ([total width] - [total whitespace]) / [child count]
- //
- // 2. Set it to width/height of each children.
- // If we have a remainder, some tiles will have 1 pixel larger width than its height.
- //
- // 3. Set the dimensions of itself.
- // Let width = given width.
- // Let height = wrap content.
-
- final int totalWhitespaceInPixels = (mColumnCount - 1) * mPaddingInPixels
- + mWhitespaceStartEnd * 2;
-
- // Preferred width / height for images (excluding the padding).
- // The actual width may be 1 pixel larger than this if we have a remainder.
- final int imageSize = (width - totalWhitespaceInPixels) / mColumnCount;
- final int remainder = width - (imageSize * mColumnCount) - totalWhitespaceInPixels;
-
- for (int i = 0; i < childCount; i++) {
- final View child = getChildAt(i);
- final int childWidth = imageSize + child.getPaddingRight() + child.getPaddingLeft()
- // Compensate for the remainder
- + (i < remainder ? 1 : 0);
-
- child.measure(
- MeasureSpec.makeMeasureSpec(childWidth, MeasureSpec.EXACTLY),
- MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)
- );
- }
- setMeasuredDimension(width, getChildAt(0).getMeasuredHeight());
- }
- }
-
- protected static class ViewTypes {
- public static final int COUNT = 4;
- public static final int STARRED = 0;
- public static final int DIVIDER = 1;
- public static final int FREQUENT = 2;
- }
-}
diff --git a/src/com/android/contacts/list/ContactTileFrequentView.java b/src/com/android/contacts/list/ContactTileFrequentView.java
deleted file mode 100644
index 41a972f..0000000
--- a/src/com/android/contacts/list/ContactTileFrequentView.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-package com.android.contacts.list;
-
-import android.content.Context;
-import android.util.AttributeSet;
-
-import com.android.contacts.util.ViewUtil;
-
-/**
- * A {@link com.android.contacts.list.ContactTileView} that is used for most frequently contacted in the People app
- */
-public class ContactTileFrequentView extends ContactTileView {
- public ContactTileFrequentView(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- @Override
- protected boolean isDarkTheme() {
- return false;
- }
-
- @Override
- protected int getApproximateImageSize() {
- return ViewUtil.getConstantPreLayoutWidth(getPhotoView());
- }
-}
diff --git a/src/com/android/contacts/list/ContactTilePhoneFrequentView.java b/src/com/android/contacts/list/ContactTilePhoneFrequentView.java
deleted file mode 100644
index 048907d..0000000
--- a/src/com/android/contacts/list/ContactTilePhoneFrequentView.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * 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.
- */
-package com.android.contacts.list;
-
-import android.content.Context;
-import android.text.TextUtils;
-import android.util.AttributeSet;
-import android.view.View;
-
-import com.android.contacts.MoreContactUtils;
-import com.android.contacts.util.ViewUtil;
-
-/**
- * A dark version of the {@link com.android.contacts.list.ContactTileView} that is used in Dialtacts
- * for frequently called contacts. Slightly different behavior from superclass...
- * when you tap it, you want to call the frequently-called number for the
- * contact, even if that is not the default number for that contact.
- */
-public class ContactTilePhoneFrequentView extends ContactTileView {
- private String mPhoneNumberString;
-
- public ContactTilePhoneFrequentView(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- @Override
- protected boolean isDarkTheme() {
- return true;
- }
-
- @Override
- protected int getApproximateImageSize() {
- return ViewUtil.getConstantPreLayoutWidth(getQuickContact());
- }
-
- @Override
- public void loadFromContact(ContactEntry entry) {
- super.loadFromContact(entry);
- mPhoneNumberString = null; // ... in case we're reusing the view
- if (entry != null) {
- // Grab the phone-number to call directly... see {@link onClick()}
- mPhoneNumberString = entry.phoneNumber;
- }
- }
-
- @Override
- protected OnClickListener createClickListener() {
- return new OnClickListener() {
- @Override
- public void onClick(View v) {
- if (mListener == null) return;
- if (TextUtils.isEmpty(mPhoneNumberString)) {
- // Copy "superclass" implementation
- mListener.onContactSelected(getLookupUri(), MoreContactUtils
- .getTargetRectFromView(ContactTilePhoneFrequentView.this));
- } else {
- // When you tap a frequently-called contact, you want to
- // call them at the number that you usually talk to them
- // at (i.e. the one displayed in the UI), regardless of
- // whether that's their default number.
- mListener.onCallNumberDirectly(mPhoneNumberString);
- }
- }
- };
- }
-}
diff --git a/src/com/android/contacts/list/ContactTileStarredView.java b/src/com/android/contacts/list/ContactTileStarredView.java
deleted file mode 100644
index 63531ba..0000000
--- a/src/com/android/contacts/list/ContactTileStarredView.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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.
- */
-package com.android.contacts.list;
-
-import android.content.Context;
-import android.util.AttributeSet;
-
-import com.android.contacts.ContactPhotoManager;
-import com.android.contacts.ContactPhotoManager.DefaultImageRequest;
-
-/**
- * A {@link ContactTileStarredView} displays the contact's picture overlayed with their name
- * in a square. The actual dimensions are set by
- * {@link com.android.contacts.list.ContactTileAdapter.ContactTileRow}.
- */
-public class ContactTileStarredView extends ContactTileView {
-
- /**
- * The photo manager should display the default image/letter at 80% of its normal size.
- */
- private static final float DEFAULT_IMAGE_LETTER_SCALE = 0.8f;
-
- public ContactTileStarredView(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- @Override
- protected boolean isDarkTheme() {
- return false;
- }
-
- @Override
- protected int getApproximateImageSize() {
- // The picture is the full size of the tile (minus some padding, but we can be generous)
- return mListener.getApproximateTileWidth();
- }
-
- @Override
- protected DefaultImageRequest getDefaultImageRequest(String displayName, String lookupKey) {
- return new DefaultImageRequest(displayName, lookupKey, ContactPhotoManager.TYPE_DEFAULT,
- DEFAULT_IMAGE_LETTER_SCALE, /* offset = */ 0, /* isCircular = */ true);
- }
-}
diff --git a/src/com/android/contacts/list/ContactTileView.java b/src/com/android/contacts/list/ContactTileView.java
deleted file mode 100644
index 2760dbf..0000000
--- a/src/com/android/contacts/list/ContactTileView.java
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
- * 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.
- */
-package com.android.contacts.list;
-
-import android.content.Context;
-import android.graphics.Rect;
-import android.net.Uri;
-import android.text.TextUtils;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.view.View;
-import android.widget.FrameLayout;
-import android.widget.ImageView;
-import android.widget.QuickContactBadge;
-import android.widget.TextView;
-
-import com.android.contacts.ContactPhotoManager;
-import com.android.contacts.ContactPhotoManager.DefaultImageRequest;
-import com.android.contacts.MoreContactUtils;
-import com.android.contacts.R;
-
-/**
- * A ContactTile displays a contact's picture and name
- */
-public abstract class ContactTileView extends FrameLayout {
- private final static String TAG = ContactTileView.class.getSimpleName();
-
- private Uri mLookupUri;
- private ImageView mPhoto;
- private QuickContactBadge mQuickContact;
- private TextView mName;
- private TextView mStatus;
- private TextView mPhoneLabel;
- private TextView mPhoneNumber;
- private ContactPhotoManager mPhotoManager = null;
- private View mPushState;
- private View mHorizontalDivider;
- protected Listener mListener;
-
- public ContactTileView(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- @Override
- 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);
- mStatus = (TextView) findViewById(R.id.contact_tile_status);
- mPhoneLabel = (TextView) findViewById(R.id.contact_tile_phone_type);
- mPhoneNumber = (TextView) findViewById(R.id.contact_tile_phone_number);
- mPushState = findViewById(R.id.contact_tile_push_state);
- mHorizontalDivider = findViewById(R.id.contact_tile_horizontal_divider);
-
- OnClickListener listener = createClickListener();
- setOnClickListener(listener);
- }
-
- protected OnClickListener createClickListener() {
- return new OnClickListener() {
- @Override
- public void onClick(View v) {
- if (mListener == null) return;
- mListener.onContactSelected(
- getLookupUri(),
- MoreContactUtils.getTargetRectFromView(ContactTileView.this));
- }
- };
- }
-
- public void setPhotoManager(ContactPhotoManager photoManager) {
- mPhotoManager = photoManager;
- }
-
- /**
- * Populates the data members to be displayed from the
- * fields in {@link com.android.contacts.list.ContactEntry}
- */
- public void loadFromContact(ContactEntry entry) {
-
- if (entry != null) {
- mName.setText(getNameForView(entry));
- mLookupUri = entry.lookupUri;
-
- if (mStatus != null) {
- if (entry.status == null) {
- mStatus.setVisibility(View.GONE);
- } else {
- mStatus.setText(entry.status);
- mStatus.setCompoundDrawablesWithIntrinsicBounds(entry.presenceIcon,
- null, null, null);
- mStatus.setVisibility(View.VISIBLE);
- }
- }
-
- if (mPhoneLabel != null) {
- if (TextUtils.isEmpty(entry.phoneLabel)) {
- mPhoneLabel.setVisibility(View.GONE);
- } else {
- mPhoneLabel.setVisibility(View.VISIBLE);
- mPhoneLabel.setText(entry.phoneLabel);
- }
- }
-
- if (mPhoneNumber != null) {
- // TODO: Format number correctly
- mPhoneNumber.setText(entry.phoneNumber);
- }
-
- setVisibility(View.VISIBLE);
-
- if (mPhotoManager != null) {
- DefaultImageRequest request = getDefaultImageRequest(entry.namePrimary,
- entry.lookupKey);
- configureViewForImage(entry.photoUri == null);
- if (mPhoto != null) {
- mPhotoManager.loadPhoto(mPhoto, entry.photoUri, getApproximateImageSize(),
- isDarkTheme(), isContactPhotoCircular(), request);
-
- if (mQuickContact != null) {
- mQuickContact.assignContactUri(mLookupUri);
- }
- } else if (mQuickContact != null) {
- mQuickContact.assignContactUri(mLookupUri);
- mPhotoManager.loadPhoto(mQuickContact, entry.photoUri,
- getApproximateImageSize(), isDarkTheme(), isContactPhotoCircular(),
- request);
- }
- } else {
- Log.w(TAG, "contactPhotoManager not set");
- }
-
- if (mPushState != null) {
- mPushState.setContentDescription(entry.namePrimary);
- } else if (mQuickContact != null) {
- mQuickContact.setContentDescription(entry.namePrimary);
- }
- } else {
- setVisibility(View.INVISIBLE);
- }
- }
-
- public void setListener(Listener listener) {
- mListener = listener;
- }
-
- public void setHorizontalDividerVisibility(int visibility) {
- if (mHorizontalDivider != null) mHorizontalDivider.setVisibility(visibility);
- }
-
- public Uri getLookupUri() {
- return mLookupUri;
- }
-
- protected QuickContactBadge getQuickContact() {
- return mQuickContact;
- }
-
- protected View getPhotoView() {
- return mPhoto;
- }
-
- /**
- * Returns the string that should actually be displayed as the contact's name. Subclasses
- * can override this to return formatted versions of the name - i.e. first name only.
- */
- protected String getNameForView(ContactEntry contactEntry) {
- return contactEntry.namePrimary;
- }
-
- /**
- * Implemented by subclasses to estimate the size of the picture. This can return -1 if only
- * a thumbnail is shown anyway
- */
- protected abstract int getApproximateImageSize();
-
- protected abstract boolean isDarkTheme();
-
- /**
- * Implemented by subclasses to reconfigure the view's layout and subviews, based on whether
- * or not the contact has a user-defined photo.
- *
- * @param isDefaultImage True if the contact does not have a user-defined contact photo
- * (which means a default contact image will be applied by the {@link ContactPhotoManager}
- */
- protected void configureViewForImage(boolean isDefaultImage) {
- // No-op by default.
- }
-
- /**
- * Implemented by subclasses to allow them to return a {@link DefaultImageRequest} with the
- * various image parameters defined to match their own layouts.
- *
- * @param displayName The display name of the contact
- * @param lookupKey The lookup key of the contact
- * @return A {@link DefaultImageRequest} object with each field configured by the subclass
- * as desired, or {@code null}.
- */
- protected DefaultImageRequest getDefaultImageRequest(String displayName, String lookupKey) {
- return new DefaultImageRequest(displayName, lookupKey, isContactPhotoCircular());
- }
-
- /**
- * Whether contact photo should be displayed as a circular image. Implemented by subclasses
- * so they can change which drawables to fetch.
- */
- protected boolean isContactPhotoCircular() {
- return true;
- }
-
- public interface Listener {
- /**
- * Notification that the contact was selected; no specific action is dictated.
- */
- void onContactSelected(Uri contactLookupUri, Rect viewRect);
- /**
- * Notification that the specified number is to be called.
- */
- void onCallNumberDirectly(String phoneNumber);
- /**
- * @return The width of each tile. This doesn't have to be a precise number (e.g. paddings
- * can be ignored), but is used to load the correct picture size from the database
- */
- int getApproximateTileWidth();
- }
-}