Data usage: precise editing, restrict help, D-pad.
Introduce dialogs for precise editing of network policy warning/limit values, triggered by click on sweep labels. Show up to 999MB before rounding to GB, and round to nearest 5MB value when dragging. Partial D-pad navigation around chart controls. Fix jumping when relayout during drag, and fix sweep overlap bug. When restricting data without limited networks, show dialog help to guide user towards network limit. When reloading chart data, try restoring to nearest cycle. Bug: 5289641, 5111701, 5226078 Change-Id: Ic59dee6496c480a64dc56f8534acf4d81b50bca7
This commit is contained in:
@@ -69,6 +69,8 @@ public class ChartDataUsageView extends ChartView {
|
||||
public void onInspectRangeChanged();
|
||||
public void onWarningChanged();
|
||||
public void onLimitChanged();
|
||||
public void requestWarningEdit();
|
||||
public void requestLimitEdit();
|
||||
}
|
||||
|
||||
private DataUsageChartListener mListener;
|
||||
@@ -123,6 +125,15 @@ public class ChartDataUsageView extends ChartView {
|
||||
mSweepWarning.addOnSweepListener(mVertListener);
|
||||
mSweepLimit.addOnSweepListener(mVertListener);
|
||||
|
||||
mSweepWarning.setDragInterval(5 * MB_IN_BYTES);
|
||||
mSweepLimit.setDragInterval(5 * MB_IN_BYTES);
|
||||
|
||||
// TODO: make time sweeps adjustable through dpad
|
||||
mSweepLeft.setClickable(false);
|
||||
mSweepLeft.setFocusable(false);
|
||||
mSweepRight.setClickable(false);
|
||||
mSweepRight.setFocusable(false);
|
||||
|
||||
// tell everyone about our axis
|
||||
mGrid.init(mHoriz, mVert);
|
||||
mSeries.init(mHoriz, mVert);
|
||||
@@ -276,6 +287,7 @@ public class ChartDataUsageView extends ChartView {
|
||||
}
|
||||
|
||||
private OnSweepListener mHorizListener = new OnSweepListener() {
|
||||
/** {@inheritDoc} */
|
||||
public void onSweep(ChartSweepView sweep, boolean sweepDone) {
|
||||
updatePrimaryRange();
|
||||
|
||||
@@ -284,6 +296,11 @@ public class ChartDataUsageView extends ChartView {
|
||||
mListener.onInspectRangeChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void requestEdit(ChartSweepView sweep) {
|
||||
// ignored
|
||||
}
|
||||
};
|
||||
|
||||
private void sendUpdateAxisDelayed(ChartSweepView sweep, boolean force) {
|
||||
@@ -298,6 +315,7 @@ public class ChartDataUsageView extends ChartView {
|
||||
}
|
||||
|
||||
private OnSweepListener mVertListener = new OnSweepListener() {
|
||||
/** {@inheritDoc} */
|
||||
public void onSweep(ChartSweepView sweep, boolean sweepDone) {
|
||||
if (sweepDone) {
|
||||
clearUpdateAxisDelayed(sweep);
|
||||
@@ -313,6 +331,15 @@ public class ChartDataUsageView extends ChartView {
|
||||
sendUpdateAxisDelayed(sweep, false);
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void requestEdit(ChartSweepView sweep) {
|
||||
if (sweep == mSweepWarning && mListener != null) {
|
||||
mListener.requestWarningEdit();
|
||||
} else if (sweep == mSweepLimit && mListener != null) {
|
||||
mListener.requestLimitEdit();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
@@ -540,7 +567,7 @@ public class ChartDataUsageView extends ChartView {
|
||||
|
||||
final CharSequence unit;
|
||||
final long unitFactor;
|
||||
if (value <= 100 * MB_IN_BYTES) {
|
||||
if (value < 1000 * MB_IN_BYTES) {
|
||||
unit = res.getText(com.android.internal.R.string.megabyteShort);
|
||||
unitFactor = MB_IN_BYTES;
|
||||
} else {
|
||||
@@ -551,6 +578,7 @@ public class ChartDataUsageView extends ChartView {
|
||||
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;
|
||||
|
Reference in New Issue
Block a user