List of usage examples for android.widget TextView setMovementMethod
public final void setMovementMethod(MovementMethod movement)
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 w w w. j a va 2 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:edu.stanford.mobisocial.dungbeetle.feed.objects.StatusObj.java
public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) { JSONObject content = obj.getJson();/* w w w.j a va2 s. co m*/ TextView valueTV = new TextView(context); valueTV.setText(content.optString(TEXT)); valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); valueTV.setGravity(Gravity.TOP | Gravity.LEFT); if (Linkify.addLinks(valueTV, Linkify.ALL)) { if (!allowInteractions) valueTV.setMovementMethod(null); } frame.addView(valueTV); }
From source file:org.liberty.android.fantastischmemopro.downloader.DownloaderSS.java
protected void fetchDatabase(final DownloadItem di) { View alertView = View.inflate(this, R.layout.link_alert, null); TextView textView = (TextView) alertView.findViewById(R.id.link_alert_message); textView.setMovementMethod(LinkMovementMethod.getInstance()); textView.setText(/*from w w w .j a va 2 s . c o m*/ Html.fromHtml(getString(R.string.downloader_download_alert_message) + di.getDescription())); new AlertDialog.Builder(this).setView(alertView) .setTitle(getString(R.string.downloader_download_alert) + di.getTitle()) .setPositiveButton(getString(R.string.yes_text), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { mProgressDialog = ProgressDialog.show(DownloaderSS.this, getString(R.string.loading_please_wait), getString(R.string.loading_downloading)); new Thread() { public void run() { try { downloadDatabase(di); mHandler.post(new Runnable() { public void run() { mProgressDialog.dismiss(); String dbpath = Environment.getExternalStorageDirectory() .getAbsolutePath() + getString(R.string.default_dir); new AlertDialog.Builder(DownloaderSS.this) .setTitle(R.string.downloader_download_success) .setMessage( getString(R.string.downloader_download_success_message) + dbpath + di.getTitle() + ".db") .setPositiveButton(R.string.ok_text, null).create().show(); } }); } catch (final Exception e) { Log.e(TAG, "Error downloading", e); mHandler.post(new Runnable() { public void run() { mProgressDialog.dismiss(); new AlertDialog.Builder(DownloaderSS.this) .setTitle(R.string.downloader_download_fail) .setMessage(getString(R.string.downloader_download_fail_message) + " " + e.toString()) .setPositiveButton(R.string.ok_text, null).create().show(); } }); } } }.start(); } }).setNegativeButton(getString(R.string.no_text), null).show(); }
From source file:org.klnusbaum.udj.auth.AuthActivity.java
/** * {@inheritDoc}/*from ww w.j av a2s. c om*/ */ @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); mAccountManager = AccountManager.get(this); final Intent intent = getIntent(); mUsername = intent.getStringExtra(PARAM_USERNAME); mRequestNewAccount = mUsername == null; mConfirmCredentials = intent.getBooleanExtra(PARAM_CONFIRM_CREDENTIALS, false); Log.i(TAG, " request new: " + mRequestNewAccount); requestWindowFeature(Window.FEATURE_LEFT_ICON); setContentView(R.layout.login_activity); getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, android.R.drawable.ic_dialog_alert); mMessage = (TextView) findViewById(R.id.message); mUsernameEdit = (EditText) findViewById(R.id.username_edit); mPasswordEdit = (EditText) findViewById(R.id.password_edit); if (!TextUtils.isEmpty(mUsername)) mUsernameEdit.setText(mUsername); mMessage.setText(getMessage()); TextView signUp = (TextView) findViewById(R.id.signup_text); signUp.setText(Html.fromHtml(getString(R.string.dont_have_account))); signUp.setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:com.tortel.deploytrack.dialog.AboutDialog.java
@NonNull @Override/*from w ww .java 2 s . c o m*/ public Dialog onCreateDialog(Bundle savedInstanceState) { final Context wrappedContext = new ContextThemeWrapper(getActivity(), R.style.Theme_DeployThemeLight); MaterialDialog.Builder builder = new MaterialDialog.Builder(wrappedContext); LayoutInflater inflater = getActivity().getLayoutInflater().cloneInContext(wrappedContext); @SuppressLint("InflateParams") View view = inflater.inflate(R.layout.dialog_about, null); TextView text = (TextView) view.findViewById(R.id.about_view); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { text.setText(Html.fromHtml(readRawTextFile(getContent()), Html.FROM_HTML_MODE_LEGACY)); } else { //noinspection deprecation text.setText(Html.fromHtml(readRawTextFile(getContent()))); } Linkify.addLinks(text, Linkify.ALL); text.setMovementMethod(LinkMovementMethod.getInstance()); builder.customView(view, false); builder.title(getTitleString()); builder.positiveText(R.string.close); return builder.build(); }
From source file:org.runbuddy.tomahawk.dialogs.ResolverConfigDialog.java
/** * Called when this {@link android.support.v4.app.DialogFragment} is being created *//* www .j a v a 2s. c o m*/ @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { if (getArguments() != null && getArguments().containsKey(TomahawkFragment.PREFERENCEID)) { String resolverId = getArguments().getString(TomahawkFragment.PREFERENCEID); mScriptResolver = PipeLine.get().getResolver(resolverId); } EditText showKeyboardEditText = null; EditText lastEditText = null; if (mScriptResolver.getConfigUi() != null) { TextView headerTextView = (TextView) addScrollingViewToFrame(R.layout.config_textview); headerTextView.setText(mScriptResolver.getDescription()); for (ScriptResolverConfigUiField field : mScriptResolver.getConfigUi()) { Map<String, Object> config = mScriptResolver.getConfig(); if (ScriptResolverConfigUiField.TYPE_TEXTVIEW.equals(field.type)) { TextView textView = (TextView) addScrollingViewToFrame(R.layout.config_textview); if (field.text.startsWith("<html>")) { textView.setText(Html.fromHtml(field.text)); textView.setMovementMethod(LinkMovementMethod.getInstance()); } else { textView.setText(field.text); } } else if (ScriptResolverConfigUiField.TYPE_CHECKBOX.equals(field.type)) { LinearLayout checkboxLayout = (LinearLayout) addScrollingViewToFrame(R.layout.config_checkbox); TextView textView = (TextView) checkboxLayout.findViewById(R.id.config_textview); textView.setText(field.label); ConfigCheckbox checkBox = (ConfigCheckbox) checkboxLayout.findViewById(R.id.config_checkbox); checkBox.mConfigFieldId = field.id; mConfigFieldViews.add(checkBox); if (config.get(field.id) != null) { checkBox.setChecked((Boolean) config.get(field.id)); } else { checkBox.setChecked(Boolean.valueOf(field.defaultValue)); } } else if (ScriptResolverConfigUiField.TYPE_TEXTFIELD.equals(field.type)) { ConfigEdittext editText = (ConfigEdittext) addScrollingViewToFrame(R.layout.config_edittext); editText.mConfigFieldId = field.id; editText.setHint(field.label); mConfigFieldViews.add(editText); if (config.get(field.id) != null) { editText.setText((String) config.get(field.id)); } else { editText.setText(field.defaultValue); } if (field.isPassword) { editText.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD); editText.setTransformationMethod(new PasswordTransformationMethod()); } if (showKeyboardEditText == null) { showKeyboardEditText = editText; } lastEditText = editText; } else if (ScriptResolverConfigUiField.TYPE_DROPDOWN.equals(field.type)) { LinearLayout numberpickerLayout = (LinearLayout) addScrollingViewToFrame( R.layout.config_dropdown); TextView textView = (TextView) numberpickerLayout.findViewById(R.id.config_textview); textView.setText(field.label); ConfigDropDown dropDown = (ConfigDropDown) numberpickerLayout .findViewById(R.id.config_dropdown); dropDown.mConfigFieldId = field.id; mConfigFieldViews.add(dropDown); List<CharSequence> list = new ArrayList<>(); for (String item : field.items) { list.add(item); } ArrayAdapter<CharSequence> adapter = new ArrayAdapter<>(TomahawkApp.getContext(), R.layout.spinner_textview, list); adapter.setDropDownViewResource(R.layout.spinner_dropdown_textview); dropDown.setAdapter(adapter); if (config.get(field.id) != null) { dropDown.setSelection(((Double) config.get(field.id)).intValue()); } else { dropDown.setSelection(Integer.valueOf(field.defaultValue)); } } } } if (mScriptResolver.getScriptAccount().isManuallyInstalled()) { showRemoveButton(new View.OnClickListener() { @Override public void onClick(View v) { RemovePluginConfigDialog dialog = new RemovePluginConfigDialog(); Bundle args = new Bundle(); args.putString(TomahawkFragment.PREFERENCEID, mScriptResolver.getId()); dialog.setArguments(args); dialog.show(getFragmentManager(), null); dismiss(); } }); } if (lastEditText != null) { lastEditText.setOnEditorActionListener(mOnKeyboardEnterListener); } if (showKeyboardEditText != null) { ViewUtils.showSoftKeyboard(showKeyboardEditText); } setDialogTitle(mScriptResolver.getName()); showEnableButton(mEnableButtonListener); onResolverStateUpdated(mScriptResolver); hideNegativeButton(); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setView(getDialogView()); return builder.create(); }
From source file:com.yonisamlan.android.metaqr.AttributionsActivity.java
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView textView = new TextView(this); setContentView(textView);// w w w . ja va2 s. c o m String html; try { html = IOUtils.toString(getResources().openRawResource(R.raw.licenses)); } catch (NotFoundException e) { e.printStackTrace(); html = "Error reading license."; } catch (IOException e) { e.printStackTrace(); html = "Error reading license."; } textView.setText(Html.fromHtml(html)); textView.setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:pedromendes.tempodeespera.HospitalDetailActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_hospital_detail); Typeface font = Typeface.createFromAsset(getAssets(), "fontawesome-webfont.ttf"); Long hospitalId = getIntent().getExtras().getLong("HOSPITAL_ID"); String hospitalName = getIntent().getExtras().getString("HOSPITAL_NAME"); String hospitalDescription = getIntent().getExtras().getString("HOSPITAL_DESCRIPTION"); String hospitalAddress = getIntent().getExtras().getString("HOSPITAL_ADDRESS"); final String hospitalPhone = getIntent().getExtras().getString("HOSPITAL_PHONE"); String hospitalEmail = getIntent().getExtras().getString("HOSPITAL_EMAIL"); String latitude = getIntent().getExtras().getString("HOSPITAL_LAT"); String longitude = getIntent().getExtras().getString("HOSPITAL_LONG"); TextView hospitalNameView = (TextView) findViewById(R.id.hospitalName); hospitalNameView.setText(hospitalName); if (hospitalAddress != null && !hospitalAddress.isEmpty()) { TextView hospitalAddressView = (TextView) findViewById(R.id.hospitalAddress); hospitalAddressView.setText(Html.fromHtml(hospitalAddress + "<br/>" + "<a href=\"geo:" + latitude + "," + longitude + "\">" + "Ver mapa" + "</a>")); hospitalAddressView.setMovementMethod(LinkMovementMethod.getInstance()); }/*w ww. j a va 2 s. co m*/ if (hospitalPhone != null && !hospitalPhone.isEmpty()) { Button hospitalPhoneView = (Button) findViewById(R.id.hospitalPhone); hospitalPhoneView.append(" " + hospitalPhone); hospitalPhoneView.setTypeface(font); hospitalPhoneView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { Intent callIntent = new Intent(Intent.ACTION_CALL); callIntent.setData(Uri.parse("tel:" + hospitalPhone)); callIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) { return; } startActivity(callIntent); } }); } dialog = new ProgressDialog(this); dialog.setMessage("A carregar..."); dialog.show(); new RequestHospitalDetailTask().execute(hospitalId.toString()); }
From source file:net.olejon.spotcommander.AddComputerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Power manager final PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); //noinspection deprecation mWakeLock = powerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "wakeLock"); // Allow landscape? if (!mTools.allowLandscape()) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // Layout//from w ww. j av a2 s . c o m setContentView(R.layout.activity_add_computer); // Toolbar final Toolbar toolbar = (Toolbar) findViewById(R.id.add_computer_toolbar); toolbar.setTitleTextColor(ContextCompat.getColor(mContext, R.color.white)); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); mAddComputerNameInputLayout = (TextInputLayout) findViewById(R.id.add_computer_text_input_name_layout); mAddComputerUriInputLayout = (TextInputLayout) findViewById(R.id.add_computer_text_input_uri_layout); mAddComputerNameInputLayout.setHintAnimationEnabled(true); mAddComputerUriInputLayout.setHintAnimationEnabled(true); // Progress bar mProgressBar = (ProgressBar) findViewById(R.id.add_computer_progressbar); // Information final TextView textView = (TextView) findViewById(R.id.add_computer_information); textView.setMovementMethod(LinkMovementMethod.getInstance()); // Scan dialog new MaterialDialog.Builder(mContext).title(R.string.add_computer_scan_dialog_title) .content(getString(R.string.add_computer_scan_dialog_message)) .positiveText(R.string.add_computer_scan_dialog_positive_button) .negativeText(R.string.add_computer_scan_dialog_negative_button) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog materialDialog, @NonNull DialogAction dialogAction) { scanNetwork(); } }).contentColorRes(R.color.black).negativeColorRes(R.color.black).show(); }
From source file:com.concentricsky.android.khanacademy.app.HomeActivity.java
private void showTOSAcknowledgement() { View contentView = LayoutInflater.from(this).inflate(R.layout.dialog_tos, null, false); // Use this LinkMovementMethod (as opposed to just the xml setting android:autoLink="web") to allow for named links. TextView mustAccept = (TextView) contentView.findViewById(R.id.dialog_tos_must_accept); TextView notEndorsed = (TextView) contentView.findViewById(R.id.dialog_tos_not_endorsed); mustAccept.setMovementMethod(LinkMovementMethod.getInstance()); notEndorsed.setMovementMethod(LinkMovementMethod.getInstance()); new AlertDialog.Builder(this).setCancelable(false).setView(contentView) .setPositiveButton(getString(R.string.button_i_accept), new DialogInterface.OnClickListener() { @Override//from w w w . ja v a2 s.co m public void onClick(DialogInterface dialog, int which) { // Store the fact that the user has accepted. getSharedPreferences(Constants.SETTINGS_NAME, Context.MODE_PRIVATE).edit() .putBoolean(Constants.SETTING_ACKNOWLEDGEMENT, true).apply(); } }).setNegativeButton(getString(R.string.button_quit), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }).show(); }