163ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng/* 263ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng * Copyright (C) 2011 The Android Open Source Project 363ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng * 463ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng * Licensed under the Apache License, Version 2.0 (the "License"); 563ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng * you may not use this file except in compliance with the License. 663ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng * You may obtain a copy of the License at 763ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng * 863ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng * http://www.apache.org/licenses/LICENSE-2.0 963ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng * 1063ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng * Unless required by applicable law or agreed to in writing, software 1163ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng * distributed under the License is distributed on an "AS IS" BASIS, 1263ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1363ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng * See the License for the specific language governing permissions and 1463ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng * limitations under the License. 1563ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng */ 1663ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Chengpackage com.android.contacts.common.list; 1763ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng 1863ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Chengimport android.content.Context; 1963ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Chengimport android.graphics.Rect; 2063ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Chengimport android.net.Uri; 21dc234559370585e45afa79c0e989ac72b385d20cYorke Leeimport android.text.TextUtils; 2263ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Chengimport android.util.AttributeSet; 2363ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Chengimport android.util.Log; 2463ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Chengimport android.view.View; 2563ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Chengimport android.widget.FrameLayout; 2663ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Chengimport android.widget.ImageView; 2763ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Chengimport android.widget.QuickContactBadge; 2863ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Chengimport android.widget.TextView; 2963ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng 3063ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Chengimport com.android.contacts.common.ContactPhotoManager; 316084726fbdda78bdb16e2d4cc1c3b81c84fd5da1Yorke Leeimport com.android.contacts.common.ContactPhotoManager.DefaultImageRequest; 3263ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Chengimport com.android.contacts.common.MoreContactUtils; 3363ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Chengimport com.android.contacts.common.R; 3463ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng 3563ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng/** 3663ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng * A ContactTile displays a contact's picture and name 3763ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng */ 3863ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Chengpublic abstract class ContactTileView extends FrameLayout { 3963ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng private final static String TAG = ContactTileView.class.getSimpleName(); 4063ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng 4163ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng private Uri mLookupUri; 4263ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng private ImageView mPhoto; 4363ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng private QuickContactBadge mQuickContact; 4463ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng private TextView mName; 4563ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng private TextView mStatus; 4663ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng private TextView mPhoneLabel; 4763ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng private TextView mPhoneNumber; 4863ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng private ContactPhotoManager mPhotoManager = null; 4963ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng private View mPushState; 5063ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng private View mHorizontalDivider; 5163ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng protected Listener mListener; 5263ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng 5363ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng public ContactTileView(Context context, AttributeSet attrs) { 5463ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng super(context, attrs); 5563ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng } 5663ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng 5763ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng @Override 5863ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng protected void onFinishInflate() { 5963ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng super.onFinishInflate(); 6063ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng mName = (TextView) findViewById(R.id.contact_tile_name); 6163ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng 6263ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng mQuickContact = (QuickContactBadge) findViewById(R.id.contact_tile_quick); 6363ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng mPhoto = (ImageView) findViewById(R.id.contact_tile_image); 6463ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng mStatus = (TextView) findViewById(R.id.contact_tile_status); 6563ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng mPhoneLabel = (TextView) findViewById(R.id.contact_tile_phone_type); 6663ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng mPhoneNumber = (TextView) findViewById(R.id.contact_tile_phone_number); 6763ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng mPushState = findViewById(R.id.contact_tile_push_state); 6863ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng mHorizontalDivider = findViewById(R.id.contact_tile_horizontal_divider); 6963ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng 7063ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng OnClickListener listener = createClickListener(); 710706c0d2e41e3c92cf9d04f0c4f0682a4bb0bf1fChristine Chen setOnClickListener(listener); 7263ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng } 7363ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng 7463ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng protected OnClickListener createClickListener() { 7563ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng return new OnClickListener() { 7663ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng @Override 7763ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng public void onClick(View v) { 7863ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng if (mListener == null) return; 7963ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng mListener.onContactSelected( 8063ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng getLookupUri(), 81039b4d46787bd06f2faeaac8c332459c86f3cffeYorke Lee MoreContactUtils.getTargetRectFromView(ContactTileView.this)); 8263ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng } 8363ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng }; 8463ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng } 8563ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng 8663ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng public void setPhotoManager(ContactPhotoManager photoManager) { 8763ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng mPhotoManager = photoManager; 8863ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng } 8963ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng 9063ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng /** 9163ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng * Populates the data members to be displayed from the 929078a0ae8404a1dd7dec44def5a037e4e50e9d77Yorke Lee * fields in {@link com.android.contacts.common.list.ContactEntry} 9363ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng */ 949078a0ae8404a1dd7dec44def5a037e4e50e9d77Yorke Lee public void loadFromContact(ContactEntry entry) { 9563ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng 9663ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng if (entry != null) { 977771c5f33492e6b9af55a49d921cbd909bbc2c90Yorke Lee mName.setText(getNameForView(entry.name)); 986084726fbdda78bdb16e2d4cc1c3b81c84fd5da1Yorke Lee mLookupUri = entry.lookupUri; 9963ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng 10063ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng if (mStatus != null) { 10163ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng if (entry.status == null) { 10263ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng mStatus.setVisibility(View.GONE); 10363ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng } else { 10463ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng mStatus.setText(entry.status); 10563ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng mStatus.setCompoundDrawablesWithIntrinsicBounds(entry.presenceIcon, 10663ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng null, null, null); 10763ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng mStatus.setVisibility(View.VISIBLE); 10863ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng } 10963ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng } 11063ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng 11163ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng if (mPhoneLabel != null) { 112dc234559370585e45afa79c0e989ac72b385d20cYorke Lee if (TextUtils.isEmpty(entry.phoneLabel)) { 113dc234559370585e45afa79c0e989ac72b385d20cYorke Lee mPhoneLabel.setVisibility(View.GONE); 114dc234559370585e45afa79c0e989ac72b385d20cYorke Lee } else { 115dc234559370585e45afa79c0e989ac72b385d20cYorke Lee mPhoneLabel.setVisibility(View.VISIBLE); 116dc234559370585e45afa79c0e989ac72b385d20cYorke Lee mPhoneLabel.setText(entry.phoneLabel); 117dc234559370585e45afa79c0e989ac72b385d20cYorke Lee } 11863ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng } 11963ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng 12063ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng if (mPhoneNumber != null) { 12163ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng // TODO: Format number correctly 12263ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng mPhoneNumber.setText(entry.phoneNumber); 12363ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng } 12463ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng 12563ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng setVisibility(View.VISIBLE); 12663ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng 12763ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng if (mPhotoManager != null) { 1286084726fbdda78bdb16e2d4cc1c3b81c84fd5da1Yorke Lee DefaultImageRequest request = getDefaultImageRequest(entry.name, entry.lookupKey); 129906ffc8a0655f0e78a9b7307e7e76717bfdc6d58Yorke Lee configureViewForImage(entry.photoUri == null); 13063ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng if (mPhoto != null) { 13163ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng mPhotoManager.loadPhoto(mPhoto, entry.photoUri, getApproximateImageSize(), 132395d9d95e25f6fa4b8e750e36ec0a5c1886a65b5Brian Attwell isDarkTheme(), isContactPhotoCircular(), request); 13363ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng 13463ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng if (mQuickContact != null) { 13563ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng mQuickContact.assignContactUri(mLookupUri); 13663ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng } 13763ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng } else if (mQuickContact != null) { 13863ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng mQuickContact.assignContactUri(mLookupUri); 13963ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng mPhotoManager.loadPhoto(mQuickContact, entry.photoUri, 140395d9d95e25f6fa4b8e750e36ec0a5c1886a65b5Brian Attwell getApproximateImageSize(), isDarkTheme(), isContactPhotoCircular(), 1413f9c2f426058413055fa54c08c69ad9461717658Yorke Lee request); 14263ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng } 14363ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng } else { 14463ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng Log.w(TAG, "contactPhotoManager not set"); 14563ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng } 14663ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng 14763ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng if (mPushState != null) { 14863ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng mPushState.setContentDescription(entry.name); 14963ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng } else if (mQuickContact != null) { 15063ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng mQuickContact.setContentDescription(entry.name); 15163ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng } 15263ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng } else { 15363ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng setVisibility(View.INVISIBLE); 15463ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng } 15563ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng } 15663ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng 15763ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng public void setListener(Listener listener) { 15863ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng mListener = listener; 15963ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng } 16063ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng 16163ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng public void setHorizontalDividerVisibility(int visibility) { 16263ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng if (mHorizontalDivider != null) mHorizontalDivider.setVisibility(visibility); 16363ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng } 16463ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng 16563ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng public Uri getLookupUri() { 16663ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng return mLookupUri; 16763ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng } 16863ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng 16963ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng protected QuickContactBadge getQuickContact() { 17063ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng return mQuickContact; 17163ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng } 17263ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng 173440a8fb48d25b4281bd4b00ca5070da59129be14Brian Attwell protected View getPhotoView() { 174440a8fb48d25b4281bd4b00ca5070da59129be14Brian Attwell return mPhoto; 175440a8fb48d25b4281bd4b00ca5070da59129be14Brian Attwell } 176440a8fb48d25b4281bd4b00ca5070da59129be14Brian Attwell 17763ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng /** 1787771c5f33492e6b9af55a49d921cbd909bbc2c90Yorke Lee * Returns the string that should actually be displayed as the contact's name. Subclasses 1797771c5f33492e6b9af55a49d921cbd909bbc2c90Yorke Lee * can override this to return formatted versions of the name - i.e. first name only. 1807771c5f33492e6b9af55a49d921cbd909bbc2c90Yorke Lee */ 1817771c5f33492e6b9af55a49d921cbd909bbc2c90Yorke Lee protected String getNameForView(String name) { 1827771c5f33492e6b9af55a49d921cbd909bbc2c90Yorke Lee return name; 1837771c5f33492e6b9af55a49d921cbd909bbc2c90Yorke Lee } 1847771c5f33492e6b9af55a49d921cbd909bbc2c90Yorke Lee 1857771c5f33492e6b9af55a49d921cbd909bbc2c90Yorke Lee /** 18663ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng * Implemented by subclasses to estimate the size of the picture. This can return -1 if only 18763ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng * a thumbnail is shown anyway 18863ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng */ 18963ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng protected abstract int getApproximateImageSize(); 19063ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng 19163ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng protected abstract boolean isDarkTheme(); 19263ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng 1936084726fbdda78bdb16e2d4cc1c3b81c84fd5da1Yorke Lee /** 194906ffc8a0655f0e78a9b7307e7e76717bfdc6d58Yorke Lee * Implemented by subclasses to reconfigure the view's layout and subviews, based on whether 195906ffc8a0655f0e78a9b7307e7e76717bfdc6d58Yorke Lee * or not the contact has a user-defined photo. 196906ffc8a0655f0e78a9b7307e7e76717bfdc6d58Yorke Lee * 197906ffc8a0655f0e78a9b7307e7e76717bfdc6d58Yorke Lee * @param isDefaultImage True if the contact does not have a user-defined contact photo 198906ffc8a0655f0e78a9b7307e7e76717bfdc6d58Yorke Lee * (which means a default contact image will be applied by the {@link ContactPhotoManager} 199906ffc8a0655f0e78a9b7307e7e76717bfdc6d58Yorke Lee */ 200906ffc8a0655f0e78a9b7307e7e76717bfdc6d58Yorke Lee protected void configureViewForImage(boolean isDefaultImage) { 201906ffc8a0655f0e78a9b7307e7e76717bfdc6d58Yorke Lee // No-op by default. 202906ffc8a0655f0e78a9b7307e7e76717bfdc6d58Yorke Lee } 203906ffc8a0655f0e78a9b7307e7e76717bfdc6d58Yorke Lee 204906ffc8a0655f0e78a9b7307e7e76717bfdc6d58Yorke Lee /** 2056084726fbdda78bdb16e2d4cc1c3b81c84fd5da1Yorke Lee * Implemented by subclasses to allow them to return a {@link DefaultImageRequest} with the 2066084726fbdda78bdb16e2d4cc1c3b81c84fd5da1Yorke Lee * various image parameters defined to match their own layouts. 2076084726fbdda78bdb16e2d4cc1c3b81c84fd5da1Yorke Lee * 2086084726fbdda78bdb16e2d4cc1c3b81c84fd5da1Yorke Lee * @param displayName The display name of the contact 2096084726fbdda78bdb16e2d4cc1c3b81c84fd5da1Yorke Lee * @param lookupKey The lookup key of the contact 2106084726fbdda78bdb16e2d4cc1c3b81c84fd5da1Yorke Lee * @return A {@link DefaultImageRequest} object with each field configured by the subclass 2116084726fbdda78bdb16e2d4cc1c3b81c84fd5da1Yorke Lee * as desired, or {@code null}. 2126084726fbdda78bdb16e2d4cc1c3b81c84fd5da1Yorke Lee */ 2136084726fbdda78bdb16e2d4cc1c3b81c84fd5da1Yorke Lee protected DefaultImageRequest getDefaultImageRequest(String displayName, String lookupKey) { 214395d9d95e25f6fa4b8e750e36ec0a5c1886a65b5Brian Attwell return new DefaultImageRequest(displayName, lookupKey, isContactPhotoCircular()); 215395d9d95e25f6fa4b8e750e36ec0a5c1886a65b5Brian Attwell } 216395d9d95e25f6fa4b8e750e36ec0a5c1886a65b5Brian Attwell 217395d9d95e25f6fa4b8e750e36ec0a5c1886a65b5Brian Attwell /** 218395d9d95e25f6fa4b8e750e36ec0a5c1886a65b5Brian Attwell * Whether contact photo should be displayed as a circular image. Implemented by subclasses 219395d9d95e25f6fa4b8e750e36ec0a5c1886a65b5Brian Attwell * so they can change which drawables to fetch. 220395d9d95e25f6fa4b8e750e36ec0a5c1886a65b5Brian Attwell */ 221395d9d95e25f6fa4b8e750e36ec0a5c1886a65b5Brian Attwell protected boolean isContactPhotoCircular() { 222395d9d95e25f6fa4b8e750e36ec0a5c1886a65b5Brian Attwell return true; 2236084726fbdda78bdb16e2d4cc1c3b81c84fd5da1Yorke Lee } 2246084726fbdda78bdb16e2d4cc1c3b81c84fd5da1Yorke Lee 22563ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng public interface Listener { 22663ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng /** 22763ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng * Notification that the contact was selected; no specific action is dictated. 22863ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng */ 22963ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng void onContactSelected(Uri contactLookupUri, Rect viewRect); 23063ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng /** 23163ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng * Notification that the specified number is to be called. 23263ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng */ 23363ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng void onCallNumberDirectly(String phoneNumber); 23463ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng /** 23563ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng * @return The width of each tile. This doesn't have to be a precise number (e.g. paddings 23663ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng * can be ignored), but is used to load the correct picture size from the database 23763ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng */ 23863ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng int getApproximateTileWidth(); 23963ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng } 24063ac534dcf60e9a6c651ef2434557bec922b9a7dChiao Cheng} 241