Example usage for android.widget TextView setMovementMethod

List of usage examples for android.widget TextView setMovementMethod

Introduction

In this page you can find the example usage for android.widget TextView setMovementMethod.

Prototype

public final void setMovementMethod(MovementMethod movement) 

Source Link

Document

Sets the android.text.method.MovementMethod for handling arrow key movement for this TextView.

Usage

From source file:com.esminis.server.library.activity.main.MainViewImpl.java

@Override
public void setMessage(boolean preloaderBackground, boolean preloader, String buttonTitle, String message) {
    final Activity activity = this.activity.get();
    if (activity == null) {
        return;// w  w  w .  j  a v  a2  s.  com
    }
    activity.findViewById(R.id.preloader_container)
            .setVisibility(preloaderBackground ? View.VISIBLE : View.GONE);
    if (preloaderBackground) {
        final Button button = (Button) activity.findViewById(R.id.preloader_button_ok);
        button.setVisibility(buttonTitle != null ? View.VISIBLE : View.GONE);
        button.setText(buttonTitle);
        activity.findViewById(R.id.preloader).setVisibility(preloader ? View.VISIBLE : View.GONE);
        TextView textView = (TextView) activity.findViewById(R.id.preloader_label);
        textView.setMovementMethod(new ScrollingMovementMethod());
        textView.setText(message);
    }
}

From source file:com.ota.updates.fragments.AvailableFragment.java

private void setupChangelog(View view, Context context) {
    View changelog = view.findViewById(R.id.changelog);
    if (changelog != null) {
        TextView tv = (TextView) changelog;
        Bypass byPass = new Bypass(context);
        VersionSQLiteHelper helper = new VersionSQLiteHelper(mContext);
        VersionItem versionItem = helper.getLastVersionItem();
        String changelogStr = versionItem.getChangelog();
        CharSequence string = byPass.markdownToSpannable(changelogStr);
        tv.setText(string);//from  ww w .  ja v a2s.  c o m
        tv.setMovementMethod(LinkMovementMethod.getInstance());
    }
}

From source file:dcheungaa.procal.MainActivity.java

@SuppressWarnings("StatementWithEmptyBody")
@Override/*from w ww. j av a 2 s . com*/
@NonNull
public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.

    switch (item.getItemId()) {

    case R.id.nav_history:
        Intent intent = new Intent(MainActivity.context, HistoryActivity.class);
        startActivity(intent);
        return true;

    case R.id.nav_about:

        String credits = "<p>This piece of software used the work <a href=\"https://arxiv.org/abs/0908.3030v1\">\"A Java Math.BigDecimal Implementation of Core Mathematical Functions\" of Richard J. Mathar</a>, which was made available under the LGPL3.0 license as a library. As part of the obligations to the license, if the user wish to replace this library with their own, they may contact: <a href=\"mailto:dcheungaa@connect.ust.hk\">dcheungaa@connect.ust.hk</a></p>\n"
                + "\n" + "<p>Other code libraries used:</p>\n"
                + "<p><a href=\"https://github.com/atorstling/bychan\">Bychan</a><br>\n"
                + "<a href=\"https://github.com/evant/gradle-retrolambda\">Gradle-Retrolambda</a><br>\n"
                + "<a href=\"https://github.com/streamsupport/streamsupport\">SteamSupport</a></p>\n";

        final AlertDialog.Builder builder_add = new AlertDialog.Builder(MainActivity.this);
        builder_add.setTitle("About");
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        LinearLayout aboutLayout = (LinearLayout) inflater.inflate(R.layout.about_alert, null);
        builder_add.setView(aboutLayout);
        TextView aboutTextView = (TextView) aboutLayout.findViewById(R.id.about_content);
        aboutTextView.setText(Html.fromHtml(credits));
        aboutTextView.setMovementMethod(LinkMovementMethod.getInstance());

        builder_add.setPositiveButton("Close", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                dialog.dismiss();
            }
        });
        AlertDialog alert_add = builder_add.create();
        alert_add.show();
        return true;

    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}

