List of usage examples for android.support.v4.text BidiFormatter unicodeWrap
public String unicodeWrap(String str, boolean z)
From source file:com.android.messaging.ui.BlockedParticipantListItemView.java
public void bind(final ParticipantListItemData data) { mData = data;//w w w . j a v a 2 s .c om final BidiFormatter bidiFormatter = BidiFormatter.getInstance(); mNameTextView.setText(bidiFormatter.unicodeWrap(data.getDisplayName(), TextDirectionHeuristicsCompat.LTR)); mContactIconView.setImageResourceUri(data.getAvatarUri(), data.getContactId(), data.getLookupKey(), data.getNormalizedDestination()); mNameTextView.setText(data.getDisplayName()); }
From source file:com.android.messaging.ui.appsettings.PhoneNumberPreference.java
@Override protected void onBindView(final View view) { // Show the preference value if it's set, or the default number if not. // If we don't have a default, fall back to a static string (e.g. Unknown). String value = getText();/*from w ww. j ava2s .c om*/ if (TextUtils.isEmpty(value)) { value = mDefaultPhoneNumber; } final String displayValue = (!TextUtils.isEmpty(value)) ? PhoneUtils.get(mSubId).formatForDisplay(value) : getContext().getString(R.string.unknown_phone_number_pref_display_value); final BidiFormatter bidiFormatter = BidiFormatter.getInstance(); final String phoneNumber = bidiFormatter.unicodeWrap(displayValue, TextDirectionHeuristicsCompat.LTR); // Set the value as the summary and let the superclass populate the views setSummary(phoneNumber); super.onBindView(view); }
From source file:com.android.messaging.ui.appsettings.PhoneNumberPreference.java
@Override protected void onBindDialogView(final View view) { super.onBindDialogView(view); final String value = getText(); // If the preference is empty, populate the EditText with the default number instead. if (TextUtils.isEmpty(value) && !TextUtils.isEmpty(mDefaultPhoneNumber)) { final BidiFormatter bidiFormatter = BidiFormatter.getInstance(); final String phoneNumber = bidiFormatter.unicodeWrap( PhoneUtils.get(mSubId).getCanonicalBySystemLocale(mDefaultPhoneNumber), TextDirectionHeuristicsCompat.LTR); getEditText().setText(phoneNumber); }//from ww w. j av a2s .c o m getEditText().setInputType(InputType.TYPE_CLASS_PHONE); }
From source file:com.android.messaging.ui.contact.ContactDropdownLayouter.java
/** * Bind a drop down view to a RecipientEntry. We'd like regular dropdown items (BASE_RECIPIENT) * to behave the same as regular ContactListItemViews, while using the chips library's * item styling for alternates dropdown items (happens when you click on a chip). *///from w w w.ja v a2 s . c o m @Override public View bindView(final View convertView, final ViewGroup parent, final RecipientEntry entry, final int position, AdapterType type, final String substring, final StateListDrawable deleteDrawable) { if (type != AdapterType.BASE_RECIPIENT) { if (type == AdapterType.SINGLE_RECIPIENT) { // Treat single recipients the same way as alternates. The base implementation of // single recipients would try to simplify the destination by tokenizing. We'd // like to always show the full destination address per design request. type = AdapterType.RECIPIENT_ALTERNATES; } return super.bindView(convertView, parent, entry, position, type, substring, deleteDrawable); } // Default to show all the information // RTL : To format contact name and detail if they happen to be phone numbers. final BidiFormatter bidiFormatter = BidiFormatter.getInstance(); final String displayName = bidiFormatter.unicodeWrap( ContactRecipientEntryUtils.getDisplayNameForContactList(entry), TextDirectionHeuristicsCompat.LTR); final String destination = bidiFormatter.unicodeWrap(ContactRecipientEntryUtils.formatDestination(entry), TextDirectionHeuristicsCompat.LTR); final View itemView = reuseOrInflateView(convertView, parent, type); // Bold the string that is matched. final CharSequence[] styledResults = getStyledResults(substring, displayName, destination); Assert.isTrue(itemView instanceof ContactListItemView); final ContactListItemView contactListItemView = (ContactListItemView) itemView; contactListItemView.setImageClickHandlerDisabled(true); boolean isWorkContact = ContactUtil.isEnterpriseContactId(entry.getContactId()); contactListItemView.bind(entry, styledResults[0], styledResults[1], mClivHostInterface, (type == AdapterType.SINGLE_RECIPIENT), isWorkContact); return itemView; }
From source file:com.android.messaging.ui.conversationlist.ConversationListItemView.java
private void setConversationName() { if (mData.getIsRead() || mData.getShowDraft()) { mConversationNameView.setTextColor(mListItemReadColor); mConversationNameView.setTypeface(mListItemReadTypeface); } else {/*from w w w.j a va2s .c o m*/ mConversationNameView.setTextColor(mListItemUnreadColor); mConversationNameView.setTypeface(mListItemUnreadTypeface); } final String conversationName = mData.getName(); // For group conversations, ellipsize the group members that do not fit final CharSequence ellipsizedName = UiUtils.commaEllipsize(conversationName, mConversationNameView.getPaint(), mConversationNameView.getMeasuredWidth(), getPlusOneString(), getPlusNString()); // RTL : To format conversation name if it happens to be phone number. final BidiFormatter bidiFormatter = BidiFormatter.getInstance(); final String bidiFormattedName = bidiFormatter.unicodeWrap(ellipsizedName.toString(), TextDirectionHeuristicsCompat.LTR); mConversationNameView.setText(bidiFormattedName); }
From source file:com.android.messaging.ui.conversation.ConversationFragment.java
public void updateActionBar(final ActionBar actionBar) { if (mComposeMessageView == null || !mComposeMessageView.updateActionBar(actionBar)) { updateActionAndStatusBarColor(actionBar); // We update this regardless of whether or not the action bar is showing so that we // don't get a race when it reappears. actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setDisplayHomeAsUpEnabled(true); // Reset the back arrow to its default actionBar.setHomeAsUpIndicator(0); View customView = actionBar.getCustomView(); if (customView == null || customView.getId() != R.id.conversation_title_container) { final LayoutInflater inflator = (LayoutInflater) getActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); customView = inflator.inflate(R.layout.action_bar_conversation_name, null); customView.setOnClickListener(new View.OnClickListener() { @Override/* w ww. j a v a 2 s . co m*/ public void onClick(final View v) { onBackPressed(); } }); actionBar.setCustomView(customView); } final TextView conversationNameView = (TextView) customView.findViewById(R.id.conversation_title); final String conversationName = getConversationName(); if (!TextUtils.isEmpty(conversationName)) { // RTL : To format conversation title if it happens to be phone numbers. final BidiFormatter bidiFormatter = BidiFormatter.getInstance(); final String formattedName = bidiFormatter.unicodeWrap(UiUtils.commaEllipsize(conversationName, conversationNameView.getPaint(), conversationNameView.getWidth(), getString(R.string.plus_one), getString(R.string.plus_n)).toString(), TextDirectionHeuristicsCompat.LTR); conversationNameView.setText(formattedName); // In case phone numbers are mixed in the conversation name, we need to vocalize it. final String vocalizedConversationName = AccessibilityUtil.getVocalizedPhoneNumber(getResources(), conversationName); conversationNameView.setContentDescription(vocalizedConversationName); getActivity().setTitle(conversationName); } else { final String appName = getString(R.string.app_name); conversationNameView.setText(appName); getActivity().setTitle(appName); } // When conversation is showing and media picker is not showing, then hide the action // bar only when we are in landscape mode, with IME open. if (mHost.isImeOpen() && UiUtils.isLandscapeMode()) { actionBar.hide(); } else { actionBar.show(); } } }