Fabrice Di Meglio | 51bfee5 | 2014-03-20 19:52:29 -0700 | [diff] [blame] | 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 | |
Jason Monk | 91e2f89 | 2016-02-23 15:31:09 -0500 | [diff] [blame] | 19 | import android.provider.SearchIndexableResource; |
Tadashi G. Takaoka | b51f6bf | 2016-11-22 23:53:36 +0900 | [diff] [blame] | 20 | import android.support.annotation.DrawableRes; |
| 21 | import android.support.annotation.VisibleForTesting; |
| 22 | import android.support.annotation.XmlRes; |
Fan Zhang | 762b496 | 2016-11-30 15:56:17 -0800 | [diff] [blame^] | 23 | |
Fabrice Di Meglio | 51bfee5 | 2014-03-20 19:52:29 -0700 | [diff] [blame] | 24 | import com.android.settings.DateTimeSettings; |
| 25 | import com.android.settings.DevelopmentSettings; |
| 26 | import com.android.settings.DeviceInfoSettings; |
| 27 | import com.android.settings.DisplaySettings; |
Jason Monk | f940232 | 2015-06-10 10:02:59 -0400 | [diff] [blame] | 28 | import com.android.settings.LegalSettings; |
Fabrice Di Meglio | 51bfee5 | 2014-03-20 19:52:29 -0700 | [diff] [blame] | 29 | import com.android.settings.PrivacySettings; |
| 30 | import com.android.settings.R; |
John Spurlock | 45fa140 | 2015-04-09 12:50:04 -0400 | [diff] [blame] | 31 | import com.android.settings.ScreenPinningSettings; |
Fabrice Di Meglio | 51bfee5 | 2014-03-20 19:52:29 -0700 | [diff] [blame] | 32 | import com.android.settings.SecuritySettings; |
Fabrice Di Meglio | 51bfee5 | 2014-03-20 19:52:29 -0700 | [diff] [blame] | 33 | import com.android.settings.WallpaperTypeSettings; |
| 34 | import com.android.settings.WirelessSettings; |
| 35 | import com.android.settings.accessibility.AccessibilitySettings; |
Julia Reynolds | b7237a1 | 2015-08-18 08:31:11 -0400 | [diff] [blame] | 36 | import com.android.settings.accounts.AccountSettings; |
Jason Monk | 5b3aa36 | 2015-03-18 16:03:57 -0400 | [diff] [blame] | 37 | import com.android.settings.applications.AdvancedAppSettings; |
Jason Monk | 91e2f89 | 2016-02-23 15:31:09 -0500 | [diff] [blame] | 38 | import com.android.settings.applications.SpecialAccessSettings; |
Fabrice Di Meglio | 51bfee5 | 2014-03-20 19:52:29 -0700 | [diff] [blame] | 39 | import com.android.settings.bluetooth.BluetoothSettings; |
Fan Zhang | 762b496 | 2016-11-30 15:56:17 -0800 | [diff] [blame^] | 40 | import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment; |
Jason Monk | b37e288 | 2016-01-11 14:27:20 -0500 | [diff] [blame] | 41 | import com.android.settings.datausage.DataUsageMeteredSettings; |
| 42 | import com.android.settings.datausage.DataUsageSummary; |
Fan Zhang | 31a2853 | 2016-10-04 17:48:32 -0700 | [diff] [blame] | 43 | import com.android.settings.deviceinfo.StorageDashboardFragment; |
Jeff Sharkey | 42833b2 | 2015-04-11 21:27:33 -0700 | [diff] [blame] | 44 | import com.android.settings.deviceinfo.StorageSettings; |
Alan Viverette | 01a04f1 | 2015-12-10 14:07:51 -0500 | [diff] [blame] | 45 | import com.android.settings.display.ScreenZoomSettings; |
Bartosz Fabianowski | 05061fc | 2016-11-14 12:04:49 +0100 | [diff] [blame] | 46 | import com.android.settings.enterprise.EnterprisePrivacySettings; |
John Spurlock | c7f8e8c | 2014-06-04 19:11:22 -0400 | [diff] [blame] | 47 | import com.android.settings.fuelgauge.BatterySaverSettings; |
Fabrice Di Meglio | 51bfee5 | 2014-03-20 19:52:29 -0700 | [diff] [blame] | 48 | import com.android.settings.fuelgauge.PowerUsageSummary; |
Doris Ling | ffb87f7 | 2016-07-19 11:45:03 -0700 | [diff] [blame] | 49 | import com.android.settings.gestures.GestureSettings; |
Fabrice Di Meglio | 51bfee5 | 2014-03-20 19:52:29 -0700 | [diff] [blame] | 50 | import com.android.settings.inputmethod.InputMethodAndLanguageSettings; |
| 51 | import com.android.settings.location.LocationSettings; |
Lifu Tang | ff6d489 | 2015-03-26 17:56:52 -0700 | [diff] [blame] | 52 | import com.android.settings.location.ScanningSettings; |
Julia Reynolds | 8c0a423 | 2015-11-24 10:08:14 -0500 | [diff] [blame] | 53 | import com.android.settings.notification.ConfigureNotificationSettings; |
John Spurlock | 4e4cdef | 2014-05-28 09:43:45 -0400 | [diff] [blame] | 54 | import com.android.settings.notification.OtherSoundSettings; |
Julia Reynolds | 8c0a423 | 2015-11-24 10:08:14 -0500 | [diff] [blame] | 55 | import com.android.settings.notification.SoundSettings; |
John Spurlock | 48bbd5d | 2015-04-03 13:51:03 -0400 | [diff] [blame] | 56 | import com.android.settings.notification.ZenModePrioritySettings; |
John Spurlock | 4a35051 | 2014-04-08 14:08:21 -0400 | [diff] [blame] | 57 | import com.android.settings.notification.ZenModeSettings; |
Julia Reynolds | 5555d26 | 2015-11-09 10:52:17 -0500 | [diff] [blame] | 58 | import com.android.settings.notification.ZenModeVisualInterruptionSettings; |
Fabrice Di Meglio | 51bfee5 | 2014-03-20 19:52:29 -0700 | [diff] [blame] | 59 | import com.android.settings.print.PrintSettingsFragment; |
PauloftheWest | 3815561 | 2014-06-30 10:02:36 -0700 | [diff] [blame] | 60 | import com.android.settings.sim.SimSettings; |
Fan Zhang | c6540cf | 2016-10-03 17:11:11 -0700 | [diff] [blame] | 61 | import com.android.settings.system.SystemDashboardFragment; |
Fabrice Di Meglio | 51bfee5 | 2014-03-20 19:52:29 -0700 | [diff] [blame] | 62 | import com.android.settings.users.UserSettings; |
Fabrice Di Meglio | 3448374 | 2014-05-09 19:08:44 -0700 | [diff] [blame] | 63 | import com.android.settings.wifi.AdvancedWifiSettings; |
PauloftheWest | 7837b99 | 2014-06-24 07:42:27 -0700 | [diff] [blame] | 64 | import com.android.settings.wifi.SavedAccessPointsWifiSettings; |
Fabrice Di Meglio | 51bfee5 | 2014-03-20 19:52:29 -0700 | [diff] [blame] | 65 | import com.android.settings.wifi.WifiSettings; |
| 66 | |
| 67 | import java.util.Collection; |
| 68 | import java.util.HashMap; |
Fabrice Di Meglio | 51bfee5 | 2014-03-20 19:52:29 -0700 | [diff] [blame] | 69 | |
| 70 | public final class SearchIndexableResources { |
| 71 | |
Tadashi G. Takaoka | b51f6bf | 2016-11-22 23:53:36 +0900 | [diff] [blame] | 72 | @XmlRes |
| 73 | public static final int NO_DATA_RES_ID = 0; |
Fabrice Di Meglio | 51bfee5 | 2014-03-20 19:52:29 -0700 | [diff] [blame] | 74 | |
Tadashi G. Takaoka | b51f6bf | 2016-11-22 23:53:36 +0900 | [diff] [blame] | 75 | private static final HashMap<String, SearchIndexableResource> sResMap = new HashMap<>(); |
| 76 | |
| 77 | @VisibleForTesting |
| 78 | static void addIndex(Class<?> indexClass, @XmlRes int xmlResId, |
| 79 | @DrawableRes int iconResId) { |
| 80 | String className = indexClass.getName(); |
| 81 | int rank = Ranking.getRankForClassName(className); |
| 82 | sResMap.put(className, new SearchIndexableResource(rank, xmlResId, className, iconResId)); |
| 83 | } |
Fabrice Di Meglio | 51bfee5 | 2014-03-20 19:52:29 -0700 | [diff] [blame] | 84 | |
Fabrice Di Meglio | 51bfee5 | 2014-03-20 19:52:29 -0700 | [diff] [blame] | 85 | static { |
Tadashi G. Takaoka | b51f6bf | 2016-11-22 23:53:36 +0900 | [diff] [blame] | 86 | addIndex(WifiSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_wireless); |
| 87 | addIndex(AdvancedWifiSettings.class, |
Fan Zhang | 762b496 | 2016-11-30 15:56:17 -0800 | [diff] [blame^] | 88 | R.xml.wifi_advanced_settings, R.drawable.ic_settings_wireless); |
Tadashi G. Takaoka | b51f6bf | 2016-11-22 23:53:36 +0900 | [diff] [blame] | 89 | addIndex(SavedAccessPointsWifiSettings.class, |
Fan Zhang | 762b496 | 2016-11-30 15:56:17 -0800 | [diff] [blame^] | 90 | R.xml.wifi_display_saved_access_points, R.drawable.ic_settings_wireless); |
Tadashi G. Takaoka | b51f6bf | 2016-11-22 23:53:36 +0900 | [diff] [blame] | 91 | addIndex(BluetoothSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_bluetooth); |
| 92 | addIndex(SimSettings.class, NO_DATA_RES_ID, R.drawable.ic_sim_sd); |
| 93 | addIndex(DataUsageSummary.class, NO_DATA_RES_ID, R.drawable.ic_settings_data_usage); |
| 94 | addIndex(DataUsageMeteredSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_data_usage); |
| 95 | addIndex(WirelessSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_more); |
| 96 | addIndex(ScreenZoomSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_display); |
| 97 | addIndex(DisplaySettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_display); |
| 98 | addIndex(WallpaperTypeSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_display); |
| 99 | addIndex(ConfigureNotificationSettings.class, |
Fan Zhang | 762b496 | 2016-11-30 15:56:17 -0800 | [diff] [blame^] | 100 | R.xml.configure_notification_settings, R.drawable.ic_settings_notifications); |
Tadashi G. Takaoka | b51f6bf | 2016-11-22 23:53:36 +0900 | [diff] [blame] | 101 | addIndex(SoundSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_sound); |
| 102 | addIndex(OtherSoundSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_sound); |
| 103 | addIndex(ZenModeSettings.class, |
Fan Zhang | 762b496 | 2016-11-30 15:56:17 -0800 | [diff] [blame^] | 104 | R.xml.zen_mode_settings, R.drawable.ic_settings_notifications); |
Tadashi G. Takaoka | b51f6bf | 2016-11-22 23:53:36 +0900 | [diff] [blame] | 105 | addIndex(ZenModePrioritySettings.class, |
Fan Zhang | 762b496 | 2016-11-30 15:56:17 -0800 | [diff] [blame^] | 106 | R.xml.zen_mode_priority_settings, R.drawable.ic_settings_notifications); |
Tadashi G. Takaoka | b51f6bf | 2016-11-22 23:53:36 +0900 | [diff] [blame] | 107 | addIndex(StorageSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_storage); |
| 108 | addIndex(PowerUsageSummary.class, |
Fan Zhang | 762b496 | 2016-11-30 15:56:17 -0800 | [diff] [blame^] | 109 | R.xml.power_usage_summary, R.drawable.ic_settings_battery); |
Tadashi G. Takaoka | b51f6bf | 2016-11-22 23:53:36 +0900 | [diff] [blame] | 110 | addIndex(BatterySaverSettings.class, |
Fan Zhang | 762b496 | 2016-11-30 15:56:17 -0800 | [diff] [blame^] | 111 | R.xml.battery_saver_settings, R.drawable.ic_settings_battery); |
Tadashi G. Takaoka | b51f6bf | 2016-11-22 23:53:36 +0900 | [diff] [blame] | 112 | addIndex(AdvancedAppSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_applications); |
| 113 | addIndex(SpecialAccessSettings.class, |
Fan Zhang | 762b496 | 2016-11-30 15:56:17 -0800 | [diff] [blame^] | 114 | R.xml.special_access, R.drawable.ic_settings_applications); |
Tadashi G. Takaoka | b51f6bf | 2016-11-22 23:53:36 +0900 | [diff] [blame] | 115 | addIndex(UserSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_multiuser); |
| 116 | addIndex(GestureSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_gestures); |
| 117 | addIndex(LocationSettings.class, R.xml.location_settings, R.drawable.ic_settings_location); |
| 118 | addIndex(ScanningSettings.class, R.xml.location_scanning, R.drawable.ic_settings_location); |
| 119 | addIndex(SecuritySettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_security); |
| 120 | addIndex(ScreenPinningSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_security); |
| 121 | addIndex(AccountSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_accounts); |
| 122 | addIndex(InputMethodAndLanguageSettings.class, |
Fan Zhang | 762b496 | 2016-11-30 15:56:17 -0800 | [diff] [blame^] | 123 | NO_DATA_RES_ID, R.drawable.ic_settings_language); |
Tadashi G. Takaoka | b51f6bf | 2016-11-22 23:53:36 +0900 | [diff] [blame] | 124 | addIndex(PrivacySettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_backup); |
| 125 | addIndex(DateTimeSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_date_time); |
| 126 | addIndex(AccessibilitySettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_accessibility); |
| 127 | addIndex(PrintSettingsFragment.class, NO_DATA_RES_ID, R.drawable.ic_settings_print); |
| 128 | addIndex(DevelopmentSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_development); |
| 129 | addIndex(DeviceInfoSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_about); |
| 130 | addIndex(LegalSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_about); |
| 131 | addIndex(ZenModeVisualInterruptionSettings.class, |
Fan Zhang | 762b496 | 2016-11-30 15:56:17 -0800 | [diff] [blame^] | 132 | R.xml.zen_mode_visual_interruptions_settings, |
| 133 | R.drawable.ic_settings_notifications); |
Tadashi G. Takaoka | b51f6bf | 2016-11-22 23:53:36 +0900 | [diff] [blame] | 134 | addIndex(SystemDashboardFragment.class, NO_DATA_RES_ID, R.drawable.ic_settings_about); |
| 135 | addIndex(StorageDashboardFragment.class, NO_DATA_RES_ID, R.drawable.ic_settings_storage); |
Fan Zhang | 762b496 | 2016-11-30 15:56:17 -0800 | [diff] [blame^] | 136 | addIndex(ConnectedDeviceDashboardFragment.class, NO_DATA_RES_ID, R.drawable.ic_bt_laptop); |
Tadashi G. Takaoka | b51f6bf | 2016-11-22 23:53:36 +0900 | [diff] [blame] | 137 | addIndex(EnterprisePrivacySettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_about); |
Fabrice Di Meglio | 51bfee5 | 2014-03-20 19:52:29 -0700 | [diff] [blame] | 138 | } |
| 139 | |
| 140 | private SearchIndexableResources() { |
| 141 | } |
| 142 | |
| 143 | public static int size() { |
| 144 | return sResMap.size(); |
| 145 | } |
| 146 | |
| 147 | public static SearchIndexableResource getResourceByName(String className) { |
| 148 | return sResMap.get(className); |
| 149 | } |
| 150 | |
| 151 | public static Collection<SearchIndexableResource> values() { |
| 152 | return sResMap.values(); |
| 153 | } |
| 154 | } |