Example usage for android.graphics Typeface NORMAL

List of usage examples for android.graphics Typeface NORMAL

Introduction

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

Prototype

int NORMAL

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

Click Source Link

Usage

From source file:com.wanikani.androidnotifier.WebReviewActivity.java

private void applySingleSettings() {
    boolean show;

    show = kbstatus.canDoSingle() && SettingsActivity.getShowSingle(this);
    singleb.setVisibility(show ? View.VISIBLE : View.GONE);
    if (single) {
        singleb.setTextColor(selectedColor);
        singleb.setTypeface(null, Typeface.BOLD);
        wv.js(JS_SINGLE_MODE);//from w w w.  j  ava2 s.c o m
    } else {
        singleb.setTextColor(unselectedColor);
        singleb.setTypeface(null, Typeface.NORMAL);
        wv.js(JS_BULK_MODE);
    }
}

From source file:com.cssn.samplesdk.MainActivity.java

/**
 * Highlights the current option: drivers card, medical or passport.
 */// w  ww .  j a  v a2s.  co  m
private void highlightCurrentCardOption() {
    int buttonId;

    switch (mainActivityModel.getCurrentOptionType()) {

    case CardType.DRIVERS_LICENSE:
        buttonId = R.id.buttonDriver;
        if (isFacialFlow) {
            buttonId = R.id.buttonDriverFacial;
        } else {
            buttonId = R.id.buttonDriver;
        }

        break;

    case CardType.PASSPORT:
        buttonId = R.id.buttonPassport;
        if (isFacialFlow) {
            buttonId = R.id.buttonPassportFacial;
        } else {
            buttonId = R.id.buttonPassport;
        }

        break;

    case CardType.MEDICAL_INSURANCE:

        buttonId = R.id.buttonMedical;

        break;
    case CardType.FACIAL_RECOGNITION:
        buttonId = R.id.buttonDriverFacial;
        if (processedCardInformation instanceof DriversLicenseCard) {
            buttonId = R.id.buttonDriverFacial;
        } else if (processedCardInformation instanceof PassportCard) {
            buttonId = R.id.buttonPassportFacial;
        }

        break;

    default:
        throw new IllegalArgumentException(
                "This method is wrong implemented, there is not processing for the card type '"
                        + mainActivityModel.getCurrentOptionType() + "'");

    }

    ((Button) findViewById(R.id.buttonDriver)).setTypeface(null, Typeface.NORMAL);
    ((Button) findViewById(R.id.buttonPassport)).setTypeface(null, Typeface.NORMAL);
    ((Button) findViewById(R.id.buttonMedical)).setTypeface(null, Typeface.NORMAL);
    ((Button) findViewById(R.id.buttonPassportFacial)).setTypeface(null, Typeface.NORMAL);
    ((Button) findViewById(R.id.buttonPassportFacial)).setTypeface(null, Typeface.NORMAL);

    ((Button) findViewById(buttonId)).setTypeface(null, Typeface.BOLD);
}

From source file:com.nickandjerry.dynamiclayoutinflator.DynamicLayoutInflator.java

