List of usage examples for android.text Spanned SPAN_EXCLUSIVE_EXCLUSIVE
int SPAN_EXCLUSIVE_EXCLUSIVE
To view the source code for android.text Spanned SPAN_EXCLUSIVE_EXCLUSIVE.
Click Source Link
From source file:cw.kop.autobackground.tutorial.AppFragment.java
private void resetFabricText(boolean use) { SpannableString text;/*ww w .ja va 2 s. co m*/ if (use) { text = new SpannableString("Thanks!"); text.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.BLUE_OPAQUE)), 0, text.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } else { text = new SpannableString("Send reports?"); } fabricText.setText(text); fabricText.invalidate(); }
From source file:org.jraf.android.dcn.wearable.app.notif.NotificationWearableListenerService.java
private void showNotification(String title, String textShort, String textLong, @Nullable Bitmap photo, Uri contactUri, @Nullable String phoneNumber) { Log.d();/* www . java2 s. co m*/ NotificationCompat.Builder mainNotifBuilder = new NotificationCompat.Builder(this); // Small icon mainNotifBuilder.setSmallIcon(R.drawable.ic_launcher); // Title SpannableString spannableTitle = new SpannableString(title); Object appearanceSpan = new TextAppearanceSpan(this, R.style.NotificationContentTitleTextAppearance); spannableTitle.setSpan(appearanceSpan, 0, title.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); mainNotifBuilder.setContentTitle(spannableTitle); // Text (short) -- This may be completely useless since the "big text style" (below) is always used instead SpannableString spannableTextShort = new SpannableString(textShort); appearanceSpan = new TextAppearanceSpan(this, R.style.NotificationContentTextTextAppearance); spannableTextShort.setSpan(appearanceSpan, 0, textShort.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); mainNotifBuilder.setContentText(spannableTextShort); // Text (long) SpannableString spannableTextLong = new SpannableString(textLong); appearanceSpan = new TextAppearanceSpan(this, R.style.NotificationContentTextTextAppearance); spannableTextLong.setSpan(appearanceSpan, 0, textLong.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); mainNotifBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(spannableTextLong)); // Dismiss intent Intent dismissIntent = new Intent(NotificationIntentService.ACTION_DISMISS_NOTIFICATION, null, this, NotificationIntentService.class); PendingIntent dismissPendingIntent = PendingIntent.getService(this, 0, dismissIntent, PendingIntent.FLAG_UPDATE_CURRENT); mainNotifBuilder.setDeleteIntent(dismissPendingIntent); // Wear specifics NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender(); // Contact photo if (photo != null) wearableExtender.setBackground(photo); // Actions if (phoneNumber != null) { // Call action Intent callIntent = new Intent(NotificationIntentService.ACTION_CALL, null, this, NotificationIntentService.class); callIntent.putExtra(NotificationIntentService.EXTRA_PHONE_NUMBER, phoneNumber); PendingIntent callPendingIntent = PendingIntent.getService(this, 0, callIntent, PendingIntent.FLAG_UPDATE_CURRENT); String callText = getString(R.string.notification_action_call); wearableExtender.addAction( new NotificationCompat.Action(R.drawable.ic_action_call_full, callText, callPendingIntent)); // Sms action Intent smsIntent = new Intent(NotificationIntentService.ACTION_SMS, null, this, NotificationIntentService.class); smsIntent.putExtra(NotificationIntentService.EXTRA_PHONE_NUMBER, phoneNumber); PendingIntent smsPendingIntent = PendingIntent.getService(this, 0, smsIntent, PendingIntent.FLAG_UPDATE_CURRENT); String smsText = getString(R.string.notification_action_sms); wearableExtender.addAction( new NotificationCompat.Action(R.drawable.ic_action_sms_full, smsText, smsPendingIntent)); } // 'Show contact' action Intent showContactIntent = new Intent(NotificationIntentService.ACTION_SHOW_CONTACT, null, this, NotificationIntentService.class); showContactIntent.setData(contactUri); PendingIntent showContactPendingIntent = PendingIntent.getService(this, 0, showContactIntent, PendingIntent.FLAG_UPDATE_CURRENT); String showContactText = getString(R.string.notification_action_showContact); wearableExtender.addAction(new NotificationCompat.Action(R.drawable.ic_action_show_contact_full, showContactText, showContactPendingIntent)); // Misc mainNotifBuilder.setPriority(NotificationCompat.PRIORITY_HIGH); // Time sensitive, try to appear on top mainNotifBuilder.setCategory(NotificationCompat.CATEGORY_STATUS); // Not sure if this category is really the most appropriate wearableExtender.setHintScreenTimeout(NotificationCompat.WearableExtender.SCREEN_TIMEOUT_LONG); // Could be useful mainNotifBuilder.extend(wearableExtender); // Show the notification Notification notification = mainNotifBuilder.build(); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(NOTIFICATION_ID, notification); }
From source file:net.sf.fakenames.fddemo.PermissionActivity.java
private static void setBold(Spannable s, int start, int end) { s.setSpan(new StyleSpan(Typeface.BOLD), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); }
From source file:com.inter.trade.ui.fragment.buylicensekey.BuyLicenseKeyMainFragment.java
private void initView(View view) { btn_buy_licensekey = (Button) view.findViewById(R.id.btn_buy_licensekey); tv_bind = (TextView) view.findViewById(R.id.tv_bind); product_price = (TextView) view.findViewById(R.id.product_price); // //from w w w .j a va2 s . c o m SpannableString sp = new SpannableString(product_price.getText().toString()); sp.setSpan(new StrikethroughSpan(), 0, product_price.getText().length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); product_price.setText(sp); btn_buy_licensekey.setOnClickListener(this); tv_bind.setOnClickListener(this); }
From source file:com.google.zxing.client.android.result.supplement.SupplementalInfoRetriever.java
final void append(String itemID, String source, String[] newTexts, String linkURL) throws InterruptedException { final TextView textView = textViewRef.get(); if (textView == null) { throw new InterruptedException(); }//from w w w.ja va2s.c om StringBuilder newTextCombined = new StringBuilder(); if (source != null) { newTextCombined.append(source).append(" : "); } int linkStart = newTextCombined.length(); boolean first = true; for (String newText : newTexts) { if (first) { newTextCombined.append(newText); first = false; } else { newTextCombined.append(" ["); newTextCombined.append(newText); newTextCombined.append(']'); } } int linkEnd = newTextCombined.length(); String newText = newTextCombined.toString(); final Spannable content = new SpannableString(newText + "\n\n"); if (linkURL != null) { content.setSpan(new URLSpan(linkURL), linkStart, linkEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } handler.post(new Runnable() { public void run() { textView.append(content); textView.setMovementMethod(LinkMovementMethod.getInstance()); } }); // Add the text to the history. historyManager.addHistoryItemDetails(itemID, newText); }
From source file:com.joyepay.qrcode.result.supplement.SupplementalInfoRetriever.java
final void append(String itemID, String source, String[] newTexts, String linkURL) throws InterruptedException { final TextView textView = textViewRef.get(); if (textView == null) { throw new InterruptedException(); }//w w w .j ava2 s . c om StringBuilder newTextCombined = new StringBuilder(); if (source != null) { newTextCombined.append(source).append(" : "); } int linkStart = newTextCombined.length(); boolean first = true; for (String newText : newTexts) { if (first) { newTextCombined.append(newText); first = false; } else { newTextCombined.append(" ["); newTextCombined.append(newText); newTextCombined.append(']'); } } int linkEnd = newTextCombined.length(); String newText = newTextCombined.toString(); final Spannable content = new SpannableString(newText + "\n\n"); if (linkURL != null) { content.setSpan(new URLSpan(linkURL), linkStart, linkEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } handler.post(new Runnable() { public void run() { textView.append(content); textView.setMovementMethod(LinkMovementMethod.getInstance()); } }); // Add the text to the history. // historyManager.addHistoryItemDetails(itemID, newText); }
From source file:com.madgag.agit.RepoListFragment.java
private void applyToEntireString(SpannableStringBuilder string, CharacterStyle style) { string.setSpan(style, 0, string.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); }
From source file:com.android.mail.browse.SubjectAndFolderView.java
public void setFolders(ConversationViewHeaderCallbacks callbacks, Account account, Conversation conv) { mVisibleFolders = true;//from ww w. j a v a 2 s .com final BidiFormatter bidiFormatter = getBidiFormatter(); final String wrappedSubject = mSubject == null ? "" : bidiFormatter.unicodeWrap(mSubject); final SpannableStringBuilder sb = new SpannableStringBuilder(wrappedSubject); sb.append('\u0020'); final Settings settings = account.settings; final int start = sb.length(); if (settings.importanceMarkersEnabled && conv.isImportant()) { sb.append(".\u0020"); sb.setSpan(new ReplacementSpan() { @Override public int getSize(Paint paint, CharSequence text, int start, int end, Paint.FontMetricsInt fm) { return mImportanceMarkerDrawable.getIntrinsicWidth(); } @Override public void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int baseline, int bottom, Paint paint) { canvas.save(); final int transY = baseline + mChipVerticalOffset - mImportanceMarkerDrawable.getIntrinsicHeight(); canvas.translate(x, transY); mImportanceMarkerDrawable.draw(canvas); canvas.restore(); } }, start, start + 1, Spanned.SPAN_INCLUSIVE_EXCLUSIVE); } mFolderDisplayer.loadConversationFolders(conv, null /* ignoreFolder */, -1 /* ignoreFolderType */); mFolderDisplayer.constructFolderChips(sb); final int end = sb.length(); sb.setSpan(new ChangeLabelsSpan(callbacks), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); setText(sb); setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:li.barter.AbstractBarterLiActivity.java
protected final void setActionBarTitle(final String title) { final SpannableString s = new SpannableString(title); s.setSpan(new TypefacedSpan(this, TypefaceCache.ALEGREYA_BLACK_ITALIC), 0, s.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); // Update the action bar title with the TypefaceSpan instance final ActionBar actionBar = getActionBar(); actionBar.setTitle(s);//from ww w . ja va2 s .c om }
From source file:io.github.marktony.espresso.mvp.companydetails.CompanyDetailFragment.java
@Override public void setCompanyTel(String tel) { this.tel = tel; String companyTel = getString(R.string.phone_number) + "\n" + tel; Spannable spannable = new SpannableStringBuilder(companyTel); spannable.setSpan(new StyleSpan(Typeface.BOLD), 0, companyTel.length() - tel.length() - 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); spannable.setSpan(new URLSpan(tel), companyTel.length() - tel.length(), companyTel.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); textViewTel.setText(spannable);//from w w w .j a va 2s . com }