List of usage examples for android.text.method LinkMovementMethod getInstance
public static MovementMethod getInstance()
From source file:com.loserskater.suhidegui.PackageActivity.java
private void showAbout() { Spanned temp;// w ww . java 2 s . c o m String links = String.format(getString(R.string.version), BuildConfig.VERSION_NAME) + "<br><br><br><a href='https://github.com/loserskater/suhide-GUI'>" + getString(R.string.github) + "</a><br><br>" + "<a href='http://forum.xda-developers.com/android/apps-games/app-suhide-gui-1-0-t3469667'>" + getString(R.string.xda) + "</a>"; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) { temp = Html.fromHtml(links, Html.FROM_HTML_MODE_LEGACY); } else { temp = Html.fromHtml(links); } AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getString(R.string.about)); builder.setMessage(temp); builder.setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog dialog = builder.create(); dialog.show(); ((TextView) dialog.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:cn.zhangls.android.weibo.ui.message.mention.CommentFrameProvider.java
@Override protected void onBindViewHolder(@NonNull final FrameHolder holder, @NonNull final Comment comment) { holder.mBinding.setComment(comment); if (canReply) { setReplyBtnListener(holder, comment); }//www.ja va 2 s .co m final Context context = holder.mBinding.getRoot().getContext(); // ?? Glide.with(context).load(comment.getUser().getProfile_image_url()).centerCrop().crossFade().dontAnimate() .error(R.drawable.avator_default).placeholder(R.drawable.avator_default) .into(holder.mBinding.itemCommentCardUserAvatar); holder.mBinding.itemCommentCardUserAvatar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { UserActivity.actonStart(holder.mBinding.itemCommentCardUserAvatar.getContext(), comment.getUser()); } }); // holder.mBinding.itemCommentCardText.setText(TextUtil.convertText(context, comment.getText(), ContextCompat.getColor(context, R.color.colorAccent), (int) holder.mBinding.itemCommentCardText.getTextSize())); holder.mBinding.itemCommentCardText.setMovementMethod(LinkMovementMethod.getInstance()); holder.mBinding.itemCommentCardText.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { CommentActivity.actionStart(context, holder.mBinding.llCommentContentList, holder.mBinding.getComment().getStatus()); } }); onBindContentViewHolder((SubViewHolder) holder.subViewHolder, comment); }
From source file:com.androzic.About.java
private void updateAboutInfo(final View view) { // version//from w w w . j ava 2s.com String versionName = null; int versionBuild = 0; try { versionName = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionName; versionBuild = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionCode; } catch (NameNotFoundException ex) { versionName = "unable to retreive version"; } final TextView version = (TextView) view.findViewById(R.id.version); version.setText(getString(R.string.version, versionName, versionBuild)); // home links StringBuilder links = new StringBuilder(); links.append("<a href=\""); links.append(": http://androzic.com"); links.append("\">"); links.append(getString(R.string.homepage)); links.append("</a><br /><a href=\""); links.append(getString(R.string.faquri)); links.append("\">"); links.append(getString(R.string.faq)); links.append("</a><br /><a href=\""); links.append(getString(R.string.featureuri)); links.append("\">"); links.append(getString(R.string.feedback)); links.append("</a>"); final TextView homelinks = (TextView) view.findViewById(R.id.homelinks); homelinks.setText(Html.fromHtml(links.toString())); homelinks.setMovementMethod(LinkMovementMethod.getInstance()); // community links StringBuilder communities = new StringBuilder(); communities.append("<a href=\""); communities.append(getString(R.string.googleplusuri)); communities.append("\">"); communities.append(getString(R.string.googleplus)); communities.append("</a><br /><a href=\""); communities.append(getString(R.string.facebookuri)); communities.append("\">"); communities.append(getString(R.string.facebook)); communities.append("</a><br /><a href=\""); communities.append(getString(R.string.twitteruri)); communities.append("\">"); communities.append(getString(R.string.twitter)); communities.append("</a>"); final TextView communitylinks = (TextView) view.findViewById(R.id.communitylinks); communitylinks.setText(Html.fromHtml(communities.toString())); communitylinks.setMovementMethod(LinkMovementMethod.getInstance()); // donations StringBuilder donations = new StringBuilder(); donations.append("<a href=\""); donations.append(getString(R.string.playuri)); donations.append("\">"); donations.append(getString(R.string.donate_google)); donations.append("</a><br /><a href=\""); donations.append(getString(R.string.paypaluri)); donations.append("\">"); donations.append(getString(R.string.donate_paypal)); donations.append("</a>"); final TextView donationlinks = (TextView) view.findViewById(R.id.donationlinks); donationlinks.setText(Html.fromHtml(donations.toString())); donationlinks.setMovementMethod(LinkMovementMethod.getInstance()); Androzic application = Androzic.getApplication(); if (application.isPaid) { view.findViewById(R.id.donations).setVisibility(View.GONE); view.findViewById(R.id.donationtext).setVisibility(View.GONE); donationlinks.setVisibility(View.GONE); } // license final SpannableString message = new SpannableString( Html.fromHtml(getString(R.string.app_eula).replace("/n", "<br/>"))); Linkify.addLinks(message, Linkify.WEB_URLS); final TextView license = (TextView) view.findViewById(R.id.license); license.setText(message); license.setMovementMethod(LinkMovementMethod.getInstance()); // credits String[] names = getResources().getStringArray(R.array.credit_names); String[] merits = getResources().getStringArray(R.array.credit_merits); StringBuilder credits = new StringBuilder(); for (int i = 0; i < names.length; i++) { credits.append("<b>"); credits.append(merits[i]); credits.append("</b> — "); credits.append(names[i]); credits.append("<br />"); } final TextView creditlist = (TextView) view.findViewById(R.id.credits); creditlist.setText(Html.fromHtml(credits.toString())); // dedication final TextView dedicated = (TextView) view.findViewById(R.id.dedicated); dedicated.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { clicks = 1; dedicated.setVisibility(View.GONE); View photo = view.findViewById(R.id.photo); photo.setVisibility(View.VISIBLE); photo.setOnClickListener(redirect); } }); }
From source file:org.jmpm.ethbadge.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { Thread.setDefaultUncaughtExceptionHandler(handleAppCrash); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); try {//from www. j a va 2 s .com GlobalAppSettings.getInstance().initialize(getApplicationContext()); BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if (!mBluetoothAdapter.isEnabled()) { Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableIntent, BluetoothConstants.REQUEST_ENABLE_BT); } } catch (Exception e) { Utils.sendFeedbackEmail(getApplicationContext(), (Exception) e); Toast.makeText(getApplicationContext(), GlobalAppConstants.UNEXPECTED_FATAL_EXCEPTION_MESSAGE, Toast.LENGTH_LONG).show(); } try { final AppCompatActivity myself = this; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { // Only ask for these permissions on runtime when running Android 6.0 or higher switch (ContextCompat.checkSelfPermission(getBaseContext(), Manifest.permission.ACCESS_COARSE_LOCATION)) { case PackageManager.PERMISSION_DENIED: ((TextView) new AlertDialog.Builder(this).setTitle("IMPORTANT").setMessage(Html.fromHtml( "<p>This app requires Bluetooth permissions to work. In addition, some devices require access to device's location permissions to find nearby Bluetooth devices. Please click \"Allow\" on the following runtime permissions popup.</p>" + "<p>For more info see <a href=\"http://developer.android.com/about/versions/marshmallow/android-6.0-changes.html#behavior-hardware-id\">here</a>.</p>")) .setNeutralButton("Okay", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (ContextCompat.checkSelfPermission(getBaseContext(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { int i = 5; ActivityCompat.requestPermissions(myself, new String[] { Manifest.permission.ACCESS_COARSE_LOCATION }, 1); } } }).show().findViewById(android.R.id.message)) .setMovementMethod(LinkMovementMethod.getInstance()); // Make the link clickable. Needs to be called after show(), in order to generate hyperlinks break; case PackageManager.PERMISSION_GRANTED: break; } } } catch (Exception e) { Utils.sendFeedbackEmail(getApplicationContext(), (Exception) e); Toast.makeText(getApplicationContext(), "Error: Could not set permissions", Toast.LENGTH_LONG).show(); } }
From source file:org.onebusaway.android.util.UIUtils.java
public static void setClickableSpan(TextView v, ClickableSpan span) { Spannable text = (Spannable) v.getText(); text.setSpan(span, 0, text.length(), 0); v.setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:com.vuze.android.remote.dialog.DialogFragmentFilterByTags.java
@NonNull @Override//from www .java 2 s.c o m public Dialog onCreateDialog(Bundle savedInstanceState) { SessionInfo sessionInfo = getSessionInfo(); List<Map<?, ?>> tags = sessionInfo == null ? null : sessionInfo.getTags(); if (tags != null && tags.size() > 0) { TreeMap<String, Long> map = new TreeMap<>(); for (Object o : tags) { if (o instanceof Map) { Map<?, ?> mapTag = (Map<?, ?>) o; long uid = MapUtils.getMapLong(mapTag, "uid", 0); String name = MapUtils.getMapString(mapTag, "name", "??"); int type = MapUtils.getMapInt(mapTag, "type", 0); if (type == 3) { // type-name will be "Manual" :( name = "Tag: " + name; } else { String typeName = MapUtils.getMapString(mapTag, "type-name", null); if (typeName != null) { name = typeName + ": " + name; } } map.put(name, uid); } } long[] vals = new long[map.size()]; String[] strings = map.keySet().toArray(new String[map.keySet().size()]); for (int i = 0; i < vals.length; i++) { vals[i] = map.get(strings[i]); } filterByList = new ValueStringArray(vals, strings); } if (filterByList == null) { filterByList = AndroidUtils.getValueStringArray(getResources(), R.array.filterby_list); } AndroidUtils.AlertDialogBuilder alertDialogBuilder = AndroidUtils.createAlertDialogBuilder(getActivity(), R.layout.dialog_filter_by); View view = alertDialogBuilder.view; AlertDialog.Builder builder = alertDialogBuilder.builder; // get our tabHost from the xml TabHost tabHost = (TabHost) view.findViewById(R.id.filterby_tabhost); tabHost.setup(); // create tab 1 TabHost.TabSpec spec1 = tabHost.newTabSpec("tab1"); spec1.setIndicator("States"); spec1.setContent(R.id.filterby_sv_state); tabHost.addTab(spec1); //create tab2 TabHost.TabSpec spec2 = tabHost.newTabSpec("tab2"); spec2.setIndicator("Tags"); spec2.setContent(R.id.filterby_tv_tags); tabHost.addTab(spec2); int height = AndroidUtilsUI.dpToPx(32); tabHost.getTabWidget().getChildAt(0).getLayoutParams().height = height; tabHost.getTabWidget().getChildAt(1).getLayoutParams().height = height; TextView tvState = (TextView) view.findViewById(R.id.filterby_tv_state); tvState.setMovementMethod(LinkMovementMethod.getInstance()); final TextView tvTags = (TextView) view.findViewById(R.id.filterby_tv_tags); tvTags.setMovementMethod(LinkMovementMethod.getInstance()); // for API <= 10 (maybe 11?), otherwise tags will display on one line tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() { @Override public void onTabChanged(String tabId) { if (!tabId.equals("tab2")) { return; } tvTags.post(new Runnable() { @Override public void run() { spanTags.updateTags(); } }); } }); builder.setTitle(R.string.filterby_title); // Add action buttons builder.setPositiveButton(R.string.action_filterby, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { if (mapSelectedTag == null) { return; } long uidSelected = MapUtils.getMapLong(mapSelectedTag, "uid", -1); String name = MapUtils.getMapString(mapSelectedTag, "name", "??"); mListener.filterBy(uidSelected, name, true); } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { DialogFragmentFilterByTags.this.getDialog().cancel(); } }); List<Map<?, ?>> manualTags = new ArrayList<>(); List<Map<?, ?>> stateTags = new ArrayList<>(); if (sessionInfo != null) { // Dialog never gets called wehn getTags has no tags List<Map<?, ?>> allTags = sessionInfo.getTags(); if (allTags != null) { for (Map<?, ?> mapTag : allTags) { int type = MapUtils.getMapInt(mapTag, "type", 0); switch (type) { case 0: case 1: case 2: stateTags.add(mapTag); break; case 3: // manual manualTags.add(mapTag); break; } } } } SpanTagsListener l = new SpanTagsListener() { @Override public void tagClicked(Map mapTag, String name) { mapSelectedTag = mapTag; // todo: long click, don't exit long uidSelected = MapUtils.getMapLong(mapSelectedTag, "uid", -1); mListener.filterBy(uidSelected, name, true); DialogFragmentFilterByTags.this.getDialog().dismiss(); } @Override public int getTagState(Map mapTag, String name) { if (mapSelectedTag == null) { return SpanTags.TAG_STATE_UNSELECTED; } long uidSelected = MapUtils.getMapLong(mapSelectedTag, "uid", -1); if (uidSelected == -1) { return SpanTags.TAG_STATE_UNSELECTED; } long uidQuery = MapUtils.getMapLong(mapTag, "uid", -1); return uidQuery == uidSelected ? SpanTags.TAG_STATE_SELECTED : SpanTags.TAG_STATE_UNSELECTED; } }; spanTags = new SpanTags(getActivity(), sessionInfo, tvTags, l); spanTags.setTagMaps(manualTags); spanTags.setShowIcon(false); spanTags.updateTags(); SpanTags spanState = new SpanTags(getActivity(), sessionInfo, tvState, l); spanState.setTagMaps(stateTags); spanState.setShowIcon(false); spanState.updateTags(); return builder.create(); }
From source file:com.geomoby.geodeals.notification.CustomNotification.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //Hide Title Bar this.requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.geomoby_offer); Intent intent = getIntent();/*from ww w. j a va 2s . c o m*/ ArrayList<GeoMessage> geoMessage = intent.getParcelableArrayListExtra("GeoMessage"); String title = geoMessage.get(0).title; String link = geoMessage.get(0).siteURL; String image_url = geoMessage.get(0).imageURL; String description = geoMessage.get(0).message; final double latitude = Double.valueOf(geoMessage.get(0).latitude); final double longitude = Double.valueOf(geoMessage.get(0).longitude); int notification_id = geoMessage.get(0).id; Button btnClose = (Button) findViewById(R.id.close); btnClose.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Perform action on click CustomNotification.this.finish(); } }); Button btnNearest = (Button) findViewById(R.id.nearest); btnNearest.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { SharedPreferences settingsActivity = CustomNotification.this.getSharedPreferences("GeoMobyPrefs", MODE_PRIVATE); final double myLatitude = Double.valueOf(settingsActivity.getString(SETTING_LAT, "")); final double myLongitude = Double.valueOf(settingsActivity.getString(SETTING_LNG, "")); Context context = CustomNotification.this; Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://maps.google.com/maps?f=d&saddr=" + myLatitude + "," + myLongitude + "&daddr=" + latitude + "," + longitude + "&dirflg=w")); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); } }); Typeface font = Typeface.createFromAsset(getAssets(), "Bitter-Bold.otf"); TextView tvTitle = (TextView) findViewById(R.id.title); tvTitle.setTypeface(font); tvTitle.setText(title); TextView tvDesc = (TextView) findViewById(R.id.description); tvDesc.setTypeface(font); tvDesc.setText(description); TextView tvLink = (TextView) findViewById(R.id.link); tvLink.setTypeface(font); String desc = "<a href=\"" + link + "\">Demo Link</a>"; tvLink.setText(Html.fromHtml(desc)); tvLink.setMovementMethod(LinkMovementMethod.getInstance()); // Warning - Big bitmap images might create errors if (!image_url.equals("")) new DownloadImageTask((ImageView) findViewById(R.id.image)).execute(image_url); //Notify GeoMoby server that user has opened the notification //new ClickThroughAsyncTask(this).execute(notification_id); }
From source file:org.catnut.ui.HelloActivity.java
private void init() { setContentView(R.layout.about);//from w w w. j a v a 2 s . c om mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setOnPageChangeListener(new PagerListener()); mImages = new ArrayList<Image>(); mPagerAdapter = new Gallery(); mViewPager.setAdapter(mPagerAdapter); mViewPager.setPageTransformer(true, new PageTransformer.DepthPageTransformer()); if (mTargetFromGrid != null) { mImages.add(mTargetFromGrid); mPagerAdapter.notifyDataSetChanged(); } mAbout = findViewById(R.id.about); mFantasyDesc = (TextView) findViewById(R.id.description); mFantasyDesc.setMovementMethod(LinkMovementMethod.getInstance()); ActionBar bar = getActionBar(); TextView about = (TextView) findViewById(R.id.about_body); TextView version = (TextView) findViewById(R.id.app_version); TextView appName = (TextView) findViewById(R.id.app_name); TextView weiboApp = (TextView) findViewById(R.id.weibo_app); weiboApp.setText(R.string.weibo_app); appName.setText(R.string.app_name); TextView appDesc = (TextView) findViewById(R.id.app_desc); appDesc.setText(R.string.app_desc); if (CatnutApp.getBoolean(R.string.pref_fantasy_say_salutation, R.bool.default_fantasy_say_salutation)) { version.setText(getString(R.string.about_version_template, getString(R.string.version_name))); int n = (int) (Math.random() * 101); if (0 < n && n < 35) { bar.setTitle(R.string.fantasy); about.setText(Html.fromHtml(getString(R.string.about_body))); about.setMovementMethod(LinkMovementMethod.getInstance()); } else { bar.setTitle(R.string.fantasy); about.setText(Html.fromHtml(getString(R.string.salutation))); about.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL); } } else { mAbout.setVisibility(View.GONE); } loadImage(); mConnectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); if (mApp.getPreferences().getBoolean(getString(R.string.enable_analytics), true)) { mTracker = EasyTracker.getInstance(this); } }
From source file:net.idlesoft.android.apps.github.activities.Repository.java
public void loadRepoInfo() { try {/*from w w w.j ava 2s . c o m*/ // TextView title = // (TextView)findViewById(R.id.tv_top_bar_title); // title.setText(m_jsonData.getString("name")); final TextView repo_name = (TextView) findViewById(R.id.tv_repository_info_name); repo_name.setText(mJson.getString("name")); repo_name.requestFocus(); final TextView repo_desc = (TextView) findViewById(R.id.tv_repository_info_description); repo_desc.setText(mJson.getString("description")); final TextView repo_owner = (TextView) findViewById(R.id.tv_repository_info_owner); repo_owner.setText(mJson.getString("owner")); final TextView repo_watcher_count = (TextView) findViewById(R.id.tv_repository_info_watchers); if (mJson.getInt("watchers") == 1) { repo_watcher_count.setText(mJson.getInt("watchers") + " watcher"); } else { repo_watcher_count.setText(mJson.getInt("watchers") + " watchers"); } final TextView repo_fork_count = (TextView) findViewById(R.id.tv_repository_info_forks); if (mJson.getInt("forks") == 1) { repo_fork_count.setText(mJson.getInt("forks") + " fork"); } else { repo_fork_count.setText(mJson.getInt("forks") + " forks"); } final TextView repo_website = (TextView) findViewById(R.id.tv_repository_info_website); if (mJson.getString("homepage") != "") { repo_website.setText(mJson.getString("homepage")); } else { repo_website.setText("N/A"); } /* Make the repository owner text link to his/her profile */ repo_owner.setMovementMethod(LinkMovementMethod.getInstance()); final Spannable spans = (Spannable) repo_owner.getText(); final ClickableSpan clickSpan = new ClickableSpan() { @Override public void onClick(final View widget) { final Intent i = new Intent(Repository.this, Profile.class); try { i.putExtra("username", mJson.getString("owner")); } catch (final JSONException e) { e.printStackTrace(); } startActivity(i); } }; spans.setSpan(clickSpan, 0, spans.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } catch (final JSONException e) { e.printStackTrace(); } ((Button) findViewById(R.id.btn_repository_info_branches)).setOnClickListener(new OnClickListener() { public void onClick(final View v) { final Intent intent = new Intent(Repository.this, BranchesList.class); intent.putExtra("repo_name", mRepositoryName); intent.putExtra("repo_owner", mRepositoryOwner); startActivity(intent); } }); ((Button) findViewById(R.id.btn_repository_info_issues)).setOnClickListener(new OnClickListener() { public void onClick(final View v) { final Intent intent = new Intent(Repository.this, Issues.class); intent.putExtra("repo_name", mRepositoryName); intent.putExtra("repo_owner", mRepositoryOwner); startActivity(intent); } }); ((Button) findViewById(R.id.btn_repository_info_network)).setOnClickListener(new OnClickListener() { public void onClick(final View v) { final Intent intent = new Intent(Repository.this, NetworkList.class); intent.putExtra("repo_name", mRepositoryName); intent.putExtra("username", mRepositoryOwner); startActivity(intent); } }); }