am 6760f923
: Merge "Fix RTL layout of text in Battery history screen" into klp-dev
* commit '6760f92321d2013676863b533606563ed2041648': Fix RTL layout of text in Battery history screen
This commit is contained in:
@@ -657,15 +657,22 @@ public class BatteryHistoryChart extends View {
|
|||||||
|
|
||||||
final int width = getWidth();
|
final int width = getWidth();
|
||||||
final int height = getHeight();
|
final int height = getHeight();
|
||||||
|
final boolean layoutRtl = isLayoutRtl();
|
||||||
|
final int textStartX = layoutRtl ? width : 0;
|
||||||
|
mTextPaint.setTextAlign(layoutRtl ? Paint.Align.RIGHT : Paint.Align.LEFT);
|
||||||
|
|
||||||
canvas.drawPath(mBatLevelPath, mBatteryBackgroundPaint);
|
canvas.drawPath(mBatLevelPath, mBatteryBackgroundPaint);
|
||||||
if (mLargeMode) {
|
if (mLargeMode) {
|
||||||
canvas.drawText(mDurationString, 0, -mTextAscent + (mLineWidth/2),
|
int durationHalfWidth = mTotalDurationStringWidth / 2;
|
||||||
|
if (layoutRtl) durationHalfWidth = -durationHalfWidth;
|
||||||
|
canvas.drawText(mDurationString, textStartX, -mTextAscent + (mLineWidth / 2),
|
||||||
mTextPaint);
|
mTextPaint);
|
||||||
canvas.drawText(mTotalDurationString, (width/2) - (mTotalDurationStringWidth/2),
|
canvas.drawText(mTotalDurationString, (width / 2) - durationHalfWidth,
|
||||||
mLevelBottom - mTextAscent + mThinLineWidth, mTextPaint);
|
mLevelBottom - mTextAscent + mThinLineWidth, mTextPaint);
|
||||||
} else {
|
} else {
|
||||||
canvas.drawText(mDurationString, (width/2) - (mDurationStringWidth/2),
|
int durationHalfWidth = mDurationStringWidth / 2;
|
||||||
|
if (layoutRtl) durationHalfWidth = -durationHalfWidth;
|
||||||
|
canvas.drawText(mDurationString, (width / 2) - durationHalfWidth,
|
||||||
(height / 2) - ((mTextDescent - mTextAscent) / 2) - mTextAscent, mTextPaint);
|
(height / 2) - ((mTextDescent - mTextAscent) / 2) - mTextAscent, mTextPaint);
|
||||||
}
|
}
|
||||||
if (!mBatGoodPath.isEmpty()) {
|
if (!mBatGoodPath.isEmpty()) {
|
||||||
@@ -703,22 +710,22 @@ public class BatteryHistoryChart extends View {
|
|||||||
|
|
||||||
if (mLargeMode) {
|
if (mLargeMode) {
|
||||||
if (mHavePhoneSignal) {
|
if (mHavePhoneSignal) {
|
||||||
canvas.drawText(mPhoneSignalLabel, 0,
|
canvas.drawText(mPhoneSignalLabel, textStartX,
|
||||||
height - mPhoneSignalOffset - mTextDescent, mTextPaint);
|
height - mPhoneSignalOffset - mTextDescent, mTextPaint);
|
||||||
}
|
}
|
||||||
if (mHaveGps) {
|
if (mHaveGps) {
|
||||||
canvas.drawText(mGpsOnLabel, 0,
|
canvas.drawText(mGpsOnLabel, textStartX,
|
||||||
height - mGpsOnOffset - mTextDescent, mTextPaint);
|
height - mGpsOnOffset - mTextDescent, mTextPaint);
|
||||||
}
|
}
|
||||||
if (mHaveWifi) {
|
if (mHaveWifi) {
|
||||||
canvas.drawText(mWifiRunningLabel, 0,
|
canvas.drawText(mWifiRunningLabel, textStartX,
|
||||||
height - mWifiRunningOffset - mTextDescent, mTextPaint);
|
height - mWifiRunningOffset - mTextDescent, mTextPaint);
|
||||||
}
|
}
|
||||||
canvas.drawText(mWakeLockLabel, 0,
|
canvas.drawText(mWakeLockLabel, textStartX,
|
||||||
height - mWakeLockOffset - mTextDescent, mTextPaint);
|
height - mWakeLockOffset - mTextDescent, mTextPaint);
|
||||||
canvas.drawText(mChargingLabel, 0,
|
canvas.drawText(mChargingLabel, textStartX,
|
||||||
height - mChargingOffset - mTextDescent, mTextPaint);
|
height - mChargingOffset - mTextDescent, mTextPaint);
|
||||||
canvas.drawText(mScreenOnLabel, 0,
|
canvas.drawText(mScreenOnLabel, textStartX,
|
||||||
height - mScreenOnOffset - mTextDescent, mTextPaint);
|
height - mScreenOnOffset - mTextDescent, mTextPaint);
|
||||||
canvas.drawLine(0, mLevelBottom+(mThinLineWidth/2), width,
|
canvas.drawLine(0, mLevelBottom+(mThinLineWidth/2), width,
|
||||||
mLevelBottom+(mThinLineWidth/2), mTextPaint);
|
mLevelBottom+(mThinLineWidth/2), mTextPaint);
|
||||||
|
Reference in New Issue
Block a user