summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2013-08-28 14:15:52 -0700
committerAmith Yamasani <yamasani@google.com>2013-08-28 15:14:16 -0700
commit74809c2679d9c046f73acb4473434f9f5ad4b1c1 (patch)
tree55f39a547731466851ace341e3ba88335685e8b9 /src/com
parent9506d857cbc87a3dcedc8c3599f1d45ac6fe995e (diff)
downloadpackages_apps_Settings-74809c2679d9c046f73acb4473434f9f5ad4b1c1.zip
packages_apps_Settings-74809c2679d9c046f73acb4473434f9f5ad4b1c1.tar.gz
packages_apps_Settings-74809c2679d9c046f73acb4473434f9f5ad4b1c1.tar.bz2
Fix RTL layout of text in Battery history screen
Change the anchor position and alignment direction for text. Bug: 10447666 Change-Id: Ida4161c738cf9a32cc8ff98037f3755046e64e33
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/settings/fuelgauge/BatteryHistoryChart.java31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/com/android/settings/fuelgauge/BatteryHistoryChart.java b/src/com/android/settings/fuelgauge/BatteryHistoryChart.java
index 5145789..9642d7c 100644
--- a/src/com/android/settings/fuelgauge/BatteryHistoryChart.java
+++ b/src/com/android/settings/fuelgauge/BatteryHistoryChart.java
@@ -654,19 +654,26 @@ public class BatteryHistoryChart extends View {
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
-
+
final int width = getWidth();
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);
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);
- canvas.drawText(mTotalDurationString, (width/2) - (mTotalDurationStringWidth/2),
+ canvas.drawText(mTotalDurationString, (width / 2) - durationHalfWidth,
mLevelBottom - mTextAscent + mThinLineWidth, mTextPaint);
} else {
- canvas.drawText(mDurationString, (width/2) - (mDurationStringWidth/2),
- (height/2) - ((mTextDescent-mTextAscent)/2) - mTextAscent, mTextPaint);
+ int durationHalfWidth = mDurationStringWidth / 2;
+ if (layoutRtl) durationHalfWidth = -durationHalfWidth;
+ canvas.drawText(mDurationString, (width / 2) - durationHalfWidth,
+ (height / 2) - ((mTextDescent - mTextAscent) / 2) - mTextAscent, mTextPaint);
}
if (!mBatGoodPath.isEmpty()) {
canvas.drawPath(mBatGoodPath, mBatteryGoodPaint);
@@ -703,22 +710,22 @@ public class BatteryHistoryChart extends View {
if (mLargeMode) {
if (mHavePhoneSignal) {
- canvas.drawText(mPhoneSignalLabel, 0,
+ canvas.drawText(mPhoneSignalLabel, textStartX,
height - mPhoneSignalOffset - mTextDescent, mTextPaint);
}
if (mHaveGps) {
- canvas.drawText(mGpsOnLabel, 0,
+ canvas.drawText(mGpsOnLabel, textStartX,
height - mGpsOnOffset - mTextDescent, mTextPaint);
}
if (mHaveWifi) {
- canvas.drawText(mWifiRunningLabel, 0,
+ canvas.drawText(mWifiRunningLabel, textStartX,
height - mWifiRunningOffset - mTextDescent, mTextPaint);
}
- canvas.drawText(mWakeLockLabel, 0,
+ canvas.drawText(mWakeLockLabel, textStartX,
height - mWakeLockOffset - mTextDescent, mTextPaint);
- canvas.drawText(mChargingLabel, 0,
+ canvas.drawText(mChargingLabel, textStartX,
height - mChargingOffset - mTextDescent, mTextPaint);
- canvas.drawText(mScreenOnLabel, 0,
+ canvas.drawText(mScreenOnLabel, textStartX,
height - mScreenOnOffset - mTextDescent, mTextPaint);
canvas.drawLine(0, mLevelBottom+(mThinLineWidth/2), width,
mLevelBottom+(mThinLineWidth/2), mTextPaint);