/** * Set to display work profile icon or not * * @param enabled set to display work profile icon or not */ public void setWorkProfileIconEnabled(boolean enabled) { if (mWorkProfileIcon != null) { mWorkProfileIcon.setVisibility(enabled ? View.VISIBLE : View.GONE); } else if (enabled) { mWorkProfileIcon = new ImageView(getContext()); addView(mWorkProfileIcon); mWorkProfileIcon.setImageResource(R.drawable.ic_work_profile); mWorkProfileIcon.setScaleType(ScaleType.CENTER_INSIDE); mWorkProfileIcon.setVisibility(View.VISIBLE); } }
/** * Adds or updates the presence icon view. */ public void setPresence(Drawable icon) { if (icon != null) { if (mPresenceIcon == null) { mPresenceIcon = new ImageView(getContext()); addView(mPresenceIcon); } mPresenceIcon.setImageDrawable(icon); mPresenceIcon.setScaleType(ScaleType.CENTER); mPresenceIcon.setVisibility(View.VISIBLE); } else { if (mPresenceIcon != null) { mPresenceIcon.setVisibility(View.GONE); } } }
/** * Returns the photo view, creating it if necessary. */ public ImageView getPhotoView() { if (mPhotoView == null) { mPhotoView = new ImageView(getContext()); mPhotoView.setLayoutParams(getDefaultPhotoLayoutParams()); // Quick contact style used above will set a background - remove it mPhotoView.setBackground(null); addView(mPhotoView); mPhotoViewWidthAndHeightAreReady = false; } return mPhotoView; }
if (mVideoCallIcon == null) { mVideoCallIcon = new ImageView(getContext()); addView(mVideoCallIcon);
/** * Returns the {@link CheckBox} view, creating it if necessary. */ public CheckBox getCheckBox() { if (mCheckBox == null) { mCheckBox = new CheckBox(getContext()); // Make non-focusable, so the rest of the ContactListItemView can be clicked. mCheckBox.setFocusable(false); addView(mCheckBox); } return mCheckBox; }
/** * Sets section header or makes it invisible if the title is null. */ public void setSectionHeader(String title) { if (!TextUtils.isEmpty(title)) { if (mHeaderTextView == null) { mHeaderTextView = new TextView(getContext()); mHeaderTextView.setTextAppearance(getContext(), R.style.SectionHeaderStyle); mHeaderTextView.setGravity( ViewUtil.isViewLayoutRtl(this) ? Gravity.RIGHT : Gravity.LEFT); addView(mHeaderTextView); } setMarqueeText(mHeaderTextView, title); mHeaderTextView.setVisibility(View.VISIBLE); mHeaderTextView.setAllCaps(true); } else if (mHeaderTextView != null) { mHeaderTextView.setVisibility(View.GONE); } }
/** * Returns the quick contact badge, creating it if necessary. */ public QuickContactBadge getQuickContact() { if (!mQuickContactEnabled) { throw new IllegalStateException("QuickContact is disabled for this view"); } if (mQuickContact == null) { mQuickContact = new QuickContactBadge(getContext()); if (CompatUtils.isLollipopCompatible()) { mQuickContact.setOverlay(null); } mQuickContact.setLayoutParams(getDefaultPhotoLayoutParams()); if (mNameTextView != null) { mQuickContact.setContentDescription(getContext().getString( R.string.description_quick_contact_for, mNameTextView.getText())); } addView(mQuickContact); mPhotoViewWidthAndHeightAreReady = false; } return mQuickContact; }
/** * Returns the text view for the contact name, creating it if necessary. */ public TextView getNameTextView() { if (mNameTextView == null) { mNameTextView = new TextView(getContext()); mNameTextView.setSingleLine(true); mNameTextView.setEllipsize(getTextEllipsis()); mNameTextView.setTextColor(mNameTextViewTextColor); mNameTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mNameTextViewTextSize); // Manually call setActivated() since this view may be added after the first // setActivated() call toward this whole item view. mNameTextView.setActivated(isActivated()); mNameTextView.setGravity(Gravity.CENTER_VERTICAL); mNameTextView.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START); mNameTextView.setId(R.id.cliv_name_textview); if (CompatUtils.isLollipopCompatible()) { mNameTextView.setElegantTextHeight(false); } addView(mNameTextView); } return mNameTextView; }
/** * Returns the text view for the status, creating it if necessary. */ public TextView getStatusView() { if (mStatusView == null) { mStatusView = new TextView(getContext()); mStatusView.setSingleLine(true); mStatusView.setEllipsize(getTextEllipsis()); mStatusView.setTextAppearance(getContext(), android.R.style.TextAppearance_Small); mStatusView.setTextColor(mSecondaryTextColor); mStatusView.setActivated(isActivated()); mStatusView.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START); addView(mStatusView); } return mStatusView; }
/** * Returns the text view for the data label, creating it if necessary. */ public TextView getLabelView() { if (mLabelView == null) { mLabelView = new TextView(getContext()); mLabelView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); mLabelView.setSingleLine(true); mLabelView.setEllipsize(getTextEllipsis()); mLabelView.setTextAppearance(getContext(), R.style.TextAppearanceSmall); if (mPhotoPosition == PhotoPosition.LEFT) { mLabelView.setAllCaps(true); } else { mLabelView.setTypeface(mLabelView.getTypeface(), Typeface.BOLD); } mLabelView.setActivated(isActivated()); mLabelView.setId(R.id.cliv_label_textview); addView(mLabelView); } return mLabelView; }
/** * Returns the text view for the phonetic name, creating it if necessary. */ public TextView getPhoneticNameTextView() { if (mPhoneticNameTextView == null) { mPhoneticNameTextView = new TextView(getContext()); mPhoneticNameTextView.setSingleLine(true); mPhoneticNameTextView.setEllipsize(getTextEllipsis()); mPhoneticNameTextView.setTextAppearance(getContext(), android.R.style.TextAppearance_Small); mPhoneticNameTextView.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START); mPhoneticNameTextView.setTypeface(mPhoneticNameTextView.getTypeface(), Typeface.BOLD); mPhoneticNameTextView.setActivated(isActivated()); mPhoneticNameTextView.setId(R.id.cliv_phoneticname_textview); addView(mPhoneticNameTextView); } return mPhoneticNameTextView; }
/** * Returns the text view for the search snippet, creating it if necessary. */ public TextView getSnippetView() { if (mSnippetView == null) { mSnippetView = new TextView(getContext()); mSnippetView.setSingleLine(true); mSnippetView.setEllipsize(getTextEllipsis()); mSnippetView.setTextAppearance(getContext(), android.R.style.TextAppearance_Small); mSnippetView.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START); mSnippetView.setActivated(isActivated()); addView(mSnippetView); } return mSnippetView; }
/** * Returns the text view for the data text, creating it if necessary. */ public TextView getDataView() { if (mDataView == null) { mDataView = new TextView(getContext()); mDataView.setSingleLine(true); mDataView.setEllipsize(getTextEllipsis()); mDataView.setTextAppearance(getContext(), R.style.TextAppearanceSmall); mDataView.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START); mDataView.setActivated(isActivated()); mDataView.setId(R.id.cliv_data_view); if (CompatUtils.isLollipopCompatible()) { mDataView.setElegantTextHeight(false); } addView(mDataView); } return mDataView; }