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.farmerbb.taskbar.adapter.StartMenuAdapter.java

@Override
public @NonNull View getView(int position, View convertView, final @NonNull ViewGroup parent) {
    // Check if an existing view is being reused, otherwise inflate the view
    if (convertView == null)
        convertView = LayoutInflater.from(getContext()).inflate(isGrid ? R.layout.row_alt : R.layout.row,
                parent, false);//ww w.  j  a  va  2s  .c om

    final AppEntry entry = getItem(position);
    assert entry != null;

    final SharedPreferences pref = U.getSharedPreferences(getContext());

    TextView textView = (TextView) convertView.findViewById(R.id.name);
    textView.setText(entry.getLabel());

    Intent intent = new Intent();
    intent.setComponent(ComponentName.unflattenFromString(entry.getComponentName()));
    ActivityInfo activityInfo = intent.resolveActivityInfo(getContext().getPackageManager(), 0);

    if (activityInfo != null)
        textView.setTypeface(null, isTopApp(activityInfo) ? Typeface.BOLD : Typeface.NORMAL);

    switch (pref.getString("theme", "light")) {
    case "light":
        textView.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color));
        break;
    case "dark":
        textView.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color_dark));
        break;
    }

    ImageView imageView = (ImageView) convertView.findViewById(R.id.icon);
    imageView.setImageDrawable(entry.getIcon(getContext()));

    LinearLayout layout = (LinearLayout) convertView.findViewById(R.id.entry);
    layout.setOnClickListener(view -> {
        LocalBroadcastManager.getInstance(getContext())
                .sendBroadcast(new Intent("com.farmerbb.taskbar.HIDE_START_MENU"));
        U.launchApp(getContext(), entry.getPackageName(), entry.getComponentName(),
                entry.getUserId(getContext()), null, false, false);
    });

    layout.setOnLongClickListener(view -> {
        int[] location = new int[2];
        view.getLocationOnScreen(location);
        openContextMenu(entry, location);
        return true;
    });

    layout.setOnGenericMotionListener((view, motionEvent) -> {
        int action = motionEvent.getAction();

        if (action == MotionEvent.ACTION_BUTTON_PRESS
                && motionEvent.getButtonState() == MotionEvent.BUTTON_SECONDARY) {
            int[] location = new int[2];
            view.getLocationOnScreen(location);
            openContextMenu(entry, location);
        }

        if (action == MotionEvent.ACTION_SCROLL && pref.getBoolean("visual_feedback", true))
            view.setBackgroundColor(0);

        return false;
    });

    if (pref.getBoolean("visual_feedback", true)) {
        layout.setOnHoverListener((v, event) -> {
            if (event.getAction() == MotionEvent.ACTION_HOVER_ENTER) {
                int backgroundTint = pref.getBoolean("transparent_start_menu", false)
                        ? U.getAccentColor(getContext())
                        : U.getBackgroundTint(getContext());

                //noinspection ResourceAsColor
                backgroundTint = ColorUtils.setAlphaComponent(backgroundTint, Color.alpha(backgroundTint) / 2);
                v.setBackgroundColor(backgroundTint);
            }

            if (event.getAction() == MotionEvent.ACTION_HOVER_EXIT)
                v.setBackgroundColor(0);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
                v.setPointerIcon(PointerIcon.getSystemIcon(getContext(), PointerIcon.TYPE_DEFAULT));

            return false;
        });

        layout.setOnTouchListener((v, event) -> {
            v.setAlpha(
                    event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_MOVE
                            ? 0.5f
                            : 1);
            return false;
        });
    }

    return convertView;
}

From source file:com.codetroopers.betterpickers.radialtimepicker.RadialTextsView.java

public void initialize(Resources res, String[] texts, String[] innerTexts, boolean is24HourMode,
        boolean disappearsOut) {
    if (mIsInitialized) {
        Log.e(TAG, "This RadialTextsView may only be initialized once.");
        return;/*  w  ww .  j a v  a 2s .com*/
    }

    // Set up the paint.
    mPaint.setColor(res.getColor(R.color.numbers_text_color));
    String typefaceFamily = res.getString(R.string.radial_numbers_typeface);
    mTypefaceLight = Typeface.create(typefaceFamily, Typeface.NORMAL);
    String typefaceFamilyRegular = res.getString(R.string.sans_serif);
    mTypefaceRegular = Typeface.create(typefaceFamilyRegular, Typeface.NORMAL);
    mPaint.setAntiAlias(true);
    mPaint.setTextAlign(Align.CENTER);

    mTexts = texts;
    mInnerTexts = innerTexts;
    mIs24HourMode = is24HourMode;
    mHasInnerCircle = (innerTexts != null);

    // Calculate the radius for the main circle.
    if (is24HourMode) {
        mCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.circle_radius_multiplier_24HourMode));
    } else {
        mCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.circle_radius_multiplier));
        mAmPmCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.ampm_circle_radius_multiplier));
    }

    // Initialize the widths and heights of the grid, and calculate the values for the numbers.
    mTextGridHeights = new float[7];
    mTextGridWidths = new float[7];
    if (mHasInnerCircle) {
        mNumbersRadiusMultiplier = Float.parseFloat(res.getString(R.string.numbers_radius_multiplier_outer));
        mTextSizeMultiplier = Float.parseFloat(res.getString(R.string.text_size_multiplier_outer));
        mInnerNumbersRadiusMultiplier = Float
                .parseFloat(res.getString(R.string.numbers_radius_multiplier_inner));
        mInnerTextSizeMultiplier = Float.parseFloat(res.getString(R.string.text_size_multiplier_inner));

        mInnerTextGridHeights = new float[7];
        mInnerTextGridWidths = new float[7];
    } else {
        mNumbersRadiusMultiplier = Float.parseFloat(res.getString(R.string.numbers_radius_multiplier_normal));
        mTextSizeMultiplier = Float.parseFloat(res.getString(R.string.text_size_multiplier_normal));
    }

    mAnimationRadiusMultiplier = 1;
    mTransitionMidRadiusMultiplier = 1f + (0.05f * (disappearsOut ? -1 : 1));
    mTransitionEndRadiusMultiplier = 1f + (0.3f * (disappearsOut ? 1 : -1));
    mInvalidateUpdateListener = new InvalidateUpdateListener();

    mTextGridValuesDirty = true;
    mIsInitialized = true;
}

From source file:org.npr.android.news.NewsListAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = inflater.inflate(R.layout.news_item, parent, false);
    }//  w w  w.j  a  va2 s .c  o m

    Story story = getItem(position);

    ImageView image = (ImageView) convertView.findViewById(R.id.NewsItemImage);
    TextView teaser = (TextView) convertView.findViewById(R.id.NewsItemTeaserText);
    TextView name = (TextView) convertView.findViewById(R.id.NewsItemNameText);

    if (story != null) {
        image.setImageDrawable(getContext().getResources()
                .getDrawable(isPlayable(story) ? R.drawable.icon_listen_main : R.drawable.bullet));
        image.setVisibility(View.VISIBLE);
        name.setTypeface(headlineTypeface, Typeface.NORMAL);
        name.setText(story.toString());
        String teaserText = story.getMiniTeaser();
        if (teaserText == null) {
            teaserText = story.getTeaser();
        }
        if (teaserText != null && teaserText.length() > 0) {
            // Disable for now.
            //        teaser.setText(story.getTeaser());
            //        teaser.setVisibility(View.VISIBLE);
        } else {
            teaser.setVisibility(View.INVISIBLE);
        }
        teaser.setVisibility(View.GONE);
    } else {
        // null marker means it's the end of the list.
        image.setVisibility(View.INVISIBLE);
        teaser.setVisibility(View.INVISIBLE);
        name.setTypeface(Typeface.SANS_SERIF, Typeface.ITALIC);
        name.setText(R.string.msg_load_more);
    }
    return convertView;
}

From source file:org.cm.podd.report.activity.ReportTypeActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    typeface = StyleUtil.getDefaultTypeface(getAssets(), Typeface.NORMAL);

    setContentView(R.layout.activity_report_type);
    listView = (ListView) findViewById(R.id.report_type_list_view);
    testLayout = (LinearLayout) findViewById(R.id.test_section);
    progressBar = (ProgressBar) findViewById(R.id.report_type_progress_bar);
    testCheckbox = (CheckBox) findViewById(R.id.test_checkbox);
    testCheckbox.setTypeface(typeface);/*ww  w. j  a  v  a  2  s  . co m*/

    dataSource = new ReportTypeDataSource(this);
    reportDataSource = new ReportDataSource(this);
    reportQueueDataSource = new ReportQueueDataSource(this);

    ArrayList<ReportType> items = getAll();
    adapter = new ReportTypeAdapter(this, R.layout.list_item_report_type, items);
    listView.setAdapter(adapter);

    listView.setOnItemClickListener(this);
    testCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            if (b) {
                testLayout.setBackgroundResource(R.color.report_test_indicator);
                compoundButton.setBackgroundResource(R.color.report_test_indicator);
            } else {
                testLayout.setBackgroundResource(R.color.white);
                compoundButton.setBackgroundResource(R.color.white);
            }
        }
    });

    registerReceiver(mSyncReceiver, new IntentFilter(SyncReportTypeService.SYNC));
}

From source file:com.chauffeurprive.kronos.time.AmPmCirclesView.java

public void initialize(Context context, TimePickerController controller, int amOrPm) {
    if (mIsInitialized) {
        Log.e(TAG, "AmPmCirclesView may only be initialized once.");
        return;/*from   w  w w  . j  a  va2  s. c  o  m*/
    }

    Resources res = context.getResources();

    mUnselectedColor = ContextCompat.getColor(context, controller.getCircleBackgroundColor());
    mAmPmTextColor = ContextCompat.getColor(context, controller.getTextColor());
    mAmPmDisabledTextColor = ContextCompat.getColor(context, controller.getDisabledTextColor());
    mSelectedAlpha = SELECTED_ALPHA;

    mSelectedColor = ContextCompat.getColor(context, controller.getAccentColor());
    mTouchedColor = ContextCompat.getColor(context, controller.getDisabledTextColor());
    mAmPmSelectedTextColor = ContextCompat.getColor(context, controller.getSelectedTextColor());

    String typefaceFamily = res.getString(R.string.mdtp_sans_serif);
    Typeface tf = Typeface.create(typefaceFamily, Typeface.NORMAL);
    mPaint.setTypeface(tf);
    mPaint.setAntiAlias(true);
    mPaint.setTextAlign(Align.CENTER);

    mCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.mdtp_circle_radius_multiplier));
    mAmPmCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.mdtp_ampm_circle_radius_multiplier));
    String[] amPmTexts = new DateFormatSymbols().getAmPmStrings();
    mAmText = amPmTexts[0];
    mPmText = amPmTexts[1];

    mAmDisabled = controller.isAmDisabled();
    mPmDisabled = controller.isPmDisabled();

    setAmOrPm(amOrPm);
    mAmOrPmPressed = -1;

    mIsInitialized = true;
}

From source file:org.cm.podd.report.activity.GroupReportTypeActivity.java

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    dataSource = new ReportTypeDataSource(this);
    reportDataSource = new ReportDataSource(this);
    reportQueueDataSource = new ReportQueueDataSource(this);

    Typeface typeface = StyleUtil.getDefaultTypeface(getAssets(), Typeface.NORMAL);
    setContentView(R.layout.activity_group_report_type);
    testCheckbox = findViewById(R.id.test_checkbox);
    testCheckbox.setTypeface(typeface);/* www  .j a  v  a  2  s . c o  m*/

    final LinearLayout testLayout = findViewById(R.id.test_section);
    testCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            if (b) {
                testLayout.setBackgroundResource(R.color.report_test_indicator);
                compoundButton.setBackgroundResource(R.color.report_test_indicator);
            } else {
                testLayout.setBackgroundResource(R.color.white);
                compoundButton.setBackgroundResource(R.color.white);
            }
        }
    });

    Toolbar topBar = findViewById(R.id.toolbar_top);
    setSupportActionBar(topBar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    listView = findViewById(R.id.report_type_list_view);

    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    int width = metrics.widthPixels;
    if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
        listView.setIndicatorBounds(width - GetPixelFromDips(100), width - GetPixelFromDips(10));
    } else {
        listView.setIndicatorBoundsRelative(width - GetPixelFromDips(100), width - GetPixelFromDips(10));
    }

    adapter = new GroupReportTypeAdapter(this, dataSource.getAllWithNoFollowAction());
    listView.setAdapter(adapter);
    listView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
        @Override
        public boolean onChildClick(ExpandableListView expandableListView, View view, int groupIndex,
                int childIndex, long id) {
            ReportType item = (ReportType) adapter.getChild(groupIndex, childIndex);
            Log.d(TAG, String.format("select report type = %d", item.getId()));
            Intent intent = ReportActivity.newReportIntent(GroupReportTypeActivity.this, item.getId(),
                    testCheckbox.isChecked());
            startActivity(intent);
            return true;
        }
    });
    listView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
        @Override
        public boolean onGroupClick(ExpandableListView expandableListView, View view, int groupPosition,
                long id) {
            Log.d(TAG, "group " + groupPosition);
            if (groupPosition == 0) {
                long reportId = reportDataSource.createPositiveReport();

                // after save positive report, submit to queue right away
                reportQueueDataSource.addDataQueue(reportId);
                broadcastReportSubmission();

                finish();
                return true;
            }
            return false;
        }
    });

    progress = new ProgressDialog(this);
    progress.setTitle(getString(R.string.update_report_type));
    registerReceiver(mSyncReceiver, new IntentFilter(SyncReportTypeService.SYNC));

}

From source file:edu.mecc.race2ged.helpers.Utils.java

/**
 * Sets the font of a view to Roboto-Light
 * @param context The context of the activity.
 * @param view The view that will use Roboto-Light
 *///  w  w  w.  j av  a 2s. com
public static void setRobotoThin(Context context, View view) {
    setRobotoThin(context, view, Typeface.NORMAL);
}

From source file:com.skydoves.elasticviewsexample.ElasticVIews.ElasticButton.java

private void setTypeArray(TypedArray typedArray) {
    GradientDrawable bgShape = (GradientDrawable) view.getBackground();

    round = typedArray.getInt(R.styleable.ElasticButton_button_round, round);
    bgShape.setCornerRadius(round);/*  w  ww  . j  a  v a  2 s  . c  om*/

    color = typedArray.getInt(R.styleable.ElasticButton_button_backgroundColor, color);
    bgShape.setColor(color);

    scale = typedArray.getFloat(R.styleable.ElasticButton_button_scale, scale);

    duration = typedArray.getInt(R.styleable.ElasticButton_button_duration, duration);

    labelText = typedArray.getString(R.styleable.ElasticButton_button_labelText);
    view.setText(labelText);

    labelColor = typedArray.getInt(R.styleable.ElasticButton_button_labelColor, labelColor);
    view.setTextColor(labelColor);

    labelSize = typedArray.getInt(R.styleable.ElasticButton_button_labelSize, labelSize);
    view.setTextSize(labelSize);

    labelStyle = typedArray.getInt(R.styleable.ElasticButton_button_labelStyle, labelStyle);

    if (labelStyle == 0)
        view.setTypeface(null, Typeface.NORMAL);
    else if (labelStyle == 1)
        view.setTypeface(null, Typeface.BOLD);
    else if (labelStyle == 2)
        view.setTypeface(null, Typeface.ITALIC);
}

From source file:net.xpece.commons.android.widget.CollapsingTitleLayout.java

public CollapsingTitleLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    mTextPaint = new TextPaint();
    mTextPaint.setAntiAlias(true);/*from  w ww.  j  a  v  a2 s.co m*/

    if (AndroidUtils.API_21) {
        Typeface tf = Typeface.create("sans-serif-medium", Typeface.NORMAL);
        mTextPaint.setTypeface(tf);
    } else {
        Typeface tf = Typeface.create("sans-serif", Typeface.NORMAL);
        mTextPaint.setTypeface(tf);
    }

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CollapsingTitleLayout);

    mExpandedMarginLeft = mExpandedMarginRight = mExpandedMarginBottom = a
            .getDimensionPixelSize(R.styleable.CollapsingTitleLayout_expandedMargin, 0);

    final boolean isRtl = ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL;
    if (a.hasValue(R.styleable.CollapsingTitleLayout_expandedMarginStart)) {
        final int marginStart = a.getDimensionPixelSize(R.styleable.CollapsingTitleLayout_expandedMarginStart,
                0);
        if (isRtl) {
            mExpandedMarginRight = marginStart;
        } else {
            mExpandedMarginLeft = marginStart;
        }
    }
    if (a.hasValue(R.styleable.CollapsingTitleLayout_expandedMarginEnd)) {
        final int marginEnd = a.getDimensionPixelSize(R.styleable.CollapsingTitleLayout_expandedMarginEnd, 0);
        if (isRtl) {
            mExpandedMarginLeft = marginEnd;
        } else {
            mExpandedMarginRight = marginEnd;
        }
    }
    if (a.hasValue(R.styleable.CollapsingTitleLayout_expandedMarginBottom)) {
        mExpandedMarginBottom = a.getDimensionPixelSize(R.styleable.CollapsingTitleLayout_expandedMarginBottom,
                0);
    }

    final int tp = a.getResourceId(R.styleable.CollapsingTitleLayout_android_textAppearance,
            android.R.style.TextAppearance);
    setTextAppearance(tp);

    if (a.hasValue(R.styleable.CollapsingTitleLayout_collapsedTextSize)) {
        mCollapsedTitleTextSize = a.getDimensionPixelSize(R.styleable.CollapsingTitleLayout_collapsedTextSize,
                0);
    }

    mRequestedExpandedTitleTextSize = a
            .getDimensionPixelSize(R.styleable.CollapsingTitleLayout_expandedTextSize, mCollapsedTitleTextSize);

    final int interpolatorId = a.getResourceId(R.styleable.CollapsingTitleLayout_textSizeInterpolator,
            android.R.anim.accelerate_interpolator);
    mTextSizeInterpolator = AnimationUtils.loadInterpolator(context, interpolatorId);

    a.recycle();

    mToolbarContentBounds = new Rect();

    setWillNotDraw(false);
}

From source file:com.allmycode.flags.MyActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);//from   w  w  w .  j a  v  a2  s . c o  m
    targetActivity = (AutoCompleteTextView) findViewById(R.id.editText1);
    ArrayAdapter<String> targetsAdapter = new ArrayAdapter<String>(this, R.layout.list_item, TARGETS_LIST);
    targetActivity.setAdapter(targetsAdapter);
    flags = (AutoCompleteTextView) findViewById(R.id.editText2);
    ArrayAdapter<String> flagsAdapter = new ArrayAdapter<String>(this, R.layout.list_item, FLAGS_LIST_CONCISE);
    flags.setAdapter(flagsAdapter);
    cheatSheet = (EditText) findViewById(R.id.editText3);
    for (String item : FLAGS_LIST) {
        cheatSheet.append(item);
        cheatSheet.append("\n");
    }
    Intent whoCalled = getIntent();
    helloView = ((TextView) findViewById(R.id.textView3));
    helloView.setTextColor(android.graphics.Color.WHITE);
    helloView.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
    helloView.setText("Flags: 0x" + Integer.toHexString(whoCalled.getFlags()));
    if (whoCalled.getExtras() != null) {
        boolean areErrors = whoCalled.getExtras().getBoolean("existErrors", false);
        if (areErrors) {
            helloView.append(" There were errors!");
            helloView.setTextColor(android.graphics.Color.RED);
            helloView.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
        }
    }

    ActivityManager am = (ActivityManager) getSystemService(Service.ACTIVITY_SERVICE);
    List<ActivityManager.RunningAppProcessInfo> processes;
    processes = am.getRunningAppProcesses();
    for (ActivityManager.RunningAppProcessInfo info : processes) {
        Log.i("Process:", info.processName);
    }
}