Add indexing for Notifications preferences

- also add indexing of CheckBoxPreferences
- also some code cleaning

Change-Id: I2943caaec3d64fb2a6be85168454fc76fe572afe
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index c2b01cf..206865f 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -386,16 +386,13 @@
         // Cache the search query (can be overriden by the OnQueryTextListener)
         final String query = mSearchQuery;
 
-        // Associate searchable configuration with the SearchView
-        SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
-        mSearchView = (SearchView) menu.findItem(R.id.search).getActionView();
+        mSearchMenuItem = menu.findItem(R.id.search);
+        mSearchView = (SearchView) mSearchMenuItem.getActionView();
 
+        mSearchMenuItem.setOnActionExpandListener(this);
         mSearchView.setOnQueryTextListener(this);
         mSearchView.setOnCloseListener(this);
 
-        mSearchMenuItem = menu.findItem(R.id.search);
-        mSearchMenuItem.setOnActionExpandListener(this);
-
         if (mSearchMenuItemExpanded) {
             mSearchMenuItem.expandActionView();
         }
diff --git a/src/com/android/settings/dashboard/SearchResultsSummary.java b/src/com/android/settings/dashboard/SearchResultsSummary.java
index 992bb59..41d8609 100644
--- a/src/com/android/settings/dashboard/SearchResultsSummary.java
+++ b/src/com/android/settings/dashboard/SearchResultsSummary.java
@@ -195,14 +195,17 @@
 
     private static class SearchResult {
         public String title;
-        public String summary;
+        public String summaryOn;
+        public String summaryOff;
         public int iconResId;
         public Context context;
 
-        public SearchResult(Context context, String title, String summary, int iconResId) {
+        public SearchResult(Context context, String title, String summaryOn, String summaryOff,
+                int iconResId) {
             this.context = context;
             this.title = title;
-            this.summary = summary;
+            this.summaryOn = summaryOn;
+            this.summaryOff = summaryOff;
             this.iconResId = iconResId;
         }
     }
@@ -247,7 +250,8 @@
         public Object getItem(int position) {
             if (mDataValid && mCursor.moveToPosition(position)) {
                 final String title = mCursor.getString(Index.COLUMN_INDEX_TITLE);
-                final String summary = mCursor.getString(Index.COLUMN_INDEX_SUMMARY);
+                final String summaryOn = mCursor.getString(Index.COLUMN_INDEX_SUMMARY_ON);
+                final String summaryOff = mCursor.getString(Index.COLUMN_INDEX_SUMMARY_OFF);
                 final String iconResStr = mCursor.getString(Index.COLUMN_INDEX_ICON);
                 final String className = mCursor.getString(
                         Index.COLUMN_INDEX_CLASS_NAME);
@@ -271,7 +275,7 @@
                 }
                 final int iconResId = TextUtils.isEmpty(iconResStr) ?
                         R.drawable.empty_icon : Integer.parseInt(iconResStr);
-                return new SearchResult(packageContext, title, summary, iconResId);
+                return new SearchResult(packageContext, title, summaryOn, summaryOff, iconResId);
             }
             return null;
         }
@@ -308,7 +312,12 @@
             SearchResult result = (SearchResult) getItem(position);
 
             textTitle.setText(result.title);
