summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFabrice Di Meglio <fdimeglio@google.com>2012-07-25 11:26:41 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-07-25 11:26:42 -0700
commitfbf500877ae2f2140e82fa90a9c312cfc000be19 (patch)
tree4c98278c80bc4f4cd044ca3e7796545f7a5bcaf0 /src
parentf91b394cf67d436423f2bfe1206cffe1902e5a26 (diff)
parenta82d9a8d37c67b37733c5bdfba26548f216a374d (diff)
downloadpackages_apps_Settings-fbf500877ae2f2140e82fa90a9c312cfc000be19.zip
packages_apps_Settings-fbf500877ae2f2140e82fa90a9c312cfc000be19.tar.gz
packages_apps_Settings-fbf500877ae2f2140e82fa90a9c312cfc000be19.tar.bz2
Merge "Make Settings PercentageBar RTL aware"
Diffstat (limited to 'src')
-rw-r--r--src/com/android/settings/deviceinfo/PercentageBarChart.java63
1 files changed, 45 insertions, 18 deletions
diff --git a/src/com/android/settings/deviceinfo/PercentageBarChart.java b/src/com/android/settings/deviceinfo/PercentageBarChart.java
index 95973c4..b45eb69 100644
--- a/src/com/android/settings/deviceinfo/PercentageBarChart.java
+++ b/src/com/android/settings/deviceinfo/PercentageBarChart.java
@@ -71,29 +71,56 @@ public class PercentageBarChart extends View {
final int width = right - left;
- float lastX = left;
-
- if (mEntries != null) {
- for (final Entry e : mEntries) {
- final float entryWidth;
- if (e.percentage == 0.0f) {
- entryWidth = 0.0f;
- } else {
- entryWidth = Math.max(mMinTickWidth, width * e.percentage);
+ final boolean isLayoutRtl = isLayoutRtl();
+ if (isLayoutRtl) {
+ float nextX = right;
+
+ if (mEntries != null) {
+ for (final Entry e : mEntries) {
+ final float entryWidth;
+ if (e.percentage == 0.0f) {
+ entryWidth = 0.0f;
+ } else {
+ entryWidth = Math.max(mMinTickWidth, width * e.percentage);
+ }
+
+ final float lastX = nextX - entryWidth;
+ if (lastX < left) {
+ canvas.drawRect(left, top, nextX, bottom, e.paint);
+ return;
+ }
+
+ canvas.drawRect(lastX, top, nextX, bottom, e.paint);
+ nextX = lastX;
}
+ }
- final float nextX = lastX + entryWidth;
- if (nextX > right) {
- canvas.drawRect(lastX, top, right, bottom, e.paint);
- return;
+ canvas.drawRect(left, top, nextX, bottom, mEmptyPaint);
+ } else {
+ float lastX = left;
+
+ if (mEntries != null) {
+ for (final Entry e : mEntries) {
+ final float entryWidth;
+ if (e.percentage == 0.0f) {
+ entryWidth = 0.0f;
+ } else {
+ entryWidth = Math.max(mMinTickWidth, width * e.percentage);
+ }
+
+ final float nextX = lastX + entryWidth;
+ if (nextX > right) {
+ canvas.drawRect(lastX, top, right, bottom, e.paint);
+ return;
+ }
+
+ canvas.drawRect(lastX, top, nextX, bottom, e.paint);
+ lastX = nextX;
}
-
- canvas.drawRect(lastX, top, nextX, bottom, e.paint);
- lastX = nextX;
}
- }
- canvas.drawRect(lastX, top, right, bottom, mEmptyPaint);
+ canvas.drawRect(lastX, top, right, bottom, mEmptyPaint);
+ }
}
/**