WifiSettings: tweak the order of calls to registerReceiver() to make the UI better.

This commit is contained in:
Chia-chi Yeh
2010-02-04 16:16:25 +08:00
parent a5a67306a4
commit 9dee8a96c5
2 changed files with 5 additions and 11 deletions

View File

@@ -58,18 +58,12 @@ public class WifiEnabler implements Preference.OnPreferenceChangeListener {
};
public WifiEnabler(Context context, CheckBoxPreference checkBox) {
this(context, (WifiManager) context.getSystemService(Context.WIFI_SERVICE),
checkBox);
}
public WifiEnabler(Context context, WifiManager wifiManager,
CheckBoxPreference checkBox) {
mContext = context;
mCheckBox = checkBox;
mWifiManager = wifiManager;
mOriginalSummary = checkBox.getSummary();
checkBox.setPersistent(false);
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
mIntentFilter = new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION);
// The order matters! We really should not depend on this. :(
mIntentFilter.addAction(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION);

View File

@@ -110,7 +110,7 @@ public class WifiSettings extends PreferenceActivity implements DialogInterface.
addPreferencesFromResource(R.xml.wifi_access_points);
} else {
addPreferencesFromResource(R.xml.wifi_settings);
mWifiEnabler = new WifiEnabler(this, mWifiManager,
mWifiEnabler = new WifiEnabler(this,
(CheckBoxPreference) findPreference("enable_wifi"));
mNotifyOpenNetworks =
(CheckBoxPreference) findPreference("notify_open_networks");
@@ -128,10 +128,10 @@ public class WifiSettings extends PreferenceActivity implements DialogInterface.
@Override
protected void onResume() {
super.onResume();
registerReceiver(mReceiver, mFilter);
if (mWifiEnabler != null) {
mWifiEnabler.resume();
}
registerReceiver(mReceiver, mFilter);
if (mKeyStoreNetworkId != -1 && KeyStore.getInstance().test() == KeyStore.NO_ERROR) {
connect(mKeyStoreNetworkId);
}
@@ -141,10 +141,10 @@ public class WifiSettings extends PreferenceActivity implements DialogInterface.
@Override
protected void onPause() {
super.onPause();
unregisterReceiver(mReceiver);
if (mWifiEnabler != null) {
mWifiEnabler.pause();
}
unregisterReceiver(mReceiver);
mScanner.pause();
if (mDialog != null) {
mDialog.dismiss();