diff options
author | Dianne Hackborn <hackbod@google.com> | 2010-06-21 14:42:49 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2010-06-21 14:42:49 -0700 |
commit | b9b7e5c863c9dda33cacc9978ee8c98b6b395d60 (patch) | |
tree | 60724fd2ff8fba42a74ebb7649ac9fccf4204cde | |
parent | 2f92074b4a4878f572be9cd39231654e1ee9003c (diff) | |
download | packages_apps_Settings-b9b7e5c863c9dda33cacc9978ee8c98b6b395d60.zip packages_apps_Settings-b9b7e5c863c9dda33cacc9978ee8c98b6b395d60.tar.gz packages_apps_Settings-b9b7e5c863c9dda33cacc9978ee8c98b6b395d60.tar.bz2 |
Small improvements to bettery level graphing.
Deal with data that doesn't start with updates; don't try to
make lines horizontal (a battery doesn't change is a battery
that is dead!).
Change-Id: I10a7938a04cc5ed5e92a55857851d8d70b64c3b6
-rw-r--r-- | src/com/android/settings/fuelgauge/BatteryHistoryChart.java | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/src/com/android/settings/fuelgauge/BatteryHistoryChart.java b/src/com/android/settings/fuelgauge/BatteryHistoryChart.java index fabbf39..e4a3537 100644 --- a/src/com/android/settings/fuelgauge/BatteryHistoryChart.java +++ b/src/com/android/settings/fuelgauge/BatteryHistoryChart.java @@ -58,6 +58,7 @@ public class BatteryHistoryChart extends View { int mDurationStringWidth; int mNumHist; + BatteryStats.HistoryItem mHistFirst; long mHistStart; long mHistEnd; int mBatLow; @@ -230,10 +231,7 @@ public class BatteryHistoryChart extends View { durationString); BatteryStats.HistoryItem rec = stats.getHistory(); - if (rec != null) { - mHistStart = rec.time; - mBatLow = mBatHigh = rec.batteryLevel; - } + mHistFirst = null; int pos = 0; int lastInteresting = 0; byte lastLevel = -1; @@ -241,11 +239,16 @@ public class BatteryHistoryChart extends View { mBatHigh = 100; while (rec != null) { pos++; - if (rec.cmd == HistoryItem.CMD_UPDATE && (rec.batteryLevel != lastLevel - || pos == 1)) { - lastLevel = rec.batteryLevel; - lastInteresting = pos; - mHistEnd = rec.time; + if (rec.cmd == HistoryItem.CMD_UPDATE) { + if (mHistFirst == null) { + mHistFirst = rec; + mHistStart = rec.time; + } + if (rec.batteryLevel != lastLevel || pos == 1) { + lastLevel = rec.batteryLevel; + lastInteresting = pos; + mHistEnd = rec.time; + } } rec = rec.next; } @@ -278,7 +281,7 @@ public class BatteryHistoryChart extends View { final int batLow = mBatLow; final int batChange = mBatHigh-mBatLow; - BatteryStats.HistoryItem rec = mStats.getHistory(); + BatteryStats.HistoryItem rec = mHistFirst; int x = 0, y = 0, lastX = -1, lastY = -1, lastBatX = -1, lastBatY = -1; byte lastBatValue = 0; int i = 0, num = 0; @@ -306,15 +309,6 @@ public class BatteryHistoryChart extends View { lastBatX = x; lastBatY = y; } else { - if (lastBatX >= 0) { - // Level stayed the same up to here; put in line. - mBatLevelPath.lineTo(lastBatX, lastBatY); - mBatLevelX[mNumBatLevel] = lastBatX; - mBatLevelY[mNumBatLevel] = lastBatY; - mBatLevelValue[mNumBatLevel] = lastBatValue; - mNumBatLevel++; - num++; - } mBatLevelPath.lineTo(x, y); mBatLevelX[mNumBatLevel] = x; mBatLevelY[mNumBatLevel] = y; |