am c8e2eeea
: Fix icon location on Wifi Settings
* commit 'c8e2eeeaa1666d37abc16d0505a1ef6e9a5bae91': Fix icon location on Wifi Settings
This commit is contained in:
@@ -19,6 +19,7 @@ package com.android.settings.wifi;
|
|||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.NetworkInfo.DetailedState;
|
import android.net.NetworkInfo.DetailedState;
|
||||||
import android.net.wifi.ScanResult;
|
import android.net.wifi.ScanResult;
|
||||||
import android.net.wifi.WifiConfiguration;
|
import android.net.wifi.WifiConfiguration;
|
||||||
@@ -48,6 +49,8 @@ class AccessPoint extends Preference {
|
|||||||
};
|
};
|
||||||
private static final int[] STATE_NONE = {};
|
private static final int[] STATE_NONE = {};
|
||||||
|
|
||||||
|
private static int[] wifi_signal_attributes = { R.attr.wifi_signal };
|
||||||
|
|
||||||
/** These values are matched in string arrays -- changes must be kept in sync */
|
/** These values are matched in string arrays -- changes must be kept in sync */
|
||||||
static final int SECURITY_NONE = 0;
|
static final int SECURITY_NONE = 0;
|
||||||
static final int SECURITY_WEP = 1;
|
static final int SECURITY_WEP = 1;
|
||||||
@@ -163,21 +166,18 @@ class AccessPoint extends Preference {
|
|||||||
|
|
||||||
AccessPoint(Context context, WifiConfiguration config) {
|
AccessPoint(Context context, WifiConfiguration config) {
|
||||||
super(context);
|
super(context);
|
||||||
setWidgetLayoutResource(R.layout.preference_widget_wifi_signal);
|
|
||||||
loadConfig(config);
|
loadConfig(config);
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
AccessPoint(Context context, ScanResult result) {
|
AccessPoint(Context context, ScanResult result) {
|
||||||
super(context);
|
super(context);
|
||||||
setWidgetLayoutResource(R.layout.preference_widget_wifi_signal);
|
|
||||||
loadResult(result);
|
loadResult(result);
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
AccessPoint(Context context, Bundle savedState) {
|
AccessPoint(Context context, Bundle savedState) {
|
||||||
super(context);
|
super(context);
|
||||||
setWidgetLayoutResource(R.layout.preference_widget_wifi_signal);
|
|
||||||
|
|
||||||
mConfig = savedState.getParcelable(KEY_CONFIG);
|
mConfig = savedState.getParcelable(KEY_CONFIG);
|
||||||
if (mConfig != null) {
|
if (mConfig != null) {
|
||||||
@@ -228,18 +228,28 @@ class AccessPoint extends Preference {
|
|||||||
@Override
|
@Override
|
||||||
protected void onBindView(View view) {
|
protected void onBindView(View view) {
|
||||||
super.onBindView(view);
|
super.onBindView(view);
|
||||||
ImageView signal = (ImageView) view.findViewById(R.id.signal);
|
updateIcon(getLevel());
|
||||||
if (mRssi == Integer.MAX_VALUE) {
|
notifyChanged();
|
||||||
signal.setImageDrawable(null);
|
}
|
||||||
|
|
||||||
|
protected void updateIcon(int level) {
|
||||||
|
if (level == -1) {
|
||||||
|
setIcon(null);
|
||||||
} else {
|
} else {
|
||||||
signal.setImageLevel(getLevel());
|
Drawable drawable = getIcon();
|
||||||
signal.setImageDrawable(getContext().getTheme().obtainStyledAttributes(
|
|
||||||
new int[] {R.attr.wifi_signal}).getDrawable(0));
|
if (drawable == null) {
|
||||||
signal.setImageState((security != SECURITY_NONE) ?
|
drawable = getContext().getTheme().obtainStyledAttributes(
|
||||||
STATE_SECURED : STATE_NONE, true);
|
wifi_signal_attributes).getDrawable(0);
|
||||||
|
setIcon(drawable);
|
||||||
|
}
|
||||||
|
|
||||||
|
drawable.setLevel(level);
|
||||||
|
drawable.setState((security != SECURITY_NONE) ? STATE_SECURED : STATE_NONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(Preference preference) {
|
public int compareTo(Preference preference) {
|
||||||
if (!(preference instanceof AccessPoint)) {
|
if (!(preference instanceof AccessPoint)) {
|
||||||
@@ -253,6 +263,7 @@ class AccessPoint extends Preference {
|
|||||||
// Reachable one goes before unreachable one.
|
// Reachable one goes before unreachable one.
|
||||||
if (mRssi != Integer.MAX_VALUE && other.mRssi == Integer.MAX_VALUE) return -1;
|
if (mRssi != Integer.MAX_VALUE && other.mRssi == Integer.MAX_VALUE) return -1;
|
||||||
if (mRssi == Integer.MAX_VALUE && other.mRssi != Integer.MAX_VALUE) return 1;
|
if (mRssi == Integer.MAX_VALUE && other.mRssi != Integer.MAX_VALUE) return 1;
|
||||||
|
if (mRssi == Integer.MAX_VALUE && other.mRssi != Integer.MAX_VALUE) return 1;
|
||||||
|
|
||||||
// Configured one goes before unconfigured one.
|
// Configured one goes before unconfigured one.
|
||||||
if (networkId != WifiConfiguration.INVALID_NETWORK_ID
|
if (networkId != WifiConfiguration.INVALID_NETWORK_ID
|
||||||
@@ -463,6 +474,8 @@ class AccessPoint extends Preference {
|
|||||||
/** Updates the title and summary; may indirectly call notifyChanged() */
|
/** Updates the title and summary; may indirectly call notifyChanged() */
|
||||||
private void refresh() {
|
private void refresh() {
|
||||||
setTitle(ssid);
|
setTitle(ssid);
|
||||||
|
updateIcon(getLevel());
|
||||||
|
|
||||||
StringBuilder summary = new StringBuilder();
|
StringBuilder summary = new StringBuilder();
|
||||||
|
|
||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
|
Reference in New Issue
Block a user