Applied some minor UI changes (see below)

+ Changed wifi icons to teal
+ Removed “Secured with …” from network status
+ Added an empty state image above text when Wi-Fi is off
+ Removed Wi-Fi Direct and WPS Push button from overflow menu
+ Added Wi-Fi Direct and WPS Push button to Advance Activity
+ Input Password Dialog: Moved Signal Strength and Security to Advance
+ Input Password Dialog: Updated Password text to Material style

BugId: #15698824 #15702808
Change-Id: I542ab9aac2c098738330c92d9183d3907c4f0b38
This commit is contained in:
PauloftheWest
2014-06-18 11:20:24 -07:00
parent 0e6ffc429d
commit b4564c39b7
13 changed files with 168 additions and 114 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -148,6 +148,8 @@
style="@style/wifi_item" >
<TextView
style="@style/wifi_item_label"
android:textAppearance="@android:style/TextAppearance.Material.Body2"
android:textColor="?android:attr/colorAccent"
android:text="@string/wifi_password" />
<EditText android:id="@+id/password"

View File

@@ -1255,6 +1255,11 @@
<string name="wifi_display_listen_channel" translatable="false">Listen channel</string>
<!-- Wifi Display settings. The dropdown menu title for choosing operating channel during certification process. [CHAR LIMIT=40] -->
<string name="wifi_display_operating_channel" translatable="false">Operating channel</string>
<!-- Wifi 2.4GHz is used as an universal itendifier for 2.4GHz band -->
<string name="wifi_band_24ghz" translatable="false">2.4GHz</string>
<!-- Wifi Internal 5GHz as an universal itendifier for 5GHz band -->
<string name="wifi_band_5ghz" translatable="false">5GHz</string>
<!-- NFC settings -->
<!-- Used in the 1st-level settings screen to turn on NFC -->

View File

@@ -79,7 +79,7 @@
<item name="ic_menu_add">@drawable/ic_menu_add_dark</item>
<item name="ic_menu_moreoverflow">@*android:drawable/ic_menu_moreoverflow_holo_dark</item>
<item name="ic_wps">@drawable/ic_wps_dark</item>
<item name="wifi_signal">@drawable/wifi_signal_dark</item>
<item name="wifi_signal">@drawable/wifi_signal_light</item>
<item name="@*android:actionBarSize">@dimen/actionbar_size</item>

View File

@@ -58,6 +58,16 @@
android:title="@string/wifi_install_credentials"
android:persistent="false" />
<Preference
android:key="wifi_direct"
android:title="@string/wifi_menu_p2p"
android:persistent="false" />
<Preference
android:key="wps_push_button"
android:title="@string/wifi_menu_wps_pbc"
android:persistent="false" />
<CheckBoxPreference
android:key="suspend_optimizations"
android:title="@string/wifi_suspend_optimizations"

View File

