Example usage for android.graphics Typeface BOLD

List of usage examples for android.graphics Typeface BOLD

Introduction

In this page you can find the example usage for android.graphics Typeface BOLD.

Prototype

int BOLD

To view the source code for android.graphics Typeface BOLD.

Click Source Link

Usage

From source file:com.tr4android.support.extension.typeface.TypefaceCompat.java

/**
 * Creates a typeface object that best matches the specified typeface and the specified style.
 * Use this call if you want to pick a new style from the same family of an typeface object.
 * If family is null, this selects from the default font's family.
 *
 * @param ctx        A context.//from   ww  w . j a  v  a2 s. c  o  m
 * @param familyName May be null. The name of the font family.
 * @param style      The style (normal, bold, italic) of the typeface, e.g. NORMAL, BOLD, ITALIC, BOLD_ITALIC.
 * @return The best matching typeface.
 * @since 0.1.1
 * @deprecated
 */
@Deprecated
public static Typeface create(Context ctx, String familyName, int style) {
    if (!mInitialized)
        initialize();
    if (isSupported(familyName) || familyName == null) {
        boolean styleAfterwards = false;
        String fileName = FONT_FAMILY_FILE_PREFIX.get(familyName == null ? "sans-serif" : familyName);
        if (fileName.endsWith("-")) {
            // All styles are supported.
            fileName += STYLE_SUFFIX[style];
        } else {
            switch (style) {
            case Typeface.NORMAL:
                break;
            case Typeface.BOLD:
            case Typeface.BOLD_ITALIC:
                // These styles are not supported by default. Therefore force style after retrieving normal font.
                styleAfterwards = true;
                break;
            case Typeface.ITALIC:
                fileName += STYLE_SUFFIX[style];
                break;
            }
        }
        fileName += TTF_SUFFIX;
        // Retrieve Typeface from cache.
        Typeface tf = TYPEFACE_CACHE.get(fileName);
        if (tf == null) {
            // Create Typeface and cache it for later.
            String fontPath = "fonts/" + fileName;
            tf = Typeface.createFromAsset(ctx.getAssets(), fontPath);
            if (tf != null) {
                TYPEFACE_CACHE.put(fileName, tf);
            }
        }
        if (tf != null) {
            return styleAfterwards ? Typeface.create(tf, style) : tf;
        }
    }
    // Let the default implementation of Typeface try.
    return Typeface.create(familyName, style);
}

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:nz.al4.airclock.AirClockFragment.java

private View setupTz() {
    // add time zone
    textTz = new TextView(getContext());
    textTz.setId(textTzId);//from w  w  w .ja  v a2s .  co m

    RelativeLayout.LayoutParams textTzParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    textTzParams.addRule(RelativeLayout.BELOW, textDateId);
    textTz.setLayoutParams(textTzParams);
    textTz.setTypeface(textTz.getTypeface(), Typeface.BOLD);
    textTz.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    textTz.setGravity(Gravity.CENTER_HORIZONTAL);

    return textTz;
}

From source file:im.vector.adapters.RoomViewHolder.java

/**
 * Refresh the holder layout/*from w  w w .  ja v  a  2s. c o m*/
 *
 * @param room                   the room
 * @param isDirectChat           true when the room is a direct chat one
 * @param isInvitation           true when the room is an invitation one
 * @param moreRoomActionListener
 */
