Merge "Prevent wifi icon from disappearing" into nyc-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
09b64ade22
@@ -29,7 +29,6 @@ import android.text.TextUtils;
|
|||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.android.settingslib.R;
|
import com.android.settingslib.R;
|
||||||
|
|
||||||
public class AccessPointPreference extends Preference {
|
public class AccessPointPreference extends Preference {
|
||||||
@@ -44,13 +43,14 @@ public class AccessPointPreference extends Preference {
|
|||||||
private final StateListDrawable mWifiSld;
|
private final StateListDrawable mWifiSld;
|
||||||
private final int mBadgePadding;
|
private final int mBadgePadding;
|
||||||
private final UserBadgeCache mBadgeCache;
|
private final UserBadgeCache mBadgeCache;
|
||||||
|
|
||||||
private TextView mTitleView;
|
private TextView mTitleView;
|
||||||
|
|
||||||
private boolean mForSavedNetworks = false;
|
private boolean mForSavedNetworks = false;
|
||||||
private AccessPoint mAccessPoint;
|
private AccessPoint mAccessPoint;
|
||||||
private Drawable mBadge;
|
private Drawable mBadge;
|
||||||
private int mLevel;
|
private int mLevel;
|
||||||
private CharSequence mContentDescription;
|
private CharSequence mContentDescription;
|
||||||
|
private int mDefaultIconResId;
|
||||||
|
|
||||||
static final int[] WIFI_CONNECTION_STRENGTH = {
|
static final int[] WIFI_CONNECTION_STRENGTH = {
|
||||||
R.string.accessibility_wifi_one_bar,
|
R.string.accessibility_wifi_one_bar,
|
||||||
@@ -85,6 +85,24 @@ public class AccessPointPreference extends Preference {
|
|||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AccessPointPreference(AccessPoint accessPoint, Context context, UserBadgeCache cache,
|
||||||
|
int iconResId, boolean forSavedNetworks) {
|
||||||
|
super(context);
|
||||||
|
mBadgeCache = cache;
|
||||||
|
mAccessPoint = accessPoint;
|
||||||
|
mForSavedNetworks = forSavedNetworks;
|
||||||
|
mAccessPoint.setTag(this);
|
||||||
|
mLevel = -1;
|
||||||
|
mDefaultIconResId = iconResId;
|
||||||
|
|
||||||
|
mWifiSld = (StateListDrawable) context.getTheme()
|
||||||
|
.obtainStyledAttributes(wifi_signal_attributes).getDrawable(0);
|
||||||
|
|
||||||
|
// Distance from the end of the title at which this AP's user badge should sit.
|
||||||
|
mBadgePadding = context.getResources()
|
||||||
|
.getDimensionPixelSize(R.dimen.wifi_preference_badge_padding);
|
||||||
|
}
|
||||||
|
|
||||||
public AccessPoint getAccessPoint() {
|
public AccessPoint getAccessPoint() {
|
||||||
return mAccessPoint;
|
return mAccessPoint;
|
||||||
}
|
}
|
||||||
@@ -112,7 +130,7 @@ public class AccessPointPreference extends Preference {
|
|||||||
|
|
||||||
protected void updateIcon(int level, Context context) {
|
protected void updateIcon(int level, Context context) {
|
||||||
if (level == -1) {
|
if (level == -1) {
|
||||||
setIcon(null);
|
safeSetDefaultIcon();
|
||||||
} else {
|
} else {
|
||||||
if (getIcon() == null) {
|
if (getIcon() == null) {
|
||||||
// To avoid a drawing race condition, we first set the state (SECURE/NONE) and then
|
// To avoid a drawing race condition, we first set the state (SECURE/NONE) and then
|
||||||
@@ -124,15 +142,23 @@ public class AccessPointPreference extends Preference {
|
|||||||
? STATE_SECURED
|
? STATE_SECURED
|
||||||
: STATE_NONE);
|
: STATE_NONE);
|
||||||
Drawable drawable = mWifiSld.getCurrent();
|
Drawable drawable = mWifiSld.getCurrent();
|
||||||
if (!mForSavedNetworks) {
|
if (!mForSavedNetworks && drawable != null) {
|
||||||
setIcon(drawable);
|
setIcon(drawable);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
safeSetDefaultIcon();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void safeSetDefaultIcon() {
|
||||||
|
if (mDefaultIconResId != 0) {
|
||||||
|
setIcon(mDefaultIconResId);
|
||||||
} else {
|
} else {
|
||||||
setIcon(null);
|
setIcon(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void updateBadge(Context context) {
|
protected void updateBadge(Context context) {
|
||||||
WifiConfiguration config = mAccessPoint.getConfig();
|
WifiConfiguration config = mAccessPoint.getConfig();
|
||||||
|
|||||||
Reference in New Issue
Block a user