diff options
author | Jeff Sharkey <jsharkey@android.com> | 2011-06-24 17:30:27 -0700 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2011-06-24 23:11:51 -0700 |
commit | 2af35fb44d385d7a04ea1b421c426a0350f0e896 (patch) | |
tree | 4acce87be36aa48385c209c5975bff757fd18f13 /src/com/android/settings/widget | |
parent | f54f435f1f3215b39798c671fc64344d1867de4e (diff) | |
download | packages_apps_Settings-2af35fb44d385d7a04ea1b421c426a0350f0e896.tar.gz packages_apps_Settings-2af35fb44d385d7a04ea1b421c426a0350f0e896.tar.bz2 packages_apps_Settings-2af35fb44d385d7a04ea1b421c426a0350f0e896.zip |
Fix animation bugs, stop disabled sweep touches.
Change sweep drawables to crossfade correctly between states, and
work around 4946591 by nesting container one level deeper. Also wait
until first layout pass is finished before applying LayoutTransition.
Prevent touches from reaching sweeps when chart is disabled. Also
bring back log scale for data.
Change-Id: I2194714ab075fd32525681119f30427c1b96fc50
Diffstat (limited to 'src/com/android/settings/widget')
-rw-r--r-- | src/com/android/settings/widget/ChartSweepView.java | 7 | ||||
-rw-r--r-- | src/com/android/settings/widget/ChartView.java | 2 | ||||
-rw-r--r-- | src/com/android/settings/widget/DataUsageChartView.java | 52 |
3 files changed, 31 insertions, 30 deletions
diff --git a/src/com/android/settings/widget/ChartSweepView.java b/src/com/android/settings/widget/ChartSweepView.java index d8344d52f..6c9ded4ed 100644 --- a/src/com/android/settings/widget/ChartSweepView.java +++ b/src/com/android/settings/widget/ChartSweepView.java @@ -188,7 +188,12 @@ public class ChartSweepView extends FrameLayout { } public float getPoint() { - return mAxis.convertToPoint(mValue); + if (isEnabled()) { + return mAxis.convertToPoint(mValue); + } else { + // when disabled, show along top edge + return 0; + } } @Override diff --git a/src/com/android/settings/widget/ChartView.java b/src/com/android/settings/widget/ChartView.java index bf5616db5..9223ca6d2 100644 --- a/src/com/android/settings/widget/ChartView.java +++ b/src/com/android/settings/widget/ChartView.java @@ -21,6 +21,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import android.content.Context; import android.graphics.Rect; import android.util.AttributeSet; +import android.util.Log; import android.view.Gravity; import android.view.View; import android.widget.FrameLayout; @@ -93,7 +94,6 @@ public class ChartView extends FrameLayout { // sweep is always placed along specific dimension final ChartSweepView sweep = (ChartSweepView) child; final Rect sweepMargins = sweep.getSweepMargins(); - final float point = sweep.getPoint(); if (sweep.getFollowAxis() == ChartSweepView.HORIZONTAL) { parentRect.left = parentRect.right = diff --git a/src/com/android/settings/widget/DataUsageChartView.java b/src/com/android/settings/widget/DataUsageChartView.java index 6fe40425a..a8bdaa6f8 100644 --- a/src/com/android/settings/widget/DataUsageChartView.java +++ b/src/com/android/settings/widget/DataUsageChartView.java @@ -129,9 +129,7 @@ public class DataUsageChartView extends ChartView { mSweepLimit.setValue(policy.limitBytes); mSweepLimit.setEnabled(true); } else { - // TODO: set limit default based on axis maximum mSweepLimit.setVisibility(View.VISIBLE); - mSweepLimit.setValue(5 * GB_IN_BYTES); mSweepLimit.setEnabled(false); } @@ -189,6 +187,15 @@ public class DataUsageChartView extends ChartView { } } + @Override + public boolean onInterceptTouchEvent(MotionEvent ev) { + if (!isActivated()) { + return true; + } else { + return super.onInterceptTouchEvent(ev); + } + } + /** * Return current inspection range (start and end time) based on internal * {@link ChartSweepView} positions. @@ -302,56 +309,45 @@ public class DataUsageChartView extends ChartView { public static class DataAxis implements ChartAxis { private long mMin; private long mMax; - private long mMinLog; - private long mMaxLog; private float mSize; public DataAxis() { // TODO: adapt ranges to show when history >5GB, and handle 4G // interfaces with higher limits. - setBounds(1 * MB_IN_BYTES, 5 * GB_IN_BYTES); + setBounds(0, 5 * GB_IN_BYTES); } /** {@inheritDoc} */ public void setBounds(long min, long max) { mMin = min; mMax = max; - mMinLog = (long) Math.log(mMin); - mMaxLog = (long) Math.log(mMax); } /** {@inheritDoc} */ public void setSize(float size) { - this.mSize = size; + mSize = size; } /** {@inheritDoc} */ public float convertToPoint(long value) { - return (mSize * (value - mMin)) / (mMax - mMin); - - // TODO: finish tweaking log scale -// if (value > mMin) { -// return (float) ((mSize * (Math.log(value) - mMinLog)) / (mMaxLog - mMinLog)); -// } else { -// return 0; -// } + // TODO: this assumes range of [0,5]GB + final double fraction = Math.pow( + 10, 0.36884343106175160321 * Math.log10(value) + -3.62828151137812282556); + return (float) fraction * mSize; } /** {@inheritDoc} */ public long convertToValue(float point) { - return (long) (mMin + ((point * (mMax - mMin)) / mSize)); - - // TODO: finish tweaking log scale -// return (long) Math.pow(Math.E, (mMinLog + ((point * (mMaxLog - mMinLog)) / mSize))); + final double y = point / mSize; + // TODO: this assumes range of [0,5]GB + final double fraction = 6.869341163271789302 * Math.pow(10, 9) + * Math.pow(y, 2.71117746931646030774); + return (long) fraction; } /** {@inheritDoc} */ public CharSequence getLabel(long value) { - // TODO: use exploded string here - - - // TODO: convert to string return Long.toString(value); } @@ -365,13 +361,13 @@ public class DataUsageChartView extends ChartView { public float[] getTickPoints() { final float[] tickPoints = new float[16]; - long value = mMax; - float mult = 0.8f; + final long jump = ((mMax - mMin) / tickPoints.length); + long value = mMin; for (int i = 0; i < tickPoints.length; i++) { tickPoints[i] = convertToPoint(value); - value = (long) (value * mult); - mult *= 0.9; + value += jump; } + return tickPoints; } } |