private void setMarqueeText(TextView textView, char[] text, int size) { if (getTextEllipsis() == TruncateAt.MARQUEE) { setMarqueeText(textView, new String(text, 0, size)); } else { textView.setText(text, 0, size); } }
/** * 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); } }
/** * Adds or updates a text view for the phonetic name. */ public void setPhoneticName(char[] text, int size) { if (text == null || size == 0) { if (mPhoneticNameTextView != null) { mPhoneticNameTextView.setVisibility(View.GONE); } } else { getPhoneticNameTextView(); setMarqueeText(mPhoneticNameTextView, text, size); mPhoneticNameTextView.setVisibility(VISIBLE); } }
/** * 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); } }
/** * Adds or updates a text view for the status. */ public void setStatus(CharSequence text) { if (TextUtils.isEmpty(text)) { if (mStatusView != null) { mStatusView.setVisibility(View.GONE); } } else { getStatusView(); setMarqueeText(mStatusView, text); mStatusView.setVisibility(VISIBLE); } }
/** * 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); } }
/** * 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); } }
public void setDisplayName(CharSequence name) { if (!TextUtils.isEmpty(name)) { // Chooses the available highlighting method for highlighting. if (mHighlightedPrefix != null) { name = mTextHighlighter.applyPrefixHighlight(name, mHighlightedPrefix); } else if (mNameHighlightSequence.size() != 0) { final SpannableString spannableName = new SpannableString(name); for (HighlightSequence highlightSequence : mNameHighlightSequence) { mTextHighlighter.applyMaskingHighlight(spannableName, highlightSequence.start, highlightSequence.end); } name = spannableName; } } else { name = mUnknownNameText; } setMarqueeText(getNameTextView(), name); if (ContactDisplayUtils.isPossiblePhoneNumber(name)) { // Give the text-to-speech engine a hint that it's a phone number mNameTextView.setTextDirection(View.TEXT_DIRECTION_LTR); mNameTextView.setContentDescription( PhoneNumberUtilsCompat.createTtsSpannable(name.toString())); } else { // Remove span tags of highlighting for talkback to avoid reading highlighting and rest // of the name into two separate parts. mNameTextView.setContentDescription(name.toString()); } }