List of usage examples for android.widget TextView setMovementMethod
public final void setMovementMethod(MovementMethod movement)
From source file:com.coincide.alphafitness.ui.Activity_Main.java
public boolean optionsItemSelected(final MenuItem item) { switch (item.getItemId()) { case android.R.id.home: getFragmentManager().popBackStackImmediate(); break;// www . j av a2 s . c o m case R.id.action_settings: getFragmentManager().beginTransaction().replace(android.R.id.content, new Fragment_Settings()) .addToBackStack(null).commit(); break; case R.id.action_leaderboard: case R.id.action_achievements: AlertDialog.Builder builder2 = new AlertDialog.Builder(this); builder2.setTitle("Google services required"); builder2.setMessage("This feature is not available on the F-Droid version of the app"); builder2.setNegativeButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder2.create().show(); break; case R.id.action_faq: startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://j4velin.de/faq/index.php?app=pm")) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); 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(10, 10, 10, 10); 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:com.pedometrak.ui.ActivityMain.java
public boolean handleItemSelected(final MenuItem item) { switch (item.getItemId()) { case android.R.id.home: getFragmentManager().popBackStackImmediate(); break;//from w w w . j ava 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:fiskinfoo.no.sintef.fiskinfoo.CardViewFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View rootView = inflater.inflate(R.layout.fragment_card_view, container, false); RelativeLayout textAreaPlaceHolder = (RelativeLayout) rootView.findViewById(R.id.card_view_container); TextView title = (TextView) rootView.findViewById(R.id.card_view_title_text_view); if (subscription != null) { title.setText(subscription.GeoDataServiceName); TextView idView = generateTextViewWithText("id: " + subscription.Id, title); TextView geoDataServiceNameView = generateTextViewWithText( "Navn p kartlaget: " + subscription.GeoDataServiceName, idView); TextView fileFormatTypeView = generateTextViewWithText("Filformat: " + subscription.FileFormatType, geoDataServiceNameView); TextView userEmailView = generateTextViewWithText("Bruker e-post: " + subscription.UserEmail, fileFormatTypeView);/*w w w . j a v a2s .com*/ TextView subscriptionEmailView = generateTextViewWithText( "Abbonents e-post: " + subscription.SubscriptionEmail, userEmailView); TextView subscriptionIntervalNameView = generateTextViewWithText( "Kartet sendes: " + subscription.SubscriptionIntervalName, subscriptionEmailView); TextView createdView = generateTextViewWithText("Opprettet: " + subscription.Created, subscriptionIntervalNameView); TextView lastModifiedView = generateTextViewWithText("Sist oppdatert: " + subscription.LastModified, createdView); textAreaPlaceHolder.addView(idView); textAreaPlaceHolder.addView(geoDataServiceNameView); textAreaPlaceHolder.addView(fileFormatTypeView); textAreaPlaceHolder.addView(userEmailView); textAreaPlaceHolder.addView(subscriptionEmailView); textAreaPlaceHolder.addView(subscriptionIntervalNameView); textAreaPlaceHolder.addView(createdView); textAreaPlaceHolder.addView(lastModifiedView); } if (propertyDescription != null) { title.setText(propertyDescription.Name); Button notificationIconButton = (Button) rootView.findViewById(R.id.card_notification_image_view); CardViewInformationRow row; Button downloadMapButton; Button showOnMapButton; final ScrollView scrollView = (ScrollView) rootView.findViewById(R.id.card_view_scroll_view); final LinearLayout informationContainer = (LinearLayout) rootView .findViewById(R.id.card_view_information_container); LinearLayout bottomButtonContainer = (LinearLayout) rootView.findViewById(R.id.bottom_button_container); showOnMapButton = new Button(getActivity()); downloadMapButton = (Button) rootView.findViewById(R.id.card_view_download_map_button); row = utilityRows.getCardViewInformationRow(getActivity(), getString(R.string.last_updated), propertyDescription.LastUpdated.replace('T', ' '), true); informationContainer.addView(row.getView()); String description = (propertyDescription.LongDescription == null || propertyDescription.LongDescription.trim().equals("")) ? propertyDescription.Description : propertyDescription.LongDescription; String hyperlink = null; description = description.replace("<p>", ""); description = description.replace("</p>", ""); // TODO: should rewrite in order to handle multiple links. if (description.contains("<a href=\"")) { hyperlink = "<a href='" + description.substring(description.indexOf("href=") + 6, description.indexOf(">", description.indexOf("href=")) - 1) + "'>" + "\t\t\t* " + getString(R.string.see_more_info) + "</a>"; description = description.substring(0, description.indexOf("<a href")) + description.substring(description.indexOf(">", description.indexOf("<a href")) + 1, description.indexOf("</a")) + "*" + (description.indexOf("a>") > description.length() - 3 ? "" : description.substring(description.indexOf("a>") + 2, description.length())); } row = utilityRows.getCardViewInformationRow(getActivity(), getString(R.string.information), description, true); informationContainer.addView(row.getView()); if (hyperlink != null) { TextView textView = new TextView(getActivity()); textView.setClickable(true); textView.setMovementMethod(LinkMovementMethod.getInstance()); textView.setText(Html.fromHtml(hyperlink)); textView.setTextSize(getResources().getInteger(R.integer.hyperlinkTextSize)); informationContainer.addView(textView); } String updateFrequency = (propertyDescription.UpdateFrequencyText == null || propertyDescription.UpdateFrequencyText.trim().equals("")) ? getString(R.string.update_frequency_not_available) : propertyDescription.UpdateFrequencyText; row = utilityRows.getCardViewInformationRow(getActivity(), getString(R.string.update_frequency), updateFrequency, true); informationContainer.addView(row.getView()); if (ApiErrorType.getType(propertyDescription.ErrorType) == ApiErrorType.WARNING) { row = utilityRows.getCardViewInformationRow(getActivity(), getString(R.string.error_text), propertyDescription.ErrorText, true); final View dataField = row.getView(); final Animation animation = getBlinkAnimation(); notificationIconButton.setVisibility(View.VISIBLE); notificationIconButton .setBackground(ContextCompat.getDrawable(getActivity(), R.drawable.ic_warning_black_36dp)); row.setTextColor(getResources().getColor(R.color.warning_orange)); notificationIconButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { focusOnView(scrollView, dataField); dataField.startAnimation(animation); } }); informationContainer.addView(row.getView()); } else if (ApiErrorType.getType(propertyDescription.ErrorType) == ApiErrorType.WARNING) { row = utilityRows.getCardViewInformationRow(getActivity(), getString(R.string.error_text), propertyDescription.ErrorText, true); final TextView dataField = row.getFieldDataTextView(); final Animation animation = getBlinkAnimation(); notificationIconButton.setVisibility(View.VISIBLE); notificationIconButton.setBackground( ContextCompat.getDrawable(getActivity(), R.drawable.ic_error_outline_black_36dp)); row.setTextColor(getResources().getColor(R.color.error_red)); notificationIconButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { focusOnView(scrollView, dataField); dataField.startAnimation(animation); } }); informationContainer.addView(row.getView()); } row = utilityRows.getCardViewInformationRow(getActivity(), getString(R.string.data_owner), propertyDescription.DataOwner, true); informationContainer.addView(row.getView()); if (propertyDescription.DataOwnerLink != null && !propertyDescription.DataOwnerLink.trim().equals("")) { String partnerLink = (propertyDescription.DataOwnerLink.contains("http") || propertyDescription.DataOwnerLink.contains("www")) ? "<a href='" + propertyDescription.DataOwnerLink + "'>" + propertyDescription.DataOwnerLink + "</a>" : "<a href='" + getString(R.string.about_partners_base_address) + propertyDescription.DataOwnerLink + "'>" + getString(R.string.about_partners_base_address) + propertyDescription.DataOwnerLink + "</a>"; row = utilityRows.getCardViewInformationRow(getActivity(), getString(R.string.data_owner_link), partnerLink, true); row.setHyperlink(partnerLink); row.getFieldDataTextView().setMovementMethod(LinkMovementMethod.getInstance()); informationContainer.addView(row.getView()); } StringBuilder stringBuilder = new StringBuilder(); for (String format : propertyDescription.Formats) { stringBuilder.append(format); stringBuilder.append("\n"); } row = utilityRows.getCardViewInformationRow(getActivity(), getString(R.string.formats), stringBuilder.toString().trim(), false); informationContainer.addView(row.getView()); stringBuilder.setLength(0); for (String interval : propertyDescription.SubscriptionInterval) { stringBuilder.append(SubscriptionInterval.getType(interval).toString()); stringBuilder.append("\n"); } row = utilityRows.getCardViewInformationRow(getActivity(), getString(R.string.subscription_frequencies), stringBuilder.toString().trim(), false); informationContainer.addView(row.getView()); row = utilityRows.getCardViewInformationRow(getActivity(), getString(R.string.map_creation_date), propertyDescription.Created.substring(0, propertyDescription.Created.indexOf('T')), true); informationContainer.addView(row.getView()); LinearLayout.LayoutParams bottomButtonLayoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); bottomButtonLayoutParams.gravity = Gravity.CENTER_VERTICAL; bottomButtonLayoutParams.weight = (float) 0.5; showOnMapButton.setLayoutParams(bottomButtonLayoutParams); showOnMapButton.setText(getString(R.string.show_on_map)); showOnMapButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //TODO: Need to update the toolbar as well. List<String> layersList = new ArrayList<>(); String layerName = propertyDescription.Name; layersList.add("Grunnkart"); layersList.add(layerName); user.setActiveLayers(layersList); user.writeToSharedPref(getActivity()); getFragmentManager().beginTransaction().replace(R.id.fragment_container, new FiskInfoUtility().createFragment(MapFragment.TAG, user, TAG), MapFragment.TAG) .addToBackStack(null).commit(); } }); bottomButtonContainer.addView(showOnMapButton); downloadMapButton.setOnClickListener(utilityOnClickListeners .getSubscriptionDownloadButtonOnClickListener(getActivity(), propertyDescription, user, TAG)); } if (warning != null) { TextView content = generateTextViewWithText(warning, title); textAreaPlaceHolder.addView(content); } clearIds(); return rootView; }
From source file:com.pepperonas.showcase.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getTitle().equals("About")) { new MaterialDialog.Builder(this).title("MaterialDialog library").customView(R.layout.dialog_lib_info) .positiveText("OK").positiveColor(R.color.grey_700).icon(R.drawable.ic_launcher) .showListener(new MaterialDialog.ShowListener() { @Override//w ww.j a v a 2 s . co m public void onShow(AlertDialog d) { super.onShow(d); TextView tvLibInfo = (TextView) d.findViewById(R.id.tv_lib_info); tvLibInfo.setText(Html.fromHtml(getString(R.string.web_presentation_info))); tvLibInfo.setMovementMethod(LinkMovementMethod.getInstance()); } }).show(); } else if (item.getTitle().equals(Const.HIDE_TOASTS)) { mSharedPreferences.edit().putBoolean("SHOW_TOASTS", false).apply(); item.setTitle(Const.SHOW_TOASTS); } else if (item.getTitle().equals(Const.SHOW_TOASTS)) { mSharedPreferences.edit().putBoolean("SHOW_TOASTS", true).apply(); item.setTitle(Const.HIDE_TOASTS); } return super.onOptionsItemSelected(item); }
From source file:me.acristoffers.tracker.activities.PackageListActivity.java
@SuppressLint("InflateParams") private void about() { final View about = View.inflate(this, R.layout.about, null); final PackageManager manager = getPackageManager(); final String packageName = getPackageName(); int versionCode = 0; String versionName = ""; try {//ww w . j av a 2 s.co m final PackageInfo info = manager.getPackageInfo(packageName, 0); versionCode = info.versionCode; versionName = info.versionName; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } final TextView version = (TextView) about.findViewById(R.id.version); if (version != null) { final String versionText = getString(R.string.version, versionName, versionCode); version.setText(versionText); } final TextView issues = (TextView) about.findViewById(R.id.issues); if (issues != null) { issues.setMovementMethod(LinkMovementMethod.getInstance()); } final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.app_name); builder.setView(about); builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.dismiss(); } }); builder.setNeutralButton(R.string.rate_now, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { final String packageName = getPackageName(); final Uri uri = Uri.parse("market://details?id=" + packageName); startActivity(new Intent(Intent.ACTION_VIEW, uri)); dialogInterface.dismiss(); } }); final AlertDialog aboutDialog = builder.create(); aboutDialog.show(); }
From source file:link.kjr.file_manager.MainActivity.java
public void license(MenuItem item) { InputStream is = getResources().openRawResource(R.raw.license); String li = ""; byte[] data = new byte[1024]; int length;//from w w w. j a v a 2 s. co m try { length = is.read(data, 0, 1024); while (length > 0) { Log.i(BuildConfig.APPLICATION_ID, li); li += (new String(data)); length = is.read(data, 0, 1024); } } catch (IOException ioe) { ioe.printStackTrace(); } AlertDialog.Builder ab = new AlertDialog.Builder(this); TextView tv = new TextView(this); tv.setMovementMethod(new ScrollingMovementMethod()); tv.setText(li); ab.setView(tv); ab.create().show(); }
From source file:org.liberty.android.fantastischmemo.ui.MiscTabFragment.java
@Override public void onClick(View v) { if (v == optionButton) { startActivity(new Intent(mActivity, OptionScreen.class)); }/*from ww w . j ava 2 s . c o m*/ /* Toggle visibility for import and export buttons */ if (v == importButton) { if (importItems.getVisibility() == View.GONE) { importItems.setVisibility(View.VISIBLE); } else { importItems.setVisibility(View.GONE); } } if (v == exportButton) { if (exportItems.getVisibility() == View.GONE) { exportItems.setVisibility(View.VISIBLE); } else { exportItems.setVisibility(View.GONE); } } if (v == importMnemosyneButton) { DialogFragment df = new ConverterFragment(); Bundle b = new Bundle(); b.putSerializable(ConverterFragment.EXTRA_CONVERTER_CLASS, MnemosyneXMLImporter.class); b.putString(FileBrowserFragment.EXTRA_FILE_EXTENSIONS, ".xml"); df.setArguments(b); df.show(((FragmentActivity) mActivity).getSupportFragmentManager(), "ImportMnemosyne"); } if (v == importSupermemoButton) { DialogFragment df = new ConverterFragment(); Bundle b = new Bundle(); b.putSerializable(ConverterFragment.EXTRA_CONVERTER_CLASS, SupermemoXMLImporter.class); b.putString(FileBrowserFragment.EXTRA_FILE_EXTENSIONS, ".xml"); df.setArguments(b); df.show(((FragmentActivity) mActivity).getSupportFragmentManager(), "ImportSuperMemo2008"); } if (v == importCSVButton) { DialogFragment df = new ConverterFragment(); Bundle b = new Bundle(); b.putSerializable(ConverterFragment.EXTRA_CONVERTER_CLASS, CSVImporter.class); b.putString(FileBrowserFragment.EXTRA_FILE_EXTENSIONS, ".csv"); df.setArguments(b); df.show(((FragmentActivity) mActivity).getSupportFragmentManager(), "ImportCSV"); } if (v == importZipButton) { DialogFragment df = new ConverterFragment(); Bundle b = new Bundle(); b.putSerializable(ConverterFragment.EXTRA_CONVERTER_CLASS, ZipImporter.class); b.putString(FileBrowserFragment.EXTRA_FILE_EXTENSIONS, ".zip"); df.setArguments(b); df.show(((FragmentActivity) mActivity).getSupportFragmentManager(), "ImportZip"); } if (v == importTabButton) { DialogFragment df = new ConverterFragment(); Bundle b = new Bundle(); b.putSerializable(ConverterFragment.EXTRA_CONVERTER_CLASS, TabTxtImporter.class); b.putString(FileBrowserFragment.EXTRA_FILE_EXTENSIONS, ".txt"); df.setArguments(b); df.show(((FragmentActivity) mActivity).getSupportFragmentManager(), "ImportTabTxt"); } if (v == importQAButton) { DialogFragment df = new ConverterFragment(); Bundle b = new Bundle(); b.putSerializable(ConverterFragment.EXTRA_CONVERTER_CLASS, QATxtImporter.class); b.putString(FileBrowserFragment.EXTRA_FILE_EXTENSIONS, ".txt"); df.setArguments(b); df.show(((FragmentActivity) mActivity).getSupportFragmentManager(), "ImportCSV"); } if (v == importSupermemo2008Button) { DialogFragment df = new ConverterFragment(); Bundle b = new Bundle(); b.putSerializable(ConverterFragment.EXTRA_CONVERTER_CLASS, Supermemo2008XMLImporter.class); b.putString(FileBrowserFragment.EXTRA_FILE_EXTENSIONS, ".xml"); df.setArguments(b); df.show(((FragmentActivity) mActivity).getSupportFragmentManager(), "ImportSuperMemo2008"); } if (v == importMnemosyne2CardsButton) { DialogFragment df = new ConverterFragment(); Bundle b = new Bundle(); b.putSerializable(ConverterFragment.EXTRA_CONVERTER_CLASS, Mnemosyne2CardsImporter.class); b.putString(FileBrowserFragment.EXTRA_FILE_EXTENSIONS, ".cards"); df.setArguments(b); df.show(((FragmentActivity) mActivity).getSupportFragmentManager(), "ImportMnemosyne2Cards"); } if (v == exportMnemosyneButton) { DialogFragment df = new ConverterFragment(); Bundle b = new Bundle(); b.putSerializable(ConverterFragment.EXTRA_CONVERTER_CLASS, MnemosyneXMLExporter.class); b.putString(FileBrowserFragment.EXTRA_FILE_EXTENSIONS, ".db"); df.setArguments(b); df.show(((FragmentActivity) mActivity).getSupportFragmentManager(), "ExportMnemosyne"); } if (v == exportCSVButton) { DialogFragment df = new ConverterFragment(); Bundle b = new Bundle(); b.putSerializable(ConverterFragment.EXTRA_CONVERTER_CLASS, CSVExporter.class); b.putString(FileBrowserFragment.EXTRA_FILE_EXTENSIONS, ".db"); df.setArguments(b); df.show(((FragmentActivity) mActivity).getSupportFragmentManager(), "ExportCSV"); } if (v == exportTabButton) { DialogFragment df = new ConverterFragment(); Bundle b = new Bundle(); b.putSerializable(ConverterFragment.EXTRA_CONVERTER_CLASS, TabTxtExporter.class); b.putString(FileBrowserFragment.EXTRA_FILE_EXTENSIONS, ".db"); df.setArguments(b); df.show(((FragmentActivity) mActivity).getSupportFragmentManager(), "ExportTabTxt"); } if (v == exportQAButton) { DialogFragment df = new ConverterFragment(); Bundle b = new Bundle(); b.putSerializable(ConverterFragment.EXTRA_CONVERTER_CLASS, QATxtExporter.class); b.putString(FileBrowserFragment.EXTRA_FILE_EXTENSIONS, ".db"); df.setArguments(b); df.show(((FragmentActivity) mActivity).getSupportFragmentManager(), "ExportQA"); } if (v == exportZipButton) { DialogFragment df = new ConverterFragment(); Bundle b = new Bundle(); b.putSerializable(ConverterFragment.EXTRA_CONVERTER_CLASS, ZipExporter.class); b.putString(FileBrowserFragment.EXTRA_FILE_EXTENSIONS, ".db"); df.setArguments(b); df.show(((FragmentActivity) mActivity).getSupportFragmentManager(), "ExportZip"); } if (v == exportMnemosyne2CardsButton) { DialogFragment df = new ConverterFragment(); Bundle b = new Bundle(); b.putSerializable(ConverterFragment.EXTRA_CONVERTER_CLASS, Mnemosyne2CardsExporter.class); b.putString(FileBrowserFragment.EXTRA_FILE_EXTENSIONS, ".db"); df.setArguments(b); df.show(((FragmentActivity) mActivity).getSupportFragmentManager(), "ExportMnemosyne2Cards"); } if (v == defaultSettingsButton) { Intent intent = new Intent(mActivity, SettingsScreen.class); String emptyDbPath = mActivity.getApplicationContext().getFilesDir().getAbsolutePath() + "/" + AMEnv.EMPTY_DB_NAME; intent.putExtra(SettingsScreen.EXTRA_DBPATH, emptyDbPath); startActivity(intent); } if (v == mergeButton) { Intent myIntent = new Intent(mActivity, DatabaseMerger.class); startActivity(myIntent); } if (v == resetButton) { new AlertDialog.Builder(mActivity).setTitle(R.string.clear_all_pref) .setMessage(R.string.reset_all_pref_warning) .setPositiveButton(R.string.ok_text, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(mActivity); SharedPreferences.Editor editor = settings.edit(); editor.clear(); editor.commit(); mActivity.finish(); } }).setNegativeButton(R.string.cancel_text, null).show(); } if (v == donateButton) { View alertView = View.inflate(mActivity, R.layout.link_alert, null); TextView textView = (TextView) alertView.findViewById(R.id.link_alert_message); textView.setText(Html.fromHtml(getString(R.string.donate_summary))); textView.setMovementMethod(LinkMovementMethod.getInstance()); new AlertDialog.Builder(mActivity).setView(alertView).setTitle(R.string.donate_text) .setPositiveButton(getString(R.string.buy_pro_text), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { Intent myIntent = new Intent(); myIntent.setAction(Intent.ACTION_VIEW); myIntent.addCategory(Intent.CATEGORY_BROWSABLE); myIntent.setData(Uri.parse(getString(R.string.anymemo_pro_link))); startActivity(myIntent); } }).setNegativeButton(getString(R.string.cancel_text), null).show(); } if (v == helpButton) { Intent myIntent = new Intent(); myIntent.setAction(Intent.ACTION_VIEW); myIntent.addCategory(Intent.CATEGORY_BROWSABLE); myIntent.setData(Uri.parse(WEBSITE_VERSION)); startActivity(myIntent); } if (v == aboutButton) { // Get the version defined in the AndroidManifest. String versionName = ""; try { versionName = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionName; } catch (PackageManager.NameNotFoundException e) { versionName = "1.0"; } View alertView = View.inflate(mActivity, R.layout.link_alert, null); TextView textView = (TextView) alertView.findViewById(R.id.link_alert_message); textView.setText(Html.fromHtml(getString(R.string.about_text))); textView.setMovementMethod(LinkMovementMethod.getInstance()); new AlertDialog.Builder(mActivity).setView(alertView) .setTitle(getString(R.string.app_full_name) + " " + versionName) .setPositiveButton(getString(R.string.ok_text), null) .setNegativeButton(getString(R.string.about_version), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { Intent myIntent = new Intent(); myIntent.setAction(Intent.ACTION_VIEW); myIntent.addCategory(Intent.CATEGORY_BROWSABLE); myIntent.setData(Uri.parse(WEBSITE_VERSION)); startActivity(myIntent); } }).show(); } }
From source file:com.liushengfan.test.customerviewgroup.view.PagerSlidingTabStrip.java
private void addTextTab(final int position, SpannableString title) { TextView tab = new TextView(getContext()); tab.setText(title);//ww w . j av a2 s.co m tab.setMovementMethod(LinkMovementMethod.getInstance()); tab.setGravity(Gravity.CENTER); tab.setMaxLines(2); tab.setSingleLine(false); addTab(position, tab); }
From source file:io.github.hidroh.materialistic.ItemActivity.java
@SuppressWarnings("ConstantConditions") private void bindData(@Nullable final WebItem story) { if (story == null) { return;//from w ww. j av a2 s . c om } mCustomTabsDelegate.mayLaunchUrl(Uri.parse(story.getUrl()), null, null); bindFavorite(); mSessionManager.view(this, story.getId()); mVoteButton.setVisibility(View.VISIBLE); mVoteButton.setOnClickListener(v -> vote(story)); final TextView titleTextView = (TextView) findViewById(android.R.id.text2); if (story.isStoryType()) { titleTextView.setText(story.getDisplayedTitle()); setTaskTitle(story.getDisplayedTitle()); if (!TextUtils.isEmpty(story.getSource())) { TextView sourceTextView = (TextView) findViewById(R.id.source); sourceTextView.setText(story.getSource()); sourceTextView.setVisibility(View.VISIBLE); } } else { CharSequence title = AppUtils.fromHtml(story.getDisplayedTitle()); titleTextView.setText(title); setTaskTitle(title); } final TextView postedTextView = (TextView) findViewById(R.id.posted); postedTextView.setText(story.getDisplayedTime(this)); postedTextView.append(story.getDisplayedAuthor(this, true, 0)); postedTextView.setMovementMethod(LinkMovementMethod.getInstance()); switch (story.getType()) { case Item.JOB_TYPE: postedTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_work_white_18dp, 0, 0, 0); break; case Item.POLL_TYPE: postedTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_poll_white_18dp, 0, 0, 0); break; } mAdapter = new ItemPagerAdapter(this, getSupportFragmentManager(), new ItemPagerAdapter.Builder().setItem(story).setShowArticle(!mExternalBrowser) .setCacheMode(getIntent().getIntExtra(EXTRA_CACHE_MODE, ItemManager.MODE_DEFAULT)) .setDefaultViewMode(mStoryViewMode)); mAdapter.bind(mViewPager, mTabLayout, mNavButton, mReplyButton); mTabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager) { @Override public void onTabReselected(TabLayout.Tab tab) { mAppBar.setExpanded(true, true); } }); if (story.isStoryType() && mExternalBrowser) { findViewById(R.id.header_card_view) .setOnClickListener(v -> AppUtils.openWebUrlExternal(ItemActivity.this, story, story.getUrl(), mCustomTabsDelegate.getSession())); } else { findViewById(R.id.header_card_view).setClickable(false); } if (mFullscreen) { setFullscreen(); } }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.LinkObj.java
public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) { JSONObject content = obj.getJson();//from w w w .java2s.com TextView valueTV = new TextView(context); String title; if (content.has(TITLE)) { title = "Link: " + content.optString(TITLE); } else { title = content.optString(URI); } valueTV.setText(title); 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); }