Changed wifi status lines per UX consult
Change-Id: I656fa2c5c52338b320796a919edb5018e7b68851
This commit is contained in:
@@ -291,16 +291,27 @@
|
||||
</string-array>
|
||||
|
||||
<!-- 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">
|
||||
<!-- The Wi-Fi network does not have any security. -->
|
||||
<item>Open</item>
|
||||
<item>@string/wifi_security_none</item>
|
||||
<!-- Do not translate. -->
|
||||
<item>WEP</item>
|
||||
<item>@string/wifi_security_wep</item>
|
||||
<!-- Do not translate. -->
|
||||
<item>WPA/WPA2 PSK</item>
|
||||
<item>@string/wifi_security_psk_generic</item>
|
||||
<!-- 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>
|
||||
|
||||
<!-- Wi-Fi AP settings. The type of security a Wi-Fi AP supports. -->
|
||||
|
@@ -1213,19 +1213,59 @@
|
||||
<!-- Hint for unspecified fields -->
|
||||
<string name="wifi_unspecified">(unspecified)</string>
|
||||
<!-- Summary for the remembered network. -->
|
||||
<string name="wifi_remembered">Remembered</string>
|
||||
<!-- Summary for the disabled network. -->
|
||||
<string name="wifi_disabled">Disabled</string>
|
||||
<string name="wifi_remembered">Saved</string>
|
||||
<!-- Status for networks disabled for unknown reason -->
|
||||
<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. -->
|
||||
<string name="wifi_not_in_range">Not in range</string>
|
||||
<!-- Summary for an open network with WPS being available [CHAR LIMIT=50]-->
|
||||
<string name="wifi_open_with_wps">WPS available</string>
|
||||
<!-- Summary for the secured network. -->
|
||||
<string name="wifi_secured">Secured with <xliff:g id="wifi_security">%1$s</xliff:g></string>
|
||||
<!-- Summary for the secured network with WPS being available [CHAR LIMIT=50]-->
|
||||
<string name="wifi_secured_with_wps">Secured with <xliff:g id="wifi_security">%1$s</xliff:g> (WPS available)</string>
|
||||
<!-- Summary for the secured and remembered network. Status can be "Remembered", "Disabled" or "Not in range". -->
|
||||
<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>
|
||||
<!-- Substring of status line when Wi-Fi Protected Setup (WPS) is available and
|
||||
string is listed first -->
|
||||
<string name="wifi_wps_available_first_item">WPS available</string>
|
||||
<!-- Substring of wifi status when Wi-Fi Protected Setup (WPS) is available and
|
||||
string is listed after a wifi_secured_* string-->
|
||||
<string name="wifi_wps_available_second_item">\u0020(WPS available)</string>
|
||||
<!-- Substring of wifi status for wifi with authentication. This version is for when the
|
||||
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 -->
|
||||
<string name="wifi_connect">Connect</string>
|
||||
<!-- Button label to delete a Wi-Fi network -->
|
||||
|
@@ -16,8 +16,6 @@
|
||||
|
||||
package com.android.settings.wifi;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.NetworkInfo.DetailedState;
|
||||
import android.net.wifi.ScanResult;
|
||||
@@ -27,35 +25,48 @@ import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Bundle;
|
||||
import android.preference.Preference;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import java.util.Comparator;
|
||||
import com.android.settings.R;
|
||||
|
||||
class AccessPoint extends Preference {
|
||||
static final String TAG = "Settings.AccessPoint";
|
||||
|
||||
private static final String KEY_DETAILEDSTATE = "key_detailedstate";
|
||||
private static final String KEY_WIFIINFO = "key_wifiinfo";
|
||||
private static final String KEY_SCANRESULT = "key_scanresult";
|
||||
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 = {};
|
||||
|
||||
|
||||
/** These values are matched in string arrays -- changes must be kept in sync */
|
||||
static final int SECURITY_NONE = 0;
|
||||
static final int SECURITY_WEP = 1;
|
||||
static final int SECURITY_PSK = 2;
|
||||
static final int SECURITY_EAP = 3;
|
||||
|
||||
enum PskType {
|
||||
UNKNOWN,
|
||||
WPA,
|
||||
WPA2,
|
||||
WPA_WPA2
|
||||
}
|
||||
|
||||
String ssid;
|
||||
String bssid;
|
||||
int security;
|
||||
int networkId;
|
||||
boolean wpsAvailable = false;
|
||||
|
||||
PskType pskType = PskType.UNKNOWN;
|
||||
|
||||
private WifiConfiguration mConfig;
|
||||
/*package*/ScanResult mScanResult;
|
||||
/* package */ScanResult mScanResult;
|
||||
|
||||
private int mRssi;
|
||||
private WifiInfo mInfo;
|
||||
@@ -84,6 +95,52 @@ class AccessPoint extends Preference {
|
||||
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) {
|
||||
super(context);
|
||||
setWidgetLayoutResource(R.layout.preference_widget_wifi_signal);
|
||||
@@ -138,6 +195,8 @@ class AccessPoint extends Preference {
|
||||
bssid = result.BSSID;
|
||||
security = getSecurity(result);
|
||||
wpsAvailable = security != SECURITY_EAP && result.capabilities.contains("WPS");
|
||||
if (security == SECURITY_PSK)
|
||||
pskType = getPskType(result);
|
||||
networkId = -1;
|
||||
mRssi = result.level;
|
||||
mScanResult = result;
|
||||
@@ -185,13 +244,15 @@ class AccessPoint extends Preference {
|
||||
return ssid.compareToIgnoreCase(other.ssid);
|
||||
}
|
||||
|
||||
|
||||
boolean update(ScanResult result) {
|
||||
// We do not call refresh() since this is called before onBindView().
|
||||
if (ssid.equals(result.SSID) && security == getSecurity(result)) {
|
||||
if (WifiManager.compareSignalLevel(result.level, mRssi) > 0) {
|
||||
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 false;
|
||||
@@ -255,34 +316,46 @@ class AccessPoint extends Preference {
|
||||
Context context = getContext();
|
||||
mSignal.setImageLevel(getLevel());
|
||||
|
||||
if (mState != null) {
|
||||
if (mState != null) { // This is the active connection
|
||||
setSummary(Summary.get(context, mState));
|
||||
} else {
|
||||
String status = null;
|
||||
if (mRssi == Integer.MAX_VALUE) {
|
||||
status = context.getString(R.string.wifi_not_in_range);
|
||||
} else if (mConfig != null) {
|
||||
status = context.getString((mConfig.status == WifiConfiguration.Status.DISABLED) ?
|
||||
R.string.wifi_disabled : R.string.wifi_remembered);
|
||||
} else if (mRssi == Integer.MAX_VALUE) { // Wifi out of range
|
||||
setSummary(context.getString(R.string.wifi_not_in_range));
|
||||
} else if (mConfig != null && mConfig.status == WifiConfiguration.Status.DISABLED) {
|
||||
switch (mConfig.disableReason) {
|
||||
case WifiConfiguration.DISABLED_AUTH_FAILURE:
|
||||
setSummary(context.getString(R.string.wifi_disabled_password_failure));
|
||||
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 (wpsAvailable && mConfig == null) {
|
||||
setSummary(context.getString(R.string.wifi_open_with_wps));
|
||||
if (security != SECURITY_NONE) {
|
||||
String securityStrFormat;
|
||||
if (summary.length() == 0) {
|
||||
securityStrFormat = context.getString(R.string.wifi_secured_first_item);
|
||||
} else {
|
||||
setSummary(status);
|
||||
securityStrFormat = context.getString(R.string.wifi_secured_second_item);
|
||||
}
|
||||
} else {
|
||||
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));
|
||||
summary.append(String.format(securityStrFormat, getSecurityString(true)));
|
||||
}
|
||||
|
||||
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_security).setVisibility(View.VISIBLE);
|
||||
// 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,
|
||||
android.R.id.text1,
|
||||
context.getResources().getStringArray(R.array.wifi_security)));
|
||||
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<String>(context,
|
||||
R.layout.wifi_setup_custom_list_item_1, android.R.id.text1,
|
||||
context.getResources().getStringArray(R.array.wifi_security_no_eap));
|
||||
mSecuritySpinner.setAdapter(adapter);
|
||||
} else {
|
||||
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));
|
||||
}
|
||||
|
||||
String[] type = resources.getStringArray(R.array.wifi_security);
|
||||
addRow(group, R.string.wifi_security, type[mAccessPoint.security]);
|
||||
addRow(group, R.string.wifi_security, mAccessPoint.getSecurityString(false));
|
||||
|
||||
int level = mAccessPoint.getLevel();
|
||||
if (level != -1) {
|
||||
|
@@ -511,6 +511,7 @@ public class WifiSettings extends SettingsPreferenceFragment
|
||||
for (AccessPoint accessPoint : accessPoints) {
|
||||
if (accessPoint.update(result)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
|
Reference in New Issue
Block a user