List of usage examples for android.text.style TextAppearanceSpan TextAppearanceSpan
public TextAppearanceSpan(Context context, int appearance)
From source file:com.tct.mail.browse.SendersView.java
private static synchronized void getSenderResources(Context context, final boolean resourceCachingRequired) { if (sConfigurationChangedReceiver == null && resourceCachingRequired) { sConfigurationChangedReceiver = new BroadcastReceiver() { @Override//from w w w.ja v a2 s . com public void onReceive(Context context, Intent intent) { sDraftSingularString = null; getSenderResources(context, true); } }; context.registerReceiver(sConfigurationChangedReceiver, new IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED)); } if (sDraftSingularString == null) { Resources res = context.getResources(); sSendersSplitToken = res.getString(R.string.senders_split_token); sElidedString = res.getString(R.string.senders_elided); sDraftSingularString = res.getQuantityText(R.plurals.draft, 1); sDraftPluralString = res.getQuantityText(R.plurals.draft, 2); sDraftCountFormatString = res.getString(R.string.draft_count_format); sMeSubjectString = res.getString(R.string.me_subject_pronoun); sMeObjectString = res.getString(R.string.me_object_pronoun); sToHeaderString = res.getString(R.string.to_heading); sMessageInfoUnreadStyleSpan = new TextAppearanceSpan(context, R.style.MessageInfoUnreadTextAppearance); sMessageInfoReadStyleSpan = new TextAppearanceSpan(context, R.style.MessageInfoReadTextAppearance); sDraftsStyleSpan = new TextAppearanceSpan(context, R.style.DraftTextAppearance); sUnreadStyleSpan = new TextAppearanceSpan(context, R.style.SendersAppearanceUnreadStyle); sSendingStyleSpan = new TextAppearanceSpan(context, R.style.SendingTextAppearance); sQueuedStyleSpan = new TextAppearanceSpan(context, R.style.RetryingTextAppearance); sFailedStyleSpan = new TextAppearanceSpan(context, R.style.FailedTextAppearance); sReadStyleSpan = new TextAppearanceSpan(context, R.style.SendersAppearanceReadStyle); sMessageCountSpacerString = res.getString(R.string.message_count_spacer); sSendingString = res.getString(R.string.sending); sQueuedString = res.getString(R.string.message_retrying); sFailedString = res.getString(R.string.message_failed); sBidiFormatter = BidiFormatter.getInstance(); } }
From source file:com.google.android.gm.ay.java
public static void a(final Context context, final String s, final String s2, final long n, final int n2) { final List<String> b = com.google.android.gm.persistence.b.DD().b(context, true); int size;/*from ww w .j a v a 2 s .c o m*/ if (b != null && b.size() > 0) { size = b.size(); } else { size = 1; } final String quantityString = context.getResources().getQuantityString(n2, size); final ab ab = new ab(context); if (size > 1) { final String string = context.getResources().getString(2131297166, new Object[] { s }); final SpannableString spannableString = new SpannableString( (CharSequence) String.format(quantityString, string)); final int index = spannableString.toString().indexOf(string); spannableString.setSpan((Object) new TextAppearanceSpan(context, 2131231210), index, index + string.length(), 0); ab.b((CharSequence) spannableString); ab.e((CharSequence) spannableString); } else { ab.b(quantityString); ab.e((CharSequence) quantityString); } final int hashCode = Arrays.hashCode(new Object[] { n, s2 }); final Account x = x(context, s); final Folder h = h(context, s, "^^out"); Intent a; if (h == null || s == null) { E.f(ay.mW, "Null account or folder. account: %s folder: %s", x, h); a = null; } else { a = ag.a(context, h.azZ.aPj, x); } final NotificationManager notificationManager = (NotificationManager) context .getSystemService("notification"); ab.h(17301624); ab.a(System.currentTimeMillis()); ab.c(s2); ab.a(PendingIntent.getActivity(context, -1, a, 0)); ArrayList<Integer> list = ay.aZj.get(s); if (list == null) { list = new ArrayList<Integer>(); } list.add(hashCode); ay.aZj.put(s, list); notificationManager.notify(hashCode, ab.build()); }
From source file:com.android.mms.ui.ConversationListItem.java
private CharSequence formatMessage() { final int color = android.R.styleable.Theme_textColorSecondary; String from = mConversation.getRecipients().formatNames(", "); if (MessageUtils.isWapPushNumber(from)) { String[] mAddresses = from.split(":"); from = mAddresses[mContext.getResources().getInteger(R.integer.wap_push_address_index)]; }/*from ww w . j ava2s. c o m*/ /** * Add boolean to know that the "from" haven't the Arabic and '+'. * Make sure the "from" display normally for RTL. */ boolean isEnName = false; boolean isLayoutRtl = (TextUtils .getLayoutDirectionFromLocale(Locale.getDefault()) == View.LAYOUT_DIRECTION_RTL); if (isLayoutRtl && from != null) { if (from.length() >= 1) { Pattern pattern = Pattern.compile("[^-]+"); Matcher matcher = pattern.matcher(from); isEnName = matcher.matches(); if (isEnName && from.charAt(0) != '\u202D') { from = "\u202D" + from + "\u202C"; } } } SpannableStringBuilder buf = new SpannableStringBuilder(from); if (mConversation.getMessageCount() > 1) { int before = buf.length(); if (isLayoutRtl && isEnName) { buf.insert(1, mConversation.getMessageCount() + " "); buf.setSpan(new ForegroundColorSpan(mContext.getResources().getColor(R.color.message_count_color)), 1, buf.length() - before, Spannable.SPAN_INCLUSIVE_EXCLUSIVE); } else { buf.append(mContext.getResources().getString(R.string.message_count_format, mConversation.getMessageCount())); buf.setSpan(new ForegroundColorSpan(mContext.getResources().getColor(R.color.message_count_color)), before, buf.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE); } } if (mConversation.hasDraft()) { if (isLayoutRtl && isEnName) { int before = buf.length(); buf.insert(1, '\u202E' + mContext.getResources().getString(R.string.draft_separator) + '\u202C'); buf.setSpan(new ForegroundColorSpan(mContext.getResources().getColor(R.drawable.text_color_black)), 1, buf.length() - before + 1, Spannable.SPAN_INCLUSIVE_EXCLUSIVE); before = buf.length(); int size; buf.insert(1, mContext.getResources().getString(R.string.has_draft)); size = android.R.style.TextAppearance_Small; buf.setSpan(new TextAppearanceSpan(mContext, size), 1, buf.length() - before + 1, Spannable.SPAN_INCLUSIVE_EXCLUSIVE); buf.setSpan(new ForegroundColorSpan(mContext.getResources().getColor(R.drawable.text_color_red)), 1, buf.length() - before + 1, Spannable.SPAN_INCLUSIVE_EXCLUSIVE); } else { buf.append(mContext.getResources().getString(R.string.draft_separator)); int before = buf.length(); int size; buf.append(mContext.getResources().getString(R.string.has_draft)); size = android.R.style.TextAppearance_Small; buf.setSpan(new TextAppearanceSpan(mContext, size, color), before, buf.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE); buf.setSpan(new ForegroundColorSpan(mContext.getResources().getColor(R.drawable.text_color_red)), before, buf.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE); } } // Unread messages are shown in bold if (mConversation.hasUnreadMessages()) { buf.setSpan(STYLE_BOLD, 0, buf.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE); } return buf; }
From source file:com.jbirdvegas.mgerrit.cards.PatchSetPropertiesCard.java
private void setImageCaption(TextView textView, int resID, String authorName) { String title = mContext.getResources().getString(resID); if (title == null || authorName == null) return;/* w w w . j av a 2 s .c o m*/ SpannableString text = new SpannableString(title + "\n" + authorName); text.setSpan(new TextAppearanceSpan(mContext, R.style.CardText_CommitOwnerText), 0, title.length(), 0); int end = title.length() + 1; text.setSpan(new TextAppearanceSpan(mContext, R.style.CardText_CommitOwnerDetails), end, end + authorName.length(), 0); textView.setText(text, TextView.BufferType.SPANNABLE); }
From source file:org.jraf.android.dcn.handheld.app.geofencing.GeofencingService.java
private void showEnteredNotification(AddressInfo addressInfo) { Log.d("addressInfo=" + addressInfo); String titleShort = getNotificationTitle(addressInfo, false); String titleLong = getNotificationTitle(addressInfo, true); String textShort = getNotificationText(addressInfo, false); String textLong = getNotificationText(addressInfo, true); NotificationCompat.Builder mainNotifBuilder = new NotificationCompat.Builder(this); // Small icon mainNotifBuilder.setSmallIcon(R.drawable.ic_stat_entered); // Make a bigger title SpannableString titleSpannable = new SpannableString(titleShort); Object span = new TextAppearanceSpan(this, R.style.NotificationContentTitleTextAppearance); titleSpannable.setSpan(span, 0, titleShort.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); // Title//from ww w .ja v a2 s . c o m mainNotifBuilder.setContentTitle(titleSpannable); // Ticker mainNotifBuilder.setTicker(titleShort); // Text (short) mainNotifBuilder.setContentText(textShort); // Text (long) mainNotifBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(textLong)); // 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 mainNotifBuilder.setLights(0, 0, 0); // No light mainNotifBuilder.setShowWhen(false); // No date mainNotifBuilder.addPerson(addressInfo.contactInfo.contentLookupUri.toString()); // Contact photo Bitmap contactPhoto = addressInfo.getContactPhoto(this); if (contactPhoto != null) mainNotifBuilder.setLargeIcon(contactPhoto); // Dismiss intent Intent dismissIntent = new Intent(ACTION_DISMISS_NOTIFICATION, null, this, getClass()); PendingIntent dismissPendingIntent = PendingIntent.getService(this, 0, dismissIntent, PendingIntent.FLAG_UPDATE_CURRENT); mainNotifBuilder.setDeleteIntent(dismissPendingIntent); // Main action (click on the notification itself) Intent mainIntent = new Intent(Intent.ACTION_VIEW); mainIntent.setData(addressInfo.contactInfo.contentLookupUri); PendingIntent mainPendingIntent = PendingIntent.getActivity(this, 0, mainIntent, PendingIntent.FLAG_UPDATE_CURRENT); mainNotifBuilder.setContentIntent(mainPendingIntent); String phoneNumber = addressInfo.getContactPhoneNumber(this); if (phoneNumber != null) { // Call action Intent callIntent = new Intent(Intent.ACTION_DIAL); callIntent.setData(Uri.parse("tel:" + phoneNumber)); PendingIntent callPendingIntent = PendingIntent.getActivity(this, 0, callIntent, PendingIntent.FLAG_UPDATE_CURRENT); String callText = getString(R.string.notification_action_call); mainNotifBuilder.addAction(R.drawable.ic_action_call, callText, callPendingIntent); // Sms action Intent smsIntent = new Intent(Intent.ACTION_VIEW); smsIntent.setData(Uri.parse("sms:" + phoneNumber)); smsIntent.putExtra("sms_body", getString(R.string.notification_action_sms_body)); PendingIntent smsPendingIntent = PendingIntent.getActivity(this, 0, smsIntent, PendingIntent.FLAG_UPDATE_CURRENT); String smsText = getString(R.string.notification_action_sms); mainNotifBuilder.addAction(R.drawable.ic_action_sms, smsText, smsPendingIntent); } // Since we have a specific Wear notification, show this one only on handheld mainNotifBuilder.setLocalOnly(true); // Show it Notification notification = mainNotifBuilder.build(); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(NOTIFICATION_ID, notification); // Show a Wear notification // Blocking mWearHelper.connect(this); mWearHelper.putNotification(titleLong, textShort, textLong, contactPhoto, addressInfo.contactInfo.contentLookupUri, phoneNumber); }
From source file:com.battlelancer.seriesguide.ui.dialogs.AddShowDialogFragment.java
private void populateShowViews(Show show) { if (show == null) { mButtonPositive.setEnabled(false); if (!AndroidUtils.isNetworkConnected(getActivity())) { overview.setText(R.string.offline); }//from w ww . j a va 2 s .c o m return; } mButtonPositive.setEnabled(true); ButterKnife.apply(labelViews, VISIBLE, true); // title, overview title.setText(show.title); overview.setText(show.overview); SpannableStringBuilder meta = new SpannableStringBuilder(); // status boolean isContinuing = JsonExportTask.ShowStatusExport.CONTINUING.equals(show.status); meta.append(getString(isContinuing ? R.string.show_isalive : R.string.show_isnotalive)); // if continuing, paint status green meta.setSpan( new TextAppearanceSpan(getActivity(), isContinuing ? R.style.TextAppearance_Subhead_Green : R.style.TextAppearance_Subhead_Dim), 0, meta.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); meta.append("\n"); // release day and time String[] values = TimeTools.formatToShowReleaseTimeAndDay(getActivity(), show.airtime, show.country, show.airday); meta.append(values[1]).append(" ").append(values[0]); meta.append("\n"); // network, runtime meta.append(show.network); meta.append("\n"); meta.append(getString(R.string.runtime_minutes, show.runtime)); showmeta.setText(meta); // TheTVDB rating tvdbRating.setText(show.rating > 0 ? String.valueOf(show.rating) : getString(R.string.norating)); // genres Utils.setValueOrPlaceholder(genres, Utils.splitAndKitTVDBStrings(show.genres)); // original release Utils.setValueOrPlaceholder(released, TimeTools.getShowReleaseYear(show.firstAired, show.airtime, show.country)); // poster Utils.loadPosterThumbnail(getActivity(), poster, show.poster); }
From source file:com.uwetrottmann.wpdisplay.ui.DisplayFragment.java
private void setTemperature(TextView view, int labelResId, double value) { SpannableStringBuilder builder = new SpannableStringBuilder(); builder.append(getString(labelResId)); builder.setSpan(new TextAppearanceSpan(getActivity(), R.style.TextAppearance_AppCompat_Caption), 0, builder.length(), 0);// w ww . j a va2 s . c o m builder.append("\n"); int lengthOld = builder.length(); builder.append(String.format(Locale.getDefault(), "%.1f", value)); builder.setSpan(new TextAppearanceSpan(getActivity(), R.style.TextAppearance_AppCompat_Display3), lengthOld, builder.length(), 0); lengthOld = builder.length(); builder.append(getString(R.string.unit_celsius)); builder.setSpan(new TextAppearanceSpan(getActivity(), R.style.TextAppearance_App_Unit), lengthOld, builder.length(), 0); view.setText(builder); }
From source file:com.heath_bar.tvdb.EpisodeDetails.java
/** Populate the GUI with the data we've found */ public void PopulateStuff(TvEpisode theEpisode) { // Set Title/*from ww w . ja va 2s. co m*/ TextView textview = (TextView) findViewById(R.id.title); textview.setVisibility(View.VISIBLE); textview.setText(theEpisode.getSeason() + "x" + String.format("%02d", theEpisode.getNumber()) + " " + theEpisode.getName()); // Set Thumb if (theEpisode.getImage() != null && (theEpisode.getImage().getBitmap() == null || theEpisode.getImage().getUrl().equals(""))) { // do nothin } else { imageId = theEpisode.getImage().getId(); ImageButton banner = (ImageButton) findViewById(R.id.episode_thumb); banner.setImageBitmap(theEpisode.getImage().getBitmap()); banner.setVisibility(View.VISIBLE); banner.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { shareImage(); } }); } // Overview textview = (TextView) findViewById(R.id.overview_header); textview.setVisibility(View.VISIBLE); textview = (TextView) findViewById(R.id.overview); textview.setVisibility(View.VISIBLE); textview.setText(theEpisode.getOverview()); // Director textview = (TextView) findViewById(R.id.director_header); textview.setVisibility(View.VISIBLE); textview = (TextView) findViewById(R.id.director); textview.setVisibility(View.VISIBLE); textview.setText(theEpisode.getDirector()); // Writer textview = (TextView) findViewById(R.id.writer_header); textview.setVisibility(View.VISIBLE); textview = (TextView) findViewById(R.id.writer); textview.setVisibility(View.VISIBLE); textview.setText(theEpisode.getWriter()); // Rating textview = (TextView) findViewById(R.id.rating_header); textview.setVisibility(View.VISIBLE); textview = (TextView) findViewById(R.id.rating); textview.setVisibility(View.VISIBLE); textview.setText(theEpisode.getRating() + " / 10"); // First Aired textview = (TextView) findViewById(R.id.first_aired_header); textview.setVisibility(View.VISIBLE); textview = (TextView) findViewById(R.id.first_aired); textview.setVisibility(View.VISIBLE); textview.setText(DateUtil.toString(theEpisode.getAirDate())); // Guest Stars textview = (TextView) findViewById(R.id.guest_stars_header); textview.setVisibility(View.VISIBLE); textview = (TextView) findViewById(R.id.guest_stars); textview.setVisibility(View.VISIBLE); textview.setText(theEpisode.getGuestStars()); textview = (TextView) findViewById(R.id.imdb_link); textview.setVisibility(View.VISIBLE); final String imdbId = theEpisode.getIMDB(); if (imdbId != "") { SpannableStringBuilder ssb = new SpannableStringBuilder(getResources().getString(R.string.imdb)); ssb.setSpan(new NonUnderlinedClickableSpan(getResources().getString(R.string.imdb)) { @Override public void onClick(View v) { Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.imdb.com/title/" + imdbId)); startActivity(myIntent); } }, 0, ssb.length(), 0); ssb.setSpan(new TextAppearanceSpan(this, R.style.episode_link), 0, ssb.length(), 0); // Set the style of the text textview.setText(ssb, BufferType.SPANNABLE); textview.setMovementMethod(LinkMovementMethod.getInstance()); } }
From source file:com.uwetrottmann.wpdisplay.ui.DisplayFragment.java
private void setText(TextView view, int labelResId, String value) { SpannableStringBuilder builder = new SpannableStringBuilder(); builder.append(getString(labelResId)); builder.setSpan(new TextAppearanceSpan(getActivity(), R.style.TextAppearance_AppCompat_Caption), 0, builder.length(), 0);// ww w . j ava2s .com builder.append("\n"); int lengthOld = builder.length(); builder.append(value); builder.setSpan(new TextAppearanceSpan(getActivity(), R.style.TextAppearance_AppCompat_Display1), lengthOld, builder.length(), 0); view.setText(builder); }
From source file:com.heath_bar.tvdb.EpisodeDetails.java
/** Update the GUI with the specified rating */ private void setUserRatingTextView(int rating) { TextView ratingTextView = (TextView) findViewById(R.id.rating); String communityRatingText = myEpisode.getRating() + " / 10"; String ratingTextA = communityRatingText + " ("; String ratingTextB = (rating == 0) ? "rate" : String.valueOf(rating); String ratingTextC = ")"; int start = ratingTextA.length(); int end = ratingTextA.length() + ratingTextB.length(); SpannableStringBuilder ssb = new SpannableStringBuilder(ratingTextA + ratingTextB + ratingTextC); ssb.setSpan(new NonUnderlinedClickableSpan() { @Override/*from w w w.ja v a2 s .c o m*/ public void onClick(View v) { showRatingDialog(); } }, start, end, 0); ssb.setSpan(new TextAppearanceSpan(getApplicationContext(), R.style.episode_link), start, end, 0); // Set the style of the text ratingTextView.setText(ssb, BufferType.SPANNABLE); ratingTextView.setMovementMethod(LinkMovementMethod.getInstance()); }