Search in sources :

Example 51 with LinkMovementMethod

use of android.text.method.LinkMovementMethod in project nextcloud-notes by stefan-niedermann.

the class AboutFragmentCreditsTab method onCreateView.

@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final var binding = FragmentAboutCreditsTabBinding.inflate(inflater, container, false);
    binding.aboutVersion.setText(getString(R.string.about_version, strong(BuildConfig.VERSION_NAME)));
    binding.aboutMaintainer.setText(url(getString(R.string.about_maintainer), getString(R.string.url_maintainer)));
    binding.aboutMaintainer.setMovementMethod(new LinkMovementMethod());
    setTextWithURL(binding.aboutTranslators, getResources(), R.string.about_translators_transifex, R.string.about_translators_transifex_label, R.string.url_translations);
    return binding.getRoot();
}
Also used : LinkMovementMethod(android.text.method.LinkMovementMethod)

Example 52 with LinkMovementMethod

use of android.text.method.LinkMovementMethod in project nextcloud-notes by stefan-niedermann.

the class SupportUtil method setTextWithURL.

public static void setTextWithURL(@NonNull TextView textView, @NonNull Resources resources, @StringRes int containerTextId, @StringRes int linkLabelId, @StringRes int urlId) {
    final String linkLabel = resources.getString(linkLabelId);
    final String finalText = resources.getString(containerTextId, linkLabel);
    final var spannable = new SpannableString(finalText);
    spannable.setSpan(new URLSpan(resources.getString(urlId)), finalText.indexOf(linkLabel), finalText.indexOf(linkLabel) + linkLabel.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    textView.setText(spannable);
    textView.setMovementMethod(new LinkMovementMethod());
}
Also used : SpannableString(android.text.SpannableString) LinkMovementMethod(android.text.method.LinkMovementMethod) SpannableString(android.text.SpannableString) URLSpan(android.text.style.URLSpan)

Aggregations

LinkMovementMethod (android.text.method.LinkMovementMethod)52 TextView (android.widget.TextView)40 SmallTest (android.test.suitebuilder.annotation.SmallTest)18 View (android.view.View)12 Spannable (android.text.Spannable)8 TextAppearanceSpan (android.text.style.TextAppearanceSpan)7 ImageView (android.widget.ImageView)7 SpannableStringBuilder (android.text.SpannableStringBuilder)6 SpannableString (android.text.SpannableString)5 ActivityNotFoundException (android.content.ActivityNotFoundException)3 Context (android.content.Context)3 ViewGroup (android.view.ViewGroup)3 SystemUIDialog (com.android.systemui.statusbar.phone.SystemUIDialog)3 Intent (android.content.Intent)2 PackageManager (android.content.pm.PackageManager)2 Resources (android.content.res.Resources)2 Paint (android.graphics.Paint)2 Bundle (android.os.Bundle)2 ActionBar (android.support.v7.app.ActionBar)2 AlertDialog (android.support.v7.app.AlertDialog)2