Example usage for android.widget TextView setAutoLinkMask

List of usage examples for android.widget TextView setAutoLinkMask

Introduction

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

Prototype

@android.view.RemotableViewMethod
public final void setAutoLinkMask(int mask) 

Source Link

Document

Sets the autolink mask of the text.

Usage

From source file:com.github.wakhub.monodict.activity.bean.ActivityHelper.java

public AlertDialog.Builder buildNoticeDialog(CharSequence text) {
    TextView textView = new TextView(activity);
    textView.setAutoLinkMask(Linkify.WEB_URLS | Linkify.EMAIL_ADDRESSES);
    textView.setPadding((int) spaceSuperRelax, (int) spaceSuperRelax, (int) spaceSuperRelax,
            (int) spaceSuperRelax);
    textView.setText(text);/*w w  w .  ja  v  a  2 s  .c o  m*/
    ScrollView scrollView = new ScrollView(activity);
    scrollView.addView(textView);
    return new AlertDialog.Builder(activity).setView(scrollView).setPositiveButton(android.R.string.ok, null);
}

From source file:com.github.wakhub.monodict.activity.settings.DownloadsActivity.java

@ItemClick(android.R.id.list)
void onClickListItem(int position) {
    final DownloadsItem item = listAdapter.getItem(position);
    TextView textView = new TextView(this);
    textView.setAutoLinkMask(Linkify.WEB_URLS | Linkify.EMAIL_ADDRESSES);
    textView.setPadding((int) spaceRelax, (int) spaceRelax, (int) spaceRelax, (int) spaceRelax);
    textView.setText(String.format("%s\nsize: %s", item.getDescription(), item.getSize()));
    ScrollView scrollView = new ScrollView(this);
    scrollView.addView(textView);/*from w w  w .j  a v a  2 s. c  om*/

    new AlertDialog.Builder(this)
            .setPositiveButton(R.string.action_download, new AlertDialog.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    resultIntent.putExtra(RESULT_INTENT_ENGLISH, item.isEnglish());
                    resultIntent.putExtra(RESULT_INTENT_FILENAME, item.getName());
                    startDownload(item);
                }
            }).setNegativeButton(android.R.string.cancel, null).setIcon(R.drawable.ic_action_download)
            .setTitle(item.getName()).setView(scrollView).show();
}

From source file:it.scoppelletti.mobilepower.app.HelpActivity.java

/**
 * Creazione dell’attività.
 * /*from   w w  w  .ja va 2s. co  m*/
 * @param savedInstanceState Stato dell’istanza.
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    TextView textControl;
    MarketTagHandler tagHandler;

    super.onCreate(savedInstanceState);

    setTheme(AppUtils.getActivityTheme());
    setContentView(R.layout.textview);

    textControl = (TextView) findViewById(R.id.txt_content);
    textControl.setKeyListener(null);
    textControl.setAutoLinkMask(Linkify.EMAIL_ADDRESSES | Linkify.WEB_URLS);

    tagHandler = new MarketTagHandler();
    textControl.setText(Html.fromHtml(buildText(), null, tagHandler));
    tagHandler.addLinks(textControl, myFullPkgName);
}

From source file:it.scoppelletti.mobilepower.app.ReleaseNoteActivity.java

/**
 * Creazione dell’attività.
 * //from   ww w.  jav  a  2s.c o m
 * @param savedInstanceState Stato dell’istanza.
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    String notes;
    TextView textControl;
    Button button;
    MarketTagHandler tagHandler;

    super.onCreate(savedInstanceState);

    setTheme(AppUtils.getActivityTheme());
    setContentView(R.layout.releasenotes);

    textControl = (TextView) findViewById(R.id.txt_content);
    textControl.setKeyListener(null);
    textControl.setAutoLinkMask(Linkify.EMAIL_ADDRESSES | Linkify.WEB_URLS);

    notes = getIntent().getStringExtra(ReleaseNoteActivity.EXTRA_RELEASENOTES);
    if (!StringUtils.isBlank(notes)) {
        tagHandler = new MarketTagHandler();
        textControl.setText(Html.fromHtml(notes, null, tagHandler));
        tagHandler.addLinks(textControl, AppUtils.getFullPackageName(this, false));
    }

    button = (Button) findViewById(R.id.cmd_continue);
    button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            finish();
        }
    });
}

From source file:it.scoppelletti.mobilepower.app.AboutActivity.java

/**
 * Creazione dell’attività.
 * /*from www.j  a  v a 2  s.c  o  m*/
 * @param savedInstanceState Stato dell’istanza.
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    TextView textControl;
    MarketTagHandler tagHandler;

    super.onCreate(savedInstanceState);

    setTheme(AppUtils.getActivityTheme());
    setContentView(R.layout.textview);

    textControl = (TextView) findViewById(R.id.txt_content);
    textControl.setKeyListener(null);
    textControl.setAutoLinkMask(Linkify.EMAIL_ADDRESSES | Linkify.WEB_URLS);

    tagHandler = new MarketTagHandler();
    textControl.setText(Html.fromHtml(buildText(), null, tagHandler));
    tagHandler.addLinks(textControl, AppUtils.getFullPackageName(this, false));
}

From source file:de.hero.vertretungsplan.PrefsActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.preferences);

    mySharedPreferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext());

    ListPreference listPref = (ListPreference) findPreference("prefs_benachrichtigungsintervall");
    listPref.setSummary(/*from www .java 2s. c om*/
            getSummaryInterval(mySharedPreferences.getString("prefs_benachrichtigungsintervall", "1")));
    listPref.setOnPreferenceChangeListener(new ListPreference.OnPreferenceChangeListener() {
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            preference.setSummary(getSummaryInterval(newValue.toString()));

            MainActivity.setNewAlarm(getBaseContext(), true, newValue.toString());
            return true;
        }

    });

    Preference klasse = findPreference("prefs_klasse");
    klasse.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        public boolean onPreferenceClick(Preference preference) {
            showDialog(R.string.dialog_klasse);
            return true;
        }
    });

    CheckBoxPreference ckBxPref = (CheckBoxPreference) findPreference("prefs_benachrichtigungen");
    ckBxPref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

        public boolean onPreferenceChange(Preference preference, Object newValue) {
            if (preference.getKey().equals("prefs_benachrichtigungen")) {
                MainActivity.setNewAlarm(getBaseContext(), !((CheckBoxPreference) preference).isChecked(),
                        mySharedPreferences);
            }
            return true;
        }
    });

    CheckBoxPreference ckBxPrefAppUpdate = (CheckBoxPreference) findPreference("prefs_check_for_app_updates");
    ckBxPrefAppUpdate.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

        public boolean onPreferenceChange(Preference preference, Object newValue) {
            if (preference.getKey().equals("prefs_check_for_app_updates")) {
                Intent i = new Intent(getBaseContext(), CheckForAppUpdate.class);
                i.putExtra("setTimer", !((CheckBoxPreference) preference).isChecked());
                if (!((CheckBoxPreference) preference).isChecked()) {
                    i.putExtra("checkNow", true);
                }
                getBaseContext().startService(i);
            }
            return true;
        }
    });

    Preference ueber = findPreference("ueber");
    ueber.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        public boolean onPreferenceClick(Preference preference) {
            Dialog ueberDialog = new Dialog(PrefsActivity.this);

            ueberDialog.setContentView(R.layout.ueber_dialog_layout);
            ueberDialog.setTitle(getString(R.string.ueber));
            ueberDialog.setCancelable(true);
            ueberDialog.setCanceledOnTouchOutside(true);

            TextView dialogText = (TextView) ueberDialog.findViewById(R.id.text_in_dialog);
            dialogText.setTextColor(Color.BLACK);
            dialogText.setAutoLinkMask(Linkify.ALL);

            dialogText.setText(String.format(getString(R.string.ueberTextFormated),
                    getString(R.string.version_nr), getString(R.string.emailAdresseEntwickler),
                    getString(R.string.webAdresseAppDownload), getString(R.string.GNU_GPLwebadresse)));
            ueberDialog.show();
            return true;
        }
    });

    CheckBoxPreference ckBxPrefDebugging = (CheckBoxPreference) findPreference("prefs_debug");
    ckBxPrefDebugging.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

        public boolean onPreferenceChange(Preference preference, Object newValue) {
            if (preference.getKey().equals("prefs_debug")) {
                Log.d("PrefsActivity", "new");
                if (!((CheckBoxPreference) preference).isChecked()) {
                    AlertDialog.Builder builder = new AlertDialog.Builder(preference.getContext());

                    builder.setMessage(getString(R.string.debugText)).setTitle(getString(R.string.debugTitel));

                    AlertDialog dialog = builder.create();
                    dialog.show();
                }
            }
            return true;
        }
    });
}

From source file:com.keepassdroid.EntryActivity.java

private void showSamsungDialog() {
    String text = getString(R.string.clipboard_error).concat(System.getProperty("line.separator"))
            .concat(getString(R.string.clipboard_error_url));
    SpannableString s = new SpannableString(text);
    TextView tv = new TextView(this);
    tv.setText(s);// ww  w. j  a  v a 2s .  com
    tv.setAutoLinkMask(RESULT_OK);
    tv.setMovementMethod(LinkMovementMethod.getInstance());
    Linkify.addLinks(s, Linkify.WEB_URLS);

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.clipboard_error_title)
            .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            }).setView(tv).show();

}

From source file:com.mine.psf.PsfFileBrowserActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    // show dialog according to the id
    final String msg;
    if (id == ID_ABOUT) {
        // Get version code
        String versionString = "";
        PackageManager manager = getPackageManager();
        try {//from ww  w  . j av  a  2 s  .c  o m
            PackageInfo info = manager.getPackageInfo(getPackageName(), 0);
            versionString = info.versionName;
        } catch (NameNotFoundException e) {
            e.printStackTrace();
        }
        // Format dialog msg
        msg = String.format(getString(R.string.sexypsf_about), versionString);
    } else {
        Log.e(LOGTAG, "Unknown dialog id");
        msg = "";
    }

    final TextView msgView = new TextView(this);
    msgView.setText(msg);
    msgView.setAutoLinkMask(Linkify.ALL);
    msgView.setTextAppearance(this, android.R.style.TextAppearance_Medium);
    msgView.setMovementMethod(LinkMovementMethod.getInstance());

    return new AlertDialog.Builder(this).setView(msgView).setCancelable(true)
            .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    /* User clicked OK so do some stuff */
                }
            }).create();
}

From source file:it.scoppelletti.mobilepower.app.MarketTagHandler.java

/**
 * Attiva la rilevazione dei collegamenti.
 * /*  ww w. j a  v  a2  s . c  o  m*/
 * @param view    Controllo.
 * @param pkgName Nome del pacchetto.
 */
public void addLinks(TextView view, String pkgName) {
    String text;

    if (myEndPos <= myStartPos || StringUtils.isBlank(pkgName)) {
        return;
    }

    myPkgName = pkgName;

    // http://www.indelible.org/ink/android-linkify, 09/04/2010
    // La rilevazione dei collegamenti personalizzati e' attiva solo
    // disabilitando la rilevazione dei collegamenti di default e 
    // riabilitandola attraverso la classe Linkify.
    view.setAutoLinkMask(0);

    Linkify.addLinks(view, Linkify.ALL);
    text = String.valueOf(view.getText().subSequence(myStartPos, myEndPos));
    Linkify.addLinks(view, Pattern.compile(text), MarketTagHandler.SCHEME, this, this);
}

From source file:br.com.carlosrafaelgn.fplay.ActivityBrowserRadio.java

@Override
public void onClick(View view) {
    if (view == btnGoBack) {
        if (isAtFavorites) {
            isAtFavorites = false;//w  w w . j a  va  2s. co  m
            doSearch();
        } else {
            finish(0, view, true);
        }
    } else if (view == btnFavorite) {
        isAtFavorites = true;
        radioStationList.cancel();
        radioStationList.fetchFavorites(getApplication());
        updateButtons();
    } else if (view == btnSearch) {
        final Context ctx = getHostActivity();
        final LinearLayout l = (LinearLayout) UI.createDialogView(ctx, null);

        LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
        chkGenre = new RadioButton(ctx);
        chkGenre.setText(R.string.genre);
        chkGenre.setChecked(Player.lastRadioSearchWasByGenre);
        chkGenre.setOnClickListener(this);
        chkGenre.setTextSize(TypedValue.COMPLEX_UNIT_PX, UI._DLGsp);
        chkGenre.setLayoutParams(p);

        p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
        p.topMargin = UI._DLGsppad;
        btnGenre = new Spinner(ctx);
        btnGenre.setContentDescription(ctx.getText(R.string.genre));
        btnGenre.setLayoutParams(p);

        p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
        p.topMargin = UI._DLGsppad << 1;
        chkTerm = new RadioButton(ctx);
        chkTerm.setText(R.string.search_term);
        chkTerm.setChecked(!Player.lastRadioSearchWasByGenre);
        chkTerm.setOnClickListener(this);
        chkTerm.setTextSize(TypedValue.COMPLEX_UNIT_PX, UI._DLGsp);
        chkTerm.setLayoutParams(p);

        p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
        p.topMargin = UI._DLGsppad;
        txtTerm = new EditText(ctx);
        txtTerm.setContentDescription(ctx.getText(R.string.search_term));
        txtTerm.setText(Player.radioSearchTerm == null ? "" : Player.radioSearchTerm);
        txtTerm.setOnClickListener(this);
        txtTerm.setTextSize(TypedValue.COMPLEX_UNIT_PX, UI._DLGsp);
        txtTerm.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
        txtTerm.setSingleLine();
        txtTerm.setLayoutParams(p);

        p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
        p.topMargin = UI._DLGsppad;
        p.bottomMargin = UI._DLGsppad;
        final TextView lbl = new TextView(ctx);
        lbl.setAutoLinkMask(0);
        lbl.setLinksClickable(true);
        //http://developer.android.com/design/style/color.html
        lbl.setLinkTextColor(new BgColorStateList(UI.isAndroidThemeLight() ? 0xff0099cc : 0xff33b5e5));
        lbl.setTextSize(TypedValue.COMPLEX_UNIT_PX, UI._14sp);
        lbl.setGravity(Gravity.CENTER_HORIZONTAL);
        lbl.setText(SafeURLSpan.parseSafeHtml(getText(R.string.by_dir_xiph_org)));
        lbl.setMovementMethod(LinkMovementMethod.getInstance());
        lbl.setLayoutParams(p);

        l.addView(chkGenre);
        l.addView(btnGenre);
        l.addView(chkTerm);
        l.addView(txtTerm);
        l.addView(lbl);

        btnGenre.setAdapter(this);
        btnGenre.setSelection(getValidGenre(Player.radioLastGenre));
        defaultTextColors = txtTerm.getTextColors();

        UI.prepareDialogAndShow((new AlertDialog.Builder(ctx)).setTitle(getText(R.string.search)).setView(l)
                .setPositiveButton(R.string.search, this).setNegativeButton(R.string.cancel, this)
                .setOnCancelListener(this).create());
    } else if (view == btnGoBackToPlayer) {
        finish(-1, view, false);
    } else if (view == btnAdd) {
        addPlaySelectedItem(false);
    } else if (view == btnPlay) {
        addPlaySelectedItem(true);
    } else if (view == chkGenre || view == btnGenre) {
        chkGenre.setChecked(true);
        chkTerm.setChecked(false);
    } else if (view == chkTerm || view == txtTerm) {
        chkGenre.setChecked(false);
        chkTerm.setChecked(true);
    } else if (view == list) {
        if (!isAtFavorites && !loading && (radioStationList == null || radioStationList.getCount() == 0))
            onClick(btnFavorite);
    }
}