public void populateViews(final Context context, final MXSession session, final Room room,
        final boolean isDirectChat, final boolean isInvitation,
        final AbsAdapter.MoreRoomActionListener moreRoomActionListener) {
    // sanity check
    if (null == room) {
        Log.e(LOG_TAG, "## populateViews() : null room");
        return;
    }

    if (null == session) {
        Log.e(LOG_TAG, "## populateViews() : null session");
        return;
    }

    if (null == session.getDataHandler()) {
        Log.e(LOG_TAG, "## populateViews() : null dataHandler");
        return;
    }

    IMXStore store = session.getDataHandler().getStore(room.getRoomId());

    if (null == store) {
        Log.e(LOG_TAG, "## populateViews() : null Store");
        return;
    }

    final RoomSummary roomSummary = store.getSummary(room.getRoomId());

    if (null == roomSummary) {
        Log.e(LOG_TAG, "## populateViews() : null roomSummary");
        return;
    }

    int unreadMsgCount = roomSummary.getUnreadEventsCount();
    int highlightCount;
    int notificationCount;

    // Setup colors
    int mFuchsiaColor = ContextCompat.getColor(context, R.color.vector_fuchsia_color);
    int mGreenColor = ContextCompat.getColor(context, R.color.vector_green_color);
    int mSilverColor = ContextCompat.getColor(context, R.color.vector_silver_color);

    highlightCount = roomSummary.getHighlightCount();
    notificationCount = roomSummary.getNotificationCount();

    // fix a crash reported by GA
    if ((null != room.getDataHandler())
            && room.getDataHandler().getBingRulesManager().isRoomMentionOnly(room.getRoomId())) {
        notificationCount = highlightCount;
    }

    int bingUnreadColor;
    if (isInvitation || (0 != highlightCount)) {
        bingUnreadColor = mFuchsiaColor;
    } else if (0 != notificationCount) {
        bingUnreadColor = mGreenColor;
    } else if (0 != unreadMsgCount) {
        bingUnreadColor = mSilverColor;
    } else {
        bingUnreadColor = Color.TRANSPARENT;
    }

    if (isInvitation || (notificationCount > 0)) {
        vRoomUnreadCount.setText(isInvitation ? "!" : RoomUtils.formatUnreadMessagesCounter(notificationCount));
        vRoomUnreadCount.setTypeface(null, Typeface.BOLD);
        GradientDrawable shape = new GradientDrawable();
        shape.setShape(GradientDrawable.RECTANGLE);
        shape.setCornerRadius(100);
        shape.setColor(bingUnreadColor);
        vRoomUnreadCount.setBackground(shape);
        vRoomUnreadCount.setVisibility(View.VISIBLE);
    } else {
        vRoomUnreadCount.setVisibility(View.GONE);
    }

    String roomName = VectorUtils.getRoomDisplayName(context, session, room);
    if (vRoomNameServer != null) {
        // This view holder is for the home page, we have up to two lines to display the name
        if (MXSession.isRoomAlias(roomName)) {
            // Room alias, split to display the server name on second line
            final String[] roomAliasSplitted = roomName.split(":");
            final String firstLine = roomAliasSplitted[0] + ":";
            final String secondLine = roomAliasSplitted[1];
            vRoomName.setLines(1);
            vRoomName.setText(firstLine);
            vRoomNameServer.setText(secondLine);
            vRoomNameServer.setVisibility(View.VISIBLE);
            vRoomNameServer.setTypeface(null, (0 != unreadMsgCount) ? Typeface.BOLD : Typeface.NORMAL);
        } else {
            // Allow the name to take two lines
            vRoomName.setLines(2);
            vRoomNameServer.setVisibility(View.GONE);
            vRoomName.setText(roomName);
        }
    } else {
        vRoomName.setText(roomName);
    }
    vRoomName.setTypeface(null, (0 != unreadMsgCount) ? Typeface.BOLD : Typeface.NORMAL);

    VectorUtils.loadRoomAvatar(context, session, vRoomAvatar, room);

    // get last message to be displayed
    if (vRoomLastMessage != null) {
        CharSequence lastMsgToDisplay = RoomUtils.getRoomMessageToDisplay(context, session, roomSummary);
        vRoomLastMessage.setText(lastMsgToDisplay);
    }

    if (mDirectChatIndicator != null) {
        mDirectChatIndicator.setVisibility(isDirectChat ? View.VISIBLE : View.INVISIBLE);
    }
    vRoomEncryptedIcon.setVisibility(room.isEncrypted() ? View.VISIBLE : View.INVISIBLE);

    if (vRoomUnreadIndicator != null) {
        // set bing view background colour
        vRoomUnreadIndicator.setBackgroundColor(bingUnreadColor);
        vRoomUnreadIndicator.setVisibility(roomSummary.isInvited() ? View.INVISIBLE : View.VISIBLE);
    }

    if (vRoomTimestamp != null) {
        vRoomTimestamp.setText(RoomUtils.getRoomTimestamp(context, roomSummary.getLatestReceivedEvent()));
    }

    if (vRoomMoreActionClickArea != null && vRoomMoreActionAnchor != null) {
        vRoomMoreActionClickArea.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (null != moreRoomActionListener) {
                    moreRoomActionListener.onMoreActionClick(vRoomMoreActionAnchor, room);
                }
            }
        });
    }
}

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 . java 2  s .  c  o  m

    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.mifos.mifosxdroid.online.datatablelistfragment.DataTableListFragment.java

public void createForm(DataTable table) {

    TextView tableName = new TextView(getActivity().getApplicationContext());
    tableName.setText(table.getRegisteredTableName());
    tableName.setGravity(Gravity.CENTER_HORIZONTAL);
    tableName.setTypeface(null, Typeface.BOLD);
    tableName.setTextColor(getActivity().getResources().getColor(R.color.black));
    tableName.setTextSize(TypedValue.COMPLEX_UNIT_SP,
            getActivity().getResources().getDimension(R.dimen.datatable_name_heading));
    linearLayout.addView(tableName);// w  w w  .j a v  a  2s.c  o  m

    List<FormWidget> formWidgets = new ArrayList<FormWidget>();

    for (ColumnHeader columnHeader : table.getColumnHeaderData()) {

        if (!columnHeader.getColumnPrimaryKey()) {

            if (columnHeader.getColumnDisplayType().equals(FormWidget.SCHEMA_KEY_STRING)
                    || columnHeader.getColumnDisplayType().equals(FormWidget.SCHEMA_KEY_TEXT)) {

                FormEditText formEditText = new FormEditText(getActivity(), columnHeader.getColumnName());
                formWidgets.add(formEditText);
                linearLayout.addView(formEditText.getView());

            } else if (columnHeader.getColumnDisplayType().equals(FormWidget.SCHEMA_KEY_INT)) {

                FormNumericEditText formNumericEditText = new FormNumericEditText(getActivity(),
                        columnHeader.getColumnName());
                formNumericEditText.setReturnType(FormWidget.SCHEMA_KEY_INT);
                formWidgets.add(formNumericEditText);
                linearLayout.addView(formNumericEditText.getView());

            } else if (columnHeader.getColumnDisplayType().equals(FormWidget.SCHEMA_KEY_DECIMAL)) {

                FormNumericEditText formNumericEditText = new FormNumericEditText(getActivity(),
                        columnHeader.getColumnName());
                formNumericEditText.setReturnType(FormWidget.SCHEMA_KEY_DECIMAL);
                formWidgets.add(formNumericEditText);
                linearLayout.addView(formNumericEditText.getView());

            } else if (columnHeader.getColumnDisplayType().equals(FormWidget.SCHEMA_KEY_CODELOOKUP)
                    || columnHeader.getColumnDisplayType().equals(FormWidget.SCHEMA_KEY_CODEVALUE)) {

                if (columnHeader.getColumnValues().size() > 0) {
                    List<String> columnValueStrings = new ArrayList<String>();
                    List<Integer> columnValueIds = new ArrayList<Integer>();

                    for (ColumnValue columnValue : columnHeader.getColumnValues()) {
                        columnValueStrings.add(columnValue.getValue());
                        columnValueIds.add(columnValue.getId());
                    }

                    FormSpinner formSpinner = new FormSpinner(getActivity(), columnHeader.getColumnName(),
                            columnValueStrings, columnValueIds);
                    formSpinner.setReturnType(FormWidget.SCHEMA_KEY_CODEVALUE);
                    formWidgets.add(formSpinner);
                    linearLayout.addView(formSpinner.getView());
                }

            } else if (columnHeader.getColumnDisplayType().equals(FormWidget.SCHEMA_KEY_DATE)) {

                FormEditText formEditText = new FormEditText(getActivity(), columnHeader.getColumnName());
                formEditText.setIsDateField(true, getActivity().getSupportFragmentManager());
                formWidgets.add(formEditText);
                linearLayout.addView(formEditText.getView());
            } else if (columnHeader.getColumnDisplayType().equals(FormWidget.SCHEMA_KEY_BOOL)) {

                FormToggleButton formToggleButton = new FormToggleButton(getActivity(),
                        columnHeader.getColumnName());
                formWidgets.add(formToggleButton);
                linearLayout.addView(formToggleButton.getView());
            }
        }
    }
    listFormWidgets.add(formWidgets);
}

From source file:mobisocial.musubi.objects.IntroductionObj.java

@Override
public View createView(Context context, ViewGroup frame) {
    LinearLayout wrap = new LinearLayout(context);
    wrap.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
    wrap.setOrientation(LinearLayout.VERTICAL);
    wrap.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
    wrap.setEnabled(false);/*from  www.j av a 2  s  .co m*/
    wrap.setFocusableInTouchMode(false);
    wrap.setFocusable(false);
    wrap.setClickable(false);

    TextView title = new TextView(context);
    title.setText(R.string.introduced);
    title.setTypeface(null, Typeface.BOLD);
    title.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    wrap.addView(title);

    Gallery intro = new Gallery(context);
    intro.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    hackGalleryInit(context, intro);
    wrap.addView(intro);
    return wrap;
}

From source file:info.hl.mediam.CreateGroupActivity.java

private void initialization() {

    mPasswordDialog = new HookUpPasswordDialog(this, true);
    mBtnCreate = (Button) findViewById(R.id.btnCreateGroup);
    mBtnCreate.setTypeface(MediamApp.getTfMyriadProBold());
    mEtGroupName = (EditText) findViewById(R.id.etCreateGroupName);
    mEtGroupName.setTypeface(MediamApp.getTfMyriadPro());
    mEtGroupPassword = (EditText) findViewById(R.id.etCreateGroupPassword);
    mEtGroupPassword.setTypeface(MediamApp.getTfMyriadPro());
    mEtGroupPassword.setOnTouchListener(new OnTouchListener() {

        @Override/*  w  w  w .j  a v a2  s  .  c om*/
        public boolean onTouch(View v, MotionEvent event) {
            mPasswordDialog.show();
            hideKeyboard();
            return false;
        }
    });
    mEtGroupDescription = (EditText) findViewById(R.id.etCreateGroupDescription);
    mEtGroupDescription.setTypeface(MediamApp.getTfMyriadPro());
    mIvGroupImage = (ImageView) findViewById(R.id.ivGroupImage);
    mBtnBack = (Button) findViewById(R.id.btnBack);
    mBtnBack.setTypeface(MediamApp.getTfMyriadProBold(), Typeface.BOLD);

    mSpinnerCategory = (Spinner) findViewById(R.id.spinnerCategory);
    new GetGroupCategoriesAsync(this).execute();
}

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);// w  w w  . j ava2s .c o m
}