Use SearchIndexableData enable state for WiFi Settings

- same as for Bluetooth
- now the remembered WiFi networks names can be indexed when
WiFi is turned on

Change-Id: I904ce6a425c21ee07ce3ee8fdc0cd71ab5a18d12
This commit is contained in:
Fabrice Di Meglio
2014-03-21 13:50:25 -07:00
parent 51bfee595c
commit 5f3442af6f
2 changed files with 10 additions and 1 deletions

View File

@@ -33,6 +33,7 @@ import android.widget.Toast;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.WirelessSettings; import com.android.settings.WirelessSettings;
import com.android.settings.search.Index;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
@@ -136,6 +137,7 @@ public class WifiEnabler implements CompoundButton.OnCheckedChangeListener {
case WifiManager.WIFI_STATE_ENABLED: case WifiManager.WIFI_STATE_ENABLED:
setSwitchChecked(true); setSwitchChecked(true);
mSwitch.setEnabled(true); mSwitch.setEnabled(true);
updateSearchIndex(true);
break; break;
case WifiManager.WIFI_STATE_DISABLING: case WifiManager.WIFI_STATE_DISABLING:
mSwitch.setEnabled(false); mSwitch.setEnabled(false);
@@ -143,14 +145,20 @@ public class WifiEnabler implements CompoundButton.OnCheckedChangeListener {
case WifiManager.WIFI_STATE_DISABLED: case WifiManager.WIFI_STATE_DISABLED:
setSwitchChecked(false); setSwitchChecked(false);
mSwitch.setEnabled(true); mSwitch.setEnabled(true);
updateSearchIndex(false);
break; break;
default: default:
setSwitchChecked(false); setSwitchChecked(false);
mSwitch.setEnabled(true); mSwitch.setEnabled(true);
break; updateSearchIndex(false);
} }
} }
private void updateSearchIndex(boolean isWiFiOn) {
Index.getInstance(mContext).updateFromClassNameResource(
WifiSettings.class.getName(), isWiFiOn);
}
private void setSwitchChecked(boolean checked) { private void setSwitchChecked(boolean checked) {
if (checked != mSwitch.isChecked()) { if (checked != mSwitch.isChecked()) {
mStateMachineEvent = true; mStateMachineEvent = true;

View File

@@ -1195,6 +1195,7 @@ public class WifiSettings extends RestrictedSettingsFragment
data = new SearchIndexableRaw(context); data = new SearchIndexableRaw(context);
data.title = accessPoint.getTitle().toString(); data.title = accessPoint.getTitle().toString();
data.screenTitle = res.getString(R.string.wifi_settings); data.screenTitle = res.getString(R.string.wifi_settings);
data.enabled = enabled;
result.add(data); result.add(data);
} }