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

Commit 1b6ad82a authored by Danesh M's avatar Danesh M Committed by Steve Kondik
Browse files

CircleBattery : Fix alignment regression from RTL

Rather than distributing the padding evenly to get around RTL issues,
remeasure on layout changes.

Change-Id: Ic6f7a58bd64bf2c99f0e07edb0d8fb8cdb9aa398
parent e81d947b
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.systemui.statusbar.policy;

import android.view.ViewGroup.LayoutParams;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
@@ -292,6 +291,12 @@ public class CircleBattery extends ImageView implements BatteryController.Batter
        mHandler.postDelayed(mInvalidate, 50);
    }

    @Override
    public void onRtlPropertiesChanged(int layoutDirection) {
        mRectLeft = null;
        invalidate();
    }

    /**
     * initializes all size dependent variables
     * sets stroke width and text size of all involved paints
@@ -311,13 +316,13 @@ public class CircleBattery extends ImageView implements BatteryController.Batter

        // calculate rectangle for drawArc calls
        int pLeft = getPaddingStart();
        mRectLeft = new RectF(pLeft/2 + strokeWidth / 2.0f, 0 + strokeWidth / 2.0f, mCircleSize
                - strokeWidth / 2.0f + pLeft/2, mCircleSize - strokeWidth / 2.0f);
        mRectLeft = new RectF(getPaddingLeft() + strokeWidth / 2.0f, 0 + strokeWidth / 2.0f, mCircleSize
                - strokeWidth / 2.0f + getPaddingLeft(), mCircleSize - strokeWidth / 2.0f);

        // calculate Y position for text
        Rect bounds = new Rect();
        mPaintFont.getTextBounds("99", 0, "99".length(), bounds);
        mTextLeftX = mCircleSize / 2.0f + getPaddingStart();
        mTextLeftX = mCircleSize / 2.0f + pLeft;
        // the +1 at end of formular balances out rounding issues. works out on all resolutions
        mTextY = mCircleSize / 2.0f + (bounds.bottom - bounds.top) / 2.0f - strokeWidth / 2.0f + 1;