public static void createViewRunnables() {
    viewRunnables = new HashMap<>(30);
    viewRunnables.put("scaleType", new ViewParamRunnable() {
        @Override/*from   www .ja  va  2s. co m*/
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            if (view instanceof ImageView) {
                ImageView.ScaleType scaleType = ((ImageView) view).getScaleType();
                switch (value.toLowerCase()) {
                case "center":
                    scaleType = ImageView.ScaleType.CENTER;
                    break;
                case "center_crop":
                    scaleType = ImageView.ScaleType.CENTER_CROP;
                    break;
                case "center_inside":
                    scaleType = ImageView.ScaleType.CENTER_INSIDE;
                    break;
                case "fit_center":
                    scaleType = ImageView.ScaleType.FIT_CENTER;
                    break;
                case "fit_end":
                    scaleType = ImageView.ScaleType.FIT_END;
                    break;
                case "fit_start":
                    scaleType = ImageView.ScaleType.FIT_START;
                    break;
                case "fit_xy":
                    scaleType = ImageView.ScaleType.FIT_XY;
                    break;
                case "matrix":
                    scaleType = ImageView.ScaleType.MATRIX;
                    break;
                }
                ((ImageView) view).setScaleType(scaleType);
            }
        }
    });
    viewRunnables.put("orientation", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            if (view instanceof LinearLayout) {
                ((LinearLayout) view).setOrientation(
                        value.equals("vertical") ? LinearLayout.VERTICAL : LinearLayout.HORIZONTAL);
            }
        }
    });
    viewRunnables.put("text", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            if (view instanceof TextView) {
                ((TextView) view).setText(value);
            }
        }
    });
    viewRunnables.put("textSize", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            if (view instanceof TextView) {
                ((TextView) view).setTextSize(TypedValue.COMPLEX_UNIT_PX,
                        DimensionConverter.stringToDimension(value, view.getResources().getDisplayMetrics()));
            }
        }
    });
    viewRunnables.put("textColor", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            if (view instanceof TextView) {
                ((TextView) view).setTextColor(parseColor(view, value));
            }
        }
    });
    viewRunnables.put("textStyle", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            if (view instanceof TextView) {
                int typeFace = Typeface.NORMAL;
                if (value.contains("bold"))
                    typeFace |= Typeface.BOLD;
                else if (value.contains("italic"))
                    typeFace |= Typeface.ITALIC;
                ((TextView) view).setTypeface(null, typeFace);
            }
        }
    });
    viewRunnables.put("textAlignment", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
                int alignment = View.TEXT_ALIGNMENT_TEXT_START;
                switch (value) {
                case "center":
                    alignment = View.TEXT_ALIGNMENT_CENTER;
                    break;
                case "left":
                case "textStart":
                    break;
                case "right":
                case "textEnd":
                    alignment = View.TEXT_ALIGNMENT_TEXT_END;
                    break;
                }
                view.setTextAlignment(alignment);
            } else {
                int gravity = Gravity.LEFT;
                switch (value) {
                case "center":
                    gravity = Gravity.CENTER;
                    break;
                case "left":
                case "textStart":
                    break;
                case "right":
                case "textEnd":
                    gravity = Gravity.RIGHT;
                    break;
                }
                ((TextView) view).setGravity(gravity);
            }
        }
    });
    viewRunnables.put("ellipsize", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            if (view instanceof TextView) {
                TextUtils.TruncateAt where = TextUtils.TruncateAt.END;
                switch (value) {
                case "start":
                    where = TextUtils.TruncateAt.START;
                    break;
                case "middle":
                    where = TextUtils.TruncateAt.MIDDLE;
                    break;
                case "marquee":
                    where = TextUtils.TruncateAt.MARQUEE;
                    break;
                case "end":
                    break;
                }
                ((TextView) view).setEllipsize(where);
            }
        }
    });
    viewRunnables.put("singleLine", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            if (view instanceof TextView) {
                ((TextView) view).setSingleLine();
            }
        }
    });
    viewRunnables.put("hint", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            if (view instanceof EditText) {
                ((EditText) view).setHint(value);
            }
        }
    });
    viewRunnables.put("inputType", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            if (view instanceof TextView) {
                int inputType = 0;
                switch (value) {
                case "textEmailAddress":
                    inputType |= InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
                    break;
                case "number":
                    inputType |= InputType.TYPE_CLASS_NUMBER;
                    break;
                case "phone":
                    inputType |= InputType.TYPE_CLASS_PHONE;
                    break;
                }
                if (inputType > 0)
                    ((TextView) view).setInputType(inputType);
            }
        }
    });
    viewRunnables.put("gravity", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            int gravity = parseGravity(value);
            if (view instanceof TextView) {
                ((TextView) view).setGravity(gravity);
            } else if (view instanceof LinearLayout) {
                ((LinearLayout) view).setGravity(gravity);
            } else if (view instanceof RelativeLayout) {
                ((RelativeLayout) view).setGravity(gravity);
            }
        }
    });
    viewRunnables.put("src", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            if (view instanceof ImageView) {
                String imageName = value;
                if (imageName.startsWith("//"))
                    imageName = "http:" + imageName;
                if (imageName.startsWith("http")) {
                    if (imageLoader != null) {
                        if (attrs.containsKey("cornerRadius")) {
                            int radius = DimensionConverter.stringToDimensionPixelSize(
                                    attrs.get("cornerRadius"), view.getResources().getDisplayMetrics());
                            imageLoader.loadRoundedImage((ImageView) view, imageName, radius);
                        } else {
                            imageLoader.loadImage((ImageView) view, imageName);
                        }
                    }
                } else if (imageName.startsWith("@drawable/")) {
                    imageName = imageName.substring("@drawable/".length());
                    ((ImageView) view).setImageDrawable(getDrawableByName(view, imageName));
                }
            }
        }
    });
    viewRunnables.put("visibility", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            int visibility = View.VISIBLE;
            String visValue = value.toLowerCase();
            if (visValue.equals("gone"))
                visibility = View.GONE;
            else if (visValue.equals("invisible"))
                visibility = View.INVISIBLE;
            view.setVisibility(visibility);
        }
    });
    viewRunnables.put("clickable", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            view.setClickable(value.equals("true"));
        }
    });
    viewRunnables.put("tag", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            // Sigh, this is dangerous because we use tags for other purposes
            if (view.getTag() == null)
                view.setTag(value);
        }
    });
    viewRunnables.put("onClick", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            view.setOnClickListener(getClickListener(parent, value));
        }
    });
}

