Example usage for android.graphics Typeface DEFAULT_BOLD

List of usage examples for android.graphics Typeface DEFAULT_BOLD

Introduction

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

Prototype

Typeface DEFAULT_BOLD

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

Click Source Link

Document

The default BOLD typeface object.

Usage

From source file:com.jumpintorivet.rivet.components.sliding_tab.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}./* w w w.  ja  va2 s  .c om*/
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);
    textView.setTextColor(Color.WHITE);
    textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    TypedValue outValue = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
    textView.setBackgroundResource(outValue.resourceId);
    textView.setAllCaps(true);

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(0, padding, 0, padding);

    return textView;
}

From source file:com.wukong.ttravel.Base.views.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}.//from  w w  w . j  av a  2s  . c  o m
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // If we're running on Honeycomb or newer, then we can use the Theme's
        // selectableItemBackgroundonTabClickListener to ensure that the View has a pressed state
        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        textView.setBackgroundResource(outValue.resourceId);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style
        textView.setAllCaps(true);
    }

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);

    return textView;
}

From source file:de.schildbach.wallet.ui.backup.BackupWalletDialogFragment.java

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final View view = LayoutInflater.from(activity).inflate(R.layout.backup_wallet_dialog, null);

    passwordView = (EditText) view.findViewById(R.id.backup_wallet_dialog_password);
    passwordView.setText(null);//from   ww  w. j a  v  a 2  s.  c  o m

    passwordAgainView = (EditText) view.findViewById(R.id.backup_wallet_dialog_password_again);
    passwordAgainView.setText(null);

    passwordStrengthView = (TextView) view.findViewById(R.id.backup_wallet_dialog_password_strength);

    passwordMismatchView = view.findViewById(R.id.backup_wallet_dialog_password_mismatch);

    showView = (CheckBox) view.findViewById(R.id.backup_wallet_dialog_show);

    warningView = (TextView) view.findViewById(R.id.backup_wallet_dialog_warning_encrypted);

    final DialogBuilder builder = new DialogBuilder(activity);
    builder.setTitle(R.string.export_keys_dialog_title);
    builder.setView(view);
    // dummies, just to make buttons show
    builder.setPositiveButton(R.string.button_ok, null);
    builder.setNegativeButton(R.string.button_cancel, null);
    builder.setCancelable(false);

    final AlertDialog dialog = builder.create();

    dialog.setOnShowListener(new OnShowListener() {
        @Override
        public void onShow(final DialogInterface d) {
            positiveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
            positiveButton.setTypeface(Typeface.DEFAULT_BOLD);
            positiveButton.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(final View v) {
                    handleGo();
                }
            });

            negativeButton = dialog.getButton(DialogInterface.BUTTON_NEGATIVE);
            negativeButton.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(final View v) {
                    dismissAllowingStateLoss();
                }
            });

            passwordView.addTextChangedListener(textWatcher);
            passwordAgainView.addTextChangedListener(textWatcher);

            showView.setOnCheckedChangeListener(new ShowPasswordCheckListener(passwordView, passwordAgainView));

            viewModel.wallet.observe(BackupWalletDialogFragment.this, new Observer<Wallet>() {
                @Override
                public void onChanged(final Wallet wallet) {
                    warningView.setVisibility(wallet.isEncrypted() ? View.VISIBLE : View.GONE);
                }
            });
            viewModel.password.observe(BackupWalletDialogFragment.this, new Observer<String>() {
                @Override
                public void onChanged(final String password) {
                    passwordMismatchView.setVisibility(View.INVISIBLE);

                    final int passwordLength = password.length();
                    passwordStrengthView.setVisibility(passwordLength > 0 ? View.VISIBLE : View.INVISIBLE);
                    if (passwordLength < 6) {
                        passwordStrengthView.setText(R.string.encrypt_keys_dialog_password_strength_weak);
                        passwordStrengthView
                                .setTextColor(getResources().getColor(R.color.fg_password_strength_weak));
                    } else if (passwordLength < 8) {
                        passwordStrengthView.setText(R.string.encrypt_keys_dialog_password_strength_fair);
                        passwordStrengthView
                                .setTextColor(getResources().getColor(R.color.fg_password_strength_fair));
                    } else if (passwordLength < 10) {
                        passwordStrengthView.setText(R.string.encrypt_keys_dialog_password_strength_good);
                        passwordStrengthView.setTextColor(getResources().getColor(R.color.fg_less_significant));
                    } else {
                        passwordStrengthView.setText(R.string.encrypt_keys_dialog_password_strength_strong);
                        passwordStrengthView
                                .setTextColor(getResources().getColor(R.color.fg_password_strength_strong));
                    }

                    final boolean hasPassword = !password.isEmpty();
                    final boolean hasPasswordAgain = !passwordAgainView.getText().toString().trim().isEmpty();
                    if (positiveButton != null)
                        positiveButton.setEnabled(
                                viewModel.wallet.getValue() != null && hasPassword && hasPasswordAgain);
                }
            });
        }
    });

    return dialog;
}

From source file:de.schildbach.wallet.ui.send.MaintenanceDialogFragment.java

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final View view = LayoutInflater.from(activity).inflate(R.layout.maintenance_dialog, null);

    Coin value = Coin.ZERO;// ww  w .  j a va2 s  .c  o m
    Coin fee = Coin.ZERO;
    for (final Transaction tx : determineMaintenanceTransactions()) {
        value = value.add(tx.getValueSentFromMe(wallet));
        fee = fee.add(tx.getFee());
    }
    final TextView messageView = (TextView) view.findViewById(R.id.maintenance_dialog_message);
    final MonetaryFormat format = application.getConfiguration().getFormat();
    messageView
            .setText(getString(R.string.maintenance_dialog_message, format.format(value), format.format(fee)));

    passwordGroup = view.findViewById(R.id.maintenance_dialog_password_group);

    passwordView = (EditText) view.findViewById(R.id.maintenance_dialog_password);
    passwordView.setText(null);

    badPasswordView = view.findViewById(R.id.maintenance_dialog_bad_password);

    final DialogBuilder builder = new DialogBuilder(activity);
    builder.setTitle(R.string.maintenance_dialog_title);
    builder.setView(view);
    builder.setPositiveButton(R.string.maintenance_dialog_button_move, null); // dummy, just to make it
                                                                              // show
    builder.setNegativeButton(R.string.button_dismiss, null);
    builder.setCancelable(false);

    final AlertDialog dialog = builder.create();
    dialog.setCanceledOnTouchOutside(false);

    dialog.setOnShowListener(new OnShowListener() {
        @Override
        public void onShow(final DialogInterface d) {
            positiveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
            negativeButton = dialog.getButton(DialogInterface.BUTTON_NEGATIVE);

            positiveButton.setTypeface(Typeface.DEFAULT_BOLD);
            positiveButton.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(final View v) {
                    log.info("user decided to do maintenance");
                    handleGo();
                }
            });
            negativeButton.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(final View v) {
                    log.info("user decided to dismiss");
                    dismiss();
                }
            });

            passwordView.addTextChangedListener(textWatcher);

            MaintenanceDialogFragment.this.dialog = dialog;
            updateView();
        }
    });

    log.info("showing maintenance dialog");

    return dialog;
}

From source file:com.al70b.core.extended_widgets.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}.//www .  j  a  v a 2  s.  c om
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);
    textView.setTextColor(context.getResources().getColor(R.color.white));
    textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    TypedValue outValue = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
    textView.setBackgroundResource(outValue.resourceId);
    textView.setAllCaps(true);

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);

    return textView;
}

From source file:android.olayinka.file.transfer.widget.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}./* www. j ava  2s  .c o  m*/
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // If we're running on Honeycomb or newer, then we can use the Theme's
        // selectableItemBackground to ensure that the View has a pressed state
        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        textView.setBackgroundResource(outValue.resourceId);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style
        textView.setAllCaps(true);
    }

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);
    //textView.setBackground(null);

    return textView;
}

From source file:de.egh.bikehist.ui.masterdata.SlidingTabLayout.java

/**
 Create a default view to be used for tabs. This is called if a custom tab view is not set via
 {@link #setCustomTabView(int, int)}./*from ww  w  . j a v  a  2 s  .c  o m*/
 */
private TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // If we're running on Honeycomb or newer, then we can use the Theme's
        // selectableItemBackground to ensure that the View has a pressed state
        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        textView.setBackgroundResource(outValue.resourceId);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style
        textView.setAllCaps(true);
    }

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);

    return textView;
}

From source file:io.github.carlorodriguez.alarmon.MediaListView.java

protected void query(Uri contentUri, String nameColumn, String selection, int rowResId, String[] displayColumns,
        int[] resIDs) {
    this.nameColumn = nameColumn;
    final ArrayList<String> queryColumns = new ArrayList<>(displayColumns.length + 1);
    queryColumns.addAll(Arrays.asList(displayColumns));
    // The ID column is required for the SimpleCursorAdapter.  Make sure to
    // add it if it's not already there.
    if (!queryColumns.contains(BaseColumns._ID)) {
        queryColumns.add(BaseColumns._ID);
    }/* www.j a  v  a2  s.  co  m*/

    Cursor dbCursor;

    if (ContextCompat.checkSelfPermission(getContext(),
            Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
        dbCursor = getContext().getContentResolver().query(contentUri,
                queryColumns.toArray(new String[queryColumns.size()]), selection, null, sortOrder);
    } else {
        dbCursor = new MatrixCursor(queryColumns.toArray(new String[queryColumns.size()]));
    }

    if (staticCursor != null) {
        Cursor[] cursors = new Cursor[] { staticCursor, dbCursor };
        cursor = new MergeCursor(cursors);
    } else {
        cursor = dbCursor;
    }
    manageCursor(cursor);

    this.contentUri = contentUri;

    final SimpleCursorAdapter adapter = new SimpleCursorAdapter(getContext(), rowResId, cursor, displayColumns,
            resIDs, 1);
    // Use a custom binder to highlight the selected element.
    adapter.setViewBinder(new ViewBinder() {
        @Override
        public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
            if (view.getVisibility() == View.VISIBLE && view instanceof TextView) {
                TextView text = (TextView) view;
                if (isItemChecked(cursor.getPosition())) {
                    text.setTypeface(Typeface.DEFAULT_BOLD);
                } else {
                    text.setTypeface(Typeface.DEFAULT);
                }
            }
            // Let the default binder do the real work.
            return false;
        }
    });
    setAdapter(adapter);
    setOnItemClickListener(this);
}

From source file:com.android.dialer.calllog.PhoneCallDetailsHelper.java

/** Fills the call details views with content. */
public void setPhoneCallDetails(PhoneCallDetailsViews views, PhoneCallDetails details) {
    // Display up to a given number of icons.
    views.callTypeIcons.clear();/*from w ww.jav  a2 s  .  co m*/
    int count = details.callTypes.length;
    boolean isVoicemail = false;
    for (int index = 0; index < count && index < MAX_CALL_TYPE_ICONS; ++index) {
        views.callTypeIcons.add(details.callTypes[index]);
        if (index == 0) {
            isVoicemail = details.callTypes[index] == Calls.VOICEMAIL_TYPE;
        }
    }

    // Show the video icon if the call had video enabled.
    views.callTypeIcons.setShowVideo((details.features & Calls.FEATURES_VIDEO) == Calls.FEATURES_VIDEO);
    views.callTypeIcons.requestLayout();
    views.callTypeIcons.setVisibility(View.VISIBLE);

    // Show the total call count only if there are more than the maximum number of icons.
    final Integer callCount;
    if (count > MAX_CALL_TYPE_ICONS) {
        callCount = count;
    } else {
        callCount = null;
    }

    // Set the call count, location, date and if voicemail, set the duration.
    setDetailText(views, callCount, details);

    // Set the account label if it exists.
    String accountLabel = mCallLogCache.getAccountLabel(details.accountHandle);
    if (!TextUtils.isEmpty(details.viaNumber)) {
        if (!TextUtils.isEmpty(accountLabel)) {
            accountLabel = mResources.getString(R.string.call_log_via_number_phone_account, accountLabel,
                    details.viaNumber);
        } else {
            accountLabel = mResources.getString(R.string.call_log_via_number, details.viaNumber);
        }
    }
    if (!TextUtils.isEmpty(accountLabel)) {
        views.callAccountLabel.setVisibility(View.VISIBLE);
        views.callAccountLabel.setText(accountLabel);
        int color = mCallLogCache.getAccountColor(details.accountHandle);
        if (color == PhoneAccount.NO_HIGHLIGHT_COLOR) {
            int defaultColor = R.color.dialtacts_secondary_text_color;
            views.callAccountLabel.setTextColor(mContext.getResources().getColor(defaultColor));
        } else {
            views.callAccountLabel.setTextColor(color);
        }
    } else {
        views.callAccountLabel.setVisibility(View.GONE);
    }

    final CharSequence nameText;
    final CharSequence displayNumber = details.displayNumber;
    if (TextUtils.isEmpty(details.getPreferredName())) {
        nameText = displayNumber;
        // We have a real phone number as "nameView" so make it always LTR
        views.nameView.setTextDirection(View.TEXT_DIRECTION_LTR);
    } else {
        nameText = details.getPreferredName();
    }

    views.nameView.setText(nameText);

    if (isVoicemail) {
        views.voicemailTranscriptionView
                .setText(TextUtils.isEmpty(details.transcription) ? null : details.transcription);
    }

    // Bold if not read
    Typeface typeface = details.isRead ? Typeface.SANS_SERIF : Typeface.DEFAULT_BOLD;
    views.nameView.setTypeface(typeface);
    views.voicemailTranscriptionView.setTypeface(typeface);
    views.callLocationAndDate.setTypeface(typeface);
    views.callLocationAndDate.setTextColor(ContextCompat.getColor(mContext,
            details.isRead ? R.color.call_log_detail_color : R.color.call_log_unread_text_color));
}

From source file:info.papdt.blacklight.ui.common.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}.//from  w  ww.j  a va2 s .c  om
 */
protected View createDefaultTabView(Context context) {
    View v;
    if (mIconAdapter == null) {
        TextView textView = new TextView(context);
        textView.setGravity(Gravity.CENTER);
        textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
        textView.setTypeface(Typeface.DEFAULT_BOLD);
        textView.setAllCaps(true);
        textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.MATCH_PARENT));
        int padding = (int) (TAB_TEXT_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
        textView.setPadding(padding, padding, padding, padding);

        v = textView;
    } else {
        ImageView imgView = new TintImageView(context);
        imgView.setScaleType(ImageView.ScaleType.FIT_XY);
        imgView.setLayoutParams(new LinearLayout.LayoutParams(mTabIconSize, mTabIconSize));

        v = imgView;
    }

    TypedValue outValue = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
    if (v instanceof ImageView) {
        v.setBackgroundResource(outValue.resourceId);
        int padding = (int) (TAB_ICON_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
        v.setPadding(padding, padding, padding, padding);
    }

    return v;
}