List of usage examples for android.text SpannableStringBuilder append
public SpannableStringBuilder append(char text)
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 ww w . j a v a2 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:widget.map.com.urlocationmapwidget.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 ww . ja v a 2s . 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.dialog_fragment_about, null); aboutBodyView.setText(aboutBody); aboutBodyView.setMovementMethod(new LinkMovementMethod()); return new AlertDialog.Builder(getActivity()).setTitle(R.string.menu_about).setView(aboutBodyView) .setPositiveButton(R.string.btn_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }).create(); }
From source file:com.itbooks.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 v a 2s . com*/ 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, 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.setMovementMethod(new LinkMovementMethod()); return new AlertDialog.Builder(getActivity()).setTitle(R.string.lbl_about).setView(aboutBodyView) .setPositiveButton(R.string.btn_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }).create(); }
From source file:com.marstemp.app.fragments.AboutDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Get app version PackageManager pm = getActivity().getPackageManager(); String packageName = getActivity().getPackageName(); String versionName;// www.j a v a2 s . co 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); View dialogV = layoutInflater.inflate(R.layout.fragment_dialog_about, null); ; TextView aboutBodyView = (TextView) dialogV.findViewById(R.id.dialog_text_tv); aboutBodyView.setText(aboutBody); aboutBodyView.setMovementMethod(new LinkMovementMethod()); dialogV.findViewById(R.id.powered_by_ll).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { WebViewActivity.showInstance(getActivity(), getString(R.string.lbl_maas), Prefs.getInstance().getApiHome()); } }); return new AlertDialog.Builder(getActivity()).setTitle(R.string.action_about).setView(dialogV) .setPositiveButton(R.string.btn_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }).create(); }
From source file:com.schautup.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. ja v a 2s . co m*/ String appName = getString(R.string.application_name); 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, appName, 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.dialog_about, null); aboutBodyView.setText(aboutBody); aboutBodyView.setMovementMethod(new LinkMovementMethod()); return new AlertDialog.Builder(getActivity()).setTitle(R.string.lbl_about).setView(aboutBodyView) .setPositiveButton(R.string.btn_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }).create(); }
From source file:com.playground.notification.app.fragments.AboutDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Get app version PackageManager pm = getActivity().getPackageManager(); String packageName = getActivity().getPackageName(); String versionName;//from ww w.j av a 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); View dialogV = layoutInflater.inflate(R.layout.fragment_dialog_about, null); ; TextView aboutBodyView = (TextView) dialogV.findViewById(R.id.dialog_text_tv); aboutBodyView.setText(aboutBody); aboutBodyView.setMovementMethod(new LinkMovementMethod()); dialogV.findViewById(R.id.powered_by_ll).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Utils.openExternalBrowser(getActivity(), "http://" + getString(R.string.support_spielplatz_radar)); } }); dialogV.findViewById(R.id.weather_by_ll).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Utils.openExternalBrowser(getActivity(), "http://" + getString(R.string.support_openweathermap)); } }); return new AlertDialog.Builder(getActivity()).setTitle(R.string.action_about).setView(dialogV) .setPositiveButton(R.string.btn_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }).create(); }
From source file:com.microsoft.rightsmanagement.ui.widget.UserPolicyViewerFragment.java
/** * Updates the policy viewer according to the ownership *///ww w .ja va 2s . c o m private void updateViewAccordingToOwnership() { UserPolicyModel userPolicyModel = mUserPolicyDataProvider.getUserPolicyModel(); // if this is not owner just show the rights with no header if (userPolicyModel.isIssuedToOwner()) { Logger.d(TAG, "user is the owner of user policy"); mUpperTitleTextView.setText(getString(R.string.policy_viewer_owner_content)); mOwnerNameTextView.setVisibility(View.GONE); setPolicyEditingButtonViewState(mUserPolicyDataProvider.isUserPolicyEditingEnabled()); } else { Logger.d(TAG, "user is not the owner of user policy"); //ignore input of allowing edit enabled and hide policy edit button setPolicyEditingButtonViewState(false); mUpperTitleTextView.setText(R.string.policy_viewer_non_owner_content); SpannableStringBuilder sb = new SpannableStringBuilder(); String grantedBy = getString(R.string.granted_by_string); sb.append(grantedBy); sb.append(" "); sb.append(userPolicyModel.getOwner()); sb.setSpan(new StyleSpan(Typeface.BOLD), grantedBy.length(), sb.length(), 0); mOwnerNameTextView.setText(sb); drawRights(); } }
From source file:org.telegram.ui.Cells.BotHelpCell.java
public void setText(String text) { if (text == null || text.length() == 0) { setVisibility(GONE);/*w w w . ja va2 s . c o m*/ return; } if (text != null && oldText != null && text.equals(oldText)) { return; } oldText = text; setVisibility(VISIBLE); if (AndroidUtilities.isTablet()) { width = (int) (AndroidUtilities.getMinTabletSide() * 0.7f); } else { width = (int) (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) * 0.7f); } SpannableStringBuilder stringBuilder = new SpannableStringBuilder(); String help = LocaleController.getString("BotInfoTitle", R.string.BotInfoTitle); stringBuilder.append(help); stringBuilder.append("\n\n"); stringBuilder.append(text); MessageObject.addLinks(stringBuilder); stringBuilder.setSpan(new TypefaceSpan(AndroidUtilities.getTypeface("fonts/rmedium.ttf")), 0, help.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); Emoji.replaceEmoji(stringBuilder, textPaint.getFontMetricsInt(), AndroidUtilities.dp(20), false); try { textLayout = new StaticLayout(stringBuilder, textPaint, width, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); width = 0; height = textLayout.getHeight() + AndroidUtilities.dp(4 + 18); int count = textLayout.getLineCount(); for (int a = 0; a < count; a++) { width = (int) Math.ceil(Math.max(width, textLayout.getLineWidth(a) + textLayout.getLineLeft(a))); } } catch (Exception e) { FileLog.e("tmessage", e); } width += AndroidUtilities.dp(4 + 18); }
From source file:com.yangtsaosoftware.pebblemessenger.activities.SetupFragment.java
@Override public void onInit(int i) { if (i == TextToSpeech.SUCCESS) { SpannableStringBuilder ssb = new SpannableStringBuilder(); ssb.append(textInfo.getText()); ssb.append(myTTS.getDefaultEngine() + " "); ssb.append(greenText(R.string.setup_tts_default_locale)); ssb.append(myTTS.getLanguage().getLanguage()); ssb.append('\n'); textInfo.setText(ssb);/*from www . ja v a2 s . co m*/ svMyview.fullScroll(View.FOCUS_DOWN); } else { myTTS.shutdown(); myTTS = null; } }
From source file:com.yangtsaosoftware.pebblemessenger.activities.SetupFragment.java
private void run_basic_test() { SpannableStringBuilder ssb = new SpannableStringBuilder(); ssb.append(_context.getString(R.string.setup_basic_test)); ssb.append('\n'); ssb.append(_context.getString(R.string.setup_test_pebble_title)); ssb.append(test_Pebble_state(_context)); ssb.append('\n'); ssb.append(_context.getString(R.string.setup_test_pebble_firmware)); ssb.append(test_PebbleFirmware_state(_context)); ssb.append('\n'); ssb.append(_context.getString(R.string.setup_accessibility_service_title)); // ssb.append(test_AccessService_state(_context)); ssb.append('\n'); ssb.append(_context.getString(R.string.setup_watch_list)); ssb.append(test_WatchList_state(_context)); ssb.append('\n'); ssb.append(_context.getString(R.string.setup_font_base_status)); ssb.append(test_FontBase_state(_context)); ssb.append('\n'); textInfo.setText(ssb);/*from ww w .java2s.c o m*/ svMyview.fullScroll(View.FOCUS_DOWN); }