List of usage examples for android.view View TEXT_DIRECTION_LTR
int TEXT_DIRECTION_LTR
To view the source code for android.view View TEXT_DIRECTION_LTR.
Click Source Link
From source file:Main.java
public static int getTypeOfTextDirection(String text) { Matcher matcher = RTL_CHAR.matcher(text); if (matcher.find()) { return View.TEXT_DIRECTION_RTL; } else {// w w w.j a v a 2 s .co m return View.TEXT_DIRECTION_LTR; } }
From source file:com.android.dialer.calllog.PhoneCallDetailsHelper.java
/** Fills the call details views with content. */ public void setPhoneCallDetails(PhoneCallDetailsViews views, PhoneCallDetails details) { // Display up to a given number of icons. views.callTypeIcons.clear();//from w w w . j a v a2s .co m int count = details.callTypes.length; boolean isVoicemail = false; for (int index = 0; index < count && index < MAX_CALL_TYPE_ICONS; ++index) { views.callTypeIcons.add(details.callTypes[index]); if (index == 0) { isVoicemail = details.callTypes[index] == Calls.VOICEMAIL_TYPE; } } // Show the video icon if the call had video enabled. views.callTypeIcons.setShowVideo((details.features & Calls.FEATURES_VIDEO) == Calls.FEATURES_VIDEO); views.callTypeIcons.requestLayout(); views.callTypeIcons.setVisibility(View.VISIBLE); // Show the total call count only if there are more than the maximum number of icons. final Integer callCount; if (count > MAX_CALL_TYPE_ICONS) { callCount = count; } else { callCount = null; } // Set the call count, location, date and if voicemail, set the duration. setDetailText(views, callCount, details); // Set the account label if it exists. String accountLabel = mCallLogCache.getAccountLabel(details.accountHandle); if (!TextUtils.isEmpty(details.viaNumber)) { if (!TextUtils.isEmpty(accountLabel)) { accountLabel = mResources.getString(R.string.call_log_via_number_phone_account, accountLabel, details.viaNumber); } else { accountLabel = mResources.getString(R.string.call_log_via_number, details.viaNumber); } } if (!TextUtils.isEmpty(accountLabel)) { views.callAccountLabel.setVisibility(View.VISIBLE); views.callAccountLabel.setText(accountLabel); int color = mCallLogCache.getAccountColor(details.accountHandle); if (color == PhoneAccount.NO_HIGHLIGHT_COLOR) { int defaultColor = R.color.dialtacts_secondary_text_color; views.callAccountLabel.setTextColor(mContext.getResources().getColor(defaultColor)); } else { views.callAccountLabel.setTextColor(color); } } else { views.callAccountLabel.setVisibility(View.GONE); } final CharSequence nameText; final CharSequence displayNumber = details.displayNumber; if (TextUtils.isEmpty(details.getPreferredName())) { nameText = displayNumber; // We have a real phone number as "nameView" so make it always LTR views.nameView.setTextDirection(View.TEXT_DIRECTION_LTR); } else { nameText = details.getPreferredName(); } views.nameView.setText(nameText); if (isVoicemail) { views.voicemailTranscriptionView .setText(TextUtils.isEmpty(details.transcription) ? null : details.transcription); } // Bold if not read Typeface typeface = details.isRead ? Typeface.SANS_SERIF : Typeface.DEFAULT_BOLD; views.nameView.setTypeface(typeface); views.voicemailTranscriptionView.setTypeface(typeface); views.callLocationAndDate.setTypeface(typeface); views.callLocationAndDate.setTextColor(ContextCompat.getColor(mContext, details.isRead ? R.color.call_log_detail_color : R.color.call_log_unread_text_color)); }
From source file:com.android.incallui.CallCardFragment.java
@Override public void setPrimaryName(String name, boolean nameIsNumber) { if (TextUtils.isEmpty(name)) { mPrimaryName.setText(null);/* w w w. ja va2 s.c o m*/ } else { mPrimaryName.setText(nameIsNumber ? PhoneNumberUtilsCompat.createTtsSpannable(name) : name); // Set direction of the name field int nameDirection = View.TEXT_DIRECTION_INHERIT; if (nameIsNumber) { nameDirection = View.TEXT_DIRECTION_LTR; } mPrimaryName.setTextDirection(nameDirection); } }
From source file:com.pdftron.pdf.utils.Utils.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) public static void showCommonToast(@NonNull Context context, String str, int duration) { if (sToast == null) { sToast = Toast.makeText(context, str, duration); } else if (str != sToastStr) { sToast.cancel();/*from w w w . ja va2s . co m*/ sToast = Toast.makeText(context, str, duration); } sToastStr = str; if (Utils.isRtlLayout(context)) { sToast.getView().setTextDirection(View.TEXT_DIRECTION_RTL); } else { sToast.getView().setTextDirection(View.TEXT_DIRECTION_LTR); } sToast.show(); }
From source file:com.android.incallui.CallCardFragment.java
@Override public void setPrimaryPhoneNumber(String number) { // Set the number if (TextUtils.isEmpty(number)) { mPhoneNumber.setText(null);//from w w w. ja v a 2 s.co m mPhoneNumber.setVisibility(View.GONE); } else { mPhoneNumber.setText(PhoneNumberUtilsCompat.createTtsSpannable(number)); mPhoneNumber.setVisibility(View.VISIBLE); mPhoneNumber.setTextDirection(View.TEXT_DIRECTION_LTR); } }
From source file:com.android.incallui.CallCardFragment.java
@Override public void setSecondary(boolean show, String name, boolean nameIsNumber, String label, String providerLabel, boolean isConference, boolean isVideoCall, boolean isFullscreen) { if (show) {//w w w. j av a 2 s .c om mHasSecondaryCallInfo = true; boolean hasProvider = !TextUtils.isEmpty(providerLabel); initializeSecondaryCallInfo(hasProvider); // Do not show the secondary caller info in fullscreen mode, but ensure it is populated // in case fullscreen mode is exited in the future. setSecondaryInfoVisible(!isFullscreen); mSecondaryCallConferenceCallIcon.setVisibility(isConference ? View.VISIBLE : View.GONE); mSecondaryCallVideoCallIcon.setVisibility(isVideoCall ? View.VISIBLE : View.GONE); mSecondaryCallName.setText(nameIsNumber ? PhoneNumberUtilsCompat.createTtsSpannable(name) : name); if (hasProvider) { mSecondaryCallProviderLabel.setText(providerLabel); } int nameDirection = View.TEXT_DIRECTION_INHERIT; if (nameIsNumber) { nameDirection = View.TEXT_DIRECTION_LTR; } mSecondaryCallName.setTextDirection(nameDirection); } else { mHasSecondaryCallInfo = false; setSecondaryInfoVisible(false); } }
From source file:com.android.contacts.common.list.ContactListItemView.java
/** * Sets phone number for a list item. This takes care of number highlighting if the highlight * mask exists.// w ww .j a v a2s .c om */ 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); } }
From source file:com.android.contacts.common.list.ContactListItemView.java
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); }/* w ww . ja v a 2s . co m*/ 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()); } }