List of usage examples for android.graphics Typeface BOLD
int BOLD
To view the source code for android.graphics Typeface BOLD.
Click Source Link
From source file:eu.faircode.netguard.ServiceSinkhole.java
private void showAccessNotification(int uid) { String name = TextUtils.join(", ", Util.getApplicationNames(uid, ServiceSinkhole.this)); Intent main = new Intent(ServiceSinkhole.this, ActivityMain.class); main.putExtra(ActivityMain.EXTRA_SEARCH, Integer.toString(uid)); PendingIntent pi = PendingIntent.getActivity(ServiceSinkhole.this, uid + 10000, main, PendingIntent.FLAG_UPDATE_CURRENT); TypedValue tv = new TypedValue(); getTheme().resolveAttribute(R.attr.colorOn, tv, true); int colorOn = tv.data; getTheme().resolveAttribute(R.attr.colorOff, tv, true); int colorOff = tv.data; NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_cloud_upload_white_24dp).setGroup("AccessAttempt").setContentIntent(pi) .setColor(colorOff).setOngoing(false).setAutoCancel(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) builder.setContentTitle(name).setContentText(getString(R.string.msg_access_n)); else/*from w ww .jav a 2 s. c o m*/ builder.setContentTitle(getString(R.string.app_name)) .setContentText(getString(R.string.msg_access, name)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { builder.setCategory(Notification.CATEGORY_STATUS).setVisibility(Notification.VISIBILITY_SECRET); } DateFormat df = new SimpleDateFormat("dd HH:mm"); NotificationCompat.InboxStyle notification = new NotificationCompat.InboxStyle(builder); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) notification.addLine(getString(R.string.msg_access_n)); else { String sname = getString(R.string.msg_access, name); int pos = sname.indexOf(name); Spannable sp = new SpannableString(sname); sp.setSpan(new StyleSpan(Typeface.BOLD), pos, pos + name.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); notification.addLine(sp); } Cursor cursor = DatabaseHelper.getInstance(ServiceSinkhole.this).getAccessUnset(uid, 7); int colDAddr = cursor.getColumnIndex("daddr"); int colTime = cursor.getColumnIndex("time"); int colAllowed = cursor.getColumnIndex("allowed"); while (cursor.moveToNext()) { StringBuilder sb = new StringBuilder(); sb.append(df.format(cursor.getLong(colTime))).append(' '); String daddr = cursor.getString(colDAddr); if (Util.isNumericAddress(daddr)) try { daddr = InetAddress.getByName(daddr).getHostName(); } catch (UnknownHostException ignored) { } sb.append(daddr); int allowed = cursor.getInt(colAllowed); if (allowed >= 0) { int pos = sb.indexOf(daddr); Spannable sp = new SpannableString(sb); ForegroundColorSpan fgsp = new ForegroundColorSpan(allowed > 0 ? colorOn : colorOff); sp.setSpan(fgsp, pos, pos + daddr.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); notification.addLine(sp); } else notification.addLine(sb); } cursor.close(); NotificationManagerCompat.from(this).notify(uid + 10000, notification.build()); }
From source file:com.android.mms.ui.MessageUtils.java
public static CharSequence formatMsgContent(String subject, String body, String displayAddress) { StringBuilder buf = new StringBuilder( displayAddress == null ? "" : displayAddress.replace('\n', ' ').replace('\r', ' ')); buf.append(':').append(' '); int offset = buf.length(); if (!TextUtils.isEmpty(subject)) { subject = subject.replace('\n', ' ').replace('\r', ' '); buf.append(subject);/*w w w. ja v a2 s.c o m*/ buf.append(' '); } if (!TextUtils.isEmpty(body)) { body = body.replace('\n', ' ').replace('\r', ' '); buf.append(body); } SpannableString spanText = new SpannableString(buf.toString()); spanText.setSpan(new StyleSpan(Typeface.BOLD), 0, offset, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); return spanText; }
From source file:im.vector.fragments.VectorSettingsPreferencesFragment.java
/** * Build the devices portion of the settings.<br> * Each row correspond to a device ID and its corresponding device name. Clicking on the row * display a dialog containing: the device ID, the device name and the "last seen" information. * * @param aDeviceInfoList the list of the devices *///from www . j a va 2s .c o m private void buildDevicesSettings(List<DeviceInfo> aDeviceInfoList) { VectorCustomActionEditTextPreference preference; int typeFaceHighlight; boolean isNewList = true; String myDeviceId = mSession.getCredentials().deviceId; if ((null != mDevicesNameList) && (aDeviceInfoList.size() == mDevicesNameList.size())) { isNewList = !mDevicesNameList.containsAll(aDeviceInfoList); } if (isNewList) { int prefIndex = 0; mDevicesNameList = aDeviceInfoList; // sort before display: most recent first DeviceInfo.sortByLastSeen(mDevicesNameList); // start from scratch: remove the displayed ones mDevicesListSettingsCategory.removeAll(); for (DeviceInfo deviceInfo : mDevicesNameList) { // set bold to distinguish current device ID if ((null != myDeviceId) && myDeviceId.equals(deviceInfo.device_id)) { mMyDeviceInfo = deviceInfo; typeFaceHighlight = Typeface.BOLD; } else { typeFaceHighlight = Typeface.NORMAL; } // add the edit text preference preference = new VectorCustomActionEditTextPreference(getActivity(), typeFaceHighlight); if ((null == deviceInfo.device_id) && (null == deviceInfo.display_name)) { continue; } else { if (null != deviceInfo.device_id) { preference.setTitle(deviceInfo.device_id); } // display name parameter can be null (new JSON API) if (null != deviceInfo.display_name) { preference.setSummary(deviceInfo.display_name); } } preference.setKey(DEVICES_PREFERENCE_KEY_BASE + prefIndex); prefIndex++; // onClick handler: display device details dialog final DeviceInfo fDeviceInfo = deviceInfo; preference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { displayDeviceDetailsDialog(fDeviceInfo); return true; } }); mDevicesListSettingsCategory.addPreference(preference); } refreshCryptographyPreference(mMyDeviceInfo); } }
From source file:com.skytree.epubtest.BookViewActivity.java
public void checkSettings() { if (this.setting.fontSize == 0) { decreaseButton.setTextColor(Color.LTGRAY); } else {//from w w w. j a va 2s . c o m decreaseButton.setTextColor(Color.BLACK); } if (this.setting.fontSize == 4) { increaseButton.setTextColor(Color.LTGRAY); } else { increaseButton.setTextColor(Color.BLACK); } increaseLineSpaceButton.setEnabled(true); decreaseLineSpaceButton.setEnabled(true); increaseLineSpaceButton.setColorFilter(Color.BLACK); decreaseLineSpaceButton.setColorFilter(Color.BLACK); if (this.setting.lineSpacing == 4) { increaseLineSpaceButton.setEnabled(false); increaseLineSpaceButton.setColorFilter(Color.LTGRAY); } if (this.setting.lineSpacing == 0) { decreaseLineSpaceButton.setEnabled(false); decreaseLineSpaceButton.setColorFilter(Color.LTGRAY); } int fontIndex = this.getFontIndex(setting.fontName); for (int i = 0; i < fontListView.getChildCount(); i++) { Button button = (Button) fontListView.getChildAt(i); button.setTextColor(Color.BLACK); } for (int i = 0; i < fontListView.getChildCount(); i++) { Button button = (Button) fontListView.getChildAt(i); if (button.getId() == (fontIndex + 5100)) { button.setTextColor(Color.BLUE); } } for (int i = 0; i < themesView.getChildCount(); i++) { Button button = (Button) themesView.getChildAt(i); Typeface tf = null; int size = 13; if (button.getId() == (themeIndex + 7000)) { tf = this.getTypeface(setting.fontName, Typeface.BOLD); size = 18; } else { tf = this.getTypeface(setting.fontName, Typeface.NORMAL); } button.setTypeface(tf); button.setTextSize(size); } }