summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/bluetooth
diff options
context:
space:
mode:
authorFabrice Di Meglio <fdimeglio@google.com>2014-03-12 17:12:26 -0700
committerFabrice Di Meglio <fdimeglio@google.com>2014-03-20 14:02:42 -0700
commit5135dce1429facfd764f4afffe69d60c19589750 (patch)
tree2bd90588e95515377e3f85daf360a2adf88d0e86 /src/com/android/settings/bluetooth
parentb4f18b8d3bc8f104ba2c0913b1023883ebbcec66 (diff)
downloadpackages_apps_Settings-5135dce1429facfd764f4afffe69d60c19589750.tar.gz
packages_apps_Settings-5135dce1429facfd764f4afffe69d60c19589750.tar.bz2
packages_apps_Settings-5135dce1429facfd764f4afffe69d60c19589750.zip
Add indexing for cached Bluetooth (BT) paired devices
- comply to the SEARCH_INDEX_DATA_PROVIDER - add to the Index the name of previously paired BT devices (this will work for now only and only if BT has been on during the indexing) Change-Id: I00065db0f4e9657cca3578a2fafa0ec39cfaa432
Diffstat (limited to 'src/com/android/settings/bluetooth')
-rwxr-xr-xsrc/com/android/settings/bluetooth/BluetoothSettings.java49
1 files changed, 48 insertions, 1 deletions
diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java
index acd9dada7..35c9d6c35 100755
--- a/src/com/android/settings/bluetooth/BluetoothSettings.java
+++ b/src/com/android/settings/bluetooth/BluetoothSettings.java
@@ -26,11 +26,13 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.res.Resources;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceCategory;
import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
+import android.provider.SearchIndexableResource;
import android.util.Log;
import android.view.Gravity;
import android.view.Menu;
@@ -42,12 +44,19 @@ import android.widget.TextView;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
+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;
/**
* BluetoothSettings is the Settings screen for Bluetooth configuration and
* connection management.
*/
-public final class BluetoothSettings extends DeviceListPreferenceFragment {
+public final class BluetoothSettings extends DeviceListPreferenceFragment implements Indexable {
private static final String TAG = "BluetoothSettings";
private static final int MENU_ID_SCAN = Menu.FIRST;
@@ -410,4 +419,42 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment {
protected int getHelpResource() {
return R.string.help_url_bluetooth;
}
+
+ public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+ new SearchIndexProvider() {
+
+ @Override
+ public List<SearchIndexableResource> getXmlResourcesToIndex(Context context) {
+ return null;
+ }
+
+ @Override
+ public List<SearchIndexableRaw> getRawDataToIndex(Context context) {
+
+ final List<SearchIndexableRaw> result = new ArrayList<SearchIndexableRaw>();
+
+ final Resources res = context.getResources();
+
+ // 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);
+
+ // Add cached paired BT devices
+ LocalBluetoothManager lbtm = LocalBluetoothManager.getInstance(context);
+ Set<BluetoothDevice> bondedDevices =
+ lbtm.getBluetoothAdapter().getBondedDevices();
+
+ for (BluetoothDevice device : bondedDevices) {
+ data = new SearchIndexableRaw(context);
+ data.title = device.getName();
+ data.screenTitle = res.getString(R.string.bluetooth_settings);
+ result.add(data);
+ }
+
+ return result;
+ }
+ };
+
}