Java Code Examples for android.widget.TextView#setLinkTextColor()
The following examples show how to use
android.widget.TextView#setLinkTextColor() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CommentOfStatusHolder.java From YiBo with Apache License 2.0 | 6 votes |
public CommentOfStatusHolder(View convertView) { if (convertView == null) { throw new IllegalArgumentException("convertView is null!"); } tvScreenName = (TextView) convertView.findViewById(R.id.tvScreenName); tvCreatedAt = (TextView) convertView.findViewById(R.id.tvCreatedAt); tvText = (TextView) convertView.findViewById(R.id.tvText); btnCommentReply = (Button) convertView.findViewById(R.id.btnCommentReply); replyClickListener = new CommentsOfStatusReplyClickListener(); btnCommentReply.setOnClickListener(replyClickListener); //主题设置 Theme theme = ThemeUtil.createTheme(convertView.getContext()); tvScreenName.setTextColor(theme.getColor("highlight")); tvCreatedAt.setTextColor(theme.getColor("comment_time")); tvText.setTextColor(theme.getColor("content")); tvText.setLinkTextColor(theme.getColorStateList("selector_text_link")); btnCommentReply.setBackgroundDrawable(theme.getDrawable("selector_btn_comment_reply")); reset(); }
Example 2
Source File: HtmlView.java From Ruisi with Apache License 2.0 | 6 votes |
public void into(TextView target) { if (this.target == null) { this.target = new WeakReference<>(target); } if (imageGetter == null) { WindowManager wm = (WindowManager) target.getContext() .getSystemService(Context.WINDOW_SERVICE); Point p = new Point(); wm.getDefaultDisplay().getSize(p); VIEW_WIDTH = p.x - target.getPaddingStart() - target.getPaddingEnd(); imageGetter = new DefaultImageGetter(target.getContext(), VIEW_WIDTH); } if (clickListener == null) { clickListener = new DefaultClickHandler(target.getContext()); } FONT_SIZE = target.getTextSize(); spanned = SpanConverter.convert(source, imageGetter, clickListener, this); target.setMovementMethod(LinkMovementMethod.getInstance()); target.setLinkTextColor(URL_COLOR); target.setLineSpacing(0, LINE_HEIGHT); target.setText(spanned); isViewSet = true; }
Example 3
Source File: HelpFragment.java From CapturePacket with MIT License | 6 votes |
@Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { Toolbar toolbar = view.findViewById(R.id.tool_bar); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { FragmentActivity activity = getActivity(); if (activity != null) { activity.getSupportFragmentManager() .popBackStackImmediate(); } } }); TextView textView = view.findViewById(R.id.tv_content); textView.setAutoLinkMask(Linkify.WEB_URLS); textView.setLinkTextColor(0xffFF4081); textView.setLinksClickable(true); textView.setMovementMethod(LinkMovementMethod.getInstance()); }
Example 4
Source File: SettingsActivity.java From your-local-weather with GNU General Public License v3.0 | 5 votes |
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { final TextView textView = new TextView(getActivity()); int padding = (int) getResources().getDimension(R.dimen.activity_horizontal_margin); textView.setPadding(padding, padding, padding, padding); textView.setLineSpacing(0, 1.2f); textView.setLinkTextColor(ContextCompat.getColor(getActivity(), R.color.link_color)); textView.setText(R.string.licenses); textView.setMovementMethod(LinkMovementMethod.getInstance()); return new AlertDialog.Builder(getActivity()) .setTitle(getString(R.string.title_open_source_licenses)) .setView(textView) .setPositiveButton(android.R.string.ok, null) .create(); }
Example 5
Source File: AlertsCreator.java From Telegram with GNU General Public License v2.0 | 5 votes |
public static AlertDialog createSupportAlert(BaseFragment fragment) { if (fragment == null || fragment.getParentActivity() == null) { return null; } final TextView message = new TextView(fragment.getParentActivity()); Spannable spanned = new SpannableString(Html.fromHtml(LocaleController.getString("AskAQuestionInfo", R.string.AskAQuestionInfo).replace("\n", "<br>"))); URLSpan[] spans = spanned.getSpans(0, spanned.length(), URLSpan.class); for (int i = 0; i < spans.length; i++) { URLSpan span = spans[i]; int start = spanned.getSpanStart(span); int end = spanned.getSpanEnd(span); spanned.removeSpan(span); span = new URLSpanNoUnderline(span.getURL()) { @Override public void onClick(View widget) { fragment.dismissCurrentDialig(); super.onClick(widget); } }; spanned.setSpan(span, start, end, 0); } message.setText(spanned); message.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); message.setLinkTextColor(Theme.getColor(Theme.key_dialogTextLink)); message.setHighlightColor(Theme.getColor(Theme.key_dialogLinkSelection)); message.setPadding(AndroidUtilities.dp(23), 0, AndroidUtilities.dp(23), 0); message.setMovementMethod(new AndroidUtilities.LinkMovementMethodMy()); message.setTextColor(Theme.getColor(Theme.key_dialogTextBlack)); AlertDialog.Builder builder1 = new AlertDialog.Builder(fragment.getParentActivity()); builder1.setView(message); builder1.setTitle(LocaleController.getString("AskAQuestion", R.string.AskAQuestion)); builder1.setPositiveButton(LocaleController.getString("AskButton", R.string.AskButton), (dialogInterface, i) -> performAskAQuestion(fragment)); builder1.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); return builder1.create(); }
Example 6
Source File: SettingsActivity.java From good-weather with GNU General Public License v3.0 | 5 votes |
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { final TextView textView = new TextView(getActivity()); int padding = (int) getResources().getDimension(R.dimen.activity_horizontal_margin); textView.setPadding(padding, padding, padding, padding); textView.setLineSpacing(0, 1.2f); textView.setLinkTextColor(ContextCompat.getColor(getActivity(), R.color.link_color)); textView.setText(R.string.licenses); textView.setMovementMethod(LinkMovementMethod.getInstance()); return new AlertDialog.Builder(getActivity()) .setTitle("Open source licenses") .setView(textView) .setPositiveButton(android.R.string.ok, null) .create(); }
Example 7
Source File: ChatMsgAdapter.java From MaterialQQLite with Apache License 2.0 | 5 votes |
private void setBubble(TextView txtContent, ChatMsg chatMsg) { Integer nOldBubble = (Integer)txtContent.getTag(); if (null == nOldBubble || nOldBubble != chatMsg.m_nBubble) { int left = txtContent.getPaddingLeft(); int right = txtContent.getPaddingRight(); int top = txtContent.getPaddingTop(); int bottom = txtContent.getPaddingBottom(); boolean bIsUser = (ChatMsg.RIGHT == chatMsg.m_nType); boolean bUseDefBubble = true; if (chatMsg.m_nBubble != 0) { // } if (bUseDefBubble) { if (bIsUser) { txtContent.setBackgroundResource(R.drawable.btn_style7); txtContent.setTextColor(0xFFFFFFFF); txtContent.setTextIsSelectable(true); txtContent.setLinkTextColor(0xFF0000FF); } else { txtContent.setBackgroundResource(R.drawable.btn_style6); txtContent.setTextColor(0xFF000000); txtContent.setTextIsSelectable(true); txtContent.setLinkTextColor(0xFF0000FF); } txtContent.setTag(0); } txtContent.setPadding(left, top, right, bottom); } }
Example 8
Source File: Message.java From Atomic with GNU General Public License v3.0 | 5 votes |
/** * Render message as spannable string * * @return */ public TextView render(TextView convertView) { // check if we just want to return ourselves already. if(!settings.getRenderParams().equals(currentParams)) { currentParams = settings.getRenderParams(); } Message t = (Message)convertView.getTag(); if(this.equals(t) && settings.getRenderParams().equals(t.currentParams)) { return convertView; } ColorScheme currentScheme = new ColorScheme(currentParams.colorScheme, currentParams.useDarkScheme); //_cache = new SpannableString(TextUtils.concat(timeSS, prefixSS, nickSS, " ", messageSS)); convertView.setTextColor(currentScheme.getForeground()); convertView.setLinkTextColor(currentScheme.getUrl()); convertView.setText(Message.render(this, currentParams)); convertView.setTag(this); currentParams = settings.getRenderParams(); return convertView; }
Example 9
Source File: TextInfoPrivacyCell.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public TextInfoPrivacyCell(Context context, int padding) { super(context); textView = new TextView(context); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); textView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); textView.setPadding(0, AndroidUtilities.dp(10), 0, AndroidUtilities.dp(17)); textView.setMovementMethod(LinkMovementMethod.getInstance()); textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText4)); textView.setLinkTextColor(Theme.getColor(linkTextColorKey)); addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, padding, 0, padding, 0)); }
Example 10
Source File: TextInfoPrivacyCell.java From Telegram with GNU General Public License v2.0 | 5 votes |
public TextInfoPrivacyCell(Context context, int padding) { super(context); textView = new TextView(context); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); textView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); textView.setPadding(0, AndroidUtilities.dp(10), 0, AndroidUtilities.dp(17)); textView.setMovementMethod(LinkMovementMethod.getInstance()); textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText4)); textView.setLinkTextColor(Theme.getColor(linkTextColorKey)); addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, padding, 0, padding, 0)); }
Example 11
Source File: AlertsCreator.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public static AlertDialog createSupportAlert(BaseFragment fragment) { if (fragment == null || fragment.getParentActivity() == null) { return null; } final TextView message = new TextView(fragment.getParentActivity()); Spannable spanned = new SpannableString(Html.fromHtml(LocaleController.getString("AskAQuestionInfo", R.string.AskAQuestionInfo).replace("\n", "<br>"))); URLSpan[] spans = spanned.getSpans(0, spanned.length(), URLSpan.class); for (int i = 0; i < spans.length; i++) { URLSpan span = spans[i]; int start = spanned.getSpanStart(span); int end = spanned.getSpanEnd(span); spanned.removeSpan(span); span = new URLSpanNoUnderline(span.getURL()) { @Override public void onClick(View widget) { fragment.dismissCurrentDialig(); super.onClick(widget); } }; spanned.setSpan(span, start, end, 0); } message.setText(spanned); message.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); message.setLinkTextColor(Theme.getColor(Theme.key_dialogTextLink)); message.setHighlightColor(Theme.getColor(Theme.key_dialogLinkSelection)); message.setPadding(AndroidUtilities.dp(23), 0, AndroidUtilities.dp(23), 0); message.setMovementMethod(new AndroidUtilities.LinkMovementMethodMy()); message.setTextColor(Theme.getColor(Theme.key_dialogTextBlack)); AlertDialog.Builder builder1 = new AlertDialog.Builder(fragment.getParentActivity()); builder1.setView(message); builder1.setTitle(LocaleController.getString("AskAQuestion", R.string.AskAQuestion)); builder1.setPositiveButton(LocaleController.getString("AskButton", R.string.AskButton), (dialogInterface, i) -> performAskAQuestion(fragment)); builder1.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); return builder1.create(); }
Example 12
Source File: ViewUtil.java From material with Apache License 2.0 | 4 votes |
public static void applyTextAppearance(TextView v, int resId){ if(resId == 0) return; String fontFamily = null; int typefaceIndex = -1; int styleIndex = -1; int shadowColor = 0; float dx = 0, dy = 0, r = 0; TypedArray appearance = v.getContext().obtainStyledAttributes(resId, R.styleable.TextAppearance); if (appearance != null) { int n = appearance.getIndexCount(); for (int i = 0; i < n; i++) { int attr = appearance.getIndex(i); if (attr == R.styleable.TextAppearance_android_textColorHighlight) { v.setHighlightColor(appearance.getColor(attr, 0)); } else if (attr == R.styleable.TextAppearance_android_textColor) { v.setTextColor(appearance.getColorStateList(attr)); } else if (attr == R.styleable.TextAppearance_android_textColorHint) { v.setHintTextColor(appearance.getColorStateList(attr)); } else if (attr == R.styleable.TextAppearance_android_textColorLink) { v.setLinkTextColor(appearance.getColorStateList(attr)); } else if (attr == R.styleable.TextAppearance_android_textSize) { v.setTextSize(TypedValue.COMPLEX_UNIT_PX, appearance.getDimensionPixelSize(attr, 0)); } else if (attr == R.styleable.TextAppearance_android_typeface) { typefaceIndex = appearance.getInt(attr, -1); } else if (attr == R.styleable.TextAppearance_android_fontFamily) { fontFamily = appearance.getString(attr); } else if (attr == R.styleable.TextAppearance_tv_fontFamily) { fontFamily = appearance.getString(attr); } else if (attr == R.styleable.TextAppearance_android_textStyle) { styleIndex = appearance.getInt(attr, -1); } else if (attr == R.styleable.TextAppearance_android_textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) v.setAllCaps(appearance.getBoolean(attr, false)); } else if (attr == R.styleable.TextAppearance_android_shadowColor) { shadowColor = appearance.getInt(attr, 0); } else if (attr == R.styleable.TextAppearance_android_shadowDx) { dx = appearance.getFloat(attr, 0); } else if (attr == R.styleable.TextAppearance_android_shadowDy) { dy = appearance.getFloat(attr, 0); } else if (attr == R.styleable.TextAppearance_android_shadowRadius) { r = appearance.getFloat(attr, 0); } else if (attr == R.styleable.TextAppearance_android_elegantTextHeight) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) v.setElegantTextHeight(appearance.getBoolean(attr, false)); } else if (attr == R.styleable.TextAppearance_android_letterSpacing) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) v.setLetterSpacing(appearance.getFloat(attr, 0)); } else if (attr == R.styleable.TextAppearance_android_fontFeatureSettings) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) v.setFontFeatureSettings(appearance.getString(attr)); } } appearance.recycle(); } if (shadowColor != 0) v.setShadowLayer(r, dx, dy, shadowColor); Typeface tf = null; if (fontFamily != null) { tf = TypefaceUtil.load(v.getContext(), fontFamily, styleIndex); if (tf != null) v.setTypeface(tf); } if(tf != null) { switch (typefaceIndex) { case 1: tf = Typeface.SANS_SERIF; break; case 2: tf = Typeface.SERIF; break; case 3: tf = Typeface.MONOSPACE; break; } v.setTypeface(tf, styleIndex); } }
Example 13
Source File: MicroBlogActivity.java From YiBo with Apache License 2.0 | 4 votes |
public void initComponent() { LinearLayout llRoot = (LinearLayout)findViewById(R.id.llRoot); LinearLayout llHeaderBase = (LinearLayout)findViewById(R.id.llHeaderBase); ThemeUtil.setRootBackground(llRoot); ThemeUtil.setSecondaryMicroBlogHeader(llHeaderBase); //资料头部 LayoutInflater inflater = LayoutInflater.from(this); View headerView = inflater.inflate(R.layout.include_micro_blog_list_header, null); LinearLayout llProfileHeader = (LinearLayout)headerView.findViewById(R.id.llProfileHeader); TextView tvScreenName = (TextView)headerView.findViewById(R.id.tvScreenName); ImageView ivVerify = (ImageView)headerView.findViewById(R.id.ivVerify); TextView tvImpress = (TextView)headerView.findViewById(R.id.tvImpress); ImageView ivMoreDetail = (ImageView)headerView.findViewById(R.id.ivMoreDetail); ThemeUtil.setHeaderProfile(llProfileHeader); int highlight = theme.getColor("highlight"); tvScreenName.setTextColor(highlight); ivVerify.setImageDrawable(theme.getDrawable("icon_verification")); tvImpress.setTextColor(theme.getColor("content")); ivMoreDetail.setBackgroundDrawable(theme.getDrawable("icon_more_detail")); //微博内容 TextView tvText = (TextView)headerView.findViewById(R.id.tvText); LinearLayout llThumbnailShape = (LinearLayout)headerView.findViewById(R.id.llThumbnailShape); TextView tvImageInfo = (TextView)headerView.findViewById(R.id.tvImageInfo); LinearLayout llRetweet = (LinearLayout)headerView.findViewById(R.id.llRetweet); TextView tvRetweetText = (TextView)headerView.findViewById(R.id.tvRetweetText); LinearLayout llRetweetThumbnailShape = (LinearLayout)headerView.findViewById(R.id.llRetweetThumbnailShape); TextView tvRetweetImageInfo = (TextView)headerView.findViewById(R.id.tvRetweetImageInfo); ImageView ivRetweetLocation = (ImageView)headerView.findViewById(R.id.ivRetweetLocation); TextView tvRetweetLocation = (TextView)headerView.findViewById(R.id.tvRetweetLocation); TextView tvRetweetCreatedAt = (TextView)headerView.findViewById(R.id.tvRetweetCreatedAt); TextView tvRetweetSource = (TextView)headerView.findViewById(R.id.tvRetweetSource); ImageView ivLocation = (ImageView)headerView.findViewById(R.id.ivLocation); TextView tvLocation = (TextView)headerView.findViewById(R.id.tvLocation); TextView tvCreatedAt = (TextView)headerView.findViewById(R.id.tvCreatedAt); TextView tvSource = (TextView)headerView.findViewById(R.id.tvSource); TextView tvRetweetCount = (TextView)headerView.findViewById(R.id.tvRetweetCount); TextView tvCommentCount = (TextView)headerView.findViewById(R.id.tvCommentCount); ImageView ivLineSeperator = (ImageView)headerView.findViewById(R.id.ivLineSeperator); tvText.setTextColor(theme.getColor("content")); ColorStateList selectorTextLink = theme.getColorStateList("selector_text_link"); tvText.setLinkTextColor(selectorTextLink); Drawable shapeAttachment = theme.getDrawable("shape_attachment"); llThumbnailShape.setBackgroundDrawable(shapeAttachment); int quote = theme.getColor("quote"); tvImageInfo.setTextColor(quote); llRetweet.setBackgroundDrawable(theme.getDrawable("bg_retweet_frame")); int padding10 = theme.dip2px(10); llRetweet.setPadding(padding10, padding10, padding10, theme.dip2px(6)); tvRetweetText.setTextColor(quote); tvRetweetText.setLinkTextColor(selectorTextLink); llRetweetThumbnailShape.setBackgroundDrawable(shapeAttachment); tvRetweetImageInfo.setTextColor(quote); Drawable iconLocation = theme.getDrawable("icon_location"); ivRetweetLocation.setImageDrawable(iconLocation); tvRetweetLocation.setTextColor(quote); tvRetweetCreatedAt.setTextColor(quote); tvRetweetSource.setTextColor(quote); ivLocation.setImageDrawable(iconLocation); tvLocation.setTextColor(quote); tvCreatedAt.setTextColor(quote); tvSource.setTextColor(quote); int emphasize = theme.getColor("emphasize"); tvRetweetCount.setTextColor(emphasize); tvCommentCount.setTextColor(emphasize); ivLineSeperator.setBackgroundDrawable(theme.getDrawable("line_comment_of_status_normal")); //工具条 LinearLayout llToolbar = (LinearLayout)findViewById(R.id.llToolbar); Button btnComment = (Button)findViewById(R.id.btnComment); Button btnRetweet = (Button)findViewById(R.id.btnRetweet); Button btnFavorite = (Button)findViewById(R.id.btnFavorite); Button btnShare = (Button)findViewById(R.id.btnShare); Button btnMore = (Button)findViewById(R.id.btnMore); llToolbar.setBackgroundDrawable(theme.getDrawable("bg_toolbar")); btnComment.setBackgroundDrawable(theme.getDrawable("selector_toolbar_comment")); btnRetweet.setBackgroundDrawable(theme.getDrawable("selector_toolbar_retweet")); btnFavorite.setBackgroundDrawable(theme.getDrawable("selector_toolbar_favorite_add")); btnShare.setBackgroundDrawable(theme.getDrawable("selector_toolbar_share")); btnMore.setBackgroundDrawable(theme.getDrawable("selector_toolbar_more")); lvCommentsOfStatus = (ListView) this.findViewById(R.id.lvCommentsOfStatus); ThemeUtil.setListViewStyle(lvCommentsOfStatus); lvCommentsOfStatus.addHeaderView(headerView); setBack2Top(lvCommentsOfStatus); //注册上下文菜单 View statusView = this.findViewById(R.id.llStatus); statusContextMenuListener = new MicroBlogStatusContextMenuListener(status); statusView.setOnCreateContextMenuListener(statusContextMenuListener); autoLoadMoreListener = new AutoLoadMoreListener(); }
Example 14
Source File: UndoView.java From Telegram with GNU General Public License v2.0 | 4 votes |
public UndoView(Context context, boolean top) { super(context); fromTop = top; infoTextView = new TextView(context); infoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); infoTextView.setTextColor(Theme.getColor(Theme.key_undo_infoColor)); infoTextView.setLinkTextColor(Theme.getColor(Theme.key_undo_cancelColor)); infoTextView.setMovementMethod(new LinkMovementMethodMy()); addView(infoTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 45, 13, 0, 0)); subinfoTextView = new TextView(context); subinfoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13); subinfoTextView.setTextColor(Theme.getColor(Theme.key_undo_infoColor)); subinfoTextView.setLinkTextColor(Theme.getColor(Theme.key_undo_cancelColor)); subinfoTextView.setHighlightColor(0); subinfoTextView.setSingleLine(true); subinfoTextView.setEllipsize(TextUtils.TruncateAt.END); subinfoTextView.setMovementMethod(new AndroidUtilities.LinkMovementMethodMy()); addView(subinfoTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 58, 27, 8, 0)); leftImageView = new RLottieImageView(context); leftImageView.setScaleType(ImageView.ScaleType.CENTER); leftImageView.setLayerColor("info1.**", Theme.getColor(Theme.key_undo_background) | 0xff000000); leftImageView.setLayerColor("info2.**", Theme.getColor(Theme.key_undo_background) | 0xff000000); leftImageView.setLayerColor("luc12.**", Theme.getColor(Theme.key_undo_infoColor)); leftImageView.setLayerColor("luc11.**", Theme.getColor(Theme.key_undo_infoColor)); leftImageView.setLayerColor("luc10.**", Theme.getColor(Theme.key_undo_infoColor)); leftImageView.setLayerColor("luc9.**", Theme.getColor(Theme.key_undo_infoColor)); leftImageView.setLayerColor("luc8.**", Theme.getColor(Theme.key_undo_infoColor)); leftImageView.setLayerColor("luc7.**", Theme.getColor(Theme.key_undo_infoColor)); leftImageView.setLayerColor("luc6.**", Theme.getColor(Theme.key_undo_infoColor)); leftImageView.setLayerColor("luc5.**", Theme.getColor(Theme.key_undo_infoColor)); leftImageView.setLayerColor("luc4.**", Theme.getColor(Theme.key_undo_infoColor)); leftImageView.setLayerColor("luc3.**", Theme.getColor(Theme.key_undo_infoColor)); leftImageView.setLayerColor("luc2.**", Theme.getColor(Theme.key_undo_infoColor)); leftImageView.setLayerColor("luc1.**", Theme.getColor(Theme.key_undo_infoColor)); leftImageView.setLayerColor("Oval.**", Theme.getColor(Theme.key_undo_infoColor)); addView(leftImageView, LayoutHelper.createFrame(54, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL | Gravity.LEFT, 3, 0, 0, 0)); undoButton = new LinearLayout(context); undoButton.setOrientation(LinearLayout.HORIZONTAL); addView(undoButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.CENTER_VERTICAL | Gravity.RIGHT, 0, 0, 19, 0)); undoButton.setOnClickListener(v -> { if (!canUndo()) { return; } hide(false, 1); }); undoImageView = new ImageView(context); undoImageView.setImageResource(R.drawable.chats_undo); undoImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_undo_cancelColor), PorterDuff.Mode.MULTIPLY)); undoButton.addView(undoImageView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL | Gravity.LEFT)); undoTextView = new TextView(context); undoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); undoTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); undoTextView.setTextColor(Theme.getColor(Theme.key_undo_cancelColor)); undoTextView.setText(LocaleController.getString("Undo", R.string.Undo)); undoButton.addView(undoTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL | Gravity.LEFT, 6, 0, 0, 0)); rect = new RectF(AndroidUtilities.dp(15), AndroidUtilities.dp(15), AndroidUtilities.dp(15 + 18), AndroidUtilities.dp(15 + 18)); progressPaint = new Paint(Paint.ANTI_ALIAS_FLAG); progressPaint.setStyle(Paint.Style.STROKE); progressPaint.setStrokeWidth(AndroidUtilities.dp(2)); progressPaint.setStrokeCap(Paint.Cap.ROUND); progressPaint.setColor(Theme.getColor(Theme.key_undo_infoColor)); textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); textPaint.setTextSize(AndroidUtilities.dp(12)); textPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); textPaint.setColor(Theme.getColor(Theme.key_undo_infoColor)); setBackgroundDrawable(Theme.createRoundRectDrawable(AndroidUtilities.dp(6), Theme.getColor(Theme.key_undo_background))); setOnTouchListener((v, event) -> true); setVisibility(INVISIBLE); }
Example 15
Source File: StatusHolder.java From YiBo with Apache License 2.0 | 4 votes |
public StatusHolder(View convertView, ServiceProvider serviceProvider) { if (convertView == null) { throw new IllegalArgumentException("convertView is null!"); } context = convertView.getContext(); ivProfilePicture = (ImageView) convertView.findViewById(R.id.ivProfilePicture); tvScreenName = (TextView) convertView.findViewById(R.id.tvScreenName); ivVerify = (ImageView) convertView.findViewById(R.id.ivVerify); ivLocation = (ImageView) convertView.findViewById(R.id.ivLocation); ivFavorite = (ImageView) convertView.findViewById(R.id.ivFavorite); ivAttachment = (ImageView) convertView.findViewById(R.id.ivAttachment); tvCreatedAt = (TextView) convertView.findViewById(R.id.tvCreatedAt); tvText = (TextView) convertView.findViewById(R.id.tvText); ivThumbnail = (ImageView) convertView.findViewById(R.id.ivThumbnail); ivRetweetThumbnail = (ImageView) convertView.findViewById(R.id.ivRetweetThumbnail); tvImageInfo = (TextView) convertView.findViewById(R.id.tvImageInfo); tvRetweetImageInfo = (TextView) convertView.findViewById(R.id.tvRetweetImageInfo); tvRetweetText = (TextView) convertView.findViewById(R.id.tvRetweetText); llRetweet = convertView.findViewById(R.id.llRetweet); tvResponse = (TextView) convertView.findViewById(R.id.tvResponse); tvSource = (TextView) convertView.findViewById(R.id.tvSource); if (tvText instanceof RichTextView) { ((RichTextView)tvText).setProvider(serviceProvider); } if (tvRetweetText instanceof RichTextView) { ((RichTextView)tvRetweetText).setProvider(serviceProvider); } //初始图片资源 Theme theme = ThemeUtil.createTheme(context); ivVerify.setImageDrawable(GlobalResource.getIconVerification(context)); ivLocation.setImageDrawable(GlobalResource.getIconLocation(context)); ivFavorite.setImageDrawable(GlobalResource.getIconFavorite(context)); ivAttachment.setImageDrawable(GlobalResource.getIconAttachment(context)); llRetweet.setBackgroundDrawable(GlobalResource.getBgRetweetFrame(context)); llRetweet.setPadding(theme.dip2px(10), theme.dip2px(12), theme.dip2px(10), theme.dip2px(6)); headClickListener = new ImageHeadClickListener(); ivProfilePicture.setOnClickListener(headClickListener); //设置主题 tvScreenName.setTextColor(theme.getColor("highlight")); tvText.setTextColor(theme.getColor("content")); tvText.setLinkTextColor(theme.getColorStateList("selector_text_link")); int quote = theme.getColor("quote"); tvRetweetText.setTextColor(quote); tvRetweetText.setLinkTextColor(theme.getColorStateList("selector_text_link")); tvSource.setTextColor(quote); tvResponse.setTextColor(theme.getColor("emphasize")); ivThumbnail.setBackgroundDrawable(theme.getDrawable("shape_attachment")); ivRetweetThumbnail.setBackgroundDrawable(theme.getDrawable("shape_attachment")); tvImageInfo.setTextColor(quote); tvRetweetImageInfo.setTextColor(quote); reset(); }
Example 16
Source File: CheckBoxCell.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
public CheckBoxCell(Context context, int type, int padding) { super(context); currentType = type; textView = new TextView(context); textView.setTextColor(Theme.getColor(type == 1 ? Theme.key_dialogTextBlack : Theme.key_windowBackgroundWhiteBlackText)); textView.setLinkTextColor(Theme.getColor(type == 1 ? Theme.key_dialogTextLink : Theme.key_windowBackgroundWhiteLinkText)); textView.setTag(Theme.getColor(type == 1 ? Theme.key_dialogTextBlack : Theme.key_windowBackgroundWhiteBlackText)); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView.setLines(1); textView.setMaxLines(1); textView.setSingleLine(true); textView.setEllipsize(TextUtils.TruncateAt.END); if (type == 3) { textView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 29, 0, 0, 0)); textView.setPadding(0, 0, 0, AndroidUtilities.dp(3)); } else { textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); if (type == 2) { addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 0 : 29), 0, (LocaleController.isRTL ? 29 : 0), 0)); } else { int offset = type == 4 ? 56 : 46; addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? padding : offset + (padding - 17)), 0, (LocaleController.isRTL ? offset + (padding - 17) : padding), 0)); } } valueTextView = new TextView(context); valueTextView.setTextColor(Theme.getColor(type == 1 ? Theme.key_dialogTextBlue : Theme.key_windowBackgroundWhiteValueText)); valueTextView.setTag(type == 1 ? Theme.key_dialogTextBlue : Theme.key_windowBackgroundWhiteValueText); valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); valueTextView.setLines(1); valueTextView.setMaxLines(1); valueTextView.setSingleLine(true); valueTextView.setEllipsize(TextUtils.TruncateAt.END); valueTextView.setGravity((LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL); addView(valueTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP, padding, 0, padding, 0)); if (type == TYPE_CHECK_BOX_ROUND) { checkBox = checkBoxRound = new CheckBox2(context, 21); checkBoxRound.setDrawUnchecked(true); checkBoxRound.setChecked(true, false); checkBoxRound.setDrawBackgroundAsArc(10); checkBoxSize = 21; addView(checkBox, LayoutHelper.createFrame(checkBoxSize, checkBoxSize, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 0 : padding), 16, (LocaleController.isRTL ? padding : 0), 0)); } else { checkBox = checkBoxSquare = new CheckBoxSquare(context, type == 1); checkBoxSize = 18; if (type == 3) { addView(checkBox, LayoutHelper.createFrame(checkBoxSize, checkBoxSize, Gravity.LEFT | Gravity.TOP, 0, 15, 0, 0)); } else if (type == 2) { addView(checkBox, LayoutHelper.createFrame(checkBoxSize, checkBoxSize, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 0, 15, 0, 0)); } else { addView(checkBox, LayoutHelper.createFrame(checkBoxSize, checkBoxSize, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 0 : padding), 16, (LocaleController.isRTL ? padding : 0), 0)); } } }
Example 17
Source File: AboutActivity.java From BusyBox with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_busybox_about); final ElasticDragDismissFrameLayout draggableLayout = getViewById(R.id.draggable_frame); final View backgroundView = getViewById(R.id.about_background); final AnimatedSvgView svgView = getViewById(R.id.svg); final TextView aboutText = getViewById(R.id.about_text); final TextView creditsText = getViewById(R.id.credits_text); backgroundView.setBackgroundColor(getRadiant().backgroundColorLight()); SvgIcons.LOGO.into(svgView).start(); svgView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { Technique.ROTATE.playOn(v); return true; } }); aboutText.setText(new HtmlBuilder().h3("BusyBox: The Swiss Army Knife of Embedded Linux") .p("BusyBox combines tiny versions of many common UNIX utilities into a single small executable. It provides replacements for most of the utilities you usually find in GNU fileutils, shellutils, etc. The utilities in BusyBox generally have fewer options than their full-featured GNU cousins; however, the options that are included provide the expected functionality and behave very much like their GNU counterparts. BusyBox provides a fairly complete environment for any small or embedded system.") .p("BusyBox has been written with size-optimization and limited resources in mind. It is also extremely modular so you can easily include or exclude commands (or features) at compile time. This makes it easy to customize your embedded systems. To create a working system, just add some device nodes in /dev, a few configuration files in /etc, and a Linux kernel.") .p() .append("BusyBox is maintained by Denys Vlasenko, and licensed under the ") .a("https://busybox.net/license.html", "GNU GENERAL PUBLIC LICENSE") .append(" version 2.") .close() .h3() .append("Learn more at ") .a("https://busybox.net", "busybox.net") .append(" or ") .a("http://busybox.jrummyapps.com", "busybox.jrummyapps.com") .append(".") .close() .build()); aboutText.setLinkTextColor(getRadiant().primaryColor()); aboutText.setMovementMethod(LinkMovementMethod.getInstance()); creditsText.setText(new HtmlBuilder() .p("Developed by Jared Rummler") .a("https://twitter.com/jrummy16", "Twitter") .append(" | ") .a("https://plus.google.com/+JaredRummler", "Google+") .build()); creditsText.setLinkTextColor(getRadiant().primaryColor()); creditsText.setMovementMethod(LinkMovementMethod.getInstance()); draggableLayout.addListener(this); SystemBarTint systemBarTint = new SystemBarTint(this); systemBarTint.setStatusBarColor(Color.TRANSPARENT); getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); }
Example 18
Source File: ViewUtil.java From MDPreference with Apache License 2.0 | 4 votes |
public static void applyTextAppearance(TextView v, int resId){ if(resId == 0) return; String fontFamily = null; int typefaceIndex = -1; int styleIndex = -1; int shadowColor = 0; float dx = 0, dy = 0, r = 0; TypedArray appearance = v.getContext().obtainStyledAttributes(resId, R.styleable.TextAppearance); if (appearance != null) { int n = appearance.getIndexCount(); for (int i = 0; i < n; i++) { int attr = appearance.getIndex(i); if (attr == R.styleable.TextAppearance_android_textColorHighlight) { v.setHighlightColor(appearance.getColor(attr, 0)); } else if (attr == R.styleable.TextAppearance_android_textColor) { v.setTextColor(appearance.getColorStateList(attr)); } else if (attr == R.styleable.TextAppearance_android_textColorHint) { v.setHintTextColor(appearance.getColorStateList(attr)); } else if (attr == R.styleable.TextAppearance_android_textColorLink) { v.setLinkTextColor(appearance.getColorStateList(attr)); } else if (attr == R.styleable.TextAppearance_android_textSize) { v.setTextSize(TypedValue.COMPLEX_UNIT_PX, appearance.getDimensionPixelSize(attr, 0)); } else if (attr == R.styleable.TextAppearance_android_typeface) { typefaceIndex = appearance.getInt(attr, -1); } else if (attr == R.styleable.TextAppearance_android_fontFamily) { fontFamily = appearance.getString(attr); } else if (attr == R.styleable.TextAppearance_tv_fontFamily) { fontFamily = appearance.getString(attr); } else if (attr == R.styleable.TextAppearance_android_textStyle) { styleIndex = appearance.getInt(attr, -1); } else if (attr == R.styleable.TextAppearance_android_textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) v.setAllCaps(appearance.getBoolean(attr, false)); } else if (attr == R.styleable.TextAppearance_android_shadowColor) { shadowColor = appearance.getInt(attr, 0); } else if (attr == R.styleable.TextAppearance_android_shadowDx) { dx = appearance.getFloat(attr, 0); } else if (attr == R.styleable.TextAppearance_android_shadowDy) { dy = appearance.getFloat(attr, 0); } else if (attr == R.styleable.TextAppearance_android_shadowRadius) { r = appearance.getFloat(attr, 0); } else if (attr == R.styleable.TextAppearance_android_elegantTextHeight) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) v.setElegantTextHeight(appearance.getBoolean(attr, false)); } else if (attr == R.styleable.TextAppearance_android_letterSpacing) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) v.setLetterSpacing(appearance.getFloat(attr, 0)); } else if (attr == R.styleable.TextAppearance_android_fontFeatureSettings) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) v.setFontFeatureSettings(appearance.getString(attr)); } } appearance.recycle(); } if (shadowColor != 0) v.setShadowLayer(r, dx, dy, shadowColor); Typeface tf = null; if (fontFamily != null) { tf = TypefaceUtil.load(v.getContext(), fontFamily, styleIndex); if (tf != null) v.setTypeface(tf); } if(tf != null) { switch (typefaceIndex) { case 1: tf = Typeface.SANS_SERIF; break; case 2: tf = Typeface.SERIF; break; case 3: tf = Typeface.MONOSPACE; break; } v.setTypeface(tf, styleIndex); } }
Example 19
Source File: FeedBackActivity.java From Musicoco with Apache License 2.0 | 4 votes |
@Override public void themeChange(ThemeEnum themeEnum, int[] colors) { ThemeEnum theme = appPreference.getTheme(); int[] cs = ColorUtils.get10ThemeColors(this, theme); int accentC = cs[2]; int mainTC = cs[5]; int vicTC = cs[6]; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { send.setBackgroundTintList(ColorStateList.valueOf(accentC)); } input.setHintTextColor(vicTC); input.setTextColor(mainTC); initInputBg(accentC, theme == ThemeEnum.WHITE ? Color.WHITE : cs[4]); TextView cent = (TextView) findViewById(R.id.feedback_tip_msg); TextView other = (TextView) findViewById(R.id.feedback_tip_other_where); TextView tip = (TextView) findViewById(R.id.feedback_tip); View tipLine = findViewById(R.id.feedback_tip_line); TextView tipO = (TextView) findViewById(R.id.feedback_tip_ow); View tipOL = findViewById(R.id.feedback_tip_ow_line); cent.setTextColor(vicTC); other.setTextColor(vicTC); other.setLinkTextColor(accentC); tipLine.setBackgroundColor(vicTC); tip.setTextColor(mainTC); tipOL.setBackgroundColor(vicTC); tipO.setTextColor(mainTC); int[] cs2 = ColorUtils.get2ActionStatusBarColors(this); int actionC = cs2[0]; int statusC = cs2[1]; toolbar.setBackgroundColor(statusC); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { getWindow().setStatusBarColor(actionC); } }
Example 20
Source File: CheckBoxCell.java From Telegram with GNU General Public License v2.0 | 4 votes |
public CheckBoxCell(Context context, int type, int padding) { super(context); currentType = type; textView = new TextView(context); textView.setTextColor(Theme.getColor(type == 1 ? Theme.key_dialogTextBlack : Theme.key_windowBackgroundWhiteBlackText)); textView.setLinkTextColor(Theme.getColor(type == 1 ? Theme.key_dialogTextLink : Theme.key_windowBackgroundWhiteLinkText)); textView.setTag(Theme.getColor(type == 1 ? Theme.key_dialogTextBlack : Theme.key_windowBackgroundWhiteBlackText)); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView.setLines(1); textView.setMaxLines(1); textView.setSingleLine(true); textView.setEllipsize(TextUtils.TruncateAt.END); if (type == 3) { textView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 29, 0, 0, 0)); textView.setPadding(0, 0, 0, AndroidUtilities.dp(3)); } else { textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); if (type == 2) { addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 0 : 29), 0, (LocaleController.isRTL ? 29 : 0), 0)); } else { int offset = type == 4 ? 56 : 46; addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? padding : offset + (padding - 17)), 0, (LocaleController.isRTL ? offset + (padding - 17) : padding), 0)); } } valueTextView = new TextView(context); valueTextView.setTextColor(Theme.getColor(type == 1 ? Theme.key_dialogTextBlue : Theme.key_windowBackgroundWhiteValueText)); valueTextView.setTag(type == 1 ? Theme.key_dialogTextBlue : Theme.key_windowBackgroundWhiteValueText); valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); valueTextView.setLines(1); valueTextView.setMaxLines(1); valueTextView.setSingleLine(true); valueTextView.setEllipsize(TextUtils.TruncateAt.END); valueTextView.setGravity((LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL); addView(valueTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP, padding, 0, padding, 0)); if (type == TYPE_CHECK_BOX_ROUND) { checkBox = checkBoxRound = new CheckBox2(context, 21); checkBoxRound.setDrawUnchecked(true); checkBoxRound.setChecked(true, false); checkBoxRound.setDrawBackgroundAsArc(10); checkBoxSize = 21; addView(checkBox, LayoutHelper.createFrame(checkBoxSize, checkBoxSize, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 0 : padding), 16, (LocaleController.isRTL ? padding : 0), 0)); } else { checkBox = checkBoxSquare = new CheckBoxSquare(context, type == 1); checkBoxSize = 18; if (type == 3) { addView(checkBox, LayoutHelper.createFrame(checkBoxSize, checkBoxSize, Gravity.LEFT | Gravity.TOP, 0, 15, 0, 0)); } else if (type == 2) { addView(checkBox, LayoutHelper.createFrame(checkBoxSize, checkBoxSize, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 0, 15, 0, 0)); } else { addView(checkBox, LayoutHelper.createFrame(checkBoxSize, checkBoxSize, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 0 : padding), 16, (LocaleController.isRTL ? padding : 0), 0)); } } }