List of usage examples for android.text.style StyleSpan StyleSpan
public StyleSpan(@NonNull Parcel src)
From source file:net.sf.fakenames.fddemo.PermissionActivity.java
private static void setBold(Spannable s, int start, int end) { s.setSpan(new StyleSpan(Typeface.BOLD), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); }
From source file:com.benext.thibault.appsample.notification.builder.NotificationBuilder.java
public static NotificationCompat.Builder buildNotificationExtenderPages(Context context) { ArrayList<Notification> pages = new ArrayList<>(); // Create first page notification Bitmap tableImg = BitmapFactory.decodeResource(context.getResources(), R.drawable.resto); Notification page1 = new NotificationCompat.Builder(context).extend( new NotificationCompat.WearableExtender().setHintShowBackgroundOnly(true).setBackground(tableImg)) .build();/* w w w. ja v a 2s. com*/ pages.add(page1); // Create second page notification Spannable meatTitle = new SpannableString(context.getString(R.string.menu_meats)); meatTitle.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, meatTitle.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); NotificationCompat.InboxStyle secondPageStyle = new NotificationCompat.InboxStyle(); secondPageStyle.setBigContentTitle("Page 2").setSummaryText("") .addLine(getSpannableString(context, R.string.menu_starters, Typeface.BOLD)) .addLine(context.getString(R.string.menu_starters_content1)) .addLine(context.getString(R.string.menu_starters_content2)) .addLine(getSpannableString(context, R.string.menu_meats, Typeface.BOLD)) .addLine(context.getString(R.string.menu_meats_content1)) .addLine(context.getString(R.string.menu_meats_content2)); Notification page2 = new NotificationCompat.Builder(context) .extend(new NotificationCompat.WearableExtender().setBackground( BitmapFactory.decodeResource(context.getResources(), R.drawable.table_restaurant))) .setStyle(secondPageStyle).build(); pages.add(page2); // Create builder for the main notification Bitmap restoImg = BitmapFactory.decodeResource(context.getResources(), R.drawable.resto); return (NotificationCompat.Builder) buildNotificationSimpleNBackground(context) .setStyle(new NotificationCompat.BigPictureStyle().bigPicture(restoImg)) .extend(new NotificationCompat.WearableExtender().addPages(pages)); }
From source file:com.icecream.snorlax.module.feature.encounter.EncounterNotification.java
private Spannable getBoldSpannable(String text) { Spannable spannable = new SpannableString(text); spannable.setSpan(new StyleSpan(Typeface.BOLD), 0, spannable.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE); return spannable; }
From source file:io.github.marktony.espresso.mvp.companydetails.CompanyDetailFragment.java
@Override public void setCompanyTel(String tel) { this.tel = tel; String companyTel = getString(R.string.phone_number) + "\n" + tel; Spannable spannable = new SpannableStringBuilder(companyTel); spannable.setSpan(new StyleSpan(Typeface.BOLD), 0, companyTel.length() - tel.length() - 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); spannable.setSpan(new URLSpan(tel), companyTel.length() - tel.length(), companyTel.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); textViewTel.setText(spannable);// ww w .j a va2 s . c o m }
From source file:com.owncloud.android.ui.dialog.SyncedFolderPreferencesDialogFragment.java
/** * find all relevant UI elements and set their values. * * @param view the parent view//from w w w.j av a 2 s . c o m */ private void setupDialogElements(View view) { // find/saves UI elements mEnabledSwitch = (SwitchCompat) view.findViewById(R.id.sync_enabled); mLocalFolderPath = (TextView) view.findViewById(R.id.folder_sync_settings_local_folder_path); mRemoteFolderSummary = (TextView) view.findViewById(R.id.remote_folder_summary); mUploadOnWifiCheckbox = (CheckBox) view.findViewById(R.id.setting_instant_upload_on_wifi_checkbox); mUploadOnChargingCheckbox = (CheckBox) view.findViewById(R.id.setting_instant_upload_on_charging_checkbox); mUploadUseSubfoldersCheckbox = (CheckBox) view .findViewById(R.id.setting_instant_upload_path_use_subfolders_checkbox); mUploadBehaviorSummary = (TextView) view.findViewById(R.id.setting_instant_behaviour_summary); // Set values setEnabled(mSyncedFolder.getEnabled()); mLocalFolderPath.setText(DisplayUtils.createTextWithSpan( String.format(getString(R.string.folder_sync_preferences_folder_path), mSyncedFolder.getLocalPath()), mSyncedFolder.getFolderName(), new StyleSpan(Typeface.BOLD))); mRemoteFolderSummary.setText(mSyncedFolder.getRemotePath()); mUploadOnWifiCheckbox.setChecked(mSyncedFolder.getWifiOnly()); mUploadOnChargingCheckbox.setChecked(mSyncedFolder.getChargingOnly()); mUploadUseSubfoldersCheckbox.setChecked(mSyncedFolder.getSubfolderByDate()); mUploadBehaviorSummary.setText(mUploadBehaviorItemStrings[mSyncedFolder.getUploadActionInteger()]); }
From source file:io.github.marktony.espresso.mvp.companydetails.CompanyDetailFragment.java
@Override public void setCompanyWebsite(String website) { this.website = website; String ws = getString(R.string.official_website) + "\n" + website; Spannable spannable = new SpannableStringBuilder(ws); spannable.setSpan(new StyleSpan(Typeface.BOLD), 0, ws.length() - website.length() - 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); spannable.setSpan(new URLSpan(website), ws.length() - website.length(), ws.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); textViewWebsite.setText(spannable);/*from ww w . j a v a2s. c o m*/ }
From source file:io.relayr.tellmewhen.gcm.GcmIntentService.java
private InboxStyle prepareBigNotificationDetails(Spannable spanTitle) { NotificationCompat.InboxStyle result = new InboxStyle(); result.setBigContentTitle(spanTitle); for (Map.Entry<Pair<SensorType, String>, Float> entry : pushedRules.entrySet()) { SensorType sensorType = entry.getKey().first; String ruleName = entry.getKey().second; if (ruleName.length() <= 20) { int empty = 20 - ruleName.length(); for (int i = 0; i < empty; i++) { ruleName += " "; }//from w w w. j a va 2 s . c om } else { ruleName = entry.getKey().second.substring(0, 20); } String notificationText = getString(R.string.push_notification_value) + " " + SensorUtil.scaleToUiData(sensorType, entry.getValue()) + sensorType.getUnit(); String all = ruleName + " (" + notificationText + ")"; Spannable spanNotif = new SpannableString(all); spanNotif.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, ruleName.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); result.addLine(spanNotif); } result.setSummaryText(getString(R.string.push_notification_summary)); return result; }
From source file:map.IconGeneratorDemoActivity.java
private CharSequence makeCharSequence() { String prefix = "Mixing "; String suffix = "different fonts"; String sequence = prefix + suffix; SpannableStringBuilder ssb = new SpannableStringBuilder(sequence); ssb.setSpan(new StyleSpan(ITALIC), 0, prefix.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); ssb.setSpan(new StyleSpan(BOLD), prefix.length(), sequence.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); return ssb;//from w ww .j ava 2 s . co m }
From source file:com.kncwallet.wallet.ui.TransactionsListFragment.java
@Override public void onViewCreated(final View view, final Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); final SpannableStringBuilder emptyText = new SpannableStringBuilder( getString(direction == Direction.SENT ? R.string.wallet_transactions_fragment_empty_text_sent : R.string.wallet_transactions_fragment_empty_text_received)); emptyText.setSpan(new StyleSpan(Typeface.BOLD), 0, emptyText.length(), SpannableStringBuilder.SPAN_POINT_MARK); if (direction != Direction.SENT) emptyText.append("\n\n").append(getString(R.string.wallet_transactions_fragment_empty_text_howto)); Drawable divider = getResources().getDrawable(R.drawable.transaction_list_divider); this.getListView().setDivider(divider); this.getListView().setDividerHeight(1); setEmptyText(emptyText);//w ww . j a va 2 s . c om }
From source file:cc.mintcoin.wallet.ui.TransactionsListFragment.java
@Override public void onViewCreated(final View view, final Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); final SpannableStringBuilder emptyText = new SpannableStringBuilder( getString(direction == Direction.SENT ? R.string.wallet_transactions_fragment_empty_text_sent : R.string.wallet_transactions_fragment_empty_text_received)); emptyText.setSpan(new StyleSpan(Typeface.BOLD), 0, emptyText.length(), SpannableStringBuilder.SPAN_POINT_MARK); if (direction != Direction.SENT) emptyText.append("\n\n").append(getString(R.string.wallet_transactions_fragment_empty_text_howto)); setEmptyText(emptyText);// ww w .j a va 2s . com }