Larger touch targets, snap to persisted value.

Extend ListView content to screen edges, and use InsetBoundsDrawable
to draw separator and divider with expected padding.  Sweep touch
targets are now much larger.

Snap sweep to persisted value, and fix NFE when parsing label value.

Bug: 5274249
Bug: 5262865
Bug: 5242857
Change-Id: Ifa0f3e622767d5b4dc85a73d6340207e6038a429
This commit is contained in:
Jeff Sharkey
2011-09-08 18:57:17 -07:00
parent 9b9db3f966
commit 5d70679c02
12 changed files with 305 additions and 35 deletions

View File

@@ -496,32 +496,32 @@ public class ChartDataUsageView extends ChartView {
public long buildLabel(Resources res, SpannableStringBuilder builder, long value) {
final CharSequence unit;
float result = value;
long labelValue = 1;
if (result <= 100 * MB_IN_BYTES) {
final long unitFactor;
if (value <= 100 * MB_IN_BYTES) {
unit = res.getText(com.android.internal.R.string.megabyteShort);
result /= MB_IN_BYTES;
labelValue = MB_IN_BYTES;
unitFactor = MB_IN_BYTES;
} else {
unit = res.getText(com.android.internal.R.string.gigabyteShort);
result /= GB_IN_BYTES;
labelValue = GB_IN_BYTES;
unitFactor = GB_IN_BYTES;
}
final double result = (double) value / unitFactor;
final double resultRounded;
final CharSequence size;
if (result < 10) {
size = String.format("%.1f", result);
resultRounded = (unitFactor * Math.round(result * 10)) / 10;
} else {
size = String.format("%.0f", result);
resultRounded = unitFactor * Math.round(result);
}
labelValue *= Float.parseFloat(size.toString());
final int[] sizeBounds = findOrCreateSpan(builder, sSpanSize, "^1");
builder.replace(sizeBounds[0], sizeBounds[1], size);
final int[] unitBounds = findOrCreateSpan(builder, sSpanUnit, "^2");
builder.replace(unitBounds[0], unitBounds[1], unit);
return labelValue;
return (long) resultRounded;
}
/** {@inheritDoc} */