diff options
author | Fabrice Di Meglio <fdimeglio@google.com> | 2014-03-20 19:52:29 -0700 |
---|---|---|
committer | Fabrice Di Meglio <fdimeglio@google.com> | 2014-03-20 20:40:04 -0700 |
commit | 51bfee595c3ce587e2e26565fd9e8f4ae02c3482 (patch) | |
tree | 14a4ccf78d5db613c2ae7f9e4f8c2672e8f49f43 /src/com/android/settings/bluetooth | |
parent | 30eb2d3dd1b5a51b02516975e497827ad817ec11 (diff) | |
download | packages_apps_Settings-51bfee595c3ce587e2e26565fd9e8f4ae02c3482.tar.gz packages_apps_Settings-51bfee595c3ce587e2e26565fd9e8f4ae02c3482.tar.bz2 packages_apps_Settings-51bfee595c3ce587e2e26565fd9e8f4ae02c3482.zip |
Add dynamic Preferences indexing (part 2)
- change the Index SQL model. Add a new "enabled" column.
- use that column for issuing a more restrictive search query
- change the SearchIndexProvider API to pass the "enable" state
- apply it to Bluetooth settings
- refactor the list of indexable resources (SearchIndexableResources)
Change-Id: Ic900fb27cb12a285a80d953aa1aa88f0070cd986
Diffstat (limited to 'src/com/android/settings/bluetooth')
-rw-r--r-- | src/com/android/settings/bluetooth/BluetoothEnabler.java | 9 | ||||
-rwxr-xr-x | src/com/android/settings/bluetooth/BluetoothSettings.java | 57 |
2 files changed, 38 insertions, 28 deletions
diff --git a/src/com/android/settings/bluetooth/BluetoothEnabler.java b/src/com/android/settings/bluetooth/BluetoothEnabler.java index 1a450d441..bbf5fcc1c 100644 --- a/src/com/android/settings/bluetooth/BluetoothEnabler.java +++ b/src/com/android/settings/bluetooth/BluetoothEnabler.java @@ -28,6 +28,7 @@ import android.widget.Toast; import com.android.settings.R; import com.android.settings.WirelessSettings; +import com.android.settings.search.Index; /** * BluetoothEnabler is a helper to manage the Bluetooth on/off checkbox @@ -132,6 +133,7 @@ public final class BluetoothEnabler implements CompoundButton.OnCheckedChangeLis case BluetoothAdapter.STATE_ON: setChecked(true); mSwitch.setEnabled(true); + updateSearchIndex(true); break; case BluetoothAdapter.STATE_TURNING_OFF: mSwitch.setEnabled(false); @@ -139,10 +141,12 @@ public final class BluetoothEnabler implements CompoundButton.OnCheckedChangeLis case BluetoothAdapter.STATE_OFF: setChecked(false); mSwitch.setEnabled(true); + updateSearchIndex(false); break; default: setChecked(false); mSwitch.setEnabled(true); + updateSearchIndex(false); } } @@ -159,4 +163,9 @@ public final class BluetoothEnabler implements CompoundButton.OnCheckedChangeLis } } } + + private void updateSearchIndex(boolean isBluetoothOn) { + Index.getInstance(mContext).updateFromClassNameResource( + BluetoothSettings.class.getName(), isBluetoothOn); + } } diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java index 35c9d6c35..cc0371fa5 100755 --- a/src/com/android/settings/bluetooth/BluetoothSettings.java +++ b/src/com/android/settings/bluetooth/BluetoothSettings.java @@ -48,7 +48,6 @@ import com.android.settings.search.Indexable; import com.android.settings.search.SearchIndexableRaw; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.Set; @@ -421,40 +420,42 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem } public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = - new SearchIndexProvider() { + new SearchIndexProvider() { - @Override - public List<SearchIndexableResource> getXmlResourcesToIndex(Context context) { - return null; - } - - @Override - public List<SearchIndexableRaw> getRawDataToIndex(Context context) { + @Override + public List<SearchIndexableResource> getXmlResourcesToIndex( + Context context, boolean enabled) { + return null; + } - final List<SearchIndexableRaw> result = new ArrayList<SearchIndexableRaw>(); + @Override + public List<SearchIndexableRaw> getRawDataToIndex(Context context, boolean enabled) { - final Resources res = context.getResources(); + final List<SearchIndexableRaw> result = new ArrayList<SearchIndexableRaw>(); - // Add fragment title - SearchIndexableRaw data = new SearchIndexableRaw(context); - data.title = res.getString(R.string.bluetooth_settings); - data.screenTitle = res.getString(R.string.bluetooth_settings); - result.add(data); + final Resources res = context.getResources(); - // Add cached paired BT devices - LocalBluetoothManager lbtm = LocalBluetoothManager.getInstance(context); - Set<BluetoothDevice> bondedDevices = - lbtm.getBluetoothAdapter().getBondedDevices(); + // Add fragment title + SearchIndexableRaw data = new SearchIndexableRaw(context); + data.title = res.getString(R.string.bluetooth_settings); + data.screenTitle = res.getString(R.string.bluetooth_settings); + result.add(data); - for (BluetoothDevice device : bondedDevices) { - data = new SearchIndexableRaw(context); - data.title = device.getName(); - data.screenTitle = res.getString(R.string.bluetooth_settings); - result.add(data); - } + // Add cached paired BT devices + LocalBluetoothManager lbtm = LocalBluetoothManager.getInstance(context); + Set<BluetoothDevice> bondedDevices = + lbtm.getBluetoothAdapter().getBondedDevices(); - return result; + for (BluetoothDevice device : bondedDevices) { + data = new SearchIndexableRaw(context); + data.title = device.getName(); + data.screenTitle = res.getString(R.string.bluetooth_settings); + data.enabled = enabled; + result.add(data); } - }; + + return result; + } + }; } |