Home | History | Annotate | Download | only in search
      1 /*
      2  * Copyright (C) 2014 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.android.settings.search;
     18 
     19 import android.provider.SearchIndexableResource;
     20 import com.android.settings.DateTimeSettings;
     21 import com.android.settings.DevelopmentSettings;
     22 import com.android.settings.DeviceInfoSettings;
     23 import com.android.settings.DisplaySettings;
     24 import com.android.settings.LegalSettings;
     25 import com.android.settings.PrivacySettings;
     26 import com.android.settings.R;
     27 import com.android.settings.ScreenPinningSettings;
     28 import com.android.settings.SecuritySettings;
     29 import com.android.settings.WallpaperTypeSettings;
     30 import com.android.settings.WirelessSettings;
     31 import com.android.settings.accessibility.AccessibilitySettings;
     32 import com.android.settings.accounts.AccountSettings;
     33 import com.android.settings.applications.AdvancedAppSettings;
     34 import com.android.settings.applications.SpecialAccessSettings;
     35 import com.android.settings.bluetooth.BluetoothSettings;
     36 import com.android.settings.datausage.DataUsageMeteredSettings;
     37 import com.android.settings.datausage.DataUsageSummary;
     38 import com.android.settings.deviceinfo.StorageSettings;
     39 import com.android.settings.display.ScreenZoomSettings;
     40 import com.android.settings.fuelgauge.BatterySaverSettings;
     41 import com.android.settings.fuelgauge.PowerUsageSummary;
     42 import com.android.settings.gestures.GestureSettings;
     43 import com.android.settings.inputmethod.InputMethodAndLanguageSettings;
     44 import com.android.settings.location.LocationSettings;
     45 import com.android.settings.location.ScanningSettings;
     46 import com.android.settings.notification.ConfigureNotificationSettings;
     47 import com.android.settings.notification.OtherSoundSettings;
     48 import com.android.settings.notification.SoundSettings;
     49 import com.android.settings.notification.ZenModePrioritySettings;
     50 import com.android.settings.notification.ZenModeSettings;
     51 import com.android.settings.notification.ZenModeVisualInterruptionSettings;
     52 import com.android.settings.print.PrintSettingsFragment;
     53 import com.android.settings.sim.SimSettings;
     54 import com.android.settings.users.UserSettings;
     55 import com.android.settings.wifi.AdvancedWifiSettings;
     56 import com.android.settings.wifi.SavedAccessPointsWifiSettings;
     57 import com.android.settings.wifi.WifiSettings;
     58 
     59 import java.util.Collection;
     60 import java.util.HashMap;
     61 
     62 public final class SearchIndexableResources {
     63 
     64     public static int NO_DATA_RES_ID = 0;
     65 
     66     private static HashMap<String, SearchIndexableResource> sResMap =
     67             new HashMap<String, SearchIndexableResource>();
     68 
     69     static {
     70         sResMap.put(WifiSettings.class.getName(),
     71                 new SearchIndexableResource(
     72                         Ranking.getRankForClassName(WifiSettings.class.getName()),
     73                         NO_DATA_RES_ID,
     74                         WifiSettings.class.getName(),
     75                         R.drawable.ic_settings_wireless));
     76 
     77         sResMap.put(AdvancedWifiSettings.class.getName(),
     78                 new SearchIndexableResource(
     79                         Ranking.getRankForClassName(AdvancedWifiSettings.class.getName()),
     80                         R.xml.wifi_advanced_settings,
     81                         AdvancedWifiSettings.class.getName(),
     82                         R.drawable.ic_settings_wireless));
     83 
     84         sResMap.put(SavedAccessPointsWifiSettings.class.getName(),
     85                 new SearchIndexableResource(
     86                         Ranking.getRankForClassName(SavedAccessPointsWifiSettings.class.getName()),
     87                         R.xml.wifi_display_saved_access_points,
     88                         SavedAccessPointsWifiSettings.class.getName(),
     89                         R.drawable.ic_settings_wireless));
     90 
     91         sResMap.put(BluetoothSettings.class.getName(),
     92                 new SearchIndexableResource(
     93                         Ranking.getRankForClassName(BluetoothSettings.class.getName()),
     94                         NO_DATA_RES_ID,
     95                         BluetoothSettings.class.getName(),
     96                         R.drawable.ic_settings_bluetooth));
     97 
     98         sResMap.put(SimSettings.class.getName(),
     99                 new SearchIndexableResource(
    100                         Ranking.getRankForClassName(SimSettings.class.getName()),
    101                         NO_DATA_RES_ID,
    102                         SimSettings.class.getName(),
    103                         R.drawable.ic_sim_sd));
    104 
    105         sResMap.put(DataUsageSummary.class.getName(),
    106                 new SearchIndexableResource(
    107                         Ranking.getRankForClassName(DataUsageSummary.class.getName()),
    108                         NO_DATA_RES_ID,
    109                         DataUsageSummary.class.getName(),
    110                         R.drawable.ic_settings_data_usage));
    111 
    112         sResMap.put(DataUsageMeteredSettings.class.getName(),
    113                 new SearchIndexableResource(
    114                         Ranking.getRankForClassName(DataUsageMeteredSettings.class.getName()),
    115                         NO_DATA_RES_ID,
    116                         DataUsageMeteredSettings.class.getName(),
    117                         R.drawable.ic_settings_data_usage));
    118 
    119         sResMap.put(WirelessSettings.class.getName(),
    120                 new SearchIndexableResource(
    121                         Ranking.getRankForClassName(WirelessSettings.class.getName()),
    122                         NO_DATA_RES_ID,
    123                         WirelessSettings.class.getName(),
    124                         R.drawable.ic_settings_more));
    125 
    126         sResMap.put(ScreenZoomSettings.class.getName(),
    127                 new SearchIndexableResource(
    128                         Ranking.getRankForClassName(ScreenZoomSettings.class.getName()),
    129                         NO_DATA_RES_ID,
    130                         ScreenZoomSettings.class.getName(),
    131                         R.drawable.ic_settings_display));
    132 
    133         sResMap.put(DisplaySettings.class.getName(),
    134                 new SearchIndexableResource(
    135                         Ranking.getRankForClassName(DisplaySettings.class.getName()),
    136                         NO_DATA_RES_ID,
    137                         DisplaySettings.class.getName(),
    138                         R.drawable.ic_settings_display));
    139 
    140         sResMap.put(WallpaperTypeSettings.class.getName(),
    141                 new SearchIndexableResource(
    142                         Ranking.getRankForClassName(WallpaperTypeSettings.class.getName()),
    143                         NO_DATA_RES_ID,
    144                         WallpaperTypeSettings.class.getName(),
    145                         R.drawable.ic_settings_display));
    146 
    147         sResMap.put(ConfigureNotificationSettings.class.getName(),
    148                 new SearchIndexableResource(
    149                         Ranking.getRankForClassName(ConfigureNotificationSettings.class.getName()),
    150                         R.xml.configure_notification_settings,
    151                         ConfigureNotificationSettings.class.getName(),
    152                         R.drawable.ic_settings_notifications));
    153 
    154         sResMap.put(SoundSettings.class.getName(),
    155                 new SearchIndexableResource(
    156                         Ranking.getRankForClassName(SoundSettings.class.getName()),
    157                         NO_DATA_RES_ID,
    158                         SoundSettings.class.getName(),
    159                         R.drawable.ic_settings_sound));
    160 
    161         sResMap.put(OtherSoundSettings.class.getName(),
    162                 new SearchIndexableResource(
    163                         Ranking.getRankForClassName(OtherSoundSettings.class.getName()),
    164                         NO_DATA_RES_ID,
    165                         OtherSoundSettings.class.getName(),
    166                         R.drawable.ic_settings_sound));
    167 
    168         sResMap.put(ZenModeSettings.class.getName(),
    169                 new SearchIndexableResource(
    170                         Ranking.getRankForClassName(ZenModeSettings.class.getName()),
    171                         R.xml.zen_mode_settings,
    172                         ZenModeSettings.class.getName(),
    173                         R.drawable.ic_settings_notifications));
    174 
    175         sResMap.put(ZenModePrioritySettings.class.getName(),
    176                 new SearchIndexableResource(
    177                         Ranking.getRankForClassName(ZenModePrioritySettings.class.getName()),
    178                         R.xml.zen_mode_priority_settings,
    179                         ZenModePrioritySettings.class.getName(),
    180                         R.drawable.ic_settings_notifications));
    181 
    182         sResMap.put(StorageSettings.class.getName(),
    183                 new SearchIndexableResource(
    184                         Ranking.getRankForClassName(StorageSettings.class.getName()),
    185                         NO_DATA_RES_ID,
    186                         StorageSettings.class.getName(),
    187                         R.drawable.ic_settings_storage));
    188 
    189         sResMap.put(PowerUsageSummary.class.getName(),
    190                 new SearchIndexableResource(
    191                         Ranking.getRankForClassName(PowerUsageSummary.class.getName()),
    192                         R.xml.power_usage_summary,
    193                         PowerUsageSummary.class.getName(),
    194                         R.drawable.ic_settings_battery));
    195 
    196         sResMap.put(BatterySaverSettings.class.getName(),
    197                 new SearchIndexableResource(
    198                         Ranking.getRankForClassName(BatterySaverSettings.class.getName()),
    199                         R.xml.battery_saver_settings,
    200                         BatterySaverSettings.class.getName(),
    201                         R.drawable.ic_settings_battery));
    202 
    203         sResMap.put(AdvancedAppSettings.class.getName(),
    204                 new SearchIndexableResource(
    205                         Ranking.getRankForClassName(AdvancedAppSettings.class.getName()),
    206                         NO_DATA_RES_ID,
    207                         AdvancedAppSettings.class.getName(),
    208                         R.drawable.ic_settings_applications));
    209 
    210         sResMap.put(SpecialAccessSettings.class.getName(),
    211                 new SearchIndexableResource(
    212                         Ranking.getRankForClassName(SpecialAccessSettings.class.getName()),
    213                         R.xml.special_access,
    214                         SpecialAccessSettings.class.getName(),
    215                         R.drawable.ic_settings_applications));
    216 
    217         sResMap.put(UserSettings.class.getName(),
    218                 new SearchIndexableResource(
    219                         Ranking.getRankForClassName(UserSettings.class.getName()),
    220                         NO_DATA_RES_ID,
    221                         UserSettings.class.getName(),
    222                         R.drawable.ic_settings_multiuser));
    223 
    224         sResMap.put(GestureSettings.class.getName(),
    225                 new SearchIndexableResource(
    226                         Ranking.getRankForClassName(GestureSettings.class.getName()),
    227                         NO_DATA_RES_ID,
    228                         GestureSettings.class.getName(),
    229                         R.drawable.ic_settings_gestures));
    230 
    231         sResMap.put(LocationSettings.class.getName(),
    232                 new SearchIndexableResource(
    233                         Ranking.getRankForClassName(LocationSettings.class.getName()),
    234                         R.xml.location_settings,
    235                         LocationSettings.class.getName(),
    236                         R.drawable.ic_settings_location));
    237 
    238         sResMap.put(ScanningSettings.class.getName(),
    239                 new SearchIndexableResource(
    240                         Ranking.getRankForClassName(ScanningSettings.class.getName()),
    241                         R.xml.location_scanning,
    242                         ScanningSettings.class.getName(),
    243                         R.drawable.ic_settings_location));
    244 
    245         sResMap.put(SecuritySettings.class.getName(),
    246                 new SearchIndexableResource(
    247                         Ranking.getRankForClassName(SecuritySettings.class.getName()),
    248                         NO_DATA_RES_ID,
    249                         SecuritySettings.class.getName(),
    250                         R.drawable.ic_settings_security));
    251 
    252         sResMap.put(ScreenPinningSettings.class.getName(),
    253                 new SearchIndexableResource(
    254                         Ranking.getRankForClassName(ScreenPinningSettings.class.getName()),
    255                         NO_DATA_RES_ID,
    256                         ScreenPinningSettings.class.getName(),
    257                         R.drawable.ic_settings_security));
    258 
    259         sResMap.put(AccountSettings.class.getName(),
    260                 new SearchIndexableResource(
    261                         Ranking.getRankForClassName(AccountSettings.class.getName()),
    262                         NO_DATA_RES_ID,
    263                         AccountSettings.class.getName(),
    264                         R.drawable.ic_settings_accounts));
    265 
    266         sResMap.put(InputMethodAndLanguageSettings.class.getName(),
    267                 new SearchIndexableResource(
    268                         Ranking.getRankForClassName(InputMethodAndLanguageSettings.class.getName()),
    269                         NO_DATA_RES_ID,
    270                         InputMethodAndLanguageSettings.class.getName(),
    271                         R.drawable.ic_settings_language));
    272 
    273         sResMap.put(PrivacySettings.class.getName(),
    274                 new SearchIndexableResource(
    275                         Ranking.getRankForClassName(PrivacySettings.class.getName()),
    276                         NO_DATA_RES_ID,
    277                         PrivacySettings.class.getName(),
    278                         R.drawable.ic_settings_backup));
    279 
    280         sResMap.put(DateTimeSettings.class.getName(),
    281                 new SearchIndexableResource(
    282                         Ranking.getRankForClassName(DateTimeSettings.class.getName()),
    283                         NO_DATA_RES_ID,
    284                         DateTimeSettings.class.getName(),
    285                         R.drawable.ic_settings_date_time));
    286 
    287         sResMap.put(AccessibilitySettings.class.getName(),
    288                 new SearchIndexableResource(
    289                         Ranking.getRankForClassName(AccessibilitySettings.class.getName()),
    290                         NO_DATA_RES_ID,
    291                         AccessibilitySettings.class.getName(),
    292                         R.drawable.ic_settings_accessibility));
    293 
    294         sResMap.put(PrintSettingsFragment.class.getName(),
    295                 new SearchIndexableResource(
    296                         Ranking.getRankForClassName(PrintSettingsFragment.class.getName()),
    297                         NO_DATA_RES_ID,
    298                         PrintSettingsFragment.class.getName(),
    299                         R.drawable.ic_settings_print));
    300 
    301         sResMap.put(DevelopmentSettings.class.getName(),
    302                 new SearchIndexableResource(
    303                         Ranking.getRankForClassName(DevelopmentSettings.class.getName()),
    304                         NO_DATA_RES_ID,
    305                         DevelopmentSettings.class.getName(),
    306                         R.drawable.ic_settings_development));
    307 
    308         sResMap.put(DeviceInfoSettings.class.getName(),
    309                 new SearchIndexableResource(
    310                         Ranking.getRankForClassName(DeviceInfoSettings.class.getName()),
    311                         NO_DATA_RES_ID,
    312                         DeviceInfoSettings.class.getName(),
    313                         R.drawable.ic_settings_about));
    314 
    315         sResMap.put(LegalSettings.class.getName(),
    316                 new SearchIndexableResource(
    317                         Ranking.getRankForClassName(LegalSettings.class.getName()),
    318                         NO_DATA_RES_ID,
    319                         LegalSettings.class.getName(),
    320                         R.drawable.ic_settings_about));
    321 
    322         sResMap.put(ZenModeVisualInterruptionSettings.class.getName(),
    323                 new SearchIndexableResource(
    324                         Ranking.getRankForClassName(
    325                                 ZenModeVisualInterruptionSettings.class.getName()),
    326                         R.xml.zen_mode_visual_interruptions_settings,
    327                         ZenModeVisualInterruptionSettings.class.getName(),
    328                         R.drawable.ic_settings_notifications));
    329     }
    330 
    331     private SearchIndexableResources() {
    332     }
    333 
    334     public static int size() {
    335         return sResMap.size();
    336     }
    337 
    338     public static SearchIndexableResource getResourceByName(String className) {
    339         return sResMap.get(className);
    340     }
    341 
    342     public static Collection<SearchIndexableResource> values() {
    343         return sResMap.values();
    344     }
    345 }
    346