Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 014575ae authored by Itzhak Katzenelson's avatar Itzhak Katzenelson
Browse files

Add new fonts to prevent "stuttering"

Bug: 7198855
Added fixed size font for digits in stopwatch and timer to prevent
the time from moving when the time change.

Change-Id: I8c5fa916c5c64c855f2806911ee8565c48ca6ede
parent ffe12a38
Loading
Loading
Loading
Loading
+5.07 KiB

File added.

No diff preview for this file type.

+5.12 KiB

File added.

No diff preview for this file type.

+5.11 KiB

File added.

No diff preview for this file type.

+7 −6
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ public class CountingTimerView extends View {
    private float mHoursLabelWidth, mMinutesLabelWidth, mSecondsLabelWidth, mHundredthsSepWidth;

    private boolean mShowTimeStr = true;
    private final Typeface mRobotoThin, mRobotoBold, mRobotoLabel;
    private final Typeface mAndroidClockMonoThin, mAndroidClockMonoBold, mRobotoLabel, mAndroidClockMonoLight;
    private final Paint mPaintBig = new Paint();
    private final Paint mPaintBigThin = new Paint();
    private final Paint mPaintMed = new Paint();
@@ -86,8 +86,9 @@ public class CountingTimerView extends View {

    public CountingTimerView(Context context, AttributeSet attrs) {
        super(context, attrs);
        mRobotoThin = Typeface.createFromAsset(context.getAssets(),"fonts/Roboto-Thin.ttf");
        mRobotoBold = Typeface.create("sans-serif", Typeface.BOLD);
        mAndroidClockMonoThin = Typeface.createFromAsset(context.getAssets(),"fonts/AndroidClockMono-Thin.ttf");
        mAndroidClockMonoBold = Typeface.createFromAsset(context.getAssets(),"fonts/AndroidClockMono-Bold.ttf");
        mAndroidClockMonoLight = Typeface.createFromAsset(context.getAssets(),"fonts/AndroidClockMono-Light.ttf");
        mRobotoLabel= Typeface.create("sans-serif-condensed", Typeface.BOLD);
        Resources r = context.getResources();
        mHoursLabel = r.getString(R.string.hours_label).toUpperCase();
@@ -101,7 +102,7 @@ public class CountingTimerView extends View {
        mPaintBig.setAntiAlias(true);
        mPaintBig.setStyle(Paint.Style.STROKE);
        mPaintBig.setTextAlign(Paint.Align.LEFT);
        mPaintBig.setTypeface(mRobotoBold);
        mPaintBig.setTypeface(mAndroidClockMonoBold);
        float bigFontSize = r.getDimension(R.dimen.big_font_size);
        mPaintBig.setTextSize(bigFontSize);
        mTextHeight = bigFontSize;
@@ -109,13 +110,13 @@ public class CountingTimerView extends View {
        mPaintBigThin.setAntiAlias(true);
        mPaintBigThin.setStyle(Paint.Style.STROKE);
        mPaintBigThin.setTextAlign(Paint.Align.LEFT);
        mPaintBigThin.setTypeface(mRobotoThin);
        mPaintBigThin.setTypeface(mAndroidClockMonoThin);
        mPaintBigThin.setTextSize(r.getDimension(R.dimen.big_font_size));

        mPaintMed.setAntiAlias(true);
        mPaintMed.setStyle(Paint.Style.STROKE);
        mPaintMed.setTextAlign(Paint.Align.LEFT);
        mPaintMed.setTypeface(mRobotoThin);
        mPaintMed.setTypeface(mAndroidClockMonoLight);
        mPaintMed.setTextSize(r.getDimension(R.dimen.small_font_size));

        mPaintLabel.setAntiAlias(true);
+7 −7
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ public class TimerView extends LinearLayout {
    private ZeroTopPaddingTextView mHoursOnes, mMinutesOnes;
    private ZeroTopPaddingTextView mHoursTens, mMinutesTens;
    private TextView mSeconds;
    private final Typeface mRobotoThin;
    private final Typeface mAndroidClockMonoThin;
    private Typeface mOriginalHoursTypeface;
    private final int mWhiteColor, mGrayColor;

@@ -43,7 +43,7 @@ public class TimerView extends LinearLayout {
    public TimerView(Context context, AttributeSet attrs) {
        super(context, attrs);

        mRobotoThin = Typeface.createFromAsset(context.getAssets(),"fonts/Roboto-Thin.ttf");
        mAndroidClockMonoThin = Typeface.createFromAsset(context.getAssets(),"fonts/AndroidClockMono-Thin.ttf");
        mWhiteColor = context.getResources().getColor(R.color.clock_white);
        mGrayColor = context.getResources().getColor(R.color.clock_gray);
    }
@@ -62,14 +62,14 @@ public class TimerView extends LinearLayout {
        }
        // Set the lowest time unit with thin font (excluding hundredths)
        if (mSeconds != null) {
            mSeconds.setTypeface(mRobotoThin);
            mSeconds.setTypeface(mAndroidClockMonoThin);
        } else  {
            if (mMinutesTens != null) {
                mMinutesTens.setTypeface(mRobotoThin);
                mMinutesTens.setTypeface(mAndroidClockMonoThin);
                mMinutesTens.updatePadding();
            }
            if (mMinutesOnes != null) {
                mMinutesOnes.setTypeface(mRobotoThin);
                mMinutesOnes.setTypeface(mAndroidClockMonoThin);
                mMinutesOnes.updatePadding();
            }
        }
@@ -84,7 +84,7 @@ public class TimerView extends LinearLayout {
                mHoursTens.setVisibility(View.INVISIBLE);
            } else if (hoursTensDigit == -1) {
                mHoursTens.setText("-");
                mHoursTens.setTypeface(mRobotoThin);
                mHoursTens.setTypeface(mAndroidClockMonoThin);
                mHoursTens.setTextColor(mGrayColor);
                mHoursTens.updatePadding();
                mHoursTens.setVisibility(View.VISIBLE);
@@ -99,7 +99,7 @@ public class TimerView extends LinearLayout {
        if (mHoursOnes != null) {
            if (hoursOnesDigit == -1) {
                mHoursOnes.setText("-");
                mHoursOnes.setTypeface(mRobotoThin);
                mHoursOnes.setTypeface(mAndroidClockMonoThin);
                mHoursOnes.setTextColor(mGrayColor);
                mHoursOnes.updatePadding();
            } else {