-            textSummary.setText(result.summary);
+            final StringBuilder sb = new StringBuilder(result.summaryOn);
+            if (!TextUtils.isEmpty(result.summaryOff)) {
+                sb.append(" | ");
+                sb.append(result.summaryOff);
+            }
+            textSummary.setText(sb.toString());
             if (result.iconResId != R.drawable.empty_icon) {
                 final Context packageContext = result.context;
                 final Drawable drawable;
diff --git a/src/com/android/settings/search/Index.java b/src/com/android/settings/search/Index.java
index 6ac5196..bfeedc9 100644
--- a/src/com/android/settings/search/Index.java
+++ b/src/com/android/settings/search/Index.java
@@ -58,34 +58,39 @@
 
     // Those indices should match the indices of SELECT_COLUMNS !
     public static final int COLUMN_INDEX_TITLE = 1;
-    public static final int COLUMN_INDEX_SUMMARY = 2;
-    public static final int COLUMN_INDEX_CLASS_NAME = 4;
-    public static final int COLUMN_INDEX_SCREEN_TITLE = 5;
-    public static final int COLUMN_INDEX_ICON = 6;
-    public static final int COLUMN_INDEX_INTENT_ACTION = 7;
-    public static final int COLUMN_INDEX_INTENT_ACTION_TARGET_PACKAGE = 8;
-    public static final int COLUMN_INDEX_INTENT_ACTION_TARGET_CLASS = 9;
-    public static final int COLUMN_INDEX_ENABLED = 10;
+    public static final int COLUMN_INDEX_SUMMARY_ON = 2;
+    public static final int COLUMN_INDEX_SUMMARY_OFF = 3;
+    public static final int COLUMN_INDEX_KEYWORDS = 4;
+    public static final int COLUMN_INDEX_CLASS_NAME = 5;
+    public static final int COLUMN_INDEX_SCREEN_TITLE = 6;
+    public static final int COLUMN_INDEX_ICON = 7;
+    public static final int COLUMN_INDEX_INTENT_ACTION = 8;
+    public static final int COLUMN_INDEX_INTENT_ACTION_TARGET_PACKAGE = 9;
+    public static final int COLUMN_INDEX_INTENT_ACTION_TARGET_CLASS = 10;
+    public static final int COLUMN_INDEX_ENABLED = 11;
 
     // If you change the order of columns here, you SHOULD change the COLUMN_INDEX_XXX values
     private static final String[] SELECT_COLUMNS = new String[] {
-            IndexColumns.DATA_RANK,
-            IndexColumns.DATA_TITLE,
-            IndexColumns.DATA_SUMMARY,
-            IndexColumns.DATA_KEYWORDS,
-            IndexColumns.CLASS_NAME,
-            IndexColumns.SCREEN_TITLE,
-            IndexColumns.ICON,
-            IndexColumns.INTENT_ACTION,
-            IndexColumns.INTENT_TARGET_PACKAGE,
-            IndexColumns.INTENT_TARGET_CLASS
+            IndexColumns.DATA_RANK,               // 0
+            IndexColumns.DATA_TITLE,              // 1
+            IndexColumns.DATA_SUMMARY_ON,         // 2
+            IndexColumns.DATA_SUMMARY_OFF,        // 3
+            IndexColumns.DATA_KEYWORDS,           // 4
+            IndexColumns.CLASS_NAME,              // 5
+            IndexColumns.SCREEN_TITLE,            // 6
+            IndexColumns.ICON,                    // 7
+            IndexColumns.INTENT_ACTION,           // 8
+            IndexColumns.INTENT_TARGET_PACKAGE,   // 9
+            IndexColumns.INTENT_TARGET_CLASS      // 10
     };
 
     private static final String[] MATCH_COLUMNS = {
             IndexColumns.DATA_TITLE,
             IndexColumns.DATA_TITLE_NORMALIZED,
-            IndexColumns.DATA_SUMMARY,
-            IndexColumns.DATA_SUMMARY_NORMALIZED,
+            IndexColumns.DATA_SUMMARY_ON,
+            IndexColumns.DATA_SUMMARY_ON_NORMALIZED,
+            IndexColumns.DATA_SUMMARY_OFF,
+            IndexColumns.DATA_SUMMARY_OFF_NORMALIZED,
             IndexColumns.DATA_KEYWORDS
     };
 
@@ -93,6 +98,12 @@
     private static final String NON_BREAKING_HYPHEN = "\u2011";
     private static final String HYPHEN = "-";
 
+    private static final String FIELD_NAME_SEARCH_INDEX_DATA_PROVIDER =
+            "SEARCH_INDEX_DATA_PROVIDER";
+
+    private static final String NODE_NAME_PREFERENCE_SCREEN = "PreferenceScreen";
+    private static final String NODE_NAME_CHECK_BOX_PREFERENCE = "CheckBoxPreference";
+
     private static Index sInstance;
     private final AtomicBoolean mIsAvailable = new AtomicBoolean(false);
     private final UpdateData mDataToProcess = new UpdateData();
@@ -335,22 +346,24 @@
                 while (cursor.moveToNext()) {
                     final int rank = cursor.getInt(0);
                     final String title = cursor.getString(1);
-                    final String summary = cursor.getString(2);
-                    final String keywords = cursor.getString(3);
+                    final String summaryOn = cursor.getString(2);
+                    final String summaryOff = cursor.getString(3);
+                    final String keywords = cursor.getString(4);
 
-                    final String screenTitle = cursor.getString(4);
+                    final String screenTitle = cursor.getString(5);
 
-                    final String className = cursor.getString(5);
-                    final int iconResId = cursor.getInt(6);
+                    final String className = cursor.getString(6);
+                    final int iconResId = cursor.getInt(7);
 
-                    final String action = cursor.getString(7);
-                    final String targetPackage = cursor.getString(8);
-                    final String targetClass = cursor.getString(9);
+                    final String action = cursor.getString(8);
+                    final String targetPackage = cursor.getString(9);
+                    final String targetClass = cursor.getString(10);
 
                     SearchIndexableRaw data = new SearchIndexableRaw(packageContext);
                     data.rank = rank;
                     data.title = title;
-                    data.summary = summary;
+                    data.summaryOn = summaryOn;
+                    data.summaryOff = summaryOff;
                     data.keywords = keywords;
                     data.screenTitle = screenTitle;
                     data.className = className;
@@ -458,7 +471,7 @@
             }
 
             String nodeName = parser.getName();
-            if (!"PreferenceScreen".equals(nodeName)) {
+            if (!NODE_NAME_PREFERENCE_SCREEN.equals(nodeName)) {
                 throw new RuntimeException(
                         "XML document must start with <PreferenceScreen> tag; found"
                                 + nodeName + " at " + parser.getPositionDescription());
@@ -474,7 +487,7 @@
 
             // Insert rows for the main PreferenceScreen node. Rewrite the data for removing
             // hyphens.
-            updateOneRowWithFilteredData(database, localeStr, title, summary, fragmentName,
+            updateOneRowWithFilteredData(database, localeStr, title, summary, null, fragmentName,
                     screenTitle, iconResId, rank, keywords,
                     intentAction, intentTargetPackage, intentTargetClass, true);
 
@@ -484,14 +497,26 @@
                     continue;
                 }
 
+                nodeName = parser.getName();
+
                 title = getDataTitle(context, attrs);
-                summary = getDataSummary(context, attrs);
                 keywords = getDataKeywords(context, attrs);
 
-                // Insert rows for the child nodes of PreferenceScreen
-                updateOneRowWithFilteredData(database, localeStr, title, summary, fragmentName,
-                        screenTitle, iconResId, rank, keywords,
-                        intentAction, intentTargetPackage, intentTargetClass, true);
+                if (!nodeName.equals(NODE_NAME_CHECK_BOX_PREFERENCE)) {
+                    summary = getDataSummary(context, attrs);
+
+                    // Insert rows for the child nodes of PreferenceScreen
+                    updateOneRowWithFilteredData(database, localeStr, title, summary, null,
+                            fragmentName, screenTitle, iconResId, rank, keywords,
+                            intentAction, intentTargetPackage, intentTargetClass, true);
+                } else {
+                    final String summaryOn = getDataSummaryOn(context, attrs);
+                    final String summaryOff = getDataSummaryOff(context, attrs);
+
+                    updateOneRowWithFilteredData(database, localeStr, title, summaryOn, summaryOff,
+                            fragmentName, screenTitle, iconResId, rank, keywords,
+                            intentAction, intentTargetPackage, intentTargetClass, true);
+                }
             }
 
         } catch (XmlPullParserException e) {
@@ -512,7 +537,8 @@
 
         updateOneRowWithFilteredData(database, localeStr,
                 raw.title,
-                raw.summary,
+                raw.summaryOn,
+                raw.summaryOff,
                 raw.className,
                 raw.screenTitle,
                 raw.iconResId,
@@ -529,7 +555,7 @@
         try {
             final Class<?> clazz = Class.forName(sir.className);
             if (Indexable.class.isAssignableFrom(clazz)) {
-                final Field f = clazz.getField("SEARCH_INDEX_DATA_PROVIDER");
+                final Field f = clazz.getField(FIELD_NAME_SEARCH_INDEX_DATA_PROVIDER);
                 final Indexable.SearchIndexProvider provider =
                         (Indexable.SearchIndexProvider) f.get(null);
 
@@ -547,7 +573,8 @@
 
                         updateOneRowWithFilteredData(database, localeStr,
                                 raw.title,
-                                raw.summary,
+                                raw.summaryOn,
+                                raw.summaryOff,
                                 sir.className,
                                 raw.screenTitle,
                                 sir.iconResId,
@@ -582,14 +609,15 @@
         } catch (ClassNotFoundException e) {
             Log.e(LOG_TAG, "Cannot find class: " + sir.className, e);
         } catch (NoSuchFieldException e) {
-            Log.e(LOG_TAG, "Cannot find field 'SEARCH_INDEX_DATA_PROVIDER'", e);
+            Log.e(LOG_TAG, "Cannot find field '" + FIELD_NAME_SEARCH_INDEX_DATA_PROVIDER + "'", e);
         } catch (IllegalAccessException e) {
-            Log.e(LOG_TAG, "Illegal access to field 'SEARCH_INDEX_DATA_PROVIDER'", e);
+            Log.e(LOG_TAG,
+                    "Illegal access to field '" + FIELD_NAME_SEARCH_INDEX_DATA_PROVIDER + "'", e);
         }
     }
 
     private void updateOneRowWithFilteredData(SQLiteDatabase database, String locale,
-            String title, String summary, String className, String screenTitle,
+            String title, String summaryOn, String summaryOff, String className, String screenTitle,
             int iconResId, int rank, String keywords,
             String intentAction, String intentTargetPackage, String intentTargetClass,
             boolean enabled) {
@@ -602,27 +630,35 @@
             updatedTitle = EMPTY;
         }
 
-        String updatedSummary;
-        if (summary != null) {
-            updatedSummary = summary.replaceAll(NON_BREAKING_HYPHEN, HYPHEN);
+        String updatedSummaryOn;
+        if (summaryOn != null) {
+            updatedSummaryOn = summaryOn.replaceAll(NON_BREAKING_HYPHEN, HYPHEN);
         } else {
-            updatedSummary = EMPTY;
+            updatedSummaryOn = EMPTY;
+        }
+
+        String updatedSummaryOff;
+        if (summaryOff != null) {
+            updatedSummaryOff = summaryOff.replaceAll(NON_BREAKING_HYPHEN, HYPHEN);
+        } else {
+            updatedSummaryOff = EMPTY;
         }
 
         String normalizedTitle = updatedTitle.replaceAll(HYPHEN, EMPTY);
-        String normalizedSummary = updatedSummary.replaceAll(HYPHEN, EMPTY);
+        String normalizedSummaryOn = updatedSummaryOn.replaceAll(HYPHEN, EMPTY);
+        String normalizedSummaryOff = updatedSummaryOff.replaceAll(HYPHEN, EMPTY);
 
         updateOneRow(database, locale,
-                updatedTitle, normalizedTitle, updatedSummary, normalizedSummary,
-                className, screenTitle, iconResId, rank, keywords,
-                intentAction, intentTargetPackage, intentTargetClass, enabled);
+                updatedTitle, normalizedTitle, updatedSummaryOn, normalizedSummaryOn,
+                updatedSummaryOff, normalizedSummaryOff, className, screenTitle, iconResId,
+                rank, keywords, intentAction, intentTargetPackage, intentTargetClass, enabled);
     }
 
     private void updateOneRow(SQLiteDatabase database, String locale,
             String updatedTitle, String normalizedTitle,
-            String updatedSummary, String normalizedSummary,
-            String className, String screenTitle,
-            int iconResId, int rank, String keywords,
+            String updatedSummaryOn, String normalizedSummaryOn,
+            String updatedSummaryOff, String normalizedSummaryOff, String className,
+            String screenTitle, int iconResId, int rank, String keywords,
             String intentAction, String intentTargetPackage, String intentTargetClass,
             boolean enabled) {
 
@@ -636,8 +672,10 @@
         values.put(IndexColumns.DATA_RANK, rank);
         values.put(IndexColumns.DATA_TITLE, updatedTitle);
         values.put(IndexColumns.DATA_TITLE_NORMALIZED, normalizedTitle);
-        values.put(IndexColumns.DATA_SUMMARY, updatedSummary);
-        values.put(IndexColumns.DATA_SUMMARY_NORMALIZED, normalizedSummary);
+        values.put(IndexColumns.DATA_SUMMARY_ON, updatedSummaryOn);
+        values.put(IndexColumns.DATA_SUMMARY_ON_NORMALIZED, normalizedSummaryOn);
+        values.put(IndexColumns.DATA_SUMMARY_OFF, updatedSummaryOff);
+        values.put(IndexColumns.DATA_SUMMARY_OFF_NORMALIZED, normalizedSummaryOff);
         values.put(IndexColumns.DATA_KEYWORDS, keywords);
         values.put(IndexColumns.CLASS_NAME, className);
         values.put(IndexColumns.SCREEN_TITLE, screenTitle);
@@ -662,6 +700,18 @@
                 com.android.internal.R.styleable.Preference_summary);
     }
 
+    private String getDataSummaryOn(Context context, AttributeSet attrs) {
+        return getData(context, attrs,
+                com.android.internal.R.styleable.CheckBoxPreference,
+                com.android.internal.R.styleable.CheckBoxPreference_summaryOn);
+    }
+
+    private String getDataSummaryOff(Context context, AttributeSet attrs) {
+        return getData(context, attrs,
+                com.android.internal.R.styleable.CheckBoxPreference,
+                com.android.internal.R.styleable.CheckBoxPreference_summaryOff);
+    }
+
     private String getDataKeywords(Context context, AttributeSet attrs) {
         return getData(context, attrs, R.styleable.Preference, R.styleable.Preference_keywords);
     }
diff --git a/src/com/android/settings/search/IndexDatabaseHelper.java b/src/com/android/settings/search/IndexDatabaseHelper.java
index 24d40a7..88ac4e7 100644
--- a/src/com/android/settings/search/IndexDatabaseHelper.java
+++ b/src/com/android/settings/search/IndexDatabaseHelper.java
@@ -28,7 +28,7 @@
     private static final String TAG = "IndexDatabaseHelper";
 
     private static final String DATABASE_NAME = "search_index.db";
-    private static final int DATABASE_VERSION = 103;
+    private static final int DATABASE_VERSION = 104;
 
     public interface Tables {
         public static final String TABLE_PREFS_INDEX = "prefs_index";
@@ -41,8 +41,10 @@
         public static final String DATA_RANK = "data_rank";
         public static final String DATA_TITLE = "data_title";
         public static final String DATA_TITLE_NORMALIZED = "data_title_normalized";
-        public static final String DATA_SUMMARY = "data_summary";
-        public static final String DATA_SUMMARY_NORMALIZED = "data_summary_normalized";
+        public static final String DATA_SUMMARY_ON = "data_summary_on";
+        public static final String DATA_SUMMARY_ON_NORMALIZED = "data_summary_on_normalized";
+        public static final String DATA_SUMMARY_OFF = "data_summary_off";
+        public static final String DATA_SUMMARY_OFF_NORMALIZED = "data_summary_off_normalized";
         public static final String DATA_KEYWORDS = "data_keywords";
         public static final String CLASS_NAME = "class_name";
         public static final String SCREEN_TITLE = "screen_title";
@@ -68,9 +70,13 @@
                     ", " +
                     IndexColumns.DATA_TITLE_NORMALIZED +
                     ", " +
-                    IndexColumns.DATA_SUMMARY +
+                    IndexColumns.DATA_SUMMARY_ON +
                     ", " +
-                    IndexColumns.DATA_SUMMARY_NORMALIZED +
+                    IndexColumns.DATA_SUMMARY_ON_NORMALIZED +
+                    ", " +
+                    IndexColumns.DATA_SUMMARY_OFF +
+                    ", " +
+                    IndexColumns.DATA_SUMMARY_OFF_NORMALIZED +
                     ", " +
                     IndexColumns.DATA_KEYWORDS +
                     ", " +
@@ -129,9 +135,9 @@
 
     @Override
     public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
-        if (oldVersion == 100 || oldVersion == 101 || oldVersion == 102) {
-            Log.w(TAG, "Detected schema version 100, 101 or 102. " +
-                    "Index needs to be rebuilt for schema version 103");
+        if (oldVersion == 100 || oldVersion == 101 || oldVersion == 102 || oldVersion == 103) {
+            Log.w(TAG, "Detected schema version 100, 101, 102 or 103. " +
+                    "Index needs to be rebuilt for schema version 104");
             // We need to drop the tables and recreate them
             dropTables(db);
             bootstrapDB(db);
diff --git a/src/com/android/settings/search/SearchIndexableRaw.java b/src/com/android/settings/search/SearchIndexableRaw.java
index a175be9..e800535 100644
--- a/src/com/android/settings/search/SearchIndexableRaw.java
+++ b/src/com/android/settings/search/SearchIndexableRaw.java
@@ -29,7 +29,8 @@
 public class SearchIndexableRaw extends SearchIndexableData {
 
     public String title;
-    public String summary;
+    public String summaryOn;
+    public String summaryOff;
     public String keywords;
 
     public String screenTitle;
diff --git a/src/com/android/settings/search/SearchIndexableResources.java b/src/com/android/settings/search/SearchIndexableResources.java
index c65e50c..061be54 100644
--- a/src/com/android/settings/search/SearchIndexableResources.java
+++ b/src/com/android/settings/search/SearchIndexableResources.java
@@ -22,6 +22,8 @@
 import com.android.settings.DeviceInfoSettings;
 import com.android.settings.DisplaySettings;
 import com.android.settings.HomeSettings;
+import com.android.settings.NotificationAccessSettings;
+import com.android.settings.NotificationSettings;
 import com.android.settings.PrivacySettings;
 import com.android.settings.R;
 import com.android.settings.SecuritySettings;
@@ -47,110 +49,137 @@
 
     private static int NO_DATA_RES_ID = 0;
 
+    private static final int RANK_WIFI = 1;
+    private static final int RANK_BT = 2;
+    private static final int RANK_DATA_USAGE = 3;
+    private static final int RANK_WIRELESS = 4;
+    private static final int RANK_HOME = 5;
+    private static final int RANK_SOUND = 6;
+    private static final int RANK_DISPLAY = 7;
+    private static final int RANK_WALLPAPER = 7;
+    private static final int RANK_NOTIFICATIONS = 8;
+    private static final int RANK_MEMORY = 9;
+    private static final int RANK_POWER_USAGE = 10;
+    private static final int RANK_USERS = 11;
+    private static final int RANK_LOCATION = 12;
+    private static final int RANK_SECURITY = 13;
+    private static final int RANK_IME = 14;
+    private static final int RANK_PRIVACY = 15;
+    private static final int RANK_DATE_TIME = 16;
+    private static final int RANK_ACCESSIBILITY = 17;
+    private static final int RANK_PRINTING = 18;
+    private static final int RANK_DEVELOPEMENT = 19;
+    private static final int RANK_DEVICE_INFO = 20;
+
     private static HashMap<String, SearchIndexableResource> sResMap =
             new HashMap<String, SearchIndexableResource>();
 
 
     static {
         sResMap.put(WifiSettings.class.getName(),
-                new SearchIndexableResource(1,
+                new SearchIndexableResource(RANK_WIFI,
                         NO_DATA_RES_ID,
                         WifiSettings.class.getName(),
                         R.drawable.ic_settings_wireless));
 
         sResMap.put(BluetoothSettings.class.getName(),
-                new SearchIndexableResource(2,
+                new SearchIndexableResource(RANK_BT,
                         NO_DATA_RES_ID,
                         BluetoothSettings.class.getName(),
                         R.drawable.ic_settings_bluetooth2));
 
         sResMap.put(DataUsageMeteredSettings.class.getName(),
-                new SearchIndexableResource(3, R.xml.data_usage_metered_prefs,
+                new SearchIndexableResource(RANK_DATA_USAGE, R.xml.data_usage_metered_prefs,
                         DataUsageMeteredSettings.class.getName(),
                         R.drawable.ic_settings_data_usage));
 
         sResMap.put(WirelessSettings.class.getName(),
-                new SearchIndexableResource(4, R.xml.wireless_settings,
+                new SearchIndexableResource(RANK_WIRELESS, R.xml.wireless_settings,
                         WirelessSettings.class.getName(),
                         R.drawable.empty_icon));
 
         sResMap.put(HomeSettings.class.getName(),
-                new SearchIndexableResource(5, R.xml.home_selection,
+                new SearchIndexableResource(RANK_HOME, R.xml.home_selection,
                         HomeSettings.class.getName(),
                         R.drawable.ic_settings_home));
 
         sResMap.put(SoundSettings.class.getName(),
-                new SearchIndexableResource(6, R.xml.sound_settings,
+                new SearchIndexableResource(RANK_SOUND, R.xml.sound_settings,
                         SoundSettings.class.getName(),
                         R.drawable.ic_settings_sound));
 
         sResMap.put(DisplaySettings.class.getName(),
-                new SearchIndexableResource(7, R.xml.display_settings,
+                new SearchIndexableResource(RANK_DISPLAY, R.xml.display_settings,
                         DisplaySettings.class.getName(),
                         R.drawable.ic_settings_display));
 
         sResMap.put(WallpaperTypeSettings.class.getName(),
-                new SearchIndexableResource(7, NO_DATA_RES_ID,
+                new SearchIndexableResource(RANK_WALLPAPER, NO_DATA_RES_ID,
                         WallpaperTypeSettings.class.getName(),
                         R.drawable.ic_settings_display));
 
+        sResMap.put(NotificationSettings.class.getName(),
+                new SearchIndexableResource(RANK_NOTIFICATIONS, R.xml.notification_settings,
+                        NotificationSettings.class.getName(),
+                        R.drawable.ic_settings_notifications));
+
         sResMap.put(Memory.class.getName(),
-                new SearchIndexableResource(8, R.xml.device_info_memory,
+                new SearchIndexableResource(RANK_MEMORY, R.xml.device_info_memory,
                         Memory.class.getName(),
                         R.drawable.ic_settings_storage));
 
         sResMap.put(PowerUsageSummary.class.getName(),
-                new SearchIndexableResource(9, R.xml.power_usage_summary,
+                new SearchIndexableResource(RANK_POWER_USAGE, R.xml.power_usage_summary,
                         PowerUsageSummary.class.getName(),
                         R.drawable.ic_settings_battery));
 
         sResMap.put(UserSettings.class.getName(),
-                new SearchIndexableResource(10, R.xml.user_settings,
+                new SearchIndexableResource(RANK_USERS, R.xml.user_settings,
                         UserSettings.class.getName(),
                         R.drawable.ic_settings_multiuser));
 
         sResMap.put(LocationSettings.class.getName(),
-                new SearchIndexableResource(11, R.xml.location_settings,
+                new SearchIndexableResource(RANK_LOCATION, R.xml.location_settings,
                         LocationSettings.class.getName(),
                         R.drawable.ic_settings_location));
 
         sResMap.put(SecuritySettings.class.getName(),
-                new SearchIndexableResource(12, R.xml.security_settings,
+                new SearchIndexableResource(RANK_SECURITY, R.xml.security_settings,
                         SecuritySettings.class.getName(),
                         R.drawable.ic_settings_security));
 
         sResMap.put(InputMethodAndLanguageSettings.class.getName(),
-                new SearchIndexableResource(13, R.xml.language_settings,
+                new SearchIndexableResource(RANK_IME, R.xml.language_settings,
                         InputMethodAndLanguageSettings.class.getName(),
                         R.drawable.ic_settings_language));
 
         sResMap.put(PrivacySettings.class.getName(),
-                new SearchIndexableResource(14, R.xml.privacy_settings,
+                new SearchIndexableResource(RANK_PRIVACY, R.xml.privacy_settings,
                         PrivacySettings.class.getName(),
                         R.drawable.ic_settings_backup));
 
         sResMap.put(DateTimeSettings.class.getName(),
-                new SearchIndexableResource(15, R.xml.date_time_prefs,
+                new SearchIndexableResource(RANK_DATE_TIME, R.xml.date_time_prefs,
                         DateTimeSettings.class.getName(),
                         R.drawable.ic_settings_date_time));
 
         sResMap.put(AccessibilitySettings.class.getName(),
-                new SearchIndexableResource(16, R.xml.accessibility_settings,
+                new SearchIndexableResource(RANK_ACCESSIBILITY, R.xml.accessibility_settings,
                         AccessibilitySettings.class.getName(),
                         R.drawable.ic_settings_accessibility));
 
         sResMap.put(PrintSettingsFragment.class.getName(),
-                new SearchIndexableResource(17, R.xml.print_settings,
+                new SearchIndexableResource(RANK_PRINTING, R.xml.print_settings,
                         PrintSettingsFragment.class.getName(),
                         com.android.internal.R.drawable.ic_print));
 
         sResMap.put(DevelopmentSettings.class.getName(),
-                new SearchIndexableResource(18, R.xml.development_prefs,
+                new SearchIndexableResource(RANK_DEVELOPEMENT, R.xml.development_prefs,
                         DevelopmentSettings.class.getName(),
                         R.drawable.ic_settings_development));
 
         sResMap.put(DeviceInfoSettings.class.getName(),
-                new SearchIndexableResource(19, R.xml.device_info_settings,
+                new SearchIndexableResource(RANK_DEVICE_INFO, R.xml.device_info_settings,
                         DeviceInfoSettings.class.getName(),
                         R.drawable.ic_settings_about));
     }
diff --git a/src/com/android/settings/search/SettingsSearchIndexablesProvider.java b/src/com/android/settings/search/SettingsSearchIndexablesProvider.java
index 453f7a6..603175e 100644
--- a/src/com/android/settings/search/SettingsSearchIndexablesProvider.java
+++ b/src/com/android/settings/search/SettingsSearchIndexablesProvider.java
@@ -20,27 +20,6 @@
 import android.database.MatrixCursor;
 import android.provider.SearchIndexableResource;
 import android.provider.SearchIndexablesProvider;
-import com.android.settings.DateTimeSettings;
-import com.android.settings.DevelopmentSettings;
-import com.android.settings.DeviceInfoSettings;
-import com.android.settings.DisplaySettings;
-import com.android.settings.HomeSettings;
-import com.android.settings.PrivacySettings;
-import com.android.settings.R;
-import com.android.settings.SecuritySettings;
-import com.android.settings.SoundSettings;
-import com.android.settings.WallpaperTypeSettings;
-import com.android.settings.WirelessSettings;
-import com.android.settings.accessibility.AccessibilitySettings;
-import com.android.settings.bluetooth.BluetoothSettings;
-import com.android.settings.deviceinfo.Memory;
-import com.android.settings.fuelgauge.PowerUsageSummary;
-import com.android.settings.inputmethod.InputMethodAndLanguageSettings;
-import com.android.settings.location.LocationSettings;
-import com.android.settings.net.DataUsageMeteredSettings;
-import com.android.settings.print.PrintSettingsFragment;
-import com.android.settings.users.UserSettings;
-import com.android.settings.wifi.WifiSettings;
 
 import java.util.Collection;