Merge "Data usage label width, locking, Wi-Fi fixes." into ics-mr1
This commit is contained in:
@@ -18,6 +18,7 @@ package com.android.settings;
|
|||||||
|
|
||||||
import static android.net.ConnectivityManager.TYPE_ETHERNET;
|
import static android.net.ConnectivityManager.TYPE_ETHERNET;
|
||||||
import static android.net.ConnectivityManager.TYPE_MOBILE;
|
import static android.net.ConnectivityManager.TYPE_MOBILE;
|
||||||
|
import static android.net.ConnectivityManager.TYPE_WIFI;
|
||||||
import static android.net.ConnectivityManager.TYPE_WIMAX;
|
import static android.net.ConnectivityManager.TYPE_WIMAX;
|
||||||
import static android.net.NetworkPolicy.LIMIT_DISABLED;
|
import static android.net.NetworkPolicy.LIMIT_DISABLED;
|
||||||
import static android.net.NetworkPolicy.WARNING_DISABLED;
|
import static android.net.NetworkPolicy.WARNING_DISABLED;
|
||||||
@@ -143,7 +144,7 @@ import libcore.util.Objects;
|
|||||||
*/
|
*/
|
||||||
public class DataUsageSummary extends Fragment {
|
public class DataUsageSummary extends Fragment {
|
||||||
private static final String TAG = "DataUsage";
|
private static final String TAG = "DataUsage";
|
||||||
private static final boolean LOGD = true;
|
private static final boolean LOGD = false;
|
||||||
|
|
||||||
// TODO: remove this testing code
|
// TODO: remove this testing code
|
||||||
private static final boolean TEST_ANIM = false;
|
private static final boolean TEST_ANIM = false;
|
||||||
@@ -343,6 +344,7 @@ public class DataUsageSummary extends Fragment {
|
|||||||
|
|
||||||
mChart = (ChartDataUsageView) mHeader.findViewById(R.id.chart);
|
mChart = (ChartDataUsageView) mHeader.findViewById(R.id.chart);
|
||||||
mChart.setListener(mChartListener);
|
mChart.setListener(mChartListener);
|
||||||
|
mChart.bindNetworkPolicy(null);
|
||||||
|
|
||||||
{
|
{
|
||||||
// bind app detail controls
|
// bind app detail controls
|
||||||
@@ -430,7 +432,7 @@ public class DataUsageSummary extends Fragment {
|
|||||||
mMenuDataRoaming.setChecked(getDataRoaming());
|
mMenuDataRoaming.setChecked(getDataRoaming());
|
||||||
|
|
||||||
mMenuRestrictBackground = menu.findItem(R.id.data_usage_menu_restrict_background);
|
mMenuRestrictBackground = menu.findItem(R.id.data_usage_menu_restrict_background);
|
||||||
mMenuRestrictBackground.setVisible(!appDetailMode);
|
mMenuRestrictBackground.setVisible(hasMobileRadio(context) && !appDetailMode);
|
||||||
mMenuRestrictBackground.setChecked(getRestrictBackground());
|
mMenuRestrictBackground.setChecked(getRestrictBackground());
|
||||||
|
|
||||||
final MenuItem split4g = menu.findItem(R.id.data_usage_menu_split_4g);
|
final MenuItem split4g = menu.findItem(R.id.data_usage_menu_split_4g);
|
||||||
@@ -759,7 +761,8 @@ public class DataUsageSummary extends Fragment {
|
|||||||
updateDetailData();
|
updateDetailData();
|
||||||
|
|
||||||
if (NetworkPolicyManager.isUidValidForPolicy(context, primaryUid)
|
if (NetworkPolicyManager.isUidValidForPolicy(context, primaryUid)
|
||||||
&& !getRestrictBackground() && isBandwidthControlEnabled()) {
|
&& !getRestrictBackground() && isBandwidthControlEnabled()
|
||||||
|
&& hasMobileRadio(context)) {
|
||||||
setPreferenceTitle(mAppRestrictView, R.string.data_usage_app_restrict_background);
|
setPreferenceTitle(mAppRestrictView, R.string.data_usage_app_restrict_background);
|
||||||
if (hasLimitedNetworks()) {
|
if (hasLimitedNetworks()) {
|
||||||
setPreferenceSummary(mAppRestrictView,
|
setPreferenceSummary(mAppRestrictView,
|
||||||
@@ -2042,10 +2045,7 @@ public class DataUsageSummary extends Fragment {
|
|||||||
|
|
||||||
final ConnectivityManager conn = (ConnectivityManager) context.getSystemService(
|
final ConnectivityManager conn = (ConnectivityManager) context.getSystemService(
|
||||||
Context.CONNECTIVITY_SERVICE);
|
Context.CONNECTIVITY_SERVICE);
|
||||||
|
return conn.isNetworkSupported(TYPE_MOBILE);
|
||||||
// mobile devices should have MOBILE network tracker regardless of
|
|
||||||
// connection status.
|
|
||||||
return conn.getNetworkInfo(TYPE_MOBILE) != null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2064,9 +2064,7 @@ public class DataUsageSummary extends Fragment {
|
|||||||
final TelephonyManager telephony = (TelephonyManager) context.getSystemService(
|
final TelephonyManager telephony = (TelephonyManager) context.getSystemService(
|
||||||
Context.TELEPHONY_SERVICE);
|
Context.TELEPHONY_SERVICE);
|
||||||
|
|
||||||
// WiMAX devices should have WiMAX network tracker regardless of
|
final boolean hasWimax = conn.isNetworkSupported(TYPE_WIMAX);
|
||||||
// connection status.
|
|
||||||
final boolean hasWimax = conn.getNetworkInfo(TYPE_WIMAX) != null;
|
|
||||||
final boolean hasLte = telephony.getLteOnCdmaMode() == Phone.LTE_ON_CDMA_TRUE;
|
final boolean hasLte = telephony.getLteOnCdmaMode() == Phone.LTE_ON_CDMA_TRUE;
|
||||||
return hasWimax || hasLte;
|
return hasWimax || hasLte;
|
||||||
}
|
}
|
||||||
@@ -2079,7 +2077,9 @@ public class DataUsageSummary extends Fragment {
|
|||||||
return SystemProperties.get(TEST_RADIOS_PROP).contains("wifi");
|
return SystemProperties.get(TEST_RADIOS_PROP).contains("wifi");
|
||||||
}
|
}
|
||||||
|
|
||||||
return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI);
|
final ConnectivityManager conn = (ConnectivityManager) context.getSystemService(
|
||||||
|
Context.CONNECTIVITY_SERVICE);
|
||||||
|
return conn.isNetworkSupported(TYPE_WIFI);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2092,7 +2092,7 @@ public class DataUsageSummary extends Fragment {
|
|||||||
|
|
||||||
final ConnectivityManager conn = (ConnectivityManager) context.getSystemService(
|
final ConnectivityManager conn = (ConnectivityManager) context.getSystemService(
|
||||||
Context.CONNECTIVITY_SERVICE);
|
Context.CONNECTIVITY_SERVICE);
|
||||||
return conn.getNetworkInfo(TYPE_ETHERNET) != null;
|
return conn.isNetworkSupported(TYPE_ETHERNET);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -39,14 +39,14 @@ public class UidDetailProvider {
|
|||||||
mUidDetailCache = new SparseArray<UidDetail>();
|
mUidDetailCache = new SparseArray<UidDetail>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearCache() {
|
public synchronized void clearCache() {
|
||||||
mUidDetailCache.clear();
|
mUidDetailCache.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolve best descriptive label for the given UID.
|
* Resolve best descriptive label for the given UID.
|
||||||
*/
|
*/
|
||||||
public UidDetail getUidDetail(int uid, boolean blocking) {
|
public synchronized UidDetail getUidDetail(int uid, boolean blocking) {
|
||||||
final UidDetail cached = mUidDetailCache.get(uid);
|
final UidDetail cached = mUidDetailCache.get(uid);
|
||||||
if (cached != null) {
|
if (cached != null) {
|
||||||
return cached;
|
return cached;
|
||||||
|
@@ -26,6 +26,7 @@ import android.graphics.Point;
|
|||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.text.DynamicLayout;
|
import android.text.DynamicLayout;
|
||||||
|
import android.text.Layout;
|
||||||
import android.text.Layout.Alignment;
|
import android.text.Layout.Alignment;
|
||||||
import android.text.SpannableStringBuilder;
|
import android.text.SpannableStringBuilder;
|
||||||
import android.text.TextPaint;
|
import android.text.TextPaint;
|
||||||
@@ -60,7 +61,9 @@ public class ChartSweepView extends View {
|
|||||||
|
|
||||||
private int mFollowAxis;
|
private int mFollowAxis;
|
||||||
|
|
||||||
private int mLabelSize;
|
private int mLabelMinSize;
|
||||||
|
private float mLabelSize;
|
||||||
|
|
||||||
private int mLabelTemplateRes;
|
private int mLabelTemplateRes;
|
||||||
private int mLabelColor;
|
private int mLabelColor;
|
||||||
|
|
||||||
@@ -89,6 +92,8 @@ public class ChartSweepView extends View {
|
|||||||
private static final int MODE_DRAG = 1;
|
private static final int MODE_DRAG = 1;
|
||||||
private static final int MODE_LABEL = 2;
|
private static final int MODE_LABEL = 2;
|
||||||
|
|
||||||
|
private static final int LARGE_WIDTH = 1024;
|
||||||
|
|
||||||
private long mDragInterval = 1;
|
private long mDragInterval = 1;
|
||||||
|
|
||||||
public interface OnSweepListener {
|
public interface OnSweepListener {
|
||||||
@@ -121,7 +126,7 @@ public class ChartSweepView extends View {
|
|||||||
setFollowAxis(a.getInt(R.styleable.ChartSweepView_followAxis, -1));
|
setFollowAxis(a.getInt(R.styleable.ChartSweepView_followAxis, -1));
|
||||||
setNeighborMargin(a.getDimensionPixelSize(R.styleable.ChartSweepView_neighborMargin, 0));
|
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));
|
setLabelTemplate(a.getResourceId(R.styleable.ChartSweepView_labelTemplate, 0));
|
||||||
setLabelColor(a.getColor(R.styleable.ChartSweepView_labelColor, Color.BLUE));
|
setLabelColor(a.getColor(R.styleable.ChartSweepView_labelColor, Color.BLUE));
|
||||||
|
|
||||||
@@ -231,8 +236,8 @@ public class ChartSweepView extends View {
|
|||||||
mFollowAxis = followAxis;
|
mFollowAxis = followAxis;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLabelSize(int size) {
|
public void setLabelMinSize(int minSize) {
|
||||||
mLabelSize = size;
|
mLabelMinSize = minSize;
|
||||||
invalidateLabelTemplate();
|
invalidateLabelTemplate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,7 +263,7 @@ public class ChartSweepView extends View {
|
|||||||
|
|
||||||
mLabelTemplate = new SpannableStringBuilder(template);
|
mLabelTemplate = new SpannableStringBuilder(template);
|
||||||
mLabelLayout = new DynamicLayout(
|
mLabelLayout = new DynamicLayout(
|
||||||
mLabelTemplate, paint, mLabelSize, Alignment.ALIGN_RIGHT, 1f, 0f, false);
|
mLabelTemplate, paint, LARGE_WIDTH, Alignment.ALIGN_RIGHT, 1f, 0f, false);
|
||||||
invalidateLabel();
|
invalidateLabel();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -289,20 +294,26 @@ public class ChartSweepView extends View {
|
|||||||
float labelOffset = 0;
|
float labelOffset = 0;
|
||||||
if (mFollowAxis == VERTICAL) {
|
if (mFollowAxis == VERTICAL) {
|
||||||
if (mValidAfterDynamic != null) {
|
if (mValidAfterDynamic != null) {
|
||||||
|
mLabelSize = Math.max(getLabelWidth(this), getLabelWidth(mValidAfterDynamic));
|
||||||
margin = getLabelTop(mValidAfterDynamic) - getLabelBottom(this);
|
margin = getLabelTop(mValidAfterDynamic) - getLabelBottom(this);
|
||||||
if (margin < 0) {
|
if (margin < 0) {
|
||||||
labelOffset = margin / 2;
|
labelOffset = margin / 2;
|
||||||
}
|
}
|
||||||
} else if (mValidBeforeDynamic != null) {
|
} else if (mValidBeforeDynamic != null) {
|
||||||
|
mLabelSize = Math.max(getLabelWidth(this), getLabelWidth(mValidBeforeDynamic));
|
||||||
margin = getLabelTop(this) - getLabelBottom(mValidBeforeDynamic);
|
margin = getLabelTop(this) - getLabelBottom(mValidBeforeDynamic);
|
||||||
if (margin < 0) {
|
if (margin < 0) {
|
||||||
labelOffset = -margin / 2;
|
labelOffset = -margin / 2;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
mLabelSize = getLabelWidth(this);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// TODO: implement horizontal labels
|
// TODO: implement horizontal labels
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mLabelSize = Math.max(mLabelSize, mLabelMinSize);
|
||||||
|
|
||||||
// when offsetting label, neighbor probably needs to offset too
|
// when offsetting label, neighbor probably needs to offset too
|
||||||
if (labelOffset != mLabelOffset) {
|
if (labelOffset != mLabelOffset) {
|
||||||
mLabelOffset = labelOffset;
|
mLabelOffset = labelOffset;
|
||||||
@@ -692,11 +703,13 @@ public class ChartSweepView extends View {
|
|||||||
if (isEnabled() && mLabelLayout != null) {
|
if (isEnabled() && mLabelLayout != null) {
|
||||||
final int count = canvas.save();
|
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);
|
mLabelLayout.draw(canvas);
|
||||||
}
|
}
|
||||||
canvas.restoreToCount(count);
|
canvas.restoreToCount(count);
|
||||||
labelSize = mLabelSize;
|
labelSize = (int) mLabelSize;
|
||||||
} else {
|
} else {
|
||||||
labelSize = 0;
|
labelSize = 0;
|
||||||
}
|
}
|
||||||
@@ -724,4 +737,8 @@ public class ChartSweepView extends View {
|
|||||||
public static float getLabelBottom(ChartSweepView view) {
|
public static float getLabelBottom(ChartSweepView view) {
|
||||||
return getLabelTop(view) + view.mLabelLayout.getHeight();
|
return getLabelTop(view) + view.mLabelLayout.getHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static float getLabelWidth(ChartSweepView view) {
|
||||||
|
return Layout.getDesiredWidth(view.mLabelLayout.getText(), view.mLabelLayout.getPaint());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user