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 21 import com.android.settings.DataUsageSummary; 22 import com.android.settings.DateTimeSettings; 23 import com.android.settings.DevelopmentSettings; 24 import com.android.settings.DeviceInfoSettings; 25 import com.android.settings.DisplaySettings; 26 import com.android.settings.HomeSettings; 27 import com.android.settings.ScreenPinningSettings; 28 import com.android.settings.PrivacySettings; 29 import com.android.settings.R; 30 import com.android.settings.SecuritySettings; 31 import com.android.settings.WallpaperTypeSettings; 32 import com.android.settings.WirelessSettings; 33 import com.android.settings.accessibility.AccessibilitySettings; 34 import com.android.settings.bluetooth.BluetoothSettings; 35 import com.android.settings.deviceinfo.Memory; 36 import com.android.settings.deviceinfo.UsbSettings; 37 import com.android.settings.fuelgauge.BatterySaverSettings; 38 import com.android.settings.fuelgauge.PowerUsageSummary; 39 import com.android.settings.inputmethod.InputMethodAndLanguageSettings; 40 import com.android.settings.location.LocationSettings; 41 import com.android.settings.net.DataUsageMeteredSettings; 42 import com.android.settings.notification.NotificationSettings; 43 import com.android.settings.notification.OtherSoundSettings; 44 import com.android.settings.notification.ZenModeSettings; 45 import com.android.settings.print.PrintSettingsFragment; 46 import com.android.settings.sim.SimSettings; 47 import com.android.settings.users.UserSettings; 48 import com.android.settings.voice.VoiceInputSettings; 49 import com.android.settings.wifi.AdvancedWifiSettings; 50 import com.android.settings.wifi.SavedAccessPointsWifiSettings; 51 import com.android.settings.wifi.WifiSettings; 52 53 import java.util.Collection; 54 import java.util.HashMap; 55 56 public final class SearchIndexableResources { 57 58 public static int NO_DATA_RES_ID = 0; 59 60 private static HashMap<String, SearchIndexableResource> sResMap = 61 new HashMap<String, SearchIndexableResource>(); 62 63 static { WifiSettings.class.getName()64 sResMap.put(WifiSettings.class.getName(), 65 new SearchIndexableResource( 66 Ranking.getRankForClassName(WifiSettings.class.getName()), 67 NO_DATA_RES_ID, 68 WifiSettings.class.getName(), 69 R.drawable.ic_settings_wireless)); 70 AdvancedWifiSettings.class.getName()71 sResMap.put(AdvancedWifiSettings.class.getName(), 72 new SearchIndexableResource( 73 Ranking.getRankForClassName(AdvancedWifiSettings.class.getName()), 74 R.xml.wifi_advanced_settings, 75 AdvancedWifiSettings.class.getName(), 76 R.drawable.ic_settings_wireless)); 77 SavedAccessPointsWifiSettings.class.getName()78 sResMap.put(SavedAccessPointsWifiSettings.class.getName(), 79 new SearchIndexableResource( 80 Ranking.getRankForClassName(SavedAccessPointsWifiSettings.class.getName()), 81 R.xml.wifi_display_saved_access_points, 82 SavedAccessPointsWifiSettings.class.getName(), 83 R.drawable.ic_settings_wireless)); 84 BluetoothSettings.class.getName()85 sResMap.put(BluetoothSettings.class.getName(), 86 new SearchIndexableResource( 87 Ranking.getRankForClassName(BluetoothSettings.class.getName()), 88 NO_DATA_RES_ID, 89 BluetoothSettings.class.getName(), 90 R.drawable.ic_settings_bluetooth2)); 91 SimSettings.class.getName()92 sResMap.put(SimSettings.class.getName(), 93 new SearchIndexableResource( 94 Ranking.getRankForClassName(SimSettings.class.getName()), 95 NO_DATA_RES_ID, 96 SimSettings.class.getName(), 97 R.drawable.ic_sim_sd)); 98 DataUsageSummary.class.getName()99 sResMap.put(DataUsageSummary.class.getName(), 100 new SearchIndexableResource( 101 Ranking.getRankForClassName(DataUsageSummary.class.getName()), 102 NO_DATA_RES_ID, 103 DataUsageSummary.class.getName(), 104 R.drawable.ic_settings_data_usage)); 105 DataUsageMeteredSettings.class.getName()106 sResMap.put(DataUsageMeteredSettings.class.getName(), 107 new SearchIndexableResource( 108 Ranking.getRankForClassName(DataUsageMeteredSettings.class.getName()), 109 NO_DATA_RES_ID, 110 DataUsageMeteredSettings.class.getName(), 111 R.drawable.ic_settings_data_usage)); 112 WirelessSettings.class.getName()113 sResMap.put(WirelessSettings.class.getName(), 114 new SearchIndexableResource( 115 Ranking.getRankForClassName(WirelessSettings.class.getName()), 116 NO_DATA_RES_ID, 117 WirelessSettings.class.getName(), 118 R.drawable.ic_settings_more)); 119 HomeSettings.class.getName()120 sResMap.put(HomeSettings.class.getName(), 121 new SearchIndexableResource( 122 Ranking.getRankForClassName(HomeSettings.class.getName()), 123 NO_DATA_RES_ID, 124 HomeSettings.class.getName(), 125 R.drawable.ic_settings_home)); 126 DisplaySettings.class.getName()127 sResMap.put(DisplaySettings.class.getName(), 128 new SearchIndexableResource( 129 Ranking.getRankForClassName(DisplaySettings.class.getName()), 130 NO_DATA_RES_ID, 131 DisplaySettings.class.getName(), 132 R.drawable.ic_settings_display)); 133 WallpaperTypeSettings.class.getName()134 sResMap.put(WallpaperTypeSettings.class.getName(), 135 new SearchIndexableResource( 136 Ranking.getRankForClassName(WallpaperTypeSettings.class.getName()), 137 NO_DATA_RES_ID, 138 WallpaperTypeSettings.class.getName(), 139 R.drawable.ic_settings_display)); 140 NotificationSettings.class.getName()141 sResMap.put(NotificationSettings.class.getName(), 142 new SearchIndexableResource( 143 Ranking.getRankForClassName(NotificationSettings.class.getName()), 144 NO_DATA_RES_ID, 145 NotificationSettings.class.getName(), 146 R.drawable.ic_settings_notifications)); 147 OtherSoundSettings.class.getName()148 sResMap.put(OtherSoundSettings.class.getName(), 149 new SearchIndexableResource( 150 Ranking.getRankForClassName(OtherSoundSettings.class.getName()), 151 NO_DATA_RES_ID, 152 OtherSoundSettings.class.getName(), 153 R.drawable.ic_settings_notifications)); 154 ZenModeSettings.class.getName()155 sResMap.put(ZenModeSettings.class.getName(), 156 new SearchIndexableResource( 157 Ranking.getRankForClassName(ZenModeSettings.class.getName()), 158 NO_DATA_RES_ID, 159 ZenModeSettings.class.getName(), 160 R.drawable.ic_settings_notifications)); 161 Memory.class.getName()162 sResMap.put(Memory.class.getName(), 163 new SearchIndexableResource( 164 Ranking.getRankForClassName(Memory.class.getName()), 165 NO_DATA_RES_ID, 166 Memory.class.getName(), 167 R.drawable.ic_settings_storage)); 168 UsbSettings.class.getName()169 sResMap.put(UsbSettings.class.getName(), 170 new SearchIndexableResource( 171 Ranking.getRankForClassName(UsbSettings.class.getName()), 172 R.xml.usb_settings, 173 UsbSettings.class.getName(), 174 R.drawable.ic_settings_storage)); 175 PowerUsageSummary.class.getName()176 sResMap.put(PowerUsageSummary.class.getName(), 177 new SearchIndexableResource( 178 Ranking.getRankForClassName(PowerUsageSummary.class.getName()), 179 R.xml.power_usage_summary, 180 PowerUsageSummary.class.getName(), 181 R.drawable.ic_settings_battery)); 182 BatterySaverSettings.class.getName()183 sResMap.put(BatterySaverSettings.class.getName(), 184 new SearchIndexableResource( 185 Ranking.getRankForClassName(BatterySaverSettings.class.getName()), 186 R.xml.battery_saver_settings, 187 BatterySaverSettings.class.getName(), 188 R.drawable.ic_settings_battery)); 189 UserSettings.class.getName()190 sResMap.put(UserSettings.class.getName(), 191 new SearchIndexableResource( 192 Ranking.getRankForClassName(UserSettings.class.getName()), 193 R.xml.user_settings, 194 UserSettings.class.getName(), 195 R.drawable.ic_settings_multiuser)); 196 LocationSettings.class.getName()197 sResMap.put(LocationSettings.class.getName(), 198 new SearchIndexableResource( 199 Ranking.getRankForClassName(LocationSettings.class.getName()), 200 R.xml.location_settings, 201 LocationSettings.class.getName(), 202 R.drawable.ic_settings_location)); 203 SecuritySettings.class.getName()204 sResMap.put(SecuritySettings.class.getName(), 205 new SearchIndexableResource( 206 Ranking.getRankForClassName(SecuritySettings.class.getName()), 207 NO_DATA_RES_ID, 208 SecuritySettings.class.getName(), 209 R.drawable.ic_settings_security)); 210 ScreenPinningSettings.class.getName()211 sResMap.put(ScreenPinningSettings.class.getName(), 212 new SearchIndexableResource( 213 Ranking.getRankForClassName(ScreenPinningSettings.class.getName()), 214 NO_DATA_RES_ID, 215 ScreenPinningSettings.class.getName(), 216 R.drawable.ic_settings_security)); 217 InputMethodAndLanguageSettings.class.getName()218 sResMap.put(InputMethodAndLanguageSettings.class.getName(), 219 new SearchIndexableResource( 220 Ranking.getRankForClassName(InputMethodAndLanguageSettings.class.getName()), 221 NO_DATA_RES_ID, 222 InputMethodAndLanguageSettings.class.getName(), 223 R.drawable.ic_settings_language)); 224 VoiceInputSettings.class.getName()225 sResMap.put(VoiceInputSettings.class.getName(), 226 new SearchIndexableResource( 227 Ranking.getRankForClassName(VoiceInputSettings.class.getName()), 228 NO_DATA_RES_ID, 229 VoiceInputSettings.class.getName(), 230 R.drawable.ic_settings_language)); 231 PrivacySettings.class.getName()232 sResMap.put(PrivacySettings.class.getName(), 233 new SearchIndexableResource( 234 Ranking.getRankForClassName(PrivacySettings.class.getName()), 235 NO_DATA_RES_ID, 236 PrivacySettings.class.getName(), 237 R.drawable.ic_settings_backup)); 238 DateTimeSettings.class.getName()239 sResMap.put(DateTimeSettings.class.getName(), 240 new SearchIndexableResource( 241 Ranking.getRankForClassName(DateTimeSettings.class.getName()), 242 R.xml.date_time_prefs, 243 DateTimeSettings.class.getName(), 244 R.drawable.ic_settings_date_time)); 245 AccessibilitySettings.class.getName()246 sResMap.put(AccessibilitySettings.class.getName(), 247 new SearchIndexableResource( 248 Ranking.getRankForClassName(AccessibilitySettings.class.getName()), 249 NO_DATA_RES_ID, 250 AccessibilitySettings.class.getName(), 251 R.drawable.ic_settings_accessibility)); 252 PrintSettingsFragment.class.getName()253 sResMap.put(PrintSettingsFragment.class.getName(), 254 new SearchIndexableResource( 255 Ranking.getRankForClassName(PrintSettingsFragment.class.getName()), 256 NO_DATA_RES_ID, 257 PrintSettingsFragment.class.getName(), 258 R.drawable.ic_settings_print)); 259 DevelopmentSettings.class.getName()260 sResMap.put(DevelopmentSettings.class.getName(), 261 new SearchIndexableResource( 262 Ranking.getRankForClassName(DevelopmentSettings.class.getName()), 263 NO_DATA_RES_ID, 264 DevelopmentSettings.class.getName(), 265 R.drawable.ic_settings_development)); 266 DeviceInfoSettings.class.getName()267 sResMap.put(DeviceInfoSettings.class.getName(), 268 new SearchIndexableResource( 269 Ranking.getRankForClassName(DeviceInfoSettings.class.getName()), 270 NO_DATA_RES_ID, 271 DeviceInfoSettings.class.getName(), 272 R.drawable.ic_settings_about)); 273 } 274 SearchIndexableResources()275 private SearchIndexableResources() { 276 } 277 size()278 public static int size() { 279 return sResMap.size(); 280 } 281 getResourceByName(String className)282 public static SearchIndexableResource getResourceByName(String className) { 283 return sResMap.get(className); 284 } 285 values()286 public static Collection<SearchIndexableResource> values() { 287 return sResMap.values(); 288 } 289 } 290