@Override protected ContactListItemView newView( Context context, int partition, Cursor cursor, int position, ViewGroup parent) { final ContactListItemView view = new ContactListItemView(context, null); view.setIsSectionHeaderEnabled(isSectionHeaderDisplayEnabled()); view.setAdjustSelectionBoundsEnabled(isAdjustSelectionBoundsEnabled()); return view; }
public void setDisplayName(CharSequence name, boolean highlight) { if (!TextUtils.isEmpty(name) && highlight) { clearHighlightSequences(); addNameHighlightSequence(0, name.length()); } setDisplayName(name); }
public void setViewUnblocked(ContactListItemView view) { view.setTag(R.id.block_id, null); final int textColor = mResources.getColor(R.color.dialtacts_secondary_text_color); view.getDataView().setTextColor(textColor); view.getLabelView().setTextColor(textColor); //TODO: Remove icon }
/** * Adds or updates a text view for the data element. */ public void setData(char[] text, int size) { if (text == null || size == 0) { if (mDataView != null) { mDataView.setVisibility(View.GONE); } } else { getDataView(); setMarqueeText(mDataView, text, size); mDataView.setVisibility(VISIBLE); } }
/** * 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; }
@Override protected ContactListItemView newView( Context context, int partition, Cursor cursor, int position, ViewGroup parent) { ContactListItemView view = super.newView(context, partition, cursor, position, parent); view.setUnknownNameText(mUnknownNameText); view.setQuickContactEnabled(isQuickContactEnabled()); view.setAdjustSelectionBoundsEnabled(isAdjustSelectionBoundsEnabled()); view.setActivatedStateSupported(isSelectionVisible()); if (mPhotoPosition != null) { view.setPhotoPosition(mPhotoPosition); } return view; }
throw new IllegalArgumentException("Invalid shortcut type"); v.setDrawableResource(drawableId); v.setDisplayName(text); v.setPhotoPosition(super.getPhotoPosition()); v.setAdjustSelectionBoundsEnabled(false);
/** * Sets highlight options for a List item in the SmartDial search results. * @param view ContactListItemView where the result will be displayed. * @param cursor Object containing information of the associated List item. */ @Override protected void setHighlight(ContactListItemView view, Cursor cursor) { view.clearHighlightSequences(); if (mNameMatcher.matches(cursor.getString(PhoneQuery.DISPLAY_NAME))) { final ArrayList<SmartDialMatchPosition> nameMatches = mNameMatcher.getMatchPositions(); for (SmartDialMatchPosition match:nameMatches) { view.addNameHighlightSequence(match.start, match.end); if (DEBUG) { Log.v(TAG, cursor.getString(PhoneQuery.DISPLAY_NAME) + " " + mNameMatcher.getQuery() + " " + String.valueOf(match.start)); } } } final SmartDialMatchPosition numberMatch = mNameMatcher.matchesNumber(cursor.getString( PhoneQuery.PHONE_NUMBER)); if (numberMatch != null) { view.addNumberHighlightSequence(numberMatch.start, numberMatch.end); } }
@Override protected ContactListItemView newView( Context context, int partition, Cursor cursor, int position, ViewGroup parent) { ContactListItemView view = super.newView(context, partition, cursor, position, parent); view.setUnknownNameText(mUnknownNameText); view.setQuickContactEnabled(isQuickContactEnabled()); view.setPhotoPosition(mPhotoPosition); return view; }
/** * 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; }
/** * Adds or updates a text view for the data label. */ public void setLabel(CharSequence text) { if (TextUtils.isEmpty(text)) { if (mLabelView != null) { mLabelView.setVisibility(View.GONE); } } else { getLabelView(); setMarqueeText(mLabelView, text); mLabelView.setVisibility(VISIBLE); } }
/** * 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); } }
public void showDisplayName(Cursor cursor, int nameColumnIndex, int displayOrder) { CharSequence name = cursor.getString(nameColumnIndex); setDisplayName(name); // Since the quick contact content description is derived from the display name and there is // no guarantee that when the quick contact is initialized the display name is already set, // do it here too. if (mQuickContact != null) { mQuickContact.setContentDescription(getContext().getString( R.string.description_quick_contact_for, mNameTextView.getText())); } }
/** * 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); } }
@Override public View getView(int position, View convertView, ViewGroup parent) { final int shortcutType = getShortcutTypeFromPosition(position); if (shortcutType >= 0) { if (convertView != null) { assignShortcutToView((ContactListItemView) convertView, shortcutType); return convertView; } else { final ContactListItemView v = new ContactListItemView(getContext(), null, mVideoCallingEnabled); assignShortcutToView(v, shortcutType); return v; } } else { return super.getView(position, convertView, parent); } }
/** * 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; }
/** * Sets phone number for a list item. This takes care of number highlighting if the highlight * mask exists. */ public void setPhoneNumber(String text, String countryIso) { if (text == null) { if (mDataView != null) { mDataView.setVisibility(View.GONE); } } else { getDataView(); // TODO: Format number using PhoneNumberUtils.formatNumber before assigning it to // mDataView. Make sure that determination of the highlight sequences are done only // after number formatting. // Sets phone number texts for display after highlighting it, if applicable. // CharSequence textToSet = text; final SpannableString textToSet = new SpannableString(text); if (mNumberHighlightSequence.size() != 0) { final HighlightSequence highlightSequence = mNumberHighlightSequence.get(0); mTextHighlighter.applyMaskingHighlight(textToSet, highlightSequence.start, highlightSequence.end); } setMarqueeText(mDataView, textToSet); mDataView.setVisibility(VISIBLE); // We have a phone number as "mDataView" so make it always LTR and VIEW_START mDataView.setTextDirection(View.TEXT_DIRECTION_LTR); mDataView.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START); } }
/** * 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; }
/** * 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 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; }