@@ -39,6 +39,34 @@ import java.util.Map;
class AccessPoint extends Preference {
static final String TAG = "Settings.AccessPoint";
/**
* Lower bound on the 2.4 GHz (802.11b/g/n) WLAN channels
*/
public static final int LOWER_FREQ_24GHZ = 2400;
/**
* Upper bound on the 2.4 GHz (802.11b/g/n) WLAN channels
*/
public static final int HIGHER_FREQ_24GHZ = 2500;
/**
* Lower bound on the 5.0 GHz (802.11a/h/j/n/ac) WLAN channels
*/
public static final int LOWER_FREQ_5GHZ = 4900;
/**
* Upper bound on the 5.0 GHz (802.11a/h/j/n/ac) WLAN channels
*/
public static final int HIGHER_FREQ_5GHZ = 5900;
/** Experimental: we should be able to show the user the list of BSSIDs and bands
* for that SSID.
* For now this data is used only with Verbose Logging so as to show the band and number
* of BSSIDs on which that network is seen.
*/
public LruCache<String, ScanResult> mScanResultCache;
private static final String KEY_DETAILEDSTATE = "key_detailedstate";
private static final String KEY_WIFIINFO = "key_wifiinfo";
private static final String KEY_SCANRESULT = "key_scanresult";
@@ -83,19 +111,8 @@ class AccessPoint extends Preference {
private static final int VISIBILITY_MAX_AGE_IN_MILLI = 1000000;
private static final int VISIBILITY_OUTDATED_AGE_IN_MILLI = 20000;
private static final int LOWER_FREQ_24GHZ = 2400;
private static final int HIGHER_FREQ_24GHZ = 2500;
private static final int LOWER_FREQ_5GHZ = 4900;
private static final int HIGHER_FREQ_5GHZ = 5900;
private static final int SECOND_TO_MILLI = 1000;
/** Experiemental: we should be able to show the user the list of BSSIDs and bands
* for that SSID.
* For now this data is used only with Verbose Logging so as to show the band and number
* of BSSIDs on which that network is seen.
*/
public LruCache<String, ScanResult> scanResultCache;
static int getSecurity(WifiConfiguration config) {
if (config.allowedKeyManagement.get(KeyMgmt.WPA_PSK)) {
return SECURITY_PSK;
@@ -302,10 +319,10 @@ class AccessPoint extends Preference {
mSeen = result.seen;
}
if (WifiSettings.mVerboseLogging > 0) {
if (scanResultCache == null) {
scanResultCache = new LruCache<String, ScanResult>(32);
if (mScanResultCache == null) {
mScanResultCache = new LruCache<String, ScanResult>(32);
}
scanResultCache.put(result.BSSID, result);
mScanResultCache.put(result.BSSID, result);
}
if (ssid.equals(result.SSID) && security == getSecurity(result)) {
@@ -408,12 +425,12 @@ class AccessPoint extends Preference {
visibility.append(String.format("rx=%.1f", mInfo.rxSuccessRate));
}
if (scanResultCache != null) {
if (mScanResultCache != null) {
int rssi5 = WifiConfiguration.INVALID_RSSI;
int rssi24 = WifiConfiguration.INVALID_RSSI;
int num5 = 0;
int num24 = 0;
Map<String, ScanResult> list = scanResultCache.snapshot();
Map<String, ScanResult> list = mScanResultCache.snapshot();
for (ScanResult result : list.values()) {
if (result.seen == 0)
continue;
@@ -517,16 +534,8 @@ class AccessPoint extends Preference {
} else {
securityStrFormat = context.getString(R.string.wifi_secured_second_item);
}
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));
}
}
}
if (WifiSettings.mVerboseLogging > 0) {
//add RSSI/band information for this config, what was seen up to 6 seconds ago

View File

@@ -22,10 +22,12 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.net.wifi.WpsInfo;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceScreen;
import android.provider.Settings;
import android.provider.Settings.Global;
@@ -50,6 +52,8 @@ public class AdvancedWifiSettings extends SettingsPreferenceFragment
private static final String KEY_POOR_NETWORK_DETECTION = "wifi_poor_network_detection";
private static final String KEY_SCAN_ALWAYS_AVAILABLE = "wifi_scan_always_available";
private static final String KEY_INSTALL_CREDENTIALS = "install_credentials";
private static final String KEY_WIFI_DIRECT = "wifi_direct";
private static final String KEY_WPS_PUSH = "wps_push_button";
private static final String KEY_SUSPEND_OPTIMIZATIONS = "suspend_optimizations";
private WifiManager mWifiManager;
@@ -121,13 +125,28 @@ public class AdvancedWifiSettings extends SettingsPreferenceFragment
scanAlwaysAvailable.setChecked(Global.getInt(getContentResolver(),
Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0) == 1);
Intent intent=new Intent(Credentials.INSTALL_AS_USER_ACTION);
Intent intent = new Intent(Credentials.INSTALL_AS_USER_ACTION);
intent.setClassName("com.android.certinstaller",
"com.android.certinstaller.CertInstallerMain");
intent.putExtra(Credentials.EXTRA_INSTALL_AS_UID, android.os.Process.WIFI_UID);
Preference pref = findPreference(KEY_INSTALL_CREDENTIALS);
pref.setIntent(intent);
Intent wifiDirectIntent = new Intent(getActivity(),
com.android.settings.Settings.WifiP2pSettingsActivity.class);
Preference wifiDirectPref = findPreference(KEY_WIFI_DIRECT);
wifiDirectPref.setIntent(wifiDirectIntent);
// WpsDialog: Create the dialog like WifiSettings does.
Preference wpsPushPref = findPreference(KEY_WPS_PUSH);
wpsPushPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference arg0) {
WpsDialog wpsDialog = new WpsDialog(getActivity(), WpsInfo.PBC);
wpsDialog.show();
return true;
}
});
CheckBoxPreference suspendOptimizations =
(CheckBoxPreference) findPreference(KEY_SUSPEND_OPTIMIZATIONS);
suspendOptimizations.setChecked(Global.getInt(getContentResolver(),

View File

@@ -69,36 +69,12 @@ import java.util.Iterator;
*/
public class WifiConfigController implements TextWatcher,
AdapterView.OnItemSelectedListener, OnCheckedChangeListener {
private static final String TAG = "WifiConfigController";
private final WifiConfigUiBase mConfigUi;
private final View mView;
private final AccessPoint mAccessPoint;
private boolean mEdit;
private TextView mSsidView;
// e.g. AccessPoint.SECURITY_NONE
private int mAccessPointSecurity;
private TextView mPasswordView;
private String unspecifiedCert = "unspecified";
private static final int unspecifiedCertIndex = 0;
/* Phase2 methods supported by PEAP are limited */
private final ArrayAdapter<String> PHASE2_PEAP_ADAPTER;
/* Full list of phase2 methods */
private final ArrayAdapter<String> PHASE2_FULL_ADAPTER;
private Spinner mSecuritySpinner;
private Spinner mEapMethodSpinner;
private Spinner mEapCaCertSpinner;
private Spinner mPhase2Spinner;
// Associated with mPhase2Spinner, one of PHASE2_FULL_ADAPTER or PHASE2_PEAP_ADAPTER
private ArrayAdapter<String> mPhase2Adapter;
private Spinner mEapUserCertSpinner;
private TextView mEapIdentityView;
private TextView mEapAnonymousView;
/* This value comes from "wifi_ip_settings" resource array */
private static final int DHCP = 0;
private static final int STATIC_IP = 1;
@@ -119,7 +95,32 @@ public class WifiConfigController implements TextWatcher,
public static final int WIFI_PEAP_PHASE2_MSCHAPV2 = 1;
public static final int WIFI_PEAP_PHASE2_GTC = 2;
private static final String TAG = "WifiConfigController";
/* Phase2 methods supported by PEAP are limited */
private final ArrayAdapter<String> PHASE2_PEAP_ADAPTER;
/* Full list of phase2 methods */
private final ArrayAdapter<String> PHASE2_FULL_ADAPTER;
// True when this instance is used in SetupWizard XL context.
private final boolean mInXlSetupWizard;
private final Handler mTextViewChangedHandler;
// e.g. AccessPoint.SECURITY_NONE
private int mAccessPointSecurity;
private TextView mPasswordView;
private String unspecifiedCert = "unspecified";
private static final int unspecifiedCertIndex = 0;
private Spinner mSecuritySpinner;
private Spinner mEapMethodSpinner;
private Spinner mEapCaCertSpinner;
private Spinner mPhase2Spinner;
// Associated with mPhase2Spinner, one of PHASE2_FULL_ADAPTER or PHASE2_PEAP_ADAPTER
private ArrayAdapter<String> mPhase2Adapter;
private Spinner mEapUserCertSpinner;
private TextView mEapIdentityView;
private TextView mEapAnonymousView;
private Spinner mIpSettingsSpinner;
private TextView mIpAddressView;
@@ -138,10 +139,11 @@ public class WifiConfigController implements TextWatcher,
private ProxySettings mProxySettings = ProxySettings.UNASSIGNED;
private LinkProperties mLinkProperties = new LinkProperties();
// True when this instance is used in SetupWizard XL context.
private final boolean mInXlSetupWizard;
private String[] mLevels;
private boolean mEdit;
private TextView mSsidView;
private final Handler mTextViewChangedHandler;
private Context mContext;
public WifiConfigController(
WifiConfigUiBase parent, View view, AccessPoint accessPoint, boolean edit) {
@@ -155,20 +157,21 @@ public class WifiConfigController implements TextWatcher,
mEdit = edit;
mTextViewChangedHandler = new Handler();
final Context context = mConfigUi.getContext();
final Resources resources = context.getResources();
mContext = mConfigUi.getContext();
final Resources res = mContext.getResources();
mLevels = res.getStringArray(R.array.wifi_signal);
PHASE2_PEAP_ADAPTER = new ArrayAdapter<String>(
context, android.R.layout.simple_spinner_item,
context.getResources().getStringArray(R.array.wifi_peap_phase2_entries));
mContext, android.R.layout.simple_spinner_item,
res.getStringArray(R.array.wifi_peap_phase2_entries));
PHASE2_PEAP_ADAPTER.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
PHASE2_FULL_ADAPTER = new ArrayAdapter<String>(
context, android.R.layout.simple_spinner_item,
context.getResources().getStringArray(R.array.wifi_phase2_entries));
mContext, android.R.layout.simple_spinner_item,
res.getStringArray(R.array.wifi_phase2_entries));
PHASE2_FULL_ADAPTER.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
unspecifiedCert = context.getString(R.string.wifi_unspecified);
unspecifiedCert = mContext.getString(R.string.wifi_unspecified);
mIpSettingsSpinner = (Spinner) mView.findViewById(R.id.ip_settings);
mIpSettingsSpinner.setOnItemSelectedListener(this);
mProxySettingsSpinner = (Spinner) mView.findViewById(R.id.proxy_settings);
@@ -186,9 +189,9 @@ public class WifiConfigController implements TextWatcher,
mView.findViewById(R.id.type_security).setVisibility(View.VISIBLE);
// We want custom layout. The content must be same as the other cases.
ArrayAdapter<String> adapter = new ArrayAdapter<String>(context,
ArrayAdapter<String> adapter = new ArrayAdapter<String>(mContext,
R.layout.wifi_setup_custom_list_item_1, android.R.id.text1,
context.getResources().getStringArray(R.array.wifi_security_no_eap));
res.getStringArray(R.array.wifi_security_no_eap));
mSecuritySpinner.setAdapter(adapter);
} else {
mView.findViewById(R.id.type).setVisibility(View.VISIBLE);
@@ -201,46 +204,12 @@ public class WifiConfigController implements TextWatcher,
.setOnCheckedChangeListener(this);
mConfigUi.setSubmitButton(context.getString(R.string.wifi_save));
mConfigUi.setSubmitButton(res.getString(R.string.wifi_save));
} else {
mConfigUi.setTitle(mAccessPoint.ssid);
ViewGroup group = (ViewGroup) mView.findViewById(R.id.info);
DetailedState state = mAccessPoint.getState();
if (state != null) {
addRow(group, R.string.wifi_status, Summary.get(mConfigUi.getContext(), state));
}
int level = mAccessPoint.getLevel();
if (level != -1) {
String[] signal = resources.getStringArray(R.array.wifi_signal);
addRow(group, R.string.wifi_signal, signal[level]);
}
WifiInfo info = mAccessPoint.getInfo();
if (info != null && info.getLinkSpeed() != -1) {
addRow(group, R.string.wifi_speed, info.getLinkSpeed() + WifiInfo.LINK_SPEED_UNITS);
}
if (info != null && info.getFrequency() != -1) {
// Since the frequency is defined on MHz, we need to simplify it
// to just 2.4GHz (regardless of the locale) or 5GHz.
int frequency = info.getFrequency();
String band = null;
if (frequency >= 2400 && frequency < 2500) {
band = "2.4GHz";
} else if (frequency >= 5000 && frequency < 6000) {
band = "5GHz";
} else {
Log.e(TAG, "Unexpected frequency " + frequency);
}
if (band != null) {
addRow(group, R.string.wifi_frequency, band);
}
}
addRow(group, R.string.wifi_security, mAccessPoint.getSecurityString(false));
boolean showAdvancedFields = false;
if (mAccessPoint.networkId != INVALID_NETWORK_ID) {
WifiConfiguration config = mAccessPoint.getConfig();
@@ -281,21 +250,62 @@ public class WifiConfigController implements TextWatcher,
}
if (mEdit) {
mConfigUi.setSubmitButton(context.getString(R.string.wifi_save));
mConfigUi.setSubmitButton(res.getString(R.string.wifi_save));
} else {
if (state == null && level != -1) {
mConfigUi.setSubmitButton(context.getString(R.string.wifi_connect));
final DetailedState state = mAccessPoint.getState();
final String signalLevel = getSignalString();
if (state == null && signalLevel != null) {
mConfigUi.setSubmitButton(res.getString(R.string.wifi_connect));
} else {
if (state != null) {
addRow(group, R.string.wifi_status, Summary.get(mConfigUi.getContext(),
state));
}
if (signalLevel != null) {
addRow(group, R.string.wifi_signal, signalLevel);
}
WifiInfo info = mAccessPoint.getInfo();
if (info != null && info.getLinkSpeed() != -1) {
addRow(group, R.string.wifi_speed, info.getLinkSpeed()
+ WifiInfo.LINK_SPEED_UNITS);
}
if (info != null && info.getFrequency() != -1) {
final int frequency = info.getFrequency();
String band = null;
if (frequency >= AccessPoint.LOWER_FREQ_24GHZ
&& frequency < AccessPoint.HIGHER_FREQ_24GHZ) {
band = res.getString(R.string.wifi_band_24ghz);
} else if (frequency >= AccessPoint.LOWER_FREQ_5GHZ
&& frequency < AccessPoint.HIGHER_FREQ_5GHZ) {
band = res.getString(R.string.wifi_band_5ghz);
} else {
Log.e(TAG, "Unexpected frequency " + frequency);
}
if (band != null) {
addRow(group, R.string.wifi_frequency, band);
}
}
addRow(group, R.string.wifi_security, mAccessPoint.getSecurityString(false));
mView.findViewById(R.id.ip_fields).setVisibility(View.GONE);
}
if (mAccessPoint.networkId != INVALID_NETWORK_ID) {
mConfigUi.setForgetButton(context.getString(R.string.wifi_forget));
mConfigUi.setForgetButton(res.getString(R.string.wifi_forget));
}
}
}
mConfigUi.setCancelButton(context.getString(R.string.wifi_cancel));
if (mEdit || (mAccessPoint.getState() == null && mAccessPoint.getLevel() != -1)){
mConfigUi.setCancelButton(res.getString(R.string.wifi_cancel));
}else{
mConfigUi.setCancelButton(res.getString(R.string.wifi_display_options_done));
}
if (mConfigUi.getSubmitButton() != null) {
enableSubmitIfAppropriate();
}
@@ -308,6 +318,12 @@ public class WifiConfigController implements TextWatcher,
group.addView(row);
}
private String getSignalString(){
final int level = mAccessPoint.getLevel();
return (level > -1 && level < mLevels.length) ? mLevels[level] : null;
}
/* show submit button if password, ip and proxy settings are valid */
void enableSubmitIfAppropriate() {
Button submit = mConfigUi.getSubmitButton();

View File

@@ -317,10 +317,6 @@ public class WifiSettings extends RestrictedSettingsFragment
final boolean wifiIsEnabled = mWifiManager.isWifiEnabled();
TypedArray ta = getActivity().getTheme().obtainStyledAttributes(
new int[] {R.attr.ic_menu_add, R.attr.ic_wps});
menu.add(Menu.NONE, MENU_ID_WPS_PBC, 0, R.string.wifi_menu_wps_pbc)
.setIcon(ta.getDrawable(1))
.setEnabled(wifiIsEnabled)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
menu.add(Menu.NONE, MENU_ID_ADD_NETWORK, 0, R.string.wifi_add_network)
.setIcon(ta.getDrawable(0))
.setEnabled(wifiIsEnabled)
@@ -332,11 +328,6 @@ public class WifiSettings extends RestrictedSettingsFragment
menu.add(Menu.NONE, MENU_ID_WPS_PIN, 0, R.string.wifi_menu_wps_pin)
.setEnabled(wifiIsEnabled)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
if (mP2pSupported) {
menu.add(Menu.NONE, MENU_ID_P2P, 0, R.string.wifi_menu_p2p)
.setEnabled(wifiIsEnabled)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
}
menu.add(Menu.NONE, MENU_ID_ADVANCED, 0, R.string.wifi_menu_advanced)
//.setIcon(android.R.drawable.ic_menu_manage)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
@@ -579,6 +570,8 @@ public class WifiSettings extends RestrictedSettingsFragment
private void setOffMessage() {
if (mEmptyView != null) {
mEmptyView.setCompoundDrawablesWithIntrinsicBounds(0,
R.drawable.ic_wifi_emptystate, 0, 0);
mEmptyView.setText(R.string.wifi_empty_list_wifi_off);
if (android.provider.Settings.Global.getInt(getActivity().getContentResolver(),
android.provider.Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0) == 1) {