diff options
author | Jeff Sharkey <jsharkey@android.com> | 2011-11-10 17:17:24 -0800 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2011-11-10 17:17:24 -0800 |
commit | bdf98e84ab1eeedf9662ed3c08dc917f5fa80f85 (patch) | |
tree | 5af55c77225512268a42915ddaf2bd9a328b317b /src/com/android/settings/widget | |
parent | ffc1214ccbd04655a435573f36d550c5c66d78de (diff) | |
download | packages_apps_settings-bdf98e84ab1eeedf9662ed3c08dc917f5fa80f85.zip packages_apps_settings-bdf98e84ab1eeedf9662ed3c08dc917f5fa80f85.tar.gz packages_apps_settings-bdf98e84ab1eeedf9662ed3c08dc917f5fa80f85.tar.bz2 |
Data usage label width, locking, Wi-Fi fixes.
Avoid wrapping sweep labels when underlying string is long, and avoid
showing blank "^1" sweep labels. Only offer "restrict data" when
mobile networks are present. Add locking around UidDetailProvider.
Move to isNetworkSupported() for consistency.
Bug: 5492495, 5471602, 5439402, 5373465
Change-Id: I79f5938d45ffbb4c2c242106424a466042a26c1c
Diffstat (limited to 'src/com/android/settings/widget')
-rw-r--r-- | src/com/android/settings/widget/ChartSweepView.java | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/src/com/android/settings/widget/ChartSweepView.java b/src/com/android/settings/widget/ChartSweepView.java index c5f2aba..68676d8 100644 --- a/src/com/android/settings/widget/ChartSweepView.java +++ b/src/com/android/settings/widget/ChartSweepView.java @@ -26,6 +26,7 @@ import android.graphics.Point; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.text.DynamicLayout; +import android.text.Layout; import android.text.Layout.Alignment; import android.text.SpannableStringBuilder; import android.text.TextPaint; @@ -60,7 +61,9 @@ public class ChartSweepView extends View { private int mFollowAxis; - private int mLabelSize; + private int mLabelMinSize; + private float mLabelSize; + private int mLabelTemplateRes; private int mLabelColor; @@ -89,6 +92,8 @@ public class ChartSweepView extends View { private static final int MODE_DRAG = 1; private static final int MODE_LABEL = 2; + private static final int LARGE_WIDTH = 1024; + private long mDragInterval = 1; public interface OnSweepListener { @@ -121,7 +126,7 @@ public class ChartSweepView extends View { setFollowAxis(a.getInt(R.styleable.ChartSweepView_followAxis, -1)); setNeighborMargin(a.getDimensionPixelSize(R.styleable.ChartSweepView_neighborMargin, 0)); - setLabelSize(a.getDimensionPixelSize(R.styleable.ChartSweepView_labelSize, 0)); + setLabelMinSize(a.getDimensionPixelSize(R.styleable.ChartSweepView_labelSize, 0)); setLabelTemplate(a.getResourceId(R.styleable.ChartSweepView_labelTemplate, 0)); setLabelColor(a.getColor(R.styleable.ChartSweepView_labelColor, Color.BLUE)); @@ -231,8 +236,8 @@ public class ChartSweepView extends View { mFollowAxis = followAxis; } - public void setLabelSize(int size) { - mLabelSize = size; + public void setLabelMinSize(int minSize) { + mLabelMinSize = minSize; invalidateLabelTemplate(); } @@ -258,7 +263,7 @@ public class ChartSweepView extends View { mLabelTemplate = new SpannableStringBuilder(template); mLabelLayout = new DynamicLayout( - mLabelTemplate, paint, mLabelSize, Alignment.ALIGN_RIGHT, 1f, 0f, false); + mLabelTemplate, paint, LARGE_WIDTH, Alignment.ALIGN_RIGHT, 1f, 0f, false); invalidateLabel(); } else { @@ -289,20 +294,26 @@ public class ChartSweepView extends View { float labelOffset = 0; if (mFollowAxis == VERTICAL) { if (mValidAfterDynamic != null) { + mLabelSize = Math.max(getLabelWidth(this), getLabelWidth(mValidAfterDynamic)); margin = getLabelTop(mValidAfterDynamic) - getLabelBottom(this); if (margin < 0) { labelOffset = margin / 2; } } else if (mValidBeforeDynamic != null) { + mLabelSize = Math.max(getLabelWidth(this), getLabelWidth(mValidBeforeDynamic)); margin = getLabelTop(this) - getLabelBottom(mValidBeforeDynamic); if (margin < 0) { labelOffset = -margin / 2; } + } else { + mLabelSize = getLabelWidth(this); } } else { // TODO: implement horizontal labels } + mLabelSize = Math.max(mLabelSize, mLabelMinSize); + // when offsetting label, neighbor probably needs to offset too if (labelOffset != mLabelOffset) { mLabelOffset = labelOffset; @@ -692,11 +703,13 @@ public class ChartSweepView extends View { if (isEnabled() && mLabelLayout != null) { final int count = canvas.save(); { - canvas.translate(mContentOffset.left, mContentOffset.top + mLabelOffset); + final float alignOffset = mLabelSize - LARGE_WIDTH; + canvas.translate( + mContentOffset.left + alignOffset, mContentOffset.top + mLabelOffset); mLabelLayout.draw(canvas); } canvas.restoreToCount(count); - labelSize = mLabelSize; + labelSize = (int) mLabelSize; } else { labelSize = 0; } @@ -724,4 +737,8 @@ public class ChartSweepView extends View { public static float getLabelBottom(ChartSweepView view) { return getLabelTop(view) + view.mLabelLayout.getHeight(); } + + public static float getLabelWidth(ChartSweepView view) { + return Layout.getDesiredWidth(view.mLabelLayout.getText(), view.mLabelLayout.getPaint()); + } } |