Search in sources :

Example 6 with LinkMovementMethod

use of android.text.method.LinkMovementMethod in project muzei by romannurik.

the class AboutActivity method onCreate.

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.about_activity);
    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
    ((Toolbar) findViewById(R.id.app_bar)).setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            onNavigateUp();
        }
    });
    if (savedInstanceState == null) {
        getSupportFragmentManager().beginTransaction().add(R.id.demo_view_container, MuzeiRendererFragment.createInstance(true, false)).commit();
    }
    // Get app version
    PackageManager pm = getPackageManager();
    String packageName = getPackageName();
    String versionName;
    try {
        PackageInfo info = pm.getPackageInfo(packageName, 0);
        versionName = info.versionName;
    } catch (PackageManager.NameNotFoundException e) {
        versionName = VERSION_UNAVAILABLE;
    }
    // Build the about body view and append the link to see OSS licenses
    TextView versionView = (TextView) findViewById(R.id.app_version);
    versionView.setText(Html.fromHtml(getString(R.string.about_version_template, versionName)));
    TextView aboutBodyView = (TextView) findViewById(R.id.about_body);
    aboutBodyView.setText(Html.fromHtml(getString(R.string.about_body)));
    aboutBodyView.setMovementMethod(new LinkMovementMethod());
    findViewById(R.id.android_experiment_link).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            CustomTabsIntent cti = new CustomTabsIntent.Builder().setShowTitle(true).setToolbarColor(ContextCompat.getColor(AboutActivity.this, R.color.theme_primary)).build();
            try {
                cti.launchUrl(AboutActivity.this, Uri.parse("https://www.androidexperiments.com/experiment/muzei"));
            } catch (ActivityNotFoundException ignored) {
            }
        }
    });
}
Also used : PackageInfo(android.content.pm.PackageInfo) LinkMovementMethod(android.text.method.LinkMovementMethod) TextView(android.widget.TextView) View(android.view.View) CustomTabsIntent(android.support.customtabs.CustomTabsIntent) PackageManager(android.content.pm.PackageManager) ActivityNotFoundException(android.content.ActivityNotFoundException) TextView(android.widget.TextView) Toolbar(android.support.v7.widget.Toolbar)

Example 7 with LinkMovementMethod

use of android.text.method.LinkMovementMethod in project making-apps-beautiful by ankurkotwal.

the class ArticleDetailFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_article_detail, container, false);
    // Show the dummy content as text in a TextView.
    if (mItem != null) {
        ((TextView) rootView.findViewById(R.id.article_title)).setText(mItem.title);
        ((TextView) rootView.findViewById(R.id.article_byline)).setText(Html.fromHtml(mItem.time.toUpperCase(Locale.getDefault()) + " BY <font color='" + getResources().getString(R.string.author_font_color) + "'>" + mItem.author.toUpperCase(Locale.getDefault()) + "</a>"));
        ((TextView) rootView.findViewById(R.id.article_byline)).setMovementMethod(new LinkMovementMethod());
        //            ((TextView) rootView.findViewById(R.id.article_date))
        //                    .setText(mItem.time);
        ((TextView) rootView.findViewById(R.id.article_body)).setText(Html.fromHtml(mItem.content));
        ((TextView) rootView.findViewById(R.id.article_body)).setTypeface(Typeface.createFromAsset(getResources().getAssets(), "Rosario-Regular.ttf"));
        ((ImageView) rootView.findViewById(R.id.photo)).setImageDrawable(getResources().getDrawable(mItem.photoResId));
    }
    return rootView;
}
Also used : LinkMovementMethod(android.text.method.LinkMovementMethod) TextView(android.widget.TextView) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View)

Example 8 with LinkMovementMethod

use of android.text.method.LinkMovementMethod in project platform_frameworks_base by android.

the class LinkifyTest method testNothing.

@SmallTest
public void testNothing() throws Exception {
    TextView tv;
    tv = new TextView(getContext());
    tv.setText("Hey, foo@google.com, call 415-555-1212.");
    assertFalse(tv.getMovementMethod() instanceof LinkMovementMethod);
    assertTrue(tv.getUrls().length == 0);
}
Also used : LinkMovementMethod(android.text.method.LinkMovementMethod) TextView(android.widget.TextView) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 9 with LinkMovementMethod

use of android.text.method.LinkMovementMethod in project platform_frameworks_base by android.

the class LinkifyTest method testUnclickable.

@SmallTest
public void testUnclickable() throws Exception {
    TextView tv;
    tv = new TextView(getContext());
    tv.setAutoLinkMask(Linkify.ALL);
    tv.setLinksClickable(false);
    tv.setText("Hey, foo@google.com, call 415-555-1212.");
    assertFalse(tv.getMovementMethod() instanceof LinkMovementMethod);
    assertTrue(tv.getUrls().length == 2);
}
Also used : LinkMovementMethod(android.text.method.LinkMovementMethod) TextView(android.widget.TextView) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 10 with LinkMovementMethod

use of android.text.method.LinkMovementMethod in project apps-android-wikipedia by wikimedia.

the class PageHeaderView method updateText.

private void updateText() {
    avPlayer.stop();
    SpannableStringBuilder builder = new SpannableStringBuilder(title);
    builder.setSpan(new TypefaceSpan("serif"), 0, title.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
    if (hasPronunciation()) {
        builder.append(" ");
        builder.append(pronunciationSpanned());
    }
    titleText.setMovementMethod(new LinkMovementMethod());
    titleText.setText(builder);
    if (hasSubtitle() || allowDescriptionEdit) {
        subtitleText.setMovementMethod(hasSubtitle() ? null : new LinkMovementMethod());
        subtitleText.setText(subtitleSpanned());
        subtitleText.setVisibility(VISIBLE);
    } else {
        subtitleText.setVisibility(INVISIBLE);
    }
}
Also used : LinkMovementMethod(android.text.method.LinkMovementMethod) SpannableStringBuilder(android.text.SpannableStringBuilder) TypefaceSpan(android.text.style.TypefaceSpan)

Aggregations

LinkMovementMethod (android.text.method.LinkMovementMethod)50 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)4 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