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

Commit 449c448e authored by kaiyiz's avatar kaiyiz Committed by Gerrit - the friendly Code Review server
Browse files

DeskClock: Fix the AM/PM on time picker dialog display uncomplete

TimePicker use a fix font size compute the hours and minutes numbers width
But the label font size can set by app, so it will compute error width.
lead to the am/pm position error.

When app use customer fontsize, use this size compute the time label
size.

Change-Id: Ib42983684439f25ecc84940424048c09b3069e39
CRs-fixed: 783871
parent 05b93e7b
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -93,6 +93,7 @@ class TimePickerSpinnerDelegate extends TimePicker.AbstractTimePickerDelegate im
    private Node mLegalTimesTree;
    private int mAmKeyCode;
    private int mPmKeyCode;
    private int mHeaderTimeTextAppearance = 0;

    // Accessibility strings.
    private String mHourPickerDescription;
@@ -136,6 +137,7 @@ class TimePickerSpinnerDelegate extends TimePicker.AbstractTimePickerDelegate im
        final int headerTimeTextAppearance = a.getResourceId(
                R.styleable.TimePicker_headerTimeTextAppearance, 0);
        if (headerTimeTextAppearance != 0) {
            mHeaderTimeTextAppearance = headerTimeTextAppearance;
            mHourView.setTextAppearance(context, headerTimeTextAppearance);
            mSeparatorView.setTextAppearance(context, headerTimeTextAppearance);
            mMinuteView.setTextAppearance(context, headerTimeTextAppearance);
@@ -234,7 +236,11 @@ class TimePickerSpinnerDelegate extends TimePicker.AbstractTimePickerDelegate im

    private int computeMaxWidthOfNumbers(int max) {
        TextView tempView = new TextView(mContext);
        if (mHeaderTimeTextAppearance != 0) {
            tempView.setTextAppearance(mContext, mHeaderTimeTextAppearance);
        } else {
            tempView.setTextAppearance(mContext, R.style.TextAppearance_Material_TimePicker_TimeLabel);
        }
        ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);
        tempView.setLayoutParams(lp);