Merge commit '0bd7082ef809de2aec50fc347ee0974dbc52d764' * commit '0bd7082ef809de2aec50fc347ee0974dbc52d764': Small improvements to bettery level graphing.
This commit is contained in:
@@ -58,6 +58,7 @@ public class BatteryHistoryChart extends View {
|
|||||||
int mDurationStringWidth;
|
int mDurationStringWidth;
|
||||||
|
|
||||||
int mNumHist;
|
int mNumHist;
|
||||||
|
BatteryStats.HistoryItem mHistFirst;
|
||||||
long mHistStart;
|
long mHistStart;
|
||||||
long mHistEnd;
|
long mHistEnd;
|
||||||
int mBatLow;
|
int mBatLow;
|
||||||
@@ -230,10 +231,7 @@ public class BatteryHistoryChart extends View {
|
|||||||
durationString);
|
durationString);
|
||||||
|
|
||||||
BatteryStats.HistoryItem rec = stats.getHistory();
|
BatteryStats.HistoryItem rec = stats.getHistory();
|
||||||
if (rec != null) {
|
mHistFirst = null;
|
||||||
mHistStart = rec.time;
|
|
||||||
mBatLow = mBatHigh = rec.batteryLevel;
|
|
||||||
}
|
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
int lastInteresting = 0;
|
int lastInteresting = 0;
|
||||||
byte lastLevel = -1;
|
byte lastLevel = -1;
|
||||||
@@ -241,11 +239,16 @@ public class BatteryHistoryChart extends View {
|
|||||||
mBatHigh = 100;
|
mBatHigh = 100;
|
||||||
while (rec != null) {
|
while (rec != null) {
|
||||||
pos++;
|
pos++;
|
||||||
if (rec.cmd == HistoryItem.CMD_UPDATE && (rec.batteryLevel != lastLevel
|
if (rec.cmd == HistoryItem.CMD_UPDATE) {
|
||||||
|| pos == 1)) {
|
if (mHistFirst == null) {
|
||||||
lastLevel = rec.batteryLevel;
|
mHistFirst = rec;
|
||||||
lastInteresting = pos;
|
mHistStart = rec.time;
|
||||||
mHistEnd = rec.time;
|
}
|
||||||
|
if (rec.batteryLevel != lastLevel || pos == 1) {
|
||||||
|
lastLevel = rec.batteryLevel;
|
||||||
|
lastInteresting = pos;
|
||||||
|
mHistEnd = rec.time;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
rec = rec.next;
|
rec = rec.next;
|
||||||
}
|
}
|
||||||
@@ -278,7 +281,7 @@ public class BatteryHistoryChart extends View {
|
|||||||
final int batLow = mBatLow;
|
final int batLow = mBatLow;
|
||||||
final int batChange = mBatHigh-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;
|
int x = 0, y = 0, lastX = -1, lastY = -1, lastBatX = -1, lastBatY = -1;
|
||||||
byte lastBatValue = 0;
|
byte lastBatValue = 0;
|
||||||
int i = 0, num = 0;
|
int i = 0, num = 0;
|
||||||
@@ -306,15 +309,6 @@ public class BatteryHistoryChart extends View {
|
|||||||
lastBatX = x;
|
lastBatX = x;
|
||||||
lastBatY = y;
|
lastBatY = y;
|
||||||
} else {
|
} 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);
|
mBatLevelPath.lineTo(x, y);
|
||||||
mBatLevelX[mNumBatLevel] = x;
|
mBatLevelX[mNumBatLevel] = x;
|
||||||
mBatLevelY[mNumBatLevel] = y;
|
mBatLevelY[mNumBatLevel] = y;
|
||||||
|
Reference in New Issue
Block a user