Java Code Examples for android.widget.TextView.setLinkTextColor()

The following are Jave code examples for showing how to use setLinkTextColor() of the android.widget.TextView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: dynamic-toasts   File: AboutDialogFragment.java   View Source Code Vote up 6 votes
@Override
protected @NonNull DynamicDialog onCustomiseDialog(@NonNull DynamicDialog alertDialog,
                                                   @Nullable Bundle savedInstanceState) {
    View view = LayoutInflater.from(getContext()).inflate(R.layout.dialog_about,
            new LinearLayout(getContext()), false);
    TextView message = view.findViewById(R.id.dialog_about_text);

    message.setText(Html.fromHtml(getString(R.string.about_content)
            .replace("\n", "<br/>")));
    message.setTextSize(TypedValue.COMPLEX_UNIT_SP, TEXT_SIZE);
    message.setLineSpacing(0f, 1.2f);
    message.setMovementMethod(LinkMovementMethod.getInstance());
    message.setLinkTextColor(ContextCompat.getColor(getContext(), R.color.colorPrimary));

    alertDialog.setView(view);
    return alertDialog;
}
 
Example 2
Project: dynamic-dialogs   File: AboutDialogFragment.java   View Source Code Vote up 6 votes
@Override
protected @NonNull DynamicDialog onCustomiseDialog(@NonNull DynamicDialog alertDialog,
                                                   @Nullable Bundle savedInstanceState) {
    View view = LayoutInflater.from(getContext()).inflate(R.layout.dialog_about,
            new LinearLayout(getContext()), false);
    TextView message = view.findViewById(R.id.dialog_about_text);

    message.setText(Html.fromHtml(getString(R.string.about_content)
            .replace("\n", "<br/>")));
    message.setTextSize(TypedValue.COMPLEX_UNIT_SP, TEXT_SIZE);
    message.setLineSpacing(0f, 1.2f);
    message.setMovementMethod(LinkMovementMethod.getInstance());
    message.setLinkTextColor(ContextCompat.getColor(getContext(), R.color.colorPrimary));

    alertDialog.setView(view);
    return alertDialog;
}
 
Example 3
Project: MusicX-music-player   File: TextColorTagProcessor.java   View Source Code Vote up 6 votes
@Override
public void process(@NonNull Context context, @Nullable String key, @NonNull View view, @NonNull String suffix) {
    final TextView tv = (TextView) view;
    final ColorResult result = getColorFromSuffix(context, key, view, suffix);
    if (result == null) return;

    if (mHintMode)
        result.adjustAlpha(0.5f);

    final ColorStateList sl = getTextSelector(result.getColor(), view, false);
    if (mLinkMode) {
        tv.setLinkTextColor(sl);
    } else if (mHintMode) {
        tv.setHintTextColor(sl);
        // Sets parent TextInputLayout hint color
        if (view.getParent() != null && view.getParent() instanceof TextInputLayout) {
            final TextInputLayout til = (TextInputLayout) view.getParent();
            TextInputLayoutUtil.setHint(til, result.getColor());
        }
    } else {
        tv.setTextColor(sl);
    }
}
 
Example 4
Project: urdu-font-comparator-app   File: Utils.java   View Source Code Vote up 5 votes
private static void createAndShowDialog(Context context, String title,
                                        SpannableString message, boolean showOkButton) {

    Linkify.addLinks(message, Patterns.WEB_URL, null, new Linkify.MatchFilter() {
        @Override
        public boolean acceptMatch(CharSequence seq, int start, int end) {
            return Linkify.sUrlMatchFilter.acceptMatch(seq, start, end);
        }
    }, null);

    final Dialog dialog = new LovelyInfoDialog(context)
            .setTopColorRes(R.color.colorPrimaryLight)
            .setTitle(title)
            .setIcon(R.drawable.ic_info_outline)
            .setMessage(message)
            .show();

    TextView tvMessage = (TextView) dialog.findViewById(R.id.ld_message);
    if (tvMessage != null) {
        tvMessage.setMovementMethod(LinkMovementMethod.getInstance());
        tvMessage.setLinkTextColor(ContextCompat.getColor(context, R.color.blue));
    }

    if (showOkButton) {
        Button btnOk = (Button) dialog.findViewById(R.id.ld_btn_confirm);
        if (btnOk != null) {
            btnOk.setText(R.string.button_ok);
            btnOk.setTextColor(ContextCompat.getColor(context, R.color.colorPrimaryDark));
        }
    }
}
 
Example 5
Project: airgram   File: TextInfoPrivacyCell.java   View Source Code Vote up 5 votes
public TextInfoPrivacyCell(Context context) {
    super(context);

    textView = new TextView(context);
    textView.setTypeface(FontManager.instance().getTypeface());
    textView.setTextColor(0xff808080);
    textView.setLinkTextColor(Theme.MSG_LINK_TEXT_COLOR);
    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());
    addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 0, 17, 0));
}
 