From source file:de.vanita5.twittnuker.util.ThemeUtils.java

public static Typeface getUserTypeface(final Context context, final Typeface defTypeface) {
    if (context == null || Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN)
        return Typeface.DEFAULT;
    final int fontStyle = defTypeface != null ? defTypeface.getStyle() : Typeface.NORMAL;
    final String fontFamily = getThemeFontFamily(context);
    final Typeface tf = Typeface.create(fontFamily, fontStyle);
    if (tf != null)
        return tf;
    return Typeface.create(Typeface.DEFAULT, fontStyle);
}

From source file:es.usc.citius.servando.calendula.fragments.ScheduleTimetableFragment.java

void setupDaySelectionListeners(final View rootView) {

    View.OnClickListener listener = new View.OnClickListener() {
        @Override//  w  w  w  .  ja  va2  s .  co  m
        public void onClick(View view) {

            TextView text = ((TextView) view);
            int index;
            switch (text.getId()) {
            case R.id.day_mo:
                schedule.toggleSelectedDay(0);
                index = 0;
                break;
            case R.id.day_tu:
                schedule.toggleSelectedDay(1);
                index = 1;
                break;
            case R.id.day_we:
                schedule.toggleSelectedDay(2);
                index = 2;
                break;
            case R.id.day_th:
                index = 3;
                schedule.toggleSelectedDay(3);
                break;
            case R.id.day_fr:
                schedule.toggleSelectedDay(4);
                index = 4;
                break;
            case R.id.day_sa:
                schedule.toggleSelectedDay(5);
                index = 5;
                break;
            case R.id.day_su:
                schedule.toggleSelectedDay(6);
                index = 6;
                break;
            default:
                return;
            }

            boolean daySelected = schedule.days()[index];
            StateListDrawable sld = (StateListDrawable) text.getBackground();
            GradientDrawable shape = (GradientDrawable) sld.getCurrent();
            shape.setColor(daySelected ? color : Color.WHITE);
            text.setTypeface(null, daySelected ? Typeface.BOLD : Typeface.NORMAL);
            text.setTextColor(daySelected ? Color.WHITE : Color.BLACK);

            boolean allDaysSelected = schedule.allDaysSelected();

            if (schedule.type() == Schedule.SCHEDULE_TYPE_EVERYDAY && !allDaysSelected) {
                setRepeatType(Schedule.SCHEDULE_TYPE_SOMEDAYS, rootView, false);
                ignoreNextEvent = true;
                repeatTypeSpinner.setSelection(1);
            } else if (schedule.type() == Schedule.SCHEDULE_TYPE_SOMEDAYS && allDaysSelected) {
                repeatTypeSpinner.setSelection(0);
                schedule.setType(Schedule.SCHEDULE_TYPE_EVERYDAY);
            }

            Log.d(TAG, "All days selected: " + allDaysSelected + ", repeatType: " + schedule.type());
        }
    };

    rootView.findViewById(R.id.day_mo).setOnClickListener(listener);
    rootView.findViewById(R.id.day_tu).setOnClickListener(listener);
    rootView.findViewById(R.id.day_we).setOnClickListener(listener);
    rootView.findViewById(R.id.day_th).setOnClickListener(listener);
    rootView.findViewById(R.id.day_fr).setOnClickListener(listener);
    rootView.findViewById(R.id.day_sa).setOnClickListener(listener);
    rootView.findViewById(R.id.day_su).setOnClickListener(listener);
}

