List of usage examples for android.graphics Typeface ITALIC
int ITALIC
To view the source code for android.graphics Typeface ITALIC.
Click Source Link
From source file:com.github.irshulx.Components.InputExtensions.java
public void boldifyText(EditorControl tag, TextView editText, int textMode) { if (editorCore.containsStyle(tag.editorTextStyles, EditorTextStyle.BOLD)) { tag = editorCore.updateTagStyle(tag, EditorTextStyle.BOLD, Op.Delete); editText.setTypeface(getTypeface(textMode, Typeface.NORMAL)); } else if (editorCore.containsStyle(tag.editorTextStyles, EditorTextStyle.BOLDITALIC)) { tag = editorCore.updateTagStyle(tag, EditorTextStyle.BOLDITALIC, Op.Delete); tag = editorCore.updateTagStyle(tag, EditorTextStyle.ITALIC, Op.Insert); editText.setTypeface(getTypeface(textMode, Typeface.ITALIC)); } else if (editorCore.containsStyle(tag.editorTextStyles, EditorTextStyle.ITALIC)) { tag = editorCore.updateTagStyle(tag, EditorTextStyle.BOLDITALIC, Op.Insert); tag = editorCore.updateTagStyle(tag, EditorTextStyle.ITALIC, Op.Delete); editText.setTypeface(getTypeface(textMode, Typeface.BOLD_ITALIC)); } else {// www.ja v a 2s . c o m tag = editorCore.updateTagStyle(tag, EditorTextStyle.BOLD, Op.Insert); editText.setTypeface(getTypeface(textMode, Typeface.BOLD)); } editText.setTag(tag); }
From source file:org.miaowo.miaowo.util.Html.java
private static void withinParagraph(StringBuilder out, Spanned text, int start, int end, Context context) { int next;/*from ww w.j a v a 2s.c om*/ for (int i = start; i < end; i = next) { next = text.nextSpanTransition(i, end, CharacterStyle.class); CharacterStyle[] style = text.getSpans(i, next, CharacterStyle.class); for (int j = 0; j < style.length; j++) { if (style[j] instanceof StyleSpan) { int s = ((StyleSpan) style[j]).getStyle(); if ((s & Typeface.BOLD) != 0) { out.append("<b>"); } if ((s & Typeface.ITALIC) != 0) { out.append("<i>"); } } if (style[j] instanceof TypefaceSpan) { String s = ((TypefaceSpan) style[j]).getFamily(); if ("monospace".equals(s)) { out.append("<tt>"); } } if (style[j] instanceof SuperscriptSpan) { out.append("<sup>"); } if (style[j] instanceof SubscriptSpan) { out.append("<sub>"); } if (style[j] instanceof UnderlineSpan) { out.append("<u>"); } if (style[j] instanceof StrikethroughSpan) { out.append("<span style=\"text-decoration:line-through;\">"); } if (style[j] instanceof URLSpan) { out.append("<a href=\""); out.append(((URLSpan) style[j]).getURL()); out.append("\">"); } if (style[j] instanceof ImageSpan) { out.append("<img src=\""); out.append(((ImageSpan) style[j]).getSource()); out.append("\">"); // Don't output the dummy character underlying the image. i = next; } if (style[j] instanceof AbsoluteSizeSpan) { AbsoluteSizeSpan s = ((AbsoluteSizeSpan) style[j]); float sizeDip = s.getSize(); if (!s.getDip()) { sizeDip /= context.getResources().getDisplayMetrics().density; } // px in CSS is the equivalance of dip in Android out.append(String.format("<span style=\"font-size:%.0fpx\";>", sizeDip)); } if (style[j] instanceof RelativeSizeSpan) { float sizeEm = ((RelativeSizeSpan) style[j]).getSizeChange(); out.append(String.format("<span style=\"font-size:%.2fem;\">", sizeEm)); } if (style[j] instanceof ForegroundColorSpan) { int color = ((ForegroundColorSpan) style[j]).getForegroundColor(); out.append(String.format("<span style=\"color:#%06X;\">", 0xFFFFFF & color)); } if (style[j] instanceof BackgroundColorSpan) { int color = ((BackgroundColorSpan) style[j]).getBackgroundColor(); out.append(String.format("<span style=\"background-color:#%06X;\">", 0xFFFFFF & color)); } } withinStyle(out, text, i, next); for (int j = style.length - 1; j >= 0; j--) { if (style[j] instanceof BackgroundColorSpan) { out.append("</span>"); } if (style[j] instanceof ForegroundColorSpan) { out.append("</span>"); } if (style[j] instanceof RelativeSizeSpan) { out.append("</span>"); } if (style[j] instanceof AbsoluteSizeSpan) { out.append("</span>"); } if (style[j] instanceof URLSpan) { out.append("</a>"); } if (style[j] instanceof StrikethroughSpan) { out.append("</span>"); } if (style[j] instanceof UnderlineSpan) { out.append("</u>"); } if (style[j] instanceof SubscriptSpan) { out.append("</sub>"); } if (style[j] instanceof SuperscriptSpan) { out.append("</sup>"); } if (style[j] instanceof TypefaceSpan) { String s = ((TypefaceSpan) style[j]).getFamily(); if (s.equals("monospace")) { out.append("</tt>"); } } if (style[j] instanceof StyleSpan) { int s = ((StyleSpan) style[j]).getStyle(); if ((s & Typeface.BOLD) != 0) { out.append("</b>"); } if ((s & Typeface.ITALIC) != 0) { out.append("</i>"); } } } } }
From source file:com.lastsoft.plog.adapter.PlayAdapter.java
@Override public void onBindViewHolder(final ViewHolder viewHolder, final int position) { //Log.d(TAG, "Element " + position + " set."); // Get element from your dataset at this position and replace the contents of the view // with that element //if (searchQuery.equals("") || (games.get(position).gameName.toLowerCase().contains(searchQuery.toLowerCase()))) { DateFormat outputFormatter = new SimpleDateFormat("MM/dd/yyyy"); Date theDate = plays.get(position).playDate; long diff = new Date().getTime() - theDate.getTime(); long days = TimeUnit.DAYS.convert(diff, TimeUnit.MILLISECONDS); String output_date;//from ww w .j a v a 2 s .c om if (days == 0) { output_date = mActivity.getString(R.string.played_label) + mActivity.getString(R.string.less_than_a_day_ago); } else if (days == 1) { output_date = mActivity.getString(R.string.played_label) + days + mActivity.getString(R.string.day_ago_label); } else if (days <= 6) { output_date = mActivity.getString(R.string.played_label) + days + mActivity.getString(R.string.days_ago_label); } else { output_date = mActivity.getString(R.string.played_label) + outputFormatter.format(theDate); // Output : 01/20/2012 } //String output_date = outputFormatter.format(theDate); // Output : 01/20/2012 if (plays.get(position).playLocation != null) { output_date = output_date + " at " + Location.findById(Location.class, plays.get(position).playLocation.getId()).locationName; } if (plays.get(position).playNotes != null && !plays.get(position).playNotes.equals("")) { viewHolder.getPlayDescView().setVisibility(View.VISIBLE); viewHolder.getPlayDescView().setText("\"" + plays.get(position).playNotes + "\""); } else { Log.d("V1", "gone"); viewHolder.getPlayDescView().setVisibility(View.GONE); } viewHolder.getGameNameView().setText(GamesPerPlay.getBaseGame(plays.get(position)).gameName); viewHolder.getPlayDateView().setText(output_date); viewHolder.getImageView().setTransitionName("imageTrans" + position); viewHolder.getImageView().setTag("imageTrans" + position); viewHolder.getGameNameView().setTransitionName("nameTrans" + position); viewHolder.getGameNameView().setTag("nameTrans" + position); viewHolder.getPlayDateView().setTransitionName("dateTrans" + position); viewHolder.getPlayDateView().setTag("dateTrans" + position); viewHolder.getClickLayout().setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (SystemClock.elapsedRealtime() - mLastClickTime < 2000) { return; } mLastClickTime = SystemClock.elapsedRealtime(); ((MainActivity) mActivity).onPlayClicked(plays.get(position), mFragment, viewHolder.getImageView(), viewHolder.getGameNameView(), viewHolder.getPlayDateView(), position, fromDrawer, playListType, sortType, searchQuery); } }); viewHolder.getOverflowLayout().setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { playPopup(view, position); } }); String playPhoto; playPhoto = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + "/Plog/" + plays.get(position).playPhoto; if (plays.get(position).playPhoto != null && (plays.get(position).playPhoto.equals("") || new File(playPhoto).exists() == false)) { String gameThumb = GamesPerPlay.getBaseGame(plays.get(position)).gameThumb; if (gameThumb != null && !gameThumb.equals("")) { //ImageLoader.getInstance().displayImage("http:" + GamesPerPlay.getBaseGame(plays.get(position)).gameThumb, viewHolder.getImageView(), options); //ImageLoader.getInstance().loadImage("http:" + GamesPerPlay.getBaseGame(plays.get(position)).gameThumb, options, null); Picasso.with(mActivity).load("http:" + GamesPerPlay.getBaseGame(plays.get(position)).gameThumb) .fit().into(viewHolder.getImageView()); } else { viewHolder.getImageView().setImageDrawable(null); } } else { String thumbPath = playPhoto.substring(0, playPhoto.length() - 4) + "_thumb6.jpg"; if (new File(thumbPath).exists()) { //ImageLoader.getInstance().displayImage("file://" + thumbPath, viewHolder.getImageView(), options); //ImageLoader.getInstance().loadImage("file://" + playPhoto, options, null); Picasso.with(mActivity).load("file://" + thumbPath).into(viewHolder.getImageView()); } else { ImageLoader.getInstance().displayImage("file://" + playPhoto, viewHolder.getImageView(), options); //Picasso.with(mActivity).load(playPhoto).fit().into(viewHolder.getImageView()); // make a thumb String thumbPath2 = playPhoto.substring(0, playPhoto.length() - 4) + "_thumb6.jpg"; try { FileInputStream fis; fis = new FileInputStream(playPhoto); Bitmap imageBitmap = BitmapFactory.decodeStream(fis); Bitmap b = resizeImageForImageView(imageBitmap, 500); if (b != null) { try { b.compress(Bitmap.CompressFormat.JPEG, 100, new FileOutputStream(new File(thumbPath2))); } catch (Exception ignored) { } b = null; } if (imageBitmap != null) { imageBitmap = null; } Picasso.with(mActivity).load("file://" + thumbPath2).resize(500, 500).centerCrop() .into(viewHolder.getImageView()); } catch (Exception e) { e.printStackTrace(); } //still use the og picture. next time there will be a thumb } //Picasso.with(mActivity).load(playPhoto).fetch(); //ImageLoader.getInstance().loadImage(playPhoto, options, null); } viewHolder.getPlayWinnerView().setTypeface(null, Typeface.ITALIC); /*if (plays.get(position).winners != null) { viewHolder.getPlayWinnerView().setText(mActivity.getString(R.string.winners) + plays.get(position).winners); }else{*/ String winners = Play.getWinners(plays.get(position)); if (winners == null) { viewHolder.getPlayWinnerView() .setText(mActivity.getString(R.string.winners) + mActivity.getString(R.string.none)); } else { viewHolder.getPlayWinnerView().setText(mActivity.getString(R.string.winners) + winners); } //} }
From source file:com.nttec.everychan.ui.presentation.HtmlParser.java
private void handleEndTag(String tag) { if (tag.equalsIgnoreCase("br")) { handleBr(mSpannableStringBuilder); } else if (tag.equalsIgnoreCase("p")) { handleP(mSpannableStringBuilder, mStartLength, mLastPTagLength); } else if (tag.equalsIgnoreCase("div")) { handleP(mSpannableStringBuilder, mStartLength, mLastPTagLength); } else if (tag.equalsIgnoreCase("strong")) { end(mSpannableStringBuilder, Bold.class, new StyleSpan(Typeface.BOLD)); } else if (tag.equalsIgnoreCase("b")) { end(mSpannableStringBuilder, Bold.class, new StyleSpan(Typeface.BOLD)); } else if (tag.equalsIgnoreCase("em")) { end(mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC)); } else if (tag.equalsIgnoreCase("cite")) { end(mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC)); } else if (tag.equalsIgnoreCase("dfn")) { end(mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC)); } else if (tag.equalsIgnoreCase("i")) { end(mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC)); } else if (tag.equalsIgnoreCase("s")) { end(mSpannableStringBuilder, Strike.class, new StrikethroughSpan()); } else if (tag.equalsIgnoreCase("strike")) { end(mSpannableStringBuilder, Strike.class, new StrikethroughSpan()); } else if (tag.equalsIgnoreCase("del")) { end(mSpannableStringBuilder, Strike.class, new StrikethroughSpan()); } else if (tag.equalsIgnoreCase("big")) { end(mSpannableStringBuilder, Big.class, new RelativeSizeSpan(1.25f)); } else if (tag.equalsIgnoreCase("small")) { end(mSpannableStringBuilder, Small.class, new RelativeSizeSpan(0.8f)); } else if (tag.equalsIgnoreCase("font")) { endFont(mSpannableStringBuilder); } else if (tag.equalsIgnoreCase("blockquote")) { handleP(mSpannableStringBuilder, mStartLength, mLastPTagLength); endBlockquote(mSpannableStringBuilder, mColors); } else if (tag.equalsIgnoreCase("tt")) { end(mSpannableStringBuilder, Monospace.class, new TypefaceSpan("monospace")); } else if (tag.equalsIgnoreCase("code")) { end(mSpannableStringBuilder, Monospace.class, new TypefaceSpan("monospace")); } else if (tag.equalsIgnoreCase("ul")) { if (!mListTags.isEmpty()) mListTags.removeFirst();// w w w. jav a 2 s . com } else if (tag.equalsIgnoreCase("ol")) { if (!mListTags.isEmpty()) mListTags.removeFirst(); } else if (tag.equalsIgnoreCase("li")) { //?? ?? <li> } else if (tag.equalsIgnoreCase("tr")) { handleTr(mSpannableStringBuilder, false); } else if (tag.equalsIgnoreCase("td")) { handleTd(mSpannableStringBuilder, false); } else if (tag.equalsIgnoreCase("a")) { endA(mSpannableStringBuilder); } else if (tag.equalsIgnoreCase("u")) { end(mSpannableStringBuilder, Underline.class, new UnderlineSpan()); } else if (tag.equalsIgnoreCase("sup")) { end(mSpannableStringBuilder, Super.class, new SuperscriptSpan()); } else if (tag.equalsIgnoreCase("sub")) { end(mSpannableStringBuilder, Sub.class, new SubscriptSpan()); } else if (tag.length() == 2 && Character.toLowerCase(tag.charAt(0)) == 'h' && tag.charAt(1) >= '1' && tag.charAt(1) <= '6') { handleP(mSpannableStringBuilder, mStartLength, mLastPTagLength); endHeader(mSpannableStringBuilder); } else if (tag.equalsIgnoreCase("span")) { endSpan(mSpannableStringBuilder, mColors, mOpenSpoilers); } else if (tag.equalsIgnoreCase("aibquote")) { end(mSpannableStringBuilder, Aibquote.class, new ForegroundColorSpan(mColors != null ? mColors.quoteForeground : Color.GREEN)); } else if (tag.equalsIgnoreCase("aibspoiler")) { endAibspoiler(mSpannableStringBuilder, mColors, mOpenSpoilers); } /* else if (mTagHandler != null) { mTagHandler.handleTag(false, tag, mSpannableStringBuilder, mReader); }*/ }
From source file:com.github.irshulx.Components.InputExtensions.java
public void italicizeText(EditorControl tag, TextView editText, int textMode) { if (editorCore.containsStyle(tag.editorTextStyles, EditorTextStyle.ITALIC)) { tag = editorCore.updateTagStyle(tag, EditorTextStyle.ITALIC, Op.Delete); editText.setTypeface(getTypeface(textMode, Typeface.NORMAL)); } else if (editorCore.containsStyle(tag.editorTextStyles, EditorTextStyle.BOLDITALIC)) { tag = editorCore.updateTagStyle(tag, EditorTextStyle.BOLDITALIC, Op.Delete); tag = editorCore.updateTagStyle(tag, EditorTextStyle.BOLD, Op.Insert); editText.setTypeface(getTypeface(textMode, Typeface.BOLD)); } else if (editorCore.containsStyle(tag.editorTextStyles, EditorTextStyle.BOLD)) { tag = editorCore.updateTagStyle(tag, EditorTextStyle.BOLDITALIC, Op.Insert); tag = editorCore.updateTagStyle(tag, EditorTextStyle.BOLD, Op.Delete); editText.setTypeface(getTypeface(textMode, Typeface.BOLD_ITALIC)); } else {/*from w ww . j a v a2s .c om*/ tag = editorCore.updateTagStyle(tag, EditorTextStyle.ITALIC, Op.Insert); editText.setTypeface(getTypeface(textMode, Typeface.ITALIC)); } editText.setTag(tag); }
From source file:com.juick.android.JuickMessagesAdapter.java
public static ParsedMessage formatMessageText(final Context ctx, final JuickMessage jmsg, boolean condensed) { if (jmsg.parsedText != null) { return (ParsedMessage) jmsg.parsedText; // was parsed before }/*from w w w . j av a 2 s .c o m*/ getColorTheme(ctx); SpannableStringBuilder ssb = new SpannableStringBuilder(); int spanOffset = 0; final boolean isMainMessage = jmsg.getRID() == 0; final boolean doCompactComment = !isMainMessage && compactComments; if (jmsg.continuationInformation != null) { ssb.append(jmsg.continuationInformation + "\n"); ssb.setSpan(new StyleSpan(Typeface.ITALIC), spanOffset, ssb.length() - 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } // // NAME // spanOffset = ssb.length(); String name = '@' + jmsg.User.UName; int userNameStart = ssb.length(); ssb.append(name); int userNameEnd = ssb.length(); StyleSpan userNameBoldSpan; ForegroundColorSpan userNameColorSpan; ssb.setSpan(userNameBoldSpan = new StyleSpan(Typeface.BOLD), spanOffset, ssb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); ssb.setSpan( userNameColorSpan = new ForegroundColorSpan( colorTheme.getColor(ColorsTheme.ColorKey.USERNAME, 0xFFC8934E)), spanOffset, ssb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); if (helvNueFonts) { ssb.setSpan(new CustomTypefaceSpan("", JuickAdvancedApplication.helvNueBold), spanOffset, ssb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } ssb.append(' '); spanOffset = ssb.length(); if (!condensed) { // // TAGS // String tags = jmsg.getTags(); if (feedlyFonts) tags = tags.toUpperCase(); ssb.append(tags + "\n"); if (tags.length() > 0) { ssb.setSpan(new ForegroundColorSpan(colorTheme.getColor(ColorsTheme.ColorKey.TAGS, 0xFF0000CC)), spanOffset, ssb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); if (feedlyFonts) { ssb.setSpan(new CustomTypefaceSpan("", JuickAdvancedApplication.dinWebPro), spanOffset, ssb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } else if (helvNueFonts) { ssb.setSpan(new CustomTypefaceSpan("", JuickAdvancedApplication.helvNue), spanOffset, ssb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } } spanOffset = ssb.length(); } if (jmsg.translated) { // // 'translated' // ssb.append("translated: "); ssb.setSpan( new ForegroundColorSpan(colorTheme.getColor(ColorsTheme.ColorKey.TRANSLATED_LABEL, 0xFF4ec856)), spanOffset, ssb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); ssb.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), spanOffset, ssb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); spanOffset = ssb.length(); } int bodyOffset = ssb.length(); int messageNumberStart = -1, messageNumberEnd = -1; if (showNumbers(ctx) && !condensed) { // // numbers // if (isMainMessage) { messageNumberStart = ssb.length(); ssb.append(jmsg.getDisplayMessageNo()); messageNumberEnd = ssb.length(); } else { ssb.append("/" + jmsg.getRID()); if (jmsg.getReplyTo() != 0) { ssb.append("->" + jmsg.getReplyTo()); } } ssb.append(" "); ssb.setSpan(new ForegroundColorSpan(colorTheme.getColor(ColorsTheme.ColorKey.MESSAGE_ID, 0xFFa0a5bd)), spanOffset, ssb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); spanOffset = ssb.length(); } // // MESSAGE BODY // String txt = Censor.getCensoredText(jmsg.Text); if (!condensed) { if (jmsg.Photo != null) { txt = jmsg.Photo + "\n" + txt; } if (jmsg.Video != null) { txt = jmsg.Video + "\n" + txt; } } ssb.append(txt); boolean ssbChanged = false; // allocation optimization // Highlight links http://example.com/ ArrayList<ExtractURLFromMessage.FoundURL> foundURLs = ExtractURLFromMessage.extractUrls(txt, jmsg.getMID()); ArrayList<String> urls = new ArrayList<String>(); for (ExtractURLFromMessage.FoundURL foundURL : foundURLs) { setSSBSpan(ssb, new ForegroundColorSpan(colorTheme.getColor(ColorsTheme.ColorKey.URLS, 0xFF0000CC)), spanOffset + foundURL.start, spanOffset + foundURL.end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); urls.add(foundURL.url); if (foundURL.title != null) { ssb.replace(spanOffset + foundURL.title.start - 1, spanOffset + foundURL.title.start, " "); ssb.replace(spanOffset + foundURL.title.end, spanOffset + foundURL.title.end + 1, " "); ssb.replace(spanOffset + foundURL.start - 1, spanOffset + foundURL.start, "("); ssb.replace(spanOffset + foundURL.end, spanOffset + foundURL.end + 1, ")"); ssb.setSpan(new StyleSpan(Typeface.BOLD), spanOffset + foundURL.title.start, spanOffset + foundURL.title.end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } ssbChanged = true; } // bold italic underline if (jmsg.Text.indexOf("*") != -1) { setStyleSpans(ssb, spanOffset, Typeface.BOLD, "*"); ssbChanged = true; } if (jmsg.Text.indexOf("/") != 0) { setStyleSpans(ssb, spanOffset, Typeface.ITALIC, "/"); ssbChanged = true; } if (jmsg.Text.indexOf("_") != 0) { setStyleSpans(ssb, spanOffset, UnderlineSpan.class, "_"); ssbChanged = true; } if (ssbChanged) { txt = ssb.subSequence(spanOffset, ssb.length()).toString(); // ssb was modified in between } // Highlight nick String accountName = XMPPService.getMyAccountName(jmsg.getMID(), ctx); if (accountName != null) { int scan = spanOffset; String nickScanArea = (ssb + " ").toUpperCase(); while (true) { int myNick = nickScanArea.indexOf("@" + accountName.toUpperCase(), scan); if (myNick != -1) { if (!isNickPart(nickScanArea.charAt(myNick + accountName.length() + 1))) { setSSBSpan(ssb, new BackgroundColorSpan( colorTheme.getColor(ColorsTheme.ColorKey.USERNAME_ME, 0xFF938e00)), myNick - 1, myNick + accountName.length() + 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } scan = myNick + 1; } else { break; } } } // Highlight messages #1234 int pos = 0; Matcher m = getCrossReferenceMsgPattern(jmsg.getMID()).matcher(txt); while (m.find(pos)) { ssb.setSpan(new ForegroundColorSpan(colorTheme.getColor(ColorsTheme.ColorKey.URLS, 0xFF0000CC)), spanOffset + m.start(), spanOffset + m.end(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); pos = m.end(); } SpannableStringBuilder compactDt = null; if (!condensed) { // found messages count (search results) if (jmsg.myFoundCount != 0 || jmsg.hisFoundCount != 0) { ssb.append("\n"); int where = ssb.length(); if (jmsg.myFoundCount != 0) { ssb.append(ctx.getString(R.string.MyReplies_) + jmsg.myFoundCount + " "); } if (jmsg.hisFoundCount != 0) { ssb.append(ctx.getString(R.string.UserReplies_) + jmsg.hisFoundCount); } ssb.setSpan( new ForegroundColorSpan( colorTheme.getColor(ColorsTheme.ColorKey.TRANSLATED_LABEL, 0xFF4ec856)), where, ssb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } int rightPartOffset = spanOffset = ssb.length(); if (!doCompactComment) { // // TIME (bottom of message) // try { DateFormat df = new SimpleDateFormat("HH:mm dd/MMM/yy"); String date = jmsg.Timestamp != null ? df.format(jmsg.Timestamp) : "[bad date]"; if (date.endsWith("/76")) date = date.substring(0, date.length() - 3); // special case for no year in datasource ssb.append("\n" + date + " "); } catch (Exception e) { ssb.append("\n[fmt err] "); } ssb.setSpan(new ForegroundColorSpan(colorTheme.getColor(ColorsTheme.ColorKey.DATE, 0xFFAAAAAA)), spanOffset, ssb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } else { compactDt = new SpannableStringBuilder(); try { if (true || jmsg.deltaTime != Long.MIN_VALUE) { compactDt.append(com.juickadvanced.Utils.toRelaviteDate(jmsg.Timestamp.getTime(), russian)); } else { DateFormat df = new SimpleDateFormat("HH:mm dd/MMM/yy"); String date = jmsg.Timestamp != null ? df.format(jmsg.Timestamp) : "[bad date]"; if (date.endsWith("/76")) date = date.substring(0, date.length() - 3); // special case for no year in datasource compactDt.append(date); } } catch (Exception e) { compactDt.append("\n[fmt err] "); } compactDt.setSpan( new ForegroundColorSpan(colorTheme.getColor(ColorsTheme.ColorKey.DATE, 0xFFAAAAAA)), 0, compactDt.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } spanOffset = ssb.length(); // // Number of REPLIES // if (jmsg.replies > 0) { String replies = Replies + jmsg.replies; ssb.append(" " + replies); ssb.setSpan( new ForegroundColorSpan( colorTheme.getColor(ColorsTheme.ColorKey.NUMBER_OF_COMMENTS, 0xFFC8934E)), spanOffset, ssb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); ssb.setSpan(new WrapTogetherSpan() { }, spanOffset, ssb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } if (!doCompactComment) { // right align ssb.setSpan(new AlignmentSpan.Standard(Alignment.ALIGN_OPPOSITE), rightPartOffset, ssb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } } if (helvNueFonts) { ssb.setSpan(new CustomTypefaceSpan("", JuickAdvancedApplication.helvNue), bodyOffset, ssb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } LeadingMarginSpan.LeadingMarginSpan2 userpicSpan = null; if (showUserpics(ctx) && !condensed) { userpicSpan = new LeadingMarginSpan.LeadingMarginSpan2() { @Override public int getLeadingMarginLineCount() { if (_wrapUserpics) { return 2; } else { return 22222; } } @Override public int getLeadingMargin(boolean first) { if (first) { return (int) (2 * getLineHeight(ctx, (double) textScale)); } else { return 0; } } @Override public void drawLeadingMargin(Canvas c, Paint p, int x, int dir, int top, int baseline, int bottom, CharSequence text, int start, int end, boolean first, Layout layout) { } }; ssb.setSpan(userpicSpan, 0, ssb.length(), 0); } ParsedMessage parsedMessage = new ParsedMessage(ssb, urls); parsedMessage.userpicSpan = userpicSpan; parsedMessage.userNameBoldSpan = userNameBoldSpan; parsedMessage.userNameColorSpan = userNameColorSpan; parsedMessage.userNameStart = userNameStart; parsedMessage.userNameEnd = userNameEnd; parsedMessage.messageNumberStart = messageNumberStart; parsedMessage.messageNumberEnd = messageNumberEnd; parsedMessage.compactDate = compactDt; return parsedMessage; }
From source file:com.anysoftkeyboard.keyboards.views.AnyKeyboardViewBase.java
protected boolean setValueFromTheme(TypedArray remoteTypedArray, final int[] padding, final int localAttrId, final int remoteTypedArrayIndex) { try {//from w ww . j av a2s. c om switch (localAttrId) { case android.R.attr.background: Drawable keyboardBackground = remoteTypedArray.getDrawable(remoteTypedArrayIndex); if (keyboardBackground == null) return false; CompatUtils.setViewBackgroundDrawable(this, keyboardBackground); break; case android.R.attr.paddingLeft: padding[0] = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, -1); if (padding[0] == -1) return false; break; case android.R.attr.paddingTop: padding[1] = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, -1); if (padding[1] == -1) return false; break; case android.R.attr.paddingRight: padding[2] = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, -1); if (padding[2] == -1) return false; break; case android.R.attr.paddingBottom: padding[3] = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, -1); if (padding[3] == -1) return false; break; case R.attr.keyBackground: mKeyBackground = remoteTypedArray.getDrawable(remoteTypedArrayIndex); if (mKeyBackground == null) return false; break; case R.attr.keyHysteresisDistance: mKeyHysteresisDistance = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, -1); if (mKeyHysteresisDistance == -1) return false; break; case R.attr.verticalCorrection: mOriginalVerticalCorrection = mVerticalCorrection = remoteTypedArray .getDimensionPixelOffset(remoteTypedArrayIndex, -1); if (mOriginalVerticalCorrection == -1) return false; break; case R.attr.keyTextSize: mKeyTextSize = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, -1); if (mKeyTextSize == -1) return false; // you might ask yourself "why did Menny sqrt root the factor?" // I'll tell you; the factor is mostly for the height, not the // font size, // but I also factorize the font size because I want the text to // be a little like // the key size. // the whole factor maybe too much, so I ease that a bit. if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) mKeyTextSize = (float) (mKeyTextSize * Math.sqrt(AnyApplication.getConfig().getKeysHeightFactorInLandscape())); else mKeyTextSize = (float) (mKeyTextSize * Math.sqrt(AnyApplication.getConfig().getKeysHeightFactorInPortrait())); Logger.d(TAG, "AnySoftKeyboardTheme_keyTextSize " + mKeyTextSize); break; case R.attr.keyTextColor: mKeyTextColor = remoteTypedArray.getColorStateList(remoteTypedArrayIndex); if (mKeyTextColor == null) { mKeyTextColor = new ColorStateList(new int[][] { { 0 } }, new int[] { remoteTypedArray.getColor(remoteTypedArrayIndex, 0xFF000000) }); } break; case R.attr.labelTextSize: mLabelTextSize = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, -1); if (mLabelTextSize == -1) return false; if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) mLabelTextSize = mLabelTextSize * AnyApplication.getConfig().getKeysHeightFactorInLandscape(); else mLabelTextSize = mLabelTextSize * AnyApplication.getConfig().getKeysHeightFactorInPortrait(); break; case R.attr.keyboardNameTextSize: mKeyboardNameTextSize = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, -1); if (mKeyboardNameTextSize == -1) return false; if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) mKeyboardNameTextSize = mKeyboardNameTextSize * AnyApplication.getConfig().getKeysHeightFactorInLandscape(); else mKeyboardNameTextSize = mKeyboardNameTextSize * AnyApplication.getConfig().getKeysHeightFactorInPortrait(); break; case R.attr.keyboardNameTextColor: mKeyboardNameTextColor = remoteTypedArray.getColor(remoteTypedArrayIndex, Color.WHITE); break; case R.attr.shadowColor: mShadowColor = remoteTypedArray.getColor(remoteTypedArrayIndex, 0); break; case R.attr.shadowRadius: mShadowRadius = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, 0); break; case R.attr.shadowOffsetX: mShadowOffsetX = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, 0); break; case R.attr.shadowOffsetY: mShadowOffsetY = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, 0); break; case R.attr.backgroundDimAmount: mBackgroundDimAmount = remoteTypedArray.getFloat(remoteTypedArrayIndex, -1f); if (mBackgroundDimAmount == -1f) return false; break; case R.attr.keyPreviewBackground: Drawable keyPreviewBackground = remoteTypedArray.getDrawable(remoteTypedArrayIndex); if (keyPreviewBackground == null) return false; mPreviewPopupTheme.setPreviewKeyBackground(keyPreviewBackground); break; case R.attr.keyPreviewTextColor: mPreviewPopupTheme.setPreviewKeyTextColor(remoteTypedArray.getColor(remoteTypedArrayIndex, 0xFFF)); break; case R.attr.keyPreviewTextSize: mPreviewPopupTheme .setPreviewKeyTextSize(remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, 0)); break; case R.attr.keyPreviewLabelTextSize: mPreviewPopupTheme .setPreviewLabelTextSize(remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, 0)); break; case R.attr.keyPreviewOffset: mPreviewPopupTheme .setVerticalOffset(remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, 0)); break; case R.attr.previewAnimationType: int previewAnimationType = remoteTypedArray.getInteger(remoteTypedArrayIndex, -1); if (previewAnimationType == -1) return false; mPreviewPopupTheme.setPreviewAnimationType(previewAnimationType); break; case R.attr.keyTextStyle: int textStyle = remoteTypedArray.getInt(remoteTypedArrayIndex, 0); switch (textStyle) { case 0: mKeyTextStyle = Typeface.DEFAULT; break; case 1: mKeyTextStyle = Typeface.DEFAULT_BOLD; break; case 2: mKeyTextStyle = Typeface.defaultFromStyle(Typeface.ITALIC); break; default: mKeyTextStyle = Typeface.defaultFromStyle(textStyle); break; } mPreviewPopupTheme.setKeyStyle(mKeyTextStyle); break; case R.attr.keyHorizontalGap: float themeHorizontalKeyGap = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, -1); if (themeHorizontalKeyGap == -1) return false; mKeyboardDimens.setHorizontalKeyGap(themeHorizontalKeyGap); break; case R.attr.keyVerticalGap: float themeVerticalRowGap = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, -1); if (themeVerticalRowGap == -1) return false; mKeyboardDimens.setVerticalRowGap(themeVerticalRowGap); break; case R.attr.keyNormalHeight: int themeNormalKeyHeight = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, -1); if (themeNormalKeyHeight == -1) return false; mKeyboardDimens.setNormalKeyHeight(themeNormalKeyHeight); break; case R.attr.keyLargeHeight: int themeLargeKeyHeight = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, -1); if (themeLargeKeyHeight == -1) return false; mKeyboardDimens.setLargeKeyHeight(themeLargeKeyHeight); break; case R.attr.keySmallHeight: int themeSmallKeyHeight = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, -1); if (themeSmallKeyHeight == -1) return false; mKeyboardDimens.setSmallKeyHeight(themeSmallKeyHeight); break; case R.attr.hintTextSize: mHintTextSize = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, -1); if (mHintTextSize == -1) return false; if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) mHintTextSize = mHintTextSize * AnyApplication.getConfig().getKeysHeightFactorInLandscape(); else mHintTextSize = mHintTextSize * AnyApplication.getConfig().getKeysHeightFactorInPortrait(); break; case R.attr.hintTextColor: mHintTextColor = remoteTypedArray.getColorStateList(remoteTypedArrayIndex); if (mHintTextColor == null) { mHintTextColor = new ColorStateList(new int[][] { { 0 } }, new int[] { remoteTypedArray.getColor(remoteTypedArrayIndex, 0xFF000000) }); } break; case R.attr.hintLabelVAlign: mHintLabelVAlign = remoteTypedArray.getInt(remoteTypedArrayIndex, Gravity.BOTTOM); break; case R.attr.hintLabelAlign: mHintLabelAlign = remoteTypedArray.getInt(remoteTypedArrayIndex, Gravity.RIGHT); break; case R.attr.hintOverflowLabel: mHintOverflowLabel = remoteTypedArray.getString(remoteTypedArrayIndex); break; } return true; } catch (Exception e) { // on API changes, so the incompatible themes wont crash me.. e.printStackTrace(); return false; } }
From source file:info.guardianproject.otr.app.im.app.MessageView.java
private CharSequence formatPresenceUpdates(String contact, int type, boolean isGroupChat, boolean scrolling) { String body;//from w w w . j a v a2 s. c o m Resources resources = getResources(); switch (type) { case Imps.MessageType.PRESENCE_AVAILABLE: body = resources.getString(isGroupChat ? R.string.contact_joined : R.string.contact_online, contact); break; case Imps.MessageType.PRESENCE_AWAY: body = resources.getString(R.string.contact_away, contact); break; case Imps.MessageType.PRESENCE_DND: body = resources.getString(R.string.contact_busy, contact); break; case Imps.MessageType.PRESENCE_UNAVAILABLE: body = resources.getString(isGroupChat ? R.string.contact_left : R.string.contact_offline, contact); break; default: return null; } if (scrolling) { return body; } else { SpannableString spanText = new SpannableString(body); int len = spanText.length(); spanText.setSpan(new StyleSpan(Typeface.ITALIC), 0, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); spanText.setSpan(new RelativeSizeSpan((float) 0.8), 0, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); return spanText; } }
From source file:io.plaidapp.ui.HomeActivity.java
private void setNoFiltersEmptyTextVisibility(int visibility) { if (visibility == View.VISIBLE) { if (noFiltersEmptyText == null) { // create the no filters empty text ViewStub stub = (ViewStub) findViewById(R.id.stub_no_filters); noFiltersEmptyText = (TextView) stub.inflate(); String emptyText = getString(R.string.no_filters_selected); int filterPlaceholderStart = emptyText.indexOf('\u08B4'); int altMethodStart = filterPlaceholderStart + 3; SpannableStringBuilder ssb = new SpannableStringBuilder(emptyText); // show an image of the filter icon ssb.setSpan(new ImageSpan(this, R.drawable.ic_filter_small, ImageSpan.ALIGN_BASELINE), filterPlaceholderStart, filterPlaceholderStart + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); // make the alt method (swipe from right) less prominent and italic ssb.setSpan(new ForegroundColorSpan(ContextCompat.getColor(this, R.color.text_secondary_light)), altMethodStart, emptyText.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); ssb.setSpan(new StyleSpan(Typeface.ITALIC), altMethodStart, emptyText.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); noFiltersEmptyText.setText(ssb); noFiltersEmptyText.setOnClickListener(new View.OnClickListener() { @Override//from ww w .ja v a 2 s. c om public void onClick(View v) { drawer.openDrawer(GravityCompat.END); } }); } noFiltersEmptyText.setVisibility(visibility); } else if (noFiltersEmptyText != null) { noFiltersEmptyText.setVisibility(visibility); } }
From source file:com.sigilance.CardEdit.MainActivity.java
private void populateSimpleField(int id, String text) { TextView textView = findTextViewById(id); if (text.equals("") || text.equals(BLANK_FINGERPRINT)) { textView.setText(R.string.lbl_empty); textView.setTypeface(null, Typeface.ITALIC); } else {//from www . j a v a 2s.c o m textView.setText(text); textView.setTypeface(null, Typeface.NORMAL); } }