diff options
author | Jeff Sharkey <jsharkey@android.com> | 2011-08-04 21:17:23 -0700 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2011-08-04 21:20:03 -0700 |
commit | d39c6e4083f1212519d5dc14f64132a10f2b7c7a (patch) | |
tree | 1d6383be1b378204301ec20d2d7b957f9d23ed9d /src/com/android/settings/widget | |
parent | ce919e40c9def53dad0dfd541060147939024827 (diff) | |
download | packages_apps_settings-d39c6e4083f1212519d5dc14f64132a10f2b7c7a.zip packages_apps_settings-d39c6e4083f1212519d5dc14f64132a10f2b7c7a.tar.gz packages_apps_settings-d39c6e4083f1212519d5dc14f64132a10f2b7c7a.tar.bz2 |
Data usage app icons and details, chart labels.
Add app icons into both summary list and details pane. Also show list
of all applications merged under a UID. Draw dates on chart axis, and
avoid flashing policy sweeps when switching networks in detail mode.
Bug: 5087283, 5038812
Change-Id: I1dcd03ca85b517f8726452af8a46b4be9b3d20f1
Diffstat (limited to 'src/com/android/settings/widget')
-rw-r--r-- | src/com/android/settings/widget/ChartGridView.java | 56 | ||||
-rw-r--r-- | src/com/android/settings/widget/ChartSweepView.java | 1 | ||||
-rw-r--r-- | src/com/android/settings/widget/DataUsageChartView.java | 1 |
3 files changed, 54 insertions, 4 deletions
diff --git a/src/com/android/settings/widget/ChartGridView.java b/src/com/android/settings/widget/ChartGridView.java index 7a83fbf..c2702e4 100644 --- a/src/com/android/settings/widget/ChartGridView.java +++ b/src/com/android/settings/widget/ChartGridView.java @@ -17,12 +17,20 @@ package com.android.settings.widget; import android.content.Context; +import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; import android.graphics.drawable.Drawable; +import android.text.Layout; +import android.text.StaticLayout; +import android.text.TextPaint; import android.util.AttributeSet; +import android.util.TypedValue; import android.view.View; +import com.android.settings.DataUsageSummary; import com.android.settings.R; import com.google.common.base.Preconditions; @@ -32,14 +40,16 @@ import com.google.common.base.Preconditions; */ public class ChartGridView extends View { - // TODO: eventually teach about drawing chart labels - private ChartAxis mHoriz; private ChartAxis mVert; private Drawable mPrimary; private Drawable mSecondary; private Drawable mBorder; + private int mLabelColor; + + private Layout mLayoutStart; + private Layout mLayoutEnd; public ChartGridView(Context context) { this(context, null, 0); @@ -60,7 +70,7 @@ public class ChartGridView extends View { mPrimary = a.getDrawable(R.styleable.ChartGridView_primaryDrawable); mSecondary = a.getDrawable(R.styleable.ChartGridView_secondaryDrawable); mBorder = a.getDrawable(R.styleable.ChartGridView_borderDrawable); - // TODO: eventually read labelColor + mLabelColor = a.getColor(R.styleable.ChartGridView_labelColor, Color.RED); a.recycle(); } @@ -70,6 +80,13 @@ public class ChartGridView extends View { mVert = Preconditions.checkNotNull(vert, "missing vert"); } + void setBounds(long start, long end) { + final Context context = getContext(); + mLayoutStart = makeLayout(DataUsageSummary.formatDateRange(context, start, start, true)); + mLayoutEnd = makeLayout(DataUsageSummary.formatDateRange(context, end, end, true)); + invalidate(); + } + @Override protected void onDraw(Canvas canvas) { final int width = getWidth(); @@ -98,5 +115,38 @@ public class ChartGridView extends View { mBorder.setBounds(0, 0, width, height); mBorder.draw(canvas); + + final int padding = mLayoutStart.getHeight() / 8; + + final Layout start = mLayoutStart; + if (start != null) { + canvas.save(); + canvas.translate(0, height + padding); + start.draw(canvas); + canvas.restore(); + } + + final Layout end = mLayoutEnd; + if (end != null) { + canvas.save(); + canvas.translate(width - end.getWidth(), height + padding); + end.draw(canvas); + canvas.restore(); + } } + + private Layout makeLayout(CharSequence text) { + final Resources res = getResources(); + final TextPaint paint = new TextPaint(Paint.ANTI_ALIAS_FLAG); + paint.density = res.getDisplayMetrics().density; + paint.setCompatibilityScaling(res.getCompatibilityInfo().applicationScale); + paint.setColor(mLabelColor); + paint.setTextSize( + TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 10, res.getDisplayMetrics())); + + return new StaticLayout(text, paint, + (int) Math.ceil(Layout.getDesiredWidth(text, paint)), + Layout.Alignment.ALIGN_NORMAL, 1.f, 0, true); + } + } diff --git a/src/com/android/settings/widget/ChartSweepView.java b/src/com/android/settings/widget/ChartSweepView.java index b5e044f..d5e8de8 100644 --- a/src/com/android/settings/widget/ChartSweepView.java +++ b/src/com/android/settings/widget/ChartSweepView.java @@ -29,7 +29,6 @@ import android.text.Layout.Alignment; import android.text.SpannableStringBuilder; import android.text.TextPaint; import android.util.AttributeSet; -import android.util.Log; import android.util.MathUtils; import android.view.MotionEvent; import android.view.View; diff --git a/src/com/android/settings/widget/DataUsageChartView.java b/src/com/android/settings/widget/DataUsageChartView.java index b2ad844..a1c92e1 100644 --- a/src/com/android/settings/widget/DataUsageChartView.java +++ b/src/com/android/settings/widget/DataUsageChartView.java @@ -343,6 +343,7 @@ public class DataUsageChartView extends ChartView { */ public void setVisibleRange(long visibleStart, long visibleEnd) { mHoriz.setBounds(visibleStart, visibleEnd); + mGrid.setBounds(visibleStart, visibleEnd); final long validStart = Math.max(visibleStart, getStatsStart()); final long validEnd = Math.min(visibleEnd, getStatsEnd()); |