From source file:com.edible.ocr.CaptureActivity.java

/**
 * Displays information relating to the result of OCR, and requests a translation if necessary.
 * /*  w  w  w .  jav a 2s.c om*/
 * @param ocrResult Object representing successful OCR results
 * @return True if a non-null result was received for OCR
 */
boolean handleOcrDecode(OcrResult ocrResult) {
    lastResult = ocrResult;

    // Test whether the result is null
    if (ocrResult.getText() == null || ocrResult.getText().equals("")) {
        Toast toast = Toast.makeText(this, "OCR failed. Please try again.", Toast.LENGTH_SHORT);
        toast.setGravity(Gravity.TOP, 0, 0);
        toast.show();
        return false;
    }

    // Turn off capture-related UI elements
    shutterButton.setVisibility(View.GONE);
    statusViewBottom.setVisibility(View.GONE);
    statusViewTop.setVisibility(View.GONE);
    cameraButtonView.setVisibility(View.GONE);
    viewfinderView.setVisibility(View.GONE);
    resultView.setVisibility(View.VISIBLE);

    ImageView bitmapImageView = (ImageView) findViewById(R.id.image_view);
    lastBitmap = ocrResult.getBitmap();
    if (lastBitmap == null) {
        bitmapImageView.setImageBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher));
    } else {
        bitmapImageView.setImageBitmap(lastBitmap);
    }

    // Display the recognized text
    TextView sourceLanguageTextView = (TextView) findViewById(R.id.source_language_text_view);
    sourceLanguageTextView.setText(sourceLanguageReadable);
    TextView ocrResultTextView = (TextView) findViewById(R.id.ocr_result_text_view);
    ocrResultTextView.setText(stripNoise(ocrResult.getText()));
    // Crudely scale betweeen 22 and 32 -- bigger font for shorter text
    int scaledSize = Math.max(22, 32 - ocrResult.getText().length() / 4);
    ocrResultTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, scaledSize);

    TextView translationLanguageLabelTextView = (TextView) findViewById(
            R.id.translation_language_label_text_view);
    TextView translationLanguageTextView = (TextView) findViewById(R.id.translation_language_text_view);
    TextView translationTextView = (TextView) findViewById(R.id.translation_text_view);
    if (isTranslationActive) {
        // Handle translation text fields
        translationLanguageLabelTextView.setVisibility(View.VISIBLE);
        translationLanguageTextView.setText(targetLanguageReadable);
        translationLanguageTextView.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL), Typeface.NORMAL);
        translationLanguageTextView.setVisibility(View.VISIBLE);

        // Activate/re-activate the indeterminate progress indicator
        translationTextView.setVisibility(View.GONE);
        progressView.setVisibility(View.VISIBLE);
        setProgressBarVisibility(true);

        // Get the translation asynchronously
        new TranslateAsyncTask(this, sourceLanguageCodeTranslation, targetLanguageCodeTranslation,
                stripNoise(ocrResult.getText())).execute();
    } else {
        translationLanguageLabelTextView.setVisibility(View.GONE);
        translationLanguageTextView.setVisibility(View.GONE);
        translationTextView.setVisibility(View.GONE);
        progressView.setVisibility(View.GONE);
        setProgressBarVisibility(false);
    }
    return true;
}

From source file:org.onebusaway.android.report.ui.Open311ProblemFragment.java

private void createTripHeadsign(String text) {
    LayoutInflater inflater = LayoutInflater.from(getActivity());
    RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.report_issue_description_item, null,
            false);//from www  .j a va2s.c o m

    LinearLayout linear = (LinearLayout) findViewById(R.id.ri_report_stop_problem);
    TextView tv = ((TextView) layout.findViewById(R.id.riii_textView));
    tv.setText(UIUtils.formatDisplayText(text));
    tv.setTypeface(null, Typeface.NORMAL);

    linear.addView(layout, 0);

    ImageView imageView = (ImageView) layout.findViewById(R.id.ic_action_info);
    imageView.setImageResource(R.drawable.ic_trip_details);
    imageView.setColorFilter(getResources().getColor(R.color.material_gray));
}

From source file:es.usc.citius.servando.calendula.fragments.ScheduleImportFragment.java

void checkSelectedDays(View rootView, boolean[] days) {

    Log.d(TAG, "Checking selected days: " + Arrays.toString(days));
    schedule.setDays(days);//from  w w w  .  j  a v  a 2 s .  c o  m

    TextView mo = ((TextView) rootView.findViewById(R.id.day_mo));
    TextView tu = ((TextView) rootView.findViewById(R.id.day_tu));
    TextView we = ((TextView) rootView.findViewById(R.id.day_we));
    TextView th = ((TextView) rootView.findViewById(R.id.day_th));
    TextView fr = ((TextView) rootView.findViewById(R.id.day_fr));
    TextView sa = ((TextView) rootView.findViewById(R.id.day_sa));
    TextView su = ((TextView) rootView.findViewById(R.id.day_su));

    TextView[] daysTvs = new TextView[] { mo, tu, we, th, fr, sa, su };

    for (int i = 0; i < daysTvs.length; i++) {
        boolean isSelected = days[i];

        StateListDrawable sld = (StateListDrawable) daysTvs[i].getBackground();
        GradientDrawable shape = (GradientDrawable) sld.getCurrent();
        shape.setColor(isSelected ? color : Color.WHITE);

        daysTvs[i].setTextColor(isSelected ? Color.WHITE : color);
        daysTvs[i].setTypeface(null, isSelected ? Typeface.BOLD : Typeface.NORMAL);

    }
}

From source file:es.usc.citius.servando.calendula.fragments.ScheduleTimetableFragment.java

void checkSelectedDays(View rootView, boolean[] days) {

    Log.d(TAG, "Checking selected days: " + Arrays.toString(days));
    schedule.setDays(days);// w  w w  .  j  av a  2 s  .com

    TextView mo = ((TextView) rootView.findViewById(R.id.day_mo));
    TextView tu = ((TextView) rootView.findViewById(R.id.day_tu));
    TextView we = ((TextView) rootView.findViewById(R.id.day_we));
    TextView th = ((TextView) rootView.findViewById(R.id.day_th));
    TextView fr = ((TextView) rootView.findViewById(R.id.day_fr));
    TextView sa = ((TextView) rootView.findViewById(R.id.day_sa));
    TextView su = ((TextView) rootView.findViewById(R.id.day_su));

    TextView[] daysTvs = new TextView[] { mo, tu, we, th, fr, sa, su };

    for (int i = 0; i < daysTvs.length; i++) {
        boolean isSelected = days[i];

        StateListDrawable sld = (StateListDrawable) daysTvs[i].getBackground();
        GradientDrawable shape = (GradientDrawable) sld.getCurrent();
        shape.setColor(isSelected ? color : Color.WHITE);
        daysTvs[i].setTypeface(null, isSelected ? Typeface.BOLD : Typeface.NORMAL);
        daysTvs[i].setTextColor(isSelected ? Color.WHITE : Color.BLACK);
    }
}