From source file:com.fa.mastodon.activity.LoginActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (PreferenceManager.getDefaultSharedPreferences(this).getString("theme_selection", "light")
            .equals("light")) {
        setTheme(R.style.AppTheme_Light);
    } else if (PreferenceManager.getDefaultSharedPreferences(this).getString("theme_selection", "light")
            .equals("black")) {
        setTheme(R.style.AppThemeAmoled);
    }//from w w  w.ja v a2  s. co  m

    setContentView(R.layout.activity_login);
    ButterKnife.bind(this);

    if (savedInstanceState != null) {
        domain = savedInstanceState.getString("domain");
        clientId = savedInstanceState.getString("clientId");
        clientSecret = savedInstanceState.getString("clientSecret");
    } else {
        domain = null;
        clientId = null;
        clientSecret = null;
    }

    preferences = getSharedPreferences(getString(R.string.preferences_file_key), Context.MODE_PRIVATE);

    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onButtonClick(editText);
        }
    });

    final Context context = this;

    whatsAnInstance.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            AlertDialog dialog = new AlertDialog.Builder(context).setMessage(R.string.dialog_whats_an_instance)
                    .setPositiveButton(R.string.action_close, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                        }
                    }).show();
            TextView textView = (TextView) dialog.findViewById(android.R.id.message);
            textView.setMovementMethod(LinkMovementMethod.getInstance());
        }
    });

    bp = new BillingProcessor(this, PublicValues.LICENSE_KEY, this);

    bp.loadOwnedPurchasesFromGoogle();
}

From source file:org.telegram.ui.IdenticonActivity.java

@Override
public View createView(Context context) {
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    actionBar.setTitle(LocaleController.getString("EncryptionKey", R.string.EncryptionKey));

    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override/* ww  w.  j  a  v a 2s  .c  o m*/
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            }
        }
    });

    fragmentView = new LinearLayout(context);
    LinearLayout linearLayout = (LinearLayout) fragmentView;
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.setWeightSum(100);
    linearLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.card_background));
    fragmentView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });

    FrameLayout frameLayout = new FrameLayout(context);
    frameLayout.setPadding(AndroidUtilities.dp(20), AndroidUtilities.dp(20), AndroidUtilities.dp(20),
            AndroidUtilities.dp(20));
    linearLayout.addView(frameLayout,
            LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 50.0f));

    ImageView identiconView = new ImageView(context);
    identiconView.setScaleType(ImageView.ScaleType.FIT_XY);
    frameLayout.addView(identiconView,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    frameLayout = new FrameLayout(context);
    frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.background));
    frameLayout.setPadding(AndroidUtilities.dp(10), 0, AndroidUtilities.dp(10), AndroidUtilities.dp(10));
    linearLayout.addView(frameLayout,
            LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 50.0f));

    TextView textView = new TextView(context);
    textView.setTextColor(ContextCompat.getColor(context, R.color.secondary_text));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    textView.setLinksClickable(true);
    textView.setClickable(true);
    textView.setMovementMethod(new LinkMovementMethodMy());
    //textView.setAutoLinkMask(Linkify.WEB_URLS);
    textView.setLinkTextColor(Theme.MSG_LINK_TEXT_COLOR);
    textView.setGravity(Gravity.CENTER);
    frameLayout.addView(textView,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat(chat_id);
    if (encryptedChat != null) {
        IdenticonDrawable drawable = new IdenticonDrawable();
        identiconView.setImageDrawable(drawable);
        drawable.setEncryptedChat(encryptedChat);
        TLRPC.User user = MessagesController.getInstance().getUser(encryptedChat.user_id);
        SpannableStringBuilder hash = new SpannableStringBuilder();
        if (encryptedChat.key_hash.length > 16) {
            String hex = Utilities.bytesToHex(encryptedChat.key_hash);
            for (int a = 0; a < 32; a++) {
                if (a != 0) {
                    if (a % 8 == 0) {
                        hash.append('\n');
                    } else if (a % 4 == 0) {
                        hash.append(' ');
                    }
                }
                hash.append(hex.substring(a * 2, a * 2 + 2));
                hash.append(' ');
            }
            hash.append("\n\n");
        }
        hash.append(AndroidUtilities.replaceTags(LocaleController.formatString("EncryptionKeyDescription",
                R.string.EncryptionKeyDescription, user.first_name, user.first_name)));
        final String url = "telegram.org";
        int index = hash.toString().indexOf(url);
        if (index != -1) {
            hash.setSpan(
                    new URLSpanReplacement(
                            LocaleController.getString("EncryptionKeyLink", R.string.EncryptionKeyLink)),
                    index, index + url.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
        textView.setText(hash);
    }

    return fragmentView;
}

From source file:com.bionx.res.DashMainActivity.java

@SuppressWarnings("deprecation")
@Override//from  w w w.ja v  a2s .c  o m
protected Dialog onCreateDialog(int id) {
    switch (id) {
    case 11:
        // Create our About Dialog
        TextView aboutMsg = new TextView(this);
        aboutMsg.setMovementMethod(LinkMovementMethod.getInstance());
        aboutMsg.setPadding(30, 30, 30, 30);
        aboutMsg.setText(Html.fromHtml(
                "To view more information about the development of the Bionx Dashboard, Continue into the Information Center, If you don't care much for license and authors, click 'Proceed'."));

        Builder builder = new AlertDialog.Builder(this);
        builder.setView(aboutMsg)
                .setTitle(Html.fromHtml("Dashboard <b><font color='"
                        + getResources().getColor(R.color.holo_blue) + "'>Info</font></b>"))
                .setIcon(R.drawable.ic_launcher).setCancelable(true)
                .setPositiveButton("Information Drawer", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Intent dialog_intent = new Intent(getBaseContext(), InformationDrawer.class);
                        startActivity(dialog_intent);
                    }
                }).setNegativeButton("Proceed", new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Toast.makeText(getApplicationContext(), "Bionx Dashboard", Toast.LENGTH_LONG).show();
                    }
                });
        return builder.create();
    }
    return super.onCreateDialog(id);
}

From source file:org.amahi.anywhere.activity.AuthenticationActivity.java

private void setUpAuthenticationMessages() {
    TextView authenticationFailureMessage = (TextView) findViewById(R.id.text_message_authentication);
    TextView authenticationConnectionFailureMessage = (TextView) findViewById(
            R.id.text_message_authentication_connection);

    authenticationFailureMessage.setMovementMethod(LinkMovementMethod.getInstance());
    authenticationConnectionFailureMessage.setMovementMethod(LinkMovementMethod.getInstance());
}

From source file:de.blinkt.openvpn.fragments.AboutFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.about, container, false);
    TextView ver = (TextView) v.findViewById(R.id.version);

    String version;//from  www .j a  va  2  s.  c o m
    String name = "Openvpn";
    try {
        PackageInfo packageinfo = getActivity().getPackageManager()
                .getPackageInfo(getActivity().getPackageName(), 0);
        version = packageinfo.versionName;
        name = getString(R.string.app);
    } catch (NameNotFoundException e) {
        version = "error fetching version";
    }

    ver.setText(getString(R.string.version_info, name, version));

    TextView paypal = (TextView) v.findViewById(R.id.donatestring);

    String donatetext = getActivity().getString(R.string.donatewithpaypal);
    Spanned htmltext = Html.fromHtml(donatetext);
    paypal.setText(htmltext);
    paypal.setMovementMethod(LinkMovementMethod.getInstance());
    gmsTextView = (TextView) v.findViewById(R.id.donategms);
    /* recreating view without onCreate/onDestroy cycle */

    // Disable GMS for now
    if (mService != null)
        initGooglePlayDonation();

    TextView translation = (TextView) v.findViewById(R.id.translation);

    // Don't print a text for myself
    if (getString(R.string.translationby).contains("Arne Schwabe"))
        translation.setText("");
    else
        translation.setText(R.string.translationby);

    WebView wv = (WebView) v.findViewById(R.id.webView);
    wv.loadUrl("file:///android_asset/full_licenses.html");

    return v;
}

From source file:com.orange.essentials.otb.ui.OtbTermsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    mView = inflater.inflate(R.layout.otb_terms, container, false);
    LinearLayout llayout = (LinearLayout) mView.findViewById(R.id.otb_terms_layout);
    TextView headerTv = (TextView) llayout.findViewById(R.id.otb_header_tv_text);
    headerTv.setText(R.string.otb_home_terms_content);
    List<Term> terms = TrustBadgeManager.INSTANCE.getTerms();

    for (Term term : terms) {
        View layoutToAdd = null;/*from ww  w . ja  v a 2s.c o m*/
        if (term.getTermType() == TermType.VIDEO
                && Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) {
            layoutToAdd = View.inflate(getActivity(), R.layout.otb_terms_video, null);
            TextView titleTv = (TextView) layoutToAdd.findViewById(R.id.otb_term_video_title);
            final AutoResizingFrameLayout anchorView = (AutoResizingFrameLayout) layoutToAdd
                    .findViewById(R.id.videoSurfaceContainer);
            if (mVideoViews == null) {
                mVideoViews = new ArrayList<>();
            }
            mVideoViews.add(anchorView);
            SurfaceView videoSurface = (SurfaceView) layoutToAdd.findViewById(R.id.videoSurface);

            titleTv.setText(term.getTitleId());

            SurfaceHolder videoHolder = videoSurface.getHolder();
            MediaPlayer player = new MediaPlayer();
            if (mPlayers == null) {
                mPlayers = new ArrayList<>();
            }
            mPlayers.add(player);
            final VideoControllerView controller = new VideoControllerView(getContext());
            VideoCallback videoCallback = new VideoCallback(player, controller, anchorView);
            videoHolder.addCallback(videoCallback);
            anchorView.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    controller.show();
                    return false;
                }
            });
            try {
                player.setAudioStreamType(AudioManager.STREAM_MUSIC);
                player.setDataSource(getContext(), Uri.parse(getString(term.getContentId())));
                player.setOnPreparedListener(videoCallback);
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            } catch (SecurityException e) {
                e.printStackTrace();
            } catch (IllegalStateException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        } else if (term.getTermType() == TermType.TEXT) {//TermType.TEXT
            layoutToAdd = View.inflate(getActivity(), R.layout.otb_terms_text, null);
            TextView titleTv = (TextView) layoutToAdd.findViewById(R.id.otb_term_text_title);
            TextView contentTv = (TextView) layoutToAdd.findViewById(R.id.otb_term_text_content);
            titleTv.setText(term.getTitleId());
            contentTv.setText(Html.fromHtml(getString(term.getContentId())));
            contentTv.setMovementMethod(LinkMovementMethod.getInstance());
            contentTv.setLinkTextColor(getResources().getColor(R.color.colorAccent));
        }
        if (null != layoutToAdd) {
            llayout.addView(layoutToAdd);
        }
        if (terms.indexOf(term) != terms.size() - 1) {
            View.inflate(getActivity(), R.layout.otb_separator, llayout);
        }
    }

    return mView;
}

From source file:org.anhonesteffort.flock.SelectServiceProviderFragment.java

private void initCostPerYear(View fragmentView) {
    final TextView serviceDescription = (TextView) fragmentView.findViewById(R.id.sync_service_description);
    final Double costPerYearUsd = (double) getResources().getInteger(R.integer.cost_per_year_usd);

    serviceDescription.setText(Html.fromHtml(
            getString(R.string.flock_sync_is_a_service_run_by_open_whisper_systems_available, costPerYearUsd)));
    serviceDescription.setMovementMethod(LinkMovementMethod.getInstance());
}