diff options
author | Jeff Sharkey <jsharkey@android.com> | 2012-02-03 19:27:07 -0800 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2012-02-03 19:29:15 -0800 |
commit | f3871fb2b232cd22469ccc66415f82de4995894e (patch) | |
tree | 184610c723161ad9fe829b559d41363ca0e42a35 /src | |
parent | 47e1c0bd47796fcd2b15423ba64e68a4df6e00a8 (diff) | |
download | packages_apps_settings-f3871fb2b232cd22469ccc66415f82de4995894e.zip packages_apps_settings-f3871fb2b232cd22469ccc66415f82de4995894e.tar.gz packages_apps_settings-f3871fb2b232cd22469ccc66415f82de4995894e.tar.bz2 |
Linear bytes scale, time ticks on first week day.
Move bytes to linear instead of logarithmic scale. Also render time
ticks on first week day based on locale. Also enable testing of
specific IMSI through setprop.
Bug: 5452612, 5829693
Change-Id: I13200cf58a39bfe0ac343e1f83165e899867641b
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/settings/DataUsageSummary.java | 5 | ||||
-rw-r--r-- | src/com/android/settings/widget/ChartDataUsageView.java | 60 |
2 files changed, 48 insertions, 17 deletions
diff --git a/src/com/android/settings/DataUsageSummary.java b/src/com/android/settings/DataUsageSummary.java index ce8f291..b06dc28 100644 --- a/src/com/android/settings/DataUsageSummary.java +++ b/src/com/android/settings/DataUsageSummary.java @@ -151,7 +151,9 @@ public class DataUsageSummary extends Fragment { // TODO: remove this testing code private static final boolean TEST_ANIM = false; private static final boolean TEST_RADIOS = false; + private static final String TEST_RADIOS_PROP = "test.radios"; + private static final String TEST_SUBSCRIBER_PROP = "test.subscriberid"; private static final String TAB_3G = "3g"; private static final String TAB_4G = "4g"; @@ -1217,7 +1219,8 @@ public class DataUsageSummary extends Fragment { private static String getActiveSubscriberId(Context context) { final TelephonyManager telephony = (TelephonyManager) context.getSystemService( Context.TELEPHONY_SERVICE); - return telephony.getSubscriberId(); + final String actualSubscriberId = telephony.getSubscriberId(); + return SystemProperties.get(TEST_SUBSCRIBER_PROP, actualSubscriberId); } private DataUsageChartListener mChartListener = new DataUsageChartListener() { diff --git a/src/com/android/settings/widget/ChartDataUsageView.java b/src/com/android/settings/widget/ChartDataUsageView.java index 28fbd00..4b4f37d 100644 --- a/src/com/android/settings/widget/ChartDataUsageView.java +++ b/src/com/android/settings/widget/ChartDataUsageView.java @@ -29,6 +29,7 @@ import android.text.Spannable; import android.text.SpannableStringBuilder; import android.text.TextUtils; import android.text.format.DateUtils; +import android.text.format.Time; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View; @@ -37,6 +38,9 @@ import com.android.internal.util.Objects; import com.android.settings.R; import com.android.settings.widget.ChartSweepView.OnSweepListener; +import java.util.Arrays; +import java.util.Calendar; + /** * Specific {@link ChartView} that displays {@link ChartNetworkSeriesView} along * with {@link ChartSweepView} for inspection ranges and warning/limits. @@ -449,7 +453,7 @@ public class ChartDataUsageView extends ChartView { } public static class TimeAxis implements ChartAxis { - private static final long TICK_INTERVAL = DateUtils.DAY_IN_MILLIS * 7; + private static final int FIRST_DAY_OF_WEEK = Calendar.getInstance().getFirstDayOfWeek() - 1; private long mMin; private long mMax; @@ -505,13 +509,27 @@ public class ChartDataUsageView extends ChartView { /** {@inheritDoc} */ public float[] getTickPoints() { - // tick mark for every week - final int tickCount = (int) ((mMax - mMin) / TICK_INTERVAL); - final float[] tickPoints = new float[tickCount]; - for (int i = 0; i < tickCount; i++) { - tickPoints[i] = convertToPoint(mMax - (TICK_INTERVAL * (i + 1))); + final float[] ticks = new float[32]; + int i = 0; + + // tick mark for first day of each week + final Time time = new Time(); + time.set(mMax); + time.monthDay -= time.weekDay - FIRST_DAY_OF_WEEK; + time.hour = time.minute = time.second = 0; + + time.normalize(true); + long timeMillis = time.toMillis(true); + while (timeMillis > mMin) { + if (timeMillis <= mMax) { + ticks[i++] = convertToPoint(timeMillis); + } + time.monthDay -= 7; + time.normalize(true); + timeMillis = time.toMillis(true); } - return tickPoints; + + return Arrays.copyOf(ticks, i); } /** {@inheritDoc} */ @@ -526,6 +544,8 @@ public class ChartDataUsageView extends ChartView { private long mMax; private float mSize; + private static final boolean LOG_SCALE = false; + @Override public int hashCode() { return Objects.hashCode(mMin, mMax, mSize); @@ -554,19 +574,27 @@ public class ChartDataUsageView extends ChartView { /** {@inheritDoc} */ public float convertToPoint(long value) { - // derived polynomial fit to make lower values more visible - final double normalized = ((double) value - mMin) / (mMax - mMin); - final double fraction = Math.pow( - 10, 0.36884343106175121463 * Math.log10(normalized) + -0.04328199452018252624); - return (float) (fraction * mSize); + if (LOG_SCALE) { + // derived polynomial fit to make lower values more visible + final double normalized = ((double) value - mMin) / (mMax - mMin); + final double fraction = Math.pow(10, + 0.36884343106175121463 * Math.log10(normalized) + -0.04328199452018252624); + return (float) (fraction * mSize); + } else { + return (mSize * (value - mMin)) / (mMax - mMin); + } } /** {@inheritDoc} */ public long convertToValue(float point) { - final double normalized = point / mSize; - final double fraction = 1.3102228476089056629 - * Math.pow(normalized, 2.7111774693164631640); - return (long) (mMin + (fraction * (mMax - mMin))); + if (LOG_SCALE) { + final double normalized = point / mSize; + final double fraction = 1.3102228476089056629 + * Math.pow(normalized, 2.7111774693164631640); + return (long) (mMin + (fraction * (mMax - mMin))); + } else { + return (long) (mMin + ((point * (mMax - mMin)) / mSize)); + } } private static final Object sSpanSize = new Object(); |