List of usage examples for android.text.method LinkMovementMethod getInstance
public static MovementMethod getInstance()
From source file:org.irmacard.cardemu.selfenrol.EnrollSelectActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.i(TAG, "onCreate() called"); // Disable screenshots in release builds if (!BuildConfig.DEBUG) { getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE); }//from w ww . j a v a2 s.c o m setContentView(R.layout.enroll_activity_start); setTitle(R.string.app_name_enroll); enableContinueButton(); screen = SCREEN_START; updateProgressCounter(); String helpHtml = getString(R.string.se_connect_mno); TextView helpTextView = (TextView) findViewById(R.id.se_feedback_text); if (helpTextView != null) { // Can be null if we are on error screen helpTextView.setText(Html.fromHtml(helpHtml)); helpTextView.setMovementMethod(LinkMovementMethod.getInstance()); helpTextView.setLinksClickable(true); } }
From source file:ooo.oxo.moments.feed.FeedAdapter.java
@Override public void onBindViewHolder(ViewHolder holder, int position) { Media item = feed.get(position); Glide.with(context).load(item.user.profilePicture).bitmapTransform(new CropCircleTransformation(context)) .diskCacheStrategy(DiskCacheStrategy.ALL).into(holder.avatar); ViewCompat.setTransitionName(holder.avatar, item.user.id + "_" + item.id + "_avatar"); holder.user.setText(item.user.username); holder.time.setText(DATE_FORMAT.format(item.createdTime)); Media.Resources.Resource image = item.images.standardResolution; holder.image.setOriginalSize(image.width, image.height); Glide.with(context).load(image.url).into(holder.image); if (item.likes.count > 0) { holder.likes.setText(context.getString(R.string.n_likes, item.likes.count)); holder.likes.setVisibility(View.VISIBLE); } else {/*from w ww.j a v a 2 s. c om*/ holder.likes.setVisibility(View.GONE); } holder.comments.removeAllViews(); holder.comments.setVisibility(item.caption != null || item.comments.count > 0 ? View.VISIBLE : View.GONE); if (item.caption != null) { TextView caption = (TextView) inflater.inflate(R.layout.feed_comment_item, holder.comments, false); CharSequence text = CommentTextUtils.format(item.user.username, item.caption.text, item.tags, () -> listener.onUserClick(item.user.id), null); caption.setText(text, TextView.BufferType.SPANNABLE); caption.setMovementMethod(LinkMovementMethod.getInstance()); holder.comments.addView(caption); } for (Comment comment : item.comments.data) { TextView child = (TextView) inflater.inflate(R.layout.feed_comment_item, holder.comments, false); CharSequence text = CommentTextUtils.format(comment.from.username, comment.text, () -> listener.onUserClick(comment.from.id)); child.setText(text, TextView.BufferType.SPANNABLE); child.setMovementMethod(LinkMovementMethod.getInstance()); holder.comments.addView(child); } }
From source file:com.money.manager.ex.about.AboutFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { String text, version;//from w w w . ja v a 2 s . co m View view = inflater.inflate(R.layout.about_fragment, container, false); MmxBaseFragmentActivity activity = (MmxBaseFragmentActivity) getActivity(); if (activity != null && activity.getSupportActionBar() != null) { activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true); } // Version application TextView txtVersion = (TextView) view.findViewById(R.id.textViewVersion); Core core = new Core(getActivity()); version = core.getAppVersionName(); // build = core.getAppVersionBuild(); txtVersion.setText(getString(R.string.version) + " " + version); // + " (" + getString(R.string.build) + " " + build + ")" // Send Feedback TextView txtFeedback = (TextView) view.findViewById(R.id.textViewLinkFeedback); text = "<u>" + txtFeedback.getText() + "</u>"; txtFeedback.setText(Html.fromHtml(text)); txtFeedback.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("message/rfc822"); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { Constants.EMAIL }); intent.putExtra(Intent.EXTRA_SUBJECT, "MoneyManagerEx for Android: Feedback"); try { startActivity(Intent.createChooser(intent, "Send mail...")); } catch (Exception e) { Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_SHORT).show(); } } }); // rate application TextView txtRate = (TextView) view.findViewById(R.id.textViewLinkRate); text = "<u>" + txtRate.getText() + "</u>"; txtRate.setText(Html.fromHtml(text)); txtRate.setMovementMethod(LinkMovementMethod.getInstance()); OnClickListenerUrl clickListenerRate = new OnClickListenerUrl(); clickListenerRate.setUrl("http://play.google.com/store/apps/details?id=com.money.manager.ex"); txtRate.setOnClickListener(clickListenerRate); // application issue tracker TextView txtIssues = (TextView) view.findViewById(R.id.textViewIssuesTracker); text = "<u>" + txtIssues.getText() + "</u>"; txtIssues.setText(Html.fromHtml(text)); txtIssues.setMovementMethod(LinkMovementMethod.getInstance()); OnClickListenerUrl clickListenerIssuesTracker = new OnClickListenerUrl(); clickListenerIssuesTracker.setUrl("https://github.com/moneymanagerex/android-money-manager-ex/issues/"); txtIssues.setOnClickListener(clickListenerIssuesTracker); // MMEX for Android web page TextView txtWebsite = (TextView) view.findViewById(R.id.textViewWebSite); text = "<u>" + txtWebsite.getText() + "</u>"; txtWebsite.setText(Html.fromHtml(text)); txtWebsite.setMovementMethod(LinkMovementMethod.getInstance()); OnClickListenerUrl clickListenerWebsite = new OnClickListenerUrl(); clickListenerWebsite.setUrl("http://android.moneymanagerex.org/"); txtWebsite.setOnClickListener(clickListenerWebsite); // report set link TextView txtReport = (TextView) view.findViewById(R.id.textViewLinkWebSite); text = "<u>" + txtReport.getText() + "</u>"; txtReport.setText(Html.fromHtml(text)); txtReport.setMovementMethod(LinkMovementMethod.getInstance()); OnClickListenerUrl clickListenerFeedback = new OnClickListenerUrl(); clickListenerFeedback .setUrl("http://www.moneymanagerex.org/?utm_campaign=Application_Android&utm_medium=MMEX_" + version + "&utm_source=Website"); txtReport.setOnClickListener(clickListenerFeedback); // image view google plus OnClickListenerUrl clickListenerGooglePlus = new OnClickListenerUrl(); clickListenerGooglePlus.setUrl("http://goo.gl/R693Ih"); ImageView imageViewGooglePlus = (ImageView) view.findViewById(R.id.imageViewGooglePlus); imageViewGooglePlus.setOnClickListener(clickListenerGooglePlus); // image view github OnClickListenerUrl clickListenerGithub = new OnClickListenerUrl(); clickListenerGithub.setUrl("https://github.com/moneymanagerex/android-money-manager-ex"); ImageView imageViewGithub = (ImageView) view.findViewById(R.id.imageViewGithub); imageViewGithub.setOnClickListener(clickListenerGithub); // image view twitter OnClickListenerUrl clickListenerTwitter = new OnClickListenerUrl(); clickListenerTwitter.setUrl("https://twitter.com/MMEX4Android"); ImageView imageViewTwitter = (ImageView) view.findViewById(R.id.imageViewTwitter); imageViewTwitter.setOnClickListener(clickListenerTwitter); // GPLv2 license TextView txtLicense = (TextView) view.findViewById(R.id.textViewLicense); text = "<u>" + txtLicense.getText() + "</u>"; txtLicense.setText(Html.fromHtml(text)); OnClickListenerUrl clickListenerLicense = new OnClickListenerUrl(); clickListenerLicense.setUrl("http://www.gnu.org/licenses/old-licenses/gpl-2.0.html"); txtLicense.setOnClickListener(clickListenerLicense); // logcat TextView txtLogcat = (TextView) view.findViewById(R.id.textViewLogcat); text = "<u>" + txtLogcat.getText() + "</u>"; txtLogcat.setText(Html.fromHtml(text)); txtLogcat.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { LynxConfig lynxConfig = new LynxConfig(); lynxConfig.setMaxNumberOfTracesToShow(4000); Intent lynxActivityIntent = LynxActivity.getIntent(getActivity(), lynxConfig); startActivity(lynxActivityIntent); } }); // Donate, button Button buttonDonate = (Button) view.findViewById(R.id.buttonDonateInApp); buttonDonate.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(getActivity(), DonateActivity.class)); } }); // Send logcat button Button sendLogcatButton = (Button) view.findViewById(R.id.sendLogcatButton); sendLogcatButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { sendLogcat(); } }); return view; }
From source file:me.futuretechnology.blops.ui.NewsInfoActivity.java
@Override protected void initUI() { super.initUI(); Intent intent = getIntent();/* www. j a v a 2 s . co m*/ StringBuilder txtCaption = new StringBuilder(128); String author = intent.getStringExtra(EXTRA_AUTHOR); if (!TextUtils.isEmpty(author)) { txtCaption.append(author); txtCaption.append('\n'); } txtCaption.append(DateTime.formatDateTime(this, intent.getLongExtra(EXTRA_DATE, 0), ", ")); TextView tvDate = (TextView) findViewById(R.id.news_caption); tvDate.setText(txtCaption); TextView tvTitle = (TextView) findViewById(R.id.news_title); tvTitle.setText(intent.getStringExtra(EXTRA_TITLE)); TextView tvContent = (TextView) findViewById(R.id.news_content); String txt = intent.getStringExtra(EXTRA_CONTENT_VALUES); tvContent.setText(Html.fromHtml(txt, null, new HtmlTagHandler())); // tvContent.setText(Html.fromHtml("Hello <b>world</b>!<br>This is only a <a href=\"http://www.google.com\">test</a>.")); tvContent.setMovementMethod(LinkMovementMethod.getInstance()); // Log.i("BLOPS", "types: ", intent.getStringExtra(EXTRA_CONTENT_TYPES)); Log.i("BLOPS", "values: ", txt); // Log.i("BLOPS", "url: ", intent.getStringExtra(EXTRA_URL)); // Log.i("BLOPS", "id: ", intent.getStringExtra(EXTRA_ID)); final String url = getIntent().getStringExtra(EXTRA_URL); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab_open_in_browser); if (TextUtils.isEmpty(url)) { fab.setVisibility(View.GONE); } else { fab.setVisibility(View.VISIBLE); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent iBrowser = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); iBrowser.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(iBrowser); } }); fab.attachToScrollView((ObservableScrollView) findViewById(R.id.news_container)); } }
From source file:com.limewoodmedia.nsdroid.fragments.EmbassiesFragment.java
@Override public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { root = inflater.inflate(R.layout.embassies, null, false); list = (ListView) root.findViewById(R.id.embassies_list); embassies = new ArrayList<Embassy>(); listAdapter = new ArrayAdapter<Embassy>(context, 0, embassies) { @Override//from w ww. j av a 2 s. com public View getView(int position, View convertView, ViewGroup parent) { View view; TextView name, status; Embassy embassy; if (convertView == null) { view = inflater.inflate(R.layout.embassy, null); name = (TextView) view.findViewById(R.id.embassy_name); name.setMovementMethod(LinkMovementMethod.getInstance()); status = (TextView) view.findViewById(R.id.embassy_status); } else { view = convertView; name = (TextView) view.findViewById(R.id.embassy_name); status = (TextView) view.findViewById(R.id.embassy_status); } embassy = getItem(position); // Region String eName = TagParser.idToName(embassy.region); name.setText(Html.fromHtml(eName)); // Status String str = null; Resources res = getResources(); int background = R.drawable.embassy_established; switch (embassy.status) { case INVITED: str = res.getString(R.string.embassy_invited); background = R.drawable.embassy_invited; break; case PENDING: str = res.getString(R.string.embassy_pending); background = R.drawable.embassy_pending; break; case REQUESTED: str = res.getString(R.string.embassy_requested); background = R.drawable.embassy_requested; break; case REJECTED: str = res.getString(R.string.embassy_rejected); background = R.drawable.embassy_denied; break; case CLOSING: str = res.getString(R.string.embassy_closing); background = R.drawable.embassy_closing; break; case ESTABLISHED: break; } status.setText(str); view.setBackgroundResource(background); view.setTag(embassy); view.setOnClickListener(EmbassiesFragment.this); name.setOnClickListener(EmbassiesFragment.this); status.setOnClickListener(EmbassiesFragment.this); return view; } }; list.setAdapter(listAdapter); ((Spinner) root.findViewById(R.id.embassies_filter)).setOnItemSelectedListener(this); return root; }
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 w w . j a va 2 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:org.libreoffice.impressremote.fragment.ComputersFragment.java
private void showLearnMoreMessage() { TextView learnMoreView = (TextView) getView().findViewById(R.id.text_learn_more); Animation aFadeInAnimation = AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in); learnMoreView.setMovementMethod(LinkMovementMethod.getInstance()); learnMoreView.startAnimation(aFadeInAnimation); learnMoreView.setVisibility(View.VISIBLE); }
From source file:org.runbuddy.tomahawk.dialogs.ResolverConfigDialog.java
/** * Called when this {@link android.support.v4.app.DialogFragment} is being created *//*from w ww . j a va2 s .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.pedometrak.ui.ActivityMain.java
public boolean handleItemSelected(final MenuItem item) { switch (item.getItemId()) { case android.R.id.home: getFragmentManager().popBackStackImmediate(); break;/*from www.j a v a 2 s . co m*/ case R.id.action_settings: getFragmentManager().beginTransaction().replace(android.R.id.content, new FragmentSettings()) .addToBackStack(null).commit(); break; case R.id.action_about: AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.about); TextView tv = new TextView(this); tv.setPadding(30, 30, 30, 30); tv.setText(R.string.about_text_links); try { tv.append(getString(R.string.about_app_version, getPackageManager().getPackageInfo(getPackageName(), 0).versionName)); } catch (NameNotFoundException e1) { // should not happen as the app is definitely installed when // seeing the dialog e1.printStackTrace(); } tv.setMovementMethod(LinkMovementMethod.getInstance()); builder.setView(tv); builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.create().show(); break; } return true; }
From source file:org.jared.synodroid.ds.ui.HelpFragment.java
/** * Activity creation/*from ww w .ja v a2 s . co m*/ */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); try { if (((Synodroid) getActivity().getApplication()).DEBUG) Log.v(Synodroid.DS_TAG, "HelpFragment: Creating help fragment"); } catch (Exception ex) { /*DO NOTHING*/} final FragmentActivity helpActivity = this.getActivity(); View help = inflater.inflate(R.layout.help, null, false); Button helpBtn = (Button) help.findViewById(R.id.id_email); helpBtn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { try { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("plain/text"); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "synodroid@gmail.com" }); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Synodroid Free - help"); startActivity(emailIntent); } catch (Exception e) { AlertDialog.Builder builder = new AlertDialog.Builder(helpActivity); builder.setMessage(R.string.err_noemail); builder.setTitle(getString(R.string.connect_error_title)).setCancelable(false) .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog errorDialog = builder.create(); try { errorDialog.show(); } catch (BadTokenException ex) { // Unable to show dialog probably because intent has been closed. Ignoring... } } } }); Button gplusBtn = (Button) help.findViewById(R.id.id_gplus); gplusBtn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { String url = "https://plus.google.com/111893484035545745539"; Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); } }); TextView main_web = (TextView) help.findViewById(R.id.syno_main_web); main_web.setText(Html.fromHtml("<a href=\"http://www.synology.com\">www.synology.com</a>")); main_web.setMovementMethod(LinkMovementMethod.getInstance()); TextView buy = (TextView) help.findViewById(R.id.syno_buy_web); buy.setText(Html.fromHtml( "<a href=\"http://www.synology.com/support/wheretobuy.php\">www.synology.com/support/wheretobuy.php</a>")); buy.setMovementMethod(LinkMovementMethod.getInstance()); return help; }