Example 6
Project: PlusGram   File: TextInfoPrivacyCell.java   View Source Code Vote up 5 votes
public TextInfoPrivacyCell(Context context) {
    super(context);

    textView = new TextView(context);
    textView.setTextColor(0xff808080);
    textView.setLinkTextColor(0xff316f9f);
    textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    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());
    addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 0, 17, 0));
}
 
Example 7
Project: revolution-irc   File: ThemedTextView.java   View Source Code Vote up 5 votes
public static void setupTextColor(TextView view, AttributeSet attrs) {
    StyledAttributesHelper r = StyledAttributesHelper.obtainStyledAttributes(view.getContext(), attrs, THEME_ATTRS);
    int colorResId = r.getResourceId(android.R.attr.textColor, 0);
    if (colorResId == 0) {
        int appearanceRes = r.getResourceId(android.R.attr.textAppearance, 0);
        if (appearanceRes != 0) {
            StyledAttributesHelper ta = StyledAttributesHelper.obtainStyledAttributes(
                    view.getContext(), appearanceRes, new int[] { android.R.attr.textColor });
            colorResId = ta.getResourceId(android.R.attr.textColor, 0);
            ta.recycle();
        }
    }
    if (colorResId == R.color.colorPrimary)
        view.setTextColor(ThemeHelper.getPrimaryColor(view.getContext()));
    else if (colorResId == R.color.colorAccent)
        view.setTextColor(ThemeHelper.getAccentColor(view.getContext()));
    colorResId = r.getResourceId(android.R.attr.textColorLink, 0);
    if (colorResId == R.color.colorAccent)
        view.setLinkTextColor(ThemeHelper.getAccentColor(view.getContext()));

    Drawable[] drawables = TextViewCompat.getCompoundDrawablesRelative(view);
    boolean hasChange = false;
    for (int i = 0; i < 4; i++) {
        Drawable newDrawable = tintDrawable(view.getContext(), r, DRAWABLE_ATTRS[i], drawables[i]);
        if (newDrawable != drawables[i]) {
            drawables[i] = newDrawable;
            hasChange = true;
        }
    }
    if (hasChange)
        TextViewCompat.setCompoundDrawablesRelative(view, drawables[0], drawables[1], drawables[2], drawables[3]);
    r.recycle();
}
 
Example 8
Project: urdu-font-comparator-app   File: MainFragment.java   View Source Code Vote up 4 votes
public void showFontDetailsDialog(Context context, String title, String message, double rating,
                                  int ratingCount) {
    LayoutInflater inflater = (LayoutInflater)
            context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final View viewFontDetails = inflater.inflate(R.layout.dialog_font_details, null);

    //To make sure Font FileName doesn't end up as a clickable url because it is automatically
    //turned into a url
    final SpannableString content = new SpannableString(message);
    Linkify.addLinks(content, Patterns.WEB_URL, null, new Linkify.MatchFilter() {
        @Override
        public boolean acceptMatch(CharSequence seq, int start, int end) {
            String url = seq.subSequence(start, end).toString();
            //Apply the default matcher too. This will remove filenames that matched.
            return !url.contains(".ttf") && Linkify.sUrlMatchFilter
                    .acceptMatch(seq, start, end);
        }
    }, null);

    TextView tvMessage = (TextView) viewFontDetails
            .findViewById(R.id.text_font_details_message);
    if (tvMessage != null) {
        tvMessage.setText(content);
        tvMessage.setMovementMethod(LinkMovementMethod.getInstance()); //Making link clickable
        tvMessage.setLinkTextColor(ContextCompat.getColor(context, R.color.blue));
    }

    final Dialog dialog = new LovelyCustomDialog(context)
            .setView(viewFontDetails)
            .setTopColorRes(R.color.colorPrimaryLight)
            .setTitle(title)
            .setIcon(R.drawable.ic_info_outline)
            .show();
    TextView btnGotIt = (TextView) viewFontDetails.findViewById(R.id.button_font_details_got_it);
    btnGotIt.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (dialog != null && dialog.isShowing()) {
                dialog.dismiss();
            }
        }
    });
    TextView tvRating = (TextView) viewFontDetails.findViewById(R.id.tv_rating);
    Resources res = getResources();
    String text = res.getQuantityString(R.plurals.dialog_font_rating, ratingCount,
            formatToOneDecimalPlace(rating),
            formatToOneDecimalPlace(res.getInteger(R.integer.rating_max_possible_value)),
            ratingCount);
    tvRating.setText(text);
}
 
Example 9
Project: Musicoco   File: FeedBackActivity.java   View Source Code Vote up 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);
    }

}