Foreground/background network stats pie chart.

Load foreground/background network stats, showing combined in chart
series, and also separated in pie chart.  Padding to match spec,
updated action bar tabs, and limit width for wide devices.  Also
clear UI options for requesting fragments.  Move to action bar
overflow menu instead of custom icon.  Show detail chart data outside
current inspection range.

Bug: 5106163, 5143670, 5163064, 5162671, 5148713, 5129036, 5096626
Change-Id: I548fef209e1f714f70ee6bf7098dbdb881692df4
This commit is contained in:
Jeff Sharkey
2011-08-11 18:26:57 -07:00
parent 57f947342c
commit 54d0af57fd
20 changed files with 453 additions and 149 deletions

View File

@@ -19,12 +19,16 @@ package com.android.settings.widget;
import static com.google.common.base.Preconditions.checkNotNull;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
import android.view.ViewDebug;
import android.widget.FrameLayout;
import com.android.settings.R;
/**
* Container for two-dimensional chart, drawn with a combination of
* {@link ChartGridView}, {@link ChartNetworkSeriesView} and {@link ChartSweepView}
@@ -41,6 +45,10 @@ public class ChartView extends FrameLayout {
ChartAxis mHoriz;
ChartAxis mVert;
@ViewDebug.ExportedProperty
private int mOptimalWidth = -1;
private float mOptimalWidthWeight = 0;
private Rect mContent = new Rect();
public ChartView(Context context) {
@@ -54,6 +62,12 @@ public class ChartView extends FrameLayout {
public ChartView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
final TypedArray a = context.obtainStyledAttributes(
attrs, R.styleable.ChartView, defStyle, 0);
setOptimalWidth(a.getDimensionPixelSize(R.styleable.ChartView_optimalWidth, -1),
a.getFloat(R.styleable.ChartView_optimalWidthWeight, 0));
a.recycle();
setClipToPadding(false);
setClipChildren(false);
}
@@ -63,6 +77,24 @@ public class ChartView extends FrameLayout {
mVert = checkNotNull(vert, "missing vert");
}
public void setOptimalWidth(int optimalWidth, float optimalWidthWeight) {
mOptimalWidth = optimalWidth;
mOptimalWidthWeight = optimalWidthWeight;
requestLayout();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
final int slack = getMeasuredWidth() - mOptimalWidth;
if (mOptimalWidth > 0 && slack > 0) {
final int targetWidth = (int) (mOptimalWidth + (slack * mOptimalWidthWeight));
widthMeasureSpec = MeasureSpec.makeMeasureSpec(targetWidth, MeasureSpec.EXACTLY);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
mContent.set(getPaddingLeft(), getPaddingTop(), r - l - getPaddingRight(),