summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorKenny Root <kroot@google.com>2010-12-17 11:57:14 -0800
committerKenny Root <kroot@google.com>2010-12-17 14:55:26 -0800
commit42a92e83a1f91d5e150ce069636f588a3609e69c (patch)
tree0f7ebac2b8c51587b42a2ba2de4eb60f88f44f0a /src/com
parente4330890d6996bd1ad65bc6c5ab1dfb39f224ea4 (diff)
downloadpackages_apps_Settings-42a92e83a1f91d5e150ce069636f588a3609e69c.tar.gz
packages_apps_Settings-42a92e83a1f91d5e150ce069636f588a3609e69c.tar.bz2
packages_apps_Settings-42a92e83a1f91d5e150ce069636f588a3609e69c.zip
Add minTickWidth for the bar chart
At jsharkey's request. Change-Id: Ic489e534fe793fc7ec3fd2bedc5bb256be99daec
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/settings/deviceinfo/PercentageBarChart.java22
1 files changed, 6 insertions, 16 deletions
diff --git a/src/com/android/settings/deviceinfo/PercentageBarChart.java b/src/com/android/settings/deviceinfo/PercentageBarChart.java
index 2f174fb73..7d023010e 100644
--- a/src/com/android/settings/deviceinfo/PercentageBarChart.java
+++ b/src/com/android/settings/deviceinfo/PercentageBarChart.java
@@ -36,6 +36,8 @@ public class PercentageBarChart extends View {
private Collection<Entry> mEntries;
+ private int mMinTickWidth = 1;
+
public static class Entry {
public final float percentage;
public final Paint paint;
@@ -49,21 +51,9 @@ public class PercentageBarChart extends View {
public PercentageBarChart(Context context, AttributeSet attrs) {
super(context, attrs);
- TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PercentageBarChart, 0, 0);
-
- int emptyColor = Color.BLACK;
-
- int n = a.getIndexCount();
- for (int i = 0; i < n; i++) {
- int attr = a.getIndex(i);
-
- switch (attr) {
- case R.styleable.PercentageBarChart_emptyColor:
- emptyColor = a.getColor(attr, 0);
- break;
- }
- }
-
+ TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PercentageBarChart);
+ mMinTickWidth = a.getDimensionPixelSize(R.styleable.PercentageBarChart_minTickWidth, 1);
+ int emptyColor = a.getColor(R.styleable.PercentageBarChart_emptyColor, Color.BLACK);
a.recycle();
mEmptyPaint.setColor(emptyColor);
@@ -89,7 +79,7 @@ public class PercentageBarChart extends View {
if (e.percentage == 0f) {
entryWidth = 0;
} else {
- entryWidth = Math.max(1, (int) (width * e.percentage));
+ entryWidth = Math.max(mMinTickWidth, (int) (width * e.percentage));
}
final int nextX = lastX + entryWidth;