diff options
author | Jeff Sharkey <jsharkey@android.com> | 2011-09-02 16:10:24 -0700 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2011-09-02 16:15:25 -0700 |
commit | 28130d96385d7d7b17992b45fb5d124836d85880 (patch) | |
tree | f05e9eb5842250ac07a2153d843476272c4c6148 /src/com/android/settings/widget | |
parent | 4e658ba969830e8c9617dc8938271df1ed09aa44 (diff) | |
download | packages_apps_settings-28130d96385d7d7b17992b45fb5d124836d85880.zip packages_apps_settings-28130d96385d7d7b17992b45fb5d124836d85880.tar.gz packages_apps_settings-28130d96385d7d7b17992b45fb5d124836d85880.tar.bz2 |
Unify data/power layout, confirm disable, round.
Share consistent layout between data usage and battery usage. Show
confirmation dialog before disabling mobile data. Round warning/limit
sweep values to match displayed label. Suppress fade when switching
data usage tabs.
Bug: 5208510, 5058157, 5038589, 5252816
Change-Id: I3c76f3397445d2d3b173666a41672871df4c61af
Diffstat (limited to 'src/com/android/settings/widget')
4 files changed, 25 insertions, 11 deletions
diff --git a/src/com/android/settings/widget/ChartAxis.java b/src/com/android/settings/widget/ChartAxis.java index 4e0da1d..d3d499c 100644 --- a/src/com/android/settings/widget/ChartAxis.java +++ b/src/com/android/settings/widget/ChartAxis.java @@ -35,8 +35,11 @@ public interface ChartAxis { /** Convert screen point into raw value. */ public long convertToValue(float point); - /** Build label that describes given raw value. */ - public void buildLabel(Resources res, SpannableStringBuilder builder, long value); + /** + * Build label that describes given raw value. If the label is rounded for + * display, return the rounded value. + */ + public long buildLabel(Resources res, SpannableStringBuilder builder, long value); /** Return list of tick points for drawing a grid. */ public float[] getTickPoints(); diff --git a/src/com/android/settings/widget/ChartDataUsageView.java b/src/com/android/settings/widget/ChartDataUsageView.java index 9554368..cad2ed8 100644 --- a/src/com/android/settings/widget/ChartDataUsageView.java +++ b/src/com/android/settings/widget/ChartDataUsageView.java @@ -27,7 +27,6 @@ import android.text.SpannableStringBuilder; import android.text.TextUtils; import android.text.format.DateUtils; import android.util.AttributeSet; -import android.view.Gravity; import android.view.MotionEvent; import android.view.View; @@ -334,11 +333,11 @@ public class ChartDataUsageView extends ChartView { } public long getWarningBytes() { - return mSweepWarning.getValue(); + return mSweepWarning.getLabelValue(); } public long getLimitBytes() { - return mSweepLimit.getValue(); + return mSweepLimit.getLabelValue(); } private long getStatsStart() { @@ -433,9 +432,10 @@ public class ChartDataUsageView extends ChartView { } /** {@inheritDoc} */ - public void buildLabel(Resources res, SpannableStringBuilder builder, long value) { + public long buildLabel(Resources res, SpannableStringBuilder builder, long value) { // TODO: convert to better string builder.replace(0, builder.length(), Long.toString(value)); + return value; } /** {@inheritDoc} */ @@ -493,16 +493,19 @@ public class ChartDataUsageView extends ChartView { private static final Object sSpanUnit = new Object(); /** {@inheritDoc} */ - public void buildLabel(Resources res, SpannableStringBuilder builder, long value) { + public long buildLabel(Resources res, SpannableStringBuilder builder, long value) { - float result = value; final CharSequence unit; + float result = value; + long labelValue = 1; if (result <= 100 * MB_IN_BYTES) { unit = res.getText(com.android.internal.R.string.megabyteShort); result /= MB_IN_BYTES; + labelValue = MB_IN_BYTES; } else { unit = res.getText(com.android.internal.R.string.gigabyteShort); result /= GB_IN_BYTES; + labelValue = GB_IN_BYTES; } final CharSequence size; @@ -511,11 +514,14 @@ public class ChartDataUsageView extends ChartView { } else { size = String.format("%.0f", 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; } /** {@inheritDoc} */ diff --git a/src/com/android/settings/widget/ChartSweepView.java b/src/com/android/settings/widget/ChartSweepView.java index 0d91a76..33e90c8 100644 --- a/src/com/android/settings/widget/ChartSweepView.java +++ b/src/com/android/settings/widget/ChartSweepView.java @@ -67,6 +67,7 @@ public class ChartSweepView extends View { private ChartAxis mAxis; private long mValue; + private long mLabelValue; private long mValidAfter; private long mValidBefore; @@ -226,7 +227,7 @@ public class ChartSweepView extends View { private void invalidateLabel() { if (mLabelTemplate != null && mAxis != null) { - mAxis.buildLabel(getResources(), mLabelTemplate, mValue); + mLabelValue = mAxis.buildLabel(getResources(), mLabelTemplate, mValue); invalidate(); } } @@ -265,6 +266,10 @@ public class ChartSweepView extends View { return mValue; } + public long getLabelValue() { + return mLabelValue; + } + public float getPoint() { if (isEnabled()) { return mAxis.convertToPoint(mValue); diff --git a/src/com/android/settings/widget/InvertedChartAxis.java b/src/com/android/settings/widget/InvertedChartAxis.java index 96aec7b..7dcc78a 100644 --- a/src/com/android/settings/widget/InvertedChartAxis.java +++ b/src/com/android/settings/widget/InvertedChartAxis.java @@ -52,8 +52,8 @@ public class InvertedChartAxis implements ChartAxis { } /** {@inheritDoc} */ - public void buildLabel(Resources res, SpannableStringBuilder builder, long value) { - mWrapped.buildLabel(res, builder, value); + public long buildLabel(Resources res, SpannableStringBuilder builder, long value) { + return mWrapped.buildLabel(res, builder, value); } /** {@inheritDoc} */ |