List of usage examples for android.widget TextView setLinkTextColor
public final void setLinkTextColor(ColorStateList colors)
From source file:org.rm3l.ddwrt.about.AboutDialog.java
/** * Format text view links//www . j a va 2 s .com * * @param textView the text view * @param text the text to set as content */ private static void setTextContentAndLinkify(@NotNull final TextView textView, @NotNull final String text) { textView.setText(Html.fromHtml(text)); textView.setLinkTextColor(Color.WHITE); for (final int bitFieldToLinkify : BIT_FIELDS_TO_LINKIFY) { Linkify.addLinks(textView, bitFieldToLinkify); } }
From source file:com.github.dfa.diaspora_android.ui.theme.ThemeHelper.java
public static void updateTextViewLinkColor(TextView textView) { if (textView != null) { textView.setHighlightColor(getInstance().appSettings.getAccentColor()); textView.setLinkTextColor(getInstance().appSettings.getAccentColor()); }//from w ww . j a v a 2s . com }
From source file:org.mariotaku.twidere.util.ThemedLayoutInflaterFactory.java
private static void initViewTint(View view, IThemedActivity activity) { final int noTintColor, accentColor, backgroundTintColor; final boolean isColorTint; // View context is not derived from ActionBar, apply color tint directly final Resources resources = ((Activity) activity).getResources(); final Context viewContext = view.getContext(); final boolean isActionBarContext = isActionBarContext(viewContext, getActionBarContext((Activity) activity)); final int themeResourceId = activity.getCurrentThemeResourceId(); final boolean isDarkTheme = ThemeUtils.isDarkTheme(themeResourceId); final int backgroundColorApprox; if (!isActionBarContext) { accentColor = activity.getCurrentThemeColor(); final int[] darkLightColors = new int[2]; ThemeUtils.getDarkLightForegroundColors((Context) activity, activity.getCurrentThemeResourceId(), darkLightColors);// w w w . ja v a 2 s .c om noTintColor = TwidereColorUtils.getContrastYIQ(accentColor, ThemeUtils.ACCENT_COLOR_THRESHOLD, darkLightColors[0], darkLightColors[1]); backgroundTintColor = accentColor; backgroundColorApprox = isDarkTheme ? Color.BLACK : Color.WHITE; isColorTint = true; } else if (isDarkTheme) { // View context is derived from ActionBar but is currently dark theme, so we should show // light noTintColor = Color.WHITE; accentColor = activity.getCurrentThemeColor(); backgroundTintColor = noTintColor; backgroundColorApprox = Color.BLACK; isColorTint = true; } else { // View context is derived from ActionBar and it's light theme, so we use contrast color final int actionBarColor = activity.getCurrentThemeColor(); final int actionBarTheme = ThemeUtils.getActionBarThemeResource(activity.getThemeResourceId(), actionBarColor); accentColor = ThemeUtils.getColorFromAttribute(viewContext, android.R.attr.colorForeground, 0); noTintColor = ThemeUtils.getColorFromAttribute(viewContext, android.R.attr.colorBackground, 0); backgroundTintColor = accentColor; backgroundColorApprox = Color.WHITE; isColorTint = false; } final boolean isAccentOptimal = Math .abs(TwidereColorUtils.getYIQContrast(backgroundColorApprox, accentColor)) > 64; if (view instanceof TextView) { final TextView textView = (TextView) view; if (isAccentOptimal) { textView.setLinkTextColor(accentColor); } } if (view instanceof IThemeAccentView) { if (isAccentOptimal || !isColorTint) { ((IThemeAccentView) view).setAccentTintColor(ColorStateList.valueOf(accentColor)); } else { final int defaultAccentColor = ThemeUtils.getColorFromAttribute(viewContext, R.attr.colorAccent, resources.getColor(R.color.branding_color)); ((IThemeAccentView) view).setAccentTintColor(ColorStateList.valueOf(defaultAccentColor)); } } else if (view instanceof IThemeBackgroundTintView) { if (isAccentOptimal || !isColorTint) { ((IThemeBackgroundTintView) view) .setBackgroundTintColor(ColorStateList.valueOf(backgroundTintColor)); } } else if (view instanceof TintableBackgroundView) { final TintableBackgroundView tintable = (TintableBackgroundView) view; if (isAccentOptimal || !isColorTint) { applyTintableBackgroundViewTint(tintable, accentColor, noTintColor, backgroundTintColor, isColorTint); } } else if (view instanceof TwidereToolbar) { final Context context = viewContext; if (context instanceof android.support.v7.internal.view.ContextThemeWrapper) { ((TwidereToolbar) view).setItemColor(ThemeUtils.getThemeForegroundColor(context, ((ContextThemeWrapper) context).getThemeResId())); } else { ((TwidereToolbar) view).setItemColor(ThemeUtils.getThemeForegroundColor(context)); } } else if (view instanceof EditText) { if (isAccentOptimal || !isColorTint) { ViewCompat.setBackgroundTintList(view, ColorStateList.valueOf(backgroundTintColor)); } } else if (view instanceof ProgressBar) { if (isAccentOptimal || !isColorTint) { ViewSupport.setIndeterminateTintList((ProgressBar) view, ColorStateList.valueOf(accentColor)); ViewSupport.setProgressTintList((ProgressBar) view, ColorStateList.valueOf(accentColor)); ViewSupport.setProgressBackgroundTintList((ProgressBar) view, ColorStateList.valueOf(accentColor)); } } }
From source file:com.moubry.worthwatching.ui.BaseActivity.java
public static AlertDialog createWhatsNewAlert(Context context) { final TextView message = new TextView(context); final SpannableString s = new SpannableString(context.getText(R.string.whats_new_message)); Linkify.addLinks(s, Linkify.WEB_URLS); message.setPadding(10, 10, 10, 10);//from w w w . j a va 2 s.co m message.setText(s); message.setLinkTextColor(context.getResources().getColor(R.color.blue)); message.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20); message.setMovementMethod(LinkMovementMethod.getInstance()); return new AlertDialog.Builder(context).setTitle(R.string.title_whats_new).setCancelable(true) .setPositiveButton("OK", null).setView(message).create(); }
From source file:com.bt.download.android.gui.util.UIUtils.java
/** * Android devices with SDK below target=11 do not support textView.setAlpha(). * This is a work around. // ww w. ja va2 s.c om * @param v - the text view * @param alpha - a value from 0 to 255. (0=transparent, 255=fully visible) */ public static void setTextViewAlpha(TextView v, int alpha) { v.setTextColor(v.getTextColors().withAlpha(alpha)); v.setHintTextColor(v.getHintTextColors().withAlpha(alpha)); v.setLinkTextColor(v.getLinkTextColors().withAlpha(alpha)); Drawable[] compoundDrawables = v.getCompoundDrawables(); for (int i = 0; i < compoundDrawables.length; i++) { Drawable d = compoundDrawables[i]; if (d != null) { d.setAlpha(alpha); } } }
From source file:de.vakuumverpackt.foul.About.java
@Override public void onCreate(final Bundle bundle) { setContentView(R.layout.activity_about); TextView text = (TextView) findViewById(R.id.textView); text.setLinkTextColor(getLinkColor()); text.setMovementMethod(LinkMovementMethod.getInstance()); text.setText(getText());//from ww w .j a va 2s . com text.setTextColor(getTextColor()); }
From source file:com.lendingtree.view.BaseActivity.java
void setHyperLink(TextView tvFooter) { tvFooter.setLinkTextColor(getResources().getColor(R.color.silver)); addLink(tvFooter, "Privacy", "https://www.lendingtree.com/legal/privacy-policy"); addLink(tvFooter, "Terms of Use", "https://www.lendingtree.com/legal/terms-of-use"); addLink(tvFooter, "Licenses", "https://www.lendingtree.com/legal/licenses-and-disclosures"); addLink(tvFooter, "Disclosures", "https://www.lendingtree.com/legal/advertising-disclosures"); }
From source file:com.topfeeds4j.sample.app.fragments.AboutDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Get app version PackageManager pm = getActivity().getPackageManager(); String packageName = getActivity().getPackageName(); String versionName;//from ww w . j a v a2 s. c o m try { PackageInfo info = pm.getPackageInfo(packageName, 0); versionName = info.versionName; } catch (PackageManager.NameNotFoundException e) { versionName = VERSION_UNAVAILABLE; } // About. SpannableStringBuilder aboutBody = new SpannableStringBuilder(); aboutBody.append( Html.fromHtml(getString(R.string.about_body, getString(R.string.application_name), versionName))); // Licenses. SpannableString licensesLink = new SpannableString(getString(R.string.about_licenses)); licensesLink.setSpan(new ClickableSpan() { @Override public void onClick(View view) { showOpenSourceLicenses(getActivity()); } }, 0, licensesLink.length(), 0); aboutBody.append("\n\n"); aboutBody.append(licensesLink); // End User License Agreement. SpannableString eulaLink = new SpannableString(getString(R.string.about_eula)); eulaLink.setSpan(new ClickableSpan() { @Override public void onClick(View view) { showEula(getActivity()); } }, 0, eulaLink.length(), 0); aboutBody.append("\n\n"); aboutBody.append(eulaLink); // Show "About" dialog. LayoutInflater layoutInflater = (LayoutInflater) getActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); TextView aboutBodyView = (TextView) layoutInflater.inflate(R.layout.fragment_dialog_about, null); aboutBodyView.setText(aboutBody); aboutBodyView.setLinkTextColor(getResources().getColor(R.color.com_facebook_blue)); aboutBodyView.setMovementMethod(new LinkMovementMethod()); return new AlertDialog.Builder(getActivity()).setTitle(R.string.action_about).setView(aboutBodyView) .setPositiveButton(R.string.btn_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }).create(); }
From source file:de.grobox.transportr.about.AboutFragment.java
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_about, container, false); Activity activity = getActivity();// w w w . j a v a2s .c o m String versionName; try { if (activity == null) throw new NameNotFoundException(); versionName = activity.getPackageManager().getPackageInfo(activity.getPackageName(), 0).versionName; } catch (NameNotFoundException e) { versionName = "?.?"; } // add app name and version TextView aboutApp = view.findViewById(R.id.aboutApp); aboutApp.setText(getResources().getString(R.string.app_name) + " " + versionName); // create real paragraphs TextView t = view.findViewById(R.id.aboutTextView); t.setText(Html.fromHtml(getString(R.string.about) + String.format(getString(R.string.about_bottom), getString(R.string.website), getString(R.string.bugtracker), getString(R.string.website) + "#donate"))); // make links in about text clickable t.setMovementMethod(LinkMovementMethod.getInstance()); t.setLinkTextColor(ContextCompat.getColor(getContext(), R.color.accent)); Button website = view.findViewById(R.id.websiteButton); website.setOnClickListener(v -> { Intent launchBrowser = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.website))); startActivity(launchBrowser); }); return view; }
From source file:de.grobox.liberario.fragments.AboutFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_about, container, false); Activity activity = getActivity();/*from w ww. ja v a 2 s .c o m*/ String versionName; try { versionName = activity.getPackageManager().getPackageInfo(activity.getPackageName(), 0).versionName; } catch (PackageManager.NameNotFoundException e) { versionName = "?.?"; } // add app name and version TextView aboutApp = (TextView) view.findViewById(R.id.aboutApp); aboutApp.setText(getResources().getString(R.string.app_name) + " " + versionName); // create real paragraphs TextView t = (TextView) view.findViewById(R.id.aboutTextView); t.setText(Html.fromHtml(getString(R.string.about) + String.format(getString(R.string.about_bottom), getString(R.string.website), getString(R.string.bugtracker), getString(R.string.website) + "#donate"))); // make links in about text clickable t.setMovementMethod(LinkMovementMethod.getInstance()); t.setLinkTextColor(ContextCompat.getColor(activity, R.color.accent)); Button website = (Button) view.findViewById(R.id.websiteButton); website.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent launchBrowser = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.website))); startActivity(launchBrowser); } }); return view; }