Changed wifi status lines per UX consult
Change-Id: I656fa2c5c52338b320796a919edb5018e7b68851
This commit is contained in:
@@ -291,16 +291,27 @@
|
|||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<!-- Match this with the constants in AccessPoint. --> <skip />
|
<!-- Match this with the constants in AccessPoint. --> <skip />
|
||||||
<!-- Wi-Fi settings. The type of security a Wi-Fi network has. -->
|
<!-- Wi-Fi security choices used when manually added a Wi-Fi network -->
|
||||||
<string-array name="wifi_security">
|
<string-array name="wifi_security">
|
||||||
<!-- The Wi-Fi network does not have any security. -->
|
<!-- The Wi-Fi network does not have any security. -->
|
||||||
<item>Open</item>
|
<item>@string/wifi_security_none</item>
|
||||||
<!-- Do not translate. -->
|
<!-- Do not translate. -->
|
||||||
<item>WEP</item>
|
<item>@string/wifi_security_wep</item>
|
||||||
<!-- Do not translate. -->
|
<!-- Do not translate. -->
|
||||||
<item>WPA/WPA2 PSK</item>
|
<item>@string/wifi_security_psk_generic</item>
|
||||||
<!-- Do not translate. -->
|
<!-- Do not translate. -->
|
||||||
<item>802.1x EAP</item>
|
<item>@string/wifi_security_eap</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<!-- Match this with the constants in AccessPoint. --> <skip />
|
||||||
|
<!-- Wi-Fi security types for New User Dialog. EAP is not configurable. -->
|
||||||
|
<string-array name="wifi_security_no_eap">
|
||||||
|
<!-- The Wi-Fi network does not have any security. -->
|
||||||
|
<item>@string/wifi_security_none</item>
|
||||||
|
<!-- Do not translate. -->
|
||||||
|
<item>@string/wifi_security_wep</item>
|
||||||
|
<!-- Do not translate. -->
|
||||||
|
<item>@string/wifi_security_psk_generic</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<!-- Wi-Fi AP settings. The type of security a Wi-Fi AP supports. -->
|
<!-- Wi-Fi AP settings. The type of security a Wi-Fi AP supports. -->
|
||||||
|
@@ -1213,19 +1213,59 @@
|
|||||||
<!-- Hint for unspecified fields -->
|
<!-- Hint for unspecified fields -->
|
||||||
<string name="wifi_unspecified">(unspecified)</string>
|
<string name="wifi_unspecified">(unspecified)</string>
|
||||||
<!-- Summary for the remembered network. -->
|
<!-- Summary for the remembered network. -->
|
||||||
<string name="wifi_remembered">Remembered</string>
|
<string name="wifi_remembered">Saved</string>
|
||||||
<!-- Summary for the disabled network. -->
|
<!-- Status for networks disabled for unknown reason -->
|
||||||
<string name="wifi_disabled">Disabled</string>
|
<string name="wifi_disabled_generic">Disabled</string>
|
||||||
|
<!-- Status for networked disabled from a DNS or DHCP failure -->
|
||||||
|
<string name="wifi_disabled_network_failure">Avoided poor connection</string>
|
||||||
|
<!-- Status for networks disabled from authentication failure (wrong password
|
||||||
|
or certificate). -->
|
||||||
|
<string name="wifi_disabled_password_failure">Authentication problem</string>
|
||||||
<!-- Summary for the remembered network but currently not in range. -->
|
<!-- Summary for the remembered network but currently not in range. -->
|
||||||
<string name="wifi_not_in_range">Not in range</string>
|
<string name="wifi_not_in_range">Not in range</string>
|
||||||
<!-- Summary for an open network with WPS being available [CHAR LIMIT=50]-->
|
<!-- Substring of status line when Wi-Fi Protected Setup (WPS) is available and
|
||||||
<string name="wifi_open_with_wps">WPS available</string>
|
string is listed first -->
|
||||||
<!-- Summary for the secured network. -->
|
<string name="wifi_wps_available_first_item">WPS available</string>
|
||||||
<string name="wifi_secured">Secured with <xliff:g id="wifi_security">%1$s</xliff:g></string>
|
<!-- Substring of wifi status when Wi-Fi Protected Setup (WPS) is available and
|
||||||
<!-- Summary for the secured network with WPS being available [CHAR LIMIT=50]-->
|
string is listed after a wifi_secured_* string-->
|
||||||
<string name="wifi_secured_with_wps">Secured with <xliff:g id="wifi_security">%1$s</xliff:g> (WPS available)</string>
|
<string name="wifi_wps_available_second_item">\u0020(WPS available)</string>
|
||||||
<!-- Summary for the secured and remembered network. Status can be "Remembered", "Disabled" or "Not in range". -->
|
<!-- Substring of wifi status for wifi with authentication. This version is for when the
|
||||||
<string name="wifi_secured_with_status"><xliff:g id="wifi_status">%2$s</xliff:g>, secured with <xliff:g id="wifi_security">%1$s</xliff:g></string>
|
string is first in the list (titlecase in english) -->
|
||||||
|
<string name="wifi_secured_first_item">Secured with <xliff:g id="wifi_security_short">%1$s</xliff:g></string>
|
||||||
|
<!-- Substring of wifi status for wifi with authentication. This version is for when the
|
||||||
|
string is not first in the list (lowercase in english) -->
|
||||||
|
<string name="wifi_secured_second_item">, secured with <xliff:g id="wifi_security_short">%1$s</xliff:g></string>
|
||||||
|
|
||||||
|
<!-- Do not translate. Concise terminology for wifi with WEP security -->
|
||||||
|
<string name="wifi_security_short_wep">WEP</string>
|
||||||
|
<!-- Do not translate. Concise terminology for wifi with WPA security -->
|
||||||
|
<string name="wifi_security_short_wpa">WPA</string>
|
||||||
|
<!-- Do not translate. Concise terminology for wifi with WPA2 security -->
|
||||||
|
<string name="wifi_security_short_wpa2">WPA2</string>
|
||||||
|
<!-- Do not translate. Concise terminology for wifi with both WPA/WPA2 security -->
|
||||||
|
<string name="wifi_security_short_wpa_wpa2">WPA/WPA2</string>
|
||||||
|
<!-- Do not translate. Concise terminology for wifi with unknown PSK type -->
|
||||||
|
<string name="wifi_security_short_psk_generic">@string/wifi_security_short_wpa_wpa2</string>
|
||||||
|
<!-- Do not translate. Concise terminology for wifi with 802.1x EAP security -->
|
||||||
|
<string name="wifi_security_short_eap">802.1x</string>
|
||||||
|
|
||||||
|
<!-- Used in Wi-Fi settings dialogs when Wi-Fi does not have any security. -->
|
||||||
|
<string name="wifi_security_none">None</string>
|
||||||
|
|
||||||
|
<!-- Do not translate. Terminology for wifi with WEP security -->
|
||||||
|
<string name="wifi_security_wep">WEP</string>
|
||||||
|
<!-- Do not translate. Terminology for wifi with WPA security -->
|
||||||
|
<string name="wifi_security_wpa">WPA PSK</string>
|
||||||
|
<!-- Do not translate. Terminology for wifi with WPA2 security -->
|
||||||
|
<string name="wifi_security_wpa2">WPA2 PSK</string>
|
||||||
|
<!-- Do not translate. Terminology for wifi with both WPA/WPA2 security, or unknown -->
|
||||||
|
<string name="wifi_security_wpa_wpa2">WPA/WPA2 PSK</string>
|
||||||
|
<!-- Do not translate. Terminology for wifi with unknown PSK type -->
|
||||||
|
<string name="wifi_security_psk_generic">@string/wifi_security_wpa_wpa2</string>
|
||||||
|
<!-- Do not translate. Concise terminology for wifi with 802.1x EAP security -->
|
||||||
|
<string name="wifi_security_eap">802.1x EAP</string>
|
||||||
|
|
||||||
|
|
||||||
<!-- Button label to connect to a Wi-Fi network -->
|
<!-- Button label to connect to a Wi-Fi network -->
|
||||||
<string name="wifi_connect">Connect</string>
|
<string name="wifi_connect">Connect</string>
|
||||||
<!-- Button label to delete a Wi-Fi network -->
|
<!-- Button label to delete a Wi-Fi network -->
|
||||||
|
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
package com.android.settings.wifi;
|
package com.android.settings.wifi;
|
||||||
|
|
||||||
import com.android.settings.R;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.NetworkInfo.DetailedState;
|
import android.net.NetworkInfo.DetailedState;
|
||||||
import android.net.wifi.ScanResult;
|
import android.net.wifi.ScanResult;
|
||||||
@@ -27,35 +25,48 @@ import android.net.wifi.WifiInfo;
|
|||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import com.android.settings.R;
|
||||||
|
|
||||||
class AccessPoint extends Preference {
|
class AccessPoint extends Preference {
|
||||||
|
static final String TAG = "Settings.AccessPoint";
|
||||||
|
|
||||||
private static final String KEY_DETAILEDSTATE = "key_detailedstate";
|
private static final String KEY_DETAILEDSTATE = "key_detailedstate";
|
||||||
private static final String KEY_WIFIINFO = "key_wifiinfo";
|
private static final String KEY_WIFIINFO = "key_wifiinfo";
|
||||||
private static final String KEY_SCANRESULT = "key_scanresult";
|
private static final String KEY_SCANRESULT = "key_scanresult";
|
||||||
private static final String KEY_CONFIG = "key_config";
|
private static final String KEY_CONFIG = "key_config";
|
||||||
|
|
||||||
private static final int[] STATE_SECURED = {R.attr.state_encrypted};
|
private static final int[] STATE_SECURED = {
|
||||||
|
R.attr.state_encrypted
|
||||||
|
};
|
||||||
private static final int[] STATE_NONE = {};
|
private static final int[] STATE_NONE = {};
|
||||||
|
|
||||||
|
/** 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;
|
||||||
static final int SECURITY_PSK = 2;
|
static final int SECURITY_PSK = 2;
|
||||||
static final int SECURITY_EAP = 3;
|
static final int SECURITY_EAP = 3;
|
||||||
|
|
||||||
|
enum PskType {
|
||||||
|
UNKNOWN,
|
||||||
|
WPA,
|
||||||
|
WPA2,
|
||||||
|
WPA_WPA2
|
||||||
|
}
|
||||||
|
|
||||||
String ssid;
|
String ssid;
|
||||||
String bssid;
|
String bssid;
|
||||||
int security;
|
int security;
|
||||||
int networkId;
|
int networkId;
|
||||||
boolean wpsAvailable = false;
|
boolean wpsAvailable = false;
|
||||||
|
|
||||||
|
PskType pskType = PskType.UNKNOWN;
|
||||||
|
|
||||||
private WifiConfiguration mConfig;
|
private WifiConfiguration mConfig;
|
||||||
/*package*/ScanResult mScanResult;
|
/* package */ScanResult mScanResult;
|
||||||
|
|
||||||
private int mRssi;
|
private int mRssi;
|
||||||
private WifiInfo mInfo;
|
private WifiInfo mInfo;
|
||||||
@@ -84,6 +95,52 @@ class AccessPoint extends Preference {
|
|||||||
return SECURITY_NONE;
|
return SECURITY_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getSecurityString(boolean concise) {
|
||||||
|
Context context = getContext();
|
||||||
|
switch(security) {
|
||||||
|
case SECURITY_EAP:
|
||||||
|
return concise ? context.getString(R.string.wifi_security_short_eap) :
|
||||||
|
context.getString(R.string.wifi_security_eap);
|
||||||
|
case SECURITY_PSK:
|
||||||
|
switch (pskType) {
|
||||||
|
case WPA:
|
||||||
|
return concise ? context.getString(R.string.wifi_security_short_wpa) :
|
||||||
|
context.getString(R.string.wifi_security_wpa);
|
||||||
|
case WPA2:
|
||||||
|
return concise ? context.getString(R.string.wifi_security_short_wpa2) :
|
||||||
|
context.getString(R.string.wifi_security_wpa2);
|
||||||
|
case WPA_WPA2:
|
||||||
|
return concise ? context.getString(R.string.wifi_security_short_wpa_wpa2) :
|
||||||
|
context.getString(R.string.wifi_security_wpa_wpa2);
|
||||||
|
case UNKNOWN:
|
||||||
|
default:
|
||||||
|
return concise ? context.getString(R.string.wifi_security_short_psk_generic)
|
||||||
|
: context.getString(R.string.wifi_security_psk_generic);
|
||||||
|
}
|
||||||
|
case SECURITY_WEP:
|
||||||
|
return concise ? context.getString(R.string.wifi_security_short_wep) :
|
||||||
|
context.getString(R.string.wifi_security_wep);
|
||||||
|
case SECURITY_NONE:
|
||||||
|
default:
|
||||||
|
return concise ? "" : context.getString(R.string.wifi_security_none);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static PskType getPskType(ScanResult result) {
|
||||||
|
boolean wpa = result.capabilities.contains("WPA-PSK");
|
||||||
|
boolean wpa2 = result.capabilities.contains("WPA2-PSK");
|
||||||
|
if (wpa2 && wpa) {
|
||||||
|
return PskType.WPA_WPA2;
|
||||||
|
} else if (wpa2) {
|
||||||
|
return PskType.WPA2;
|
||||||
|
} else if (wpa) {
|
||||||
|
return PskType.WPA;
|
||||||
|
} else {
|
||||||
|
Log.w(TAG, "Received abnormal flag string: " + result.capabilities);
|
||||||
|
return PskType.UNKNOWN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
AccessPoint(Context context, WifiConfiguration config) {
|
AccessPoint(Context context, WifiConfiguration config) {
|
||||||
super(context);
|
super(context);
|
||||||
setWidgetLayoutResource(R.layout.preference_widget_wifi_signal);
|
setWidgetLayoutResource(R.layout.preference_widget_wifi_signal);
|
||||||
@@ -138,6 +195,8 @@ class AccessPoint extends Preference {
|
|||||||
bssid = result.BSSID;
|
bssid = result.BSSID;
|
||||||
security = getSecurity(result);
|
security = getSecurity(result);
|
||||||
wpsAvailable = security != SECURITY_EAP && result.capabilities.contains("WPS");
|
wpsAvailable = security != SECURITY_EAP && result.capabilities.contains("WPS");
|
||||||
|
if (security == SECURITY_PSK)
|
||||||
|
pskType = getPskType(result);
|
||||||
networkId = -1;
|
networkId = -1;
|
||||||
mRssi = result.level;
|
mRssi = result.level;
|
||||||
mScanResult = result;
|
mScanResult = result;
|
||||||
@@ -185,13 +244,15 @@ class AccessPoint extends Preference {
|
|||||||
return ssid.compareToIgnoreCase(other.ssid);
|
return ssid.compareToIgnoreCase(other.ssid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
boolean update(ScanResult result) {
|
boolean update(ScanResult result) {
|
||||||
// We do not call refresh() since this is called before onBindView().
|
// We do not call refresh() since this is called before onBindView().
|
||||||
if (ssid.equals(result.SSID) && security == getSecurity(result)) {
|
if (ssid.equals(result.SSID) && security == getSecurity(result)) {
|
||||||
if (WifiManager.compareSignalLevel(result.level, mRssi) > 0) {
|
if (WifiManager.compareSignalLevel(result.level, mRssi) > 0) {
|
||||||
mRssi = result.level;
|
mRssi = result.level;
|
||||||
}
|
}
|
||||||
|
// This flag only comes from scans, is not easily saved in config
|
||||||
|
if (security == SECURITY_PSK)
|
||||||
|
pskType = getPskType(result);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -255,34 +316,46 @@ class AccessPoint extends Preference {
|
|||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
mSignal.setImageLevel(getLevel());
|
mSignal.setImageLevel(getLevel());
|
||||||
|
|
||||||
if (mState != null) {
|
if (mState != null) { // This is the active connection
|
||||||
setSummary(Summary.get(context, mState));
|
setSummary(Summary.get(context, mState));
|
||||||
} else {
|
} else if (mRssi == Integer.MAX_VALUE) { // Wifi out of range
|
||||||
String status = null;
|
setSummary(context.getString(R.string.wifi_not_in_range));
|
||||||
if (mRssi == Integer.MAX_VALUE) {
|
} else if (mConfig != null && mConfig.status == WifiConfiguration.Status.DISABLED) {
|
||||||
status = context.getString(R.string.wifi_not_in_range);
|
switch (mConfig.disableReason) {
|
||||||
} else if (mConfig != null) {
|
case WifiConfiguration.DISABLED_AUTH_FAILURE:
|
||||||
status = context.getString((mConfig.status == WifiConfiguration.Status.DISABLED) ?
|
setSummary(context.getString(R.string.wifi_disabled_password_failure));
|
||||||
R.string.wifi_disabled : R.string.wifi_remembered);
|
break;
|
||||||
|
case WifiConfiguration.DISABLED_DHCP_FAILURE:
|
||||||
|
case WifiConfiguration.DISABLED_DNS_FAILURE:
|
||||||
|
setSummary(context.getString(R.string.wifi_disabled_network_failure));
|
||||||
|
break;
|
||||||
|
case WifiConfiguration.DISABLED_UNKNOWN_REASON:
|
||||||
|
setSummary(context.getString(R.string.wifi_disabled_generic));
|
||||||
|
}
|
||||||
|
} else { // In range, not disabled.
|
||||||
|
StringBuilder summary = new StringBuilder();
|
||||||
|
if (mConfig != null) { // Is saved network
|
||||||
|
summary.append(context.getString(R.string.wifi_remembered));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (security == SECURITY_NONE) {
|
if (security != SECURITY_NONE) {
|
||||||
if (wpsAvailable && mConfig == null) {
|
String securityStrFormat;
|
||||||
setSummary(context.getString(R.string.wifi_open_with_wps));
|
if (summary.length() == 0) {
|
||||||
|
securityStrFormat = context.getString(R.string.wifi_secured_first_item);
|
||||||
} else {
|
} else {
|
||||||
setSummary(status);
|
securityStrFormat = context.getString(R.string.wifi_secured_second_item);
|
||||||
}
|
}
|
||||||
} else {
|
summary.append(String.format(securityStrFormat, getSecurityString(true)));
|
||||||
String format;
|
|
||||||
if (wpsAvailable && mConfig == null) {
|
|
||||||
format = context.getString(R.string.wifi_secured_with_wps);
|
|
||||||
} else {
|
|
||||||
format = context.getString((status == null) ?
|
|
||||||
R.string.wifi_secured : R.string.wifi_secured_with_status);
|
|
||||||
}
|
|
||||||
String[] type = context.getResources().getStringArray(R.array.wifi_security);
|
|
||||||
setSummary(String.format(format, type[security], status));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mConfig == null && wpsAvailable) { // Only list WPS available for unsaved networks
|
||||||
|
if (summary.length() == 0) {
|
||||||
|
summary.append(context.getString(R.string.wifi_wps_available_first_item));
|
||||||
|
} else {
|
||||||
|
summary.append(context.getString(R.string.wifi_wps_available_second_item));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setSummary(summary.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -158,10 +158,11 @@ public class WifiConfigController implements TextWatcher,
|
|||||||
mView.findViewById(R.id.type_ssid).setVisibility(View.VISIBLE);
|
mView.findViewById(R.id.type_ssid).setVisibility(View.VISIBLE);
|
||||||
mView.findViewById(R.id.type_security).setVisibility(View.VISIBLE);
|
mView.findViewById(R.id.type_security).setVisibility(View.VISIBLE);
|
||||||
// We want custom layout. The content must be same as the other cases.
|
// We want custom layout. The content must be same as the other cases.
|
||||||
mSecuritySpinner.setAdapter(
|
|
||||||
new ArrayAdapter<String>(context, R.layout.wifi_setup_custom_list_item_1,
|
ArrayAdapter<String> adapter = new ArrayAdapter<String>(context,
|
||||||
android.R.id.text1,
|
R.layout.wifi_setup_custom_list_item_1, android.R.id.text1,
|
||||||
context.getResources().getStringArray(R.array.wifi_security)));
|
context.getResources().getStringArray(R.array.wifi_security_no_eap));
|
||||||
|
mSecuritySpinner.setAdapter(adapter);
|
||||||
} else {
|
} else {
|
||||||
mView.findViewById(R.id.type).setVisibility(View.VISIBLE);
|
mView.findViewById(R.id.type).setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
@@ -181,8 +182,7 @@ public class WifiConfigController implements TextWatcher,
|
|||||||
addRow(group, R.string.wifi_status, Summary.get(mConfigUi.getContext(), state));
|
addRow(group, R.string.wifi_status, Summary.get(mConfigUi.getContext(), state));
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] type = resources.getStringArray(R.array.wifi_security);
|
addRow(group, R.string.wifi_security, mAccessPoint.getSecurityString(false));
|
||||||
addRow(group, R.string.wifi_security, type[mAccessPoint.security]);
|
|
||||||
|
|
||||||
int level = mAccessPoint.getLevel();
|
int level = mAccessPoint.getLevel();
|
||||||
if (level != -1) {
|
if (level != -1) {
|
||||||
|
@@ -511,6 +511,7 @@ public class WifiSettings extends SettingsPreferenceFragment
|
|||||||
for (AccessPoint accessPoint : accessPoints) {
|
for (AccessPoint accessPoint : accessPoints) {
|
||||||
if (accessPoint.update(result)) {
|
if (accessPoint.update(result)) {
|
||||||
found = true;
|
found = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found) {
|
if (!found) {
|
||||||
|
Reference in New Issue
Block a user