2 * Copyright (C) 2014 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.android.settings.search;
19 import android.provider.SearchIndexableResource;
20 import android.support.annotation.DrawableRes;
21 import android.support.annotation.VisibleForTesting;
22 import android.support.annotation.XmlRes;
23 import com.android.settings.DateTimeSettings;
24 import com.android.settings.DevelopmentSettings;
25 import com.android.settings.DeviceInfoSettings;
26 import com.android.settings.DisplaySettings;
27 import com.android.settings.EncryptionAndCredential;
28 import com.android.settings.LegalSettings;
29 import com.android.settings.PrivacySettings;
30 import com.android.settings.R;
31 import com.android.settings.ScreenPinningSettings;
32 import com.android.settings.SecuritySettings;
33 import com.android.settings.WallpaperTypeSettings;
34 import com.android.settings.WirelessSettings;
35 import com.android.settings.accessibility.AccessibilitySettings;
36 import com.android.settings.accounts.AccountSettings;
37 import com.android.settings.accounts.UserAndAccountDashboardFragment;
38 import com.android.settings.applications.AdvancedAppSettings;
39 import com.android.settings.applications.AppAndNotificationDashboardFragment;
40 import com.android.settings.applications.SpecialAccessSettings;
41 import com.android.settings.applications.assist.ManageAssist;
42 import com.android.settings.backup.BackupSettingsFragment;
43 import com.android.settings.bluetooth.BluetoothSettings;
44 import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment;
45 import com.android.settings.datausage.DataUsageMeteredSettings;
46 import com.android.settings.datausage.DataUsageSummary;
47 import com.android.settings.deviceinfo.StorageDashboardFragment;
48 import com.android.settings.deviceinfo.StorageSettings;
49 import com.android.settings.display.ScreenZoomSettings;
50 import com.android.settings.enterprise.EnterprisePrivacySettings;
51 import com.android.settings.fuelgauge.BatterySaverSettings;
52 import com.android.settings.fuelgauge.PowerUsageAdvanced;
53 import com.android.settings.fuelgauge.PowerUsageDetail;
54 import com.android.settings.fuelgauge.PowerUsageSummary;
55 import com.android.settings.gestures.AssistGestureSettings;
56 import com.android.settings.gestures.DoubleTapPowerSettings;
57 import com.android.settings.gestures.DoubleTapScreenSettings;
58 import com.android.settings.gestures.DoubleTwistGestureSettings;
59 import com.android.settings.gestures.GestureSettings;
60 import com.android.settings.gestures.PickupGestureSettings;
61 import com.android.settings.gestures.SwipeToNotificationSettings;
62 import com.android.settings.inputmethod.AvailableVirtualKeyboardFragment;
63 import com.android.settings.inputmethod.InputMethodAndLanguageSettings;
64 import com.android.settings.inputmethod.PhysicalKeyboardFragment;
65 import com.android.settings.inputmethod.VirtualKeyboardFragment;
66 import com.android.settings.language.LanguageAndInputSettings;
67 import com.android.settings.location.LocationSettings;
68 import com.android.settings.location.ScanningSettings;
69 import com.android.settings.network.NetworkDashboardFragment;
70 import com.android.settings.nfc.PaymentSettings;
71 import com.android.settings.notification.ConfigureNotificationSettings;
72 import com.android.settings.notification.OtherSoundSettings;
73 import com.android.settings.notification.SoundSettings;
74 import com.android.settings.notification.ZenModePrioritySettings;
75 import com.android.settings.notification.ZenModeSettings;
76 import com.android.settings.notification.ZenModeVisualInterruptionSettings;
77 import com.android.settings.print.PrintSettingsFragment;
78 import com.android.settings.sim.SimSettings;
79 import com.android.settings.system.SystemDashboardFragment;
80 import com.android.settings.tts.TtsEnginePreferenceFragment;
81 import com.android.settings.tts.TtsSlidersFragment;
82 import com.android.settings.users.UserSettings;
83 import com.android.settings.wifi.ConfigureWifiSettings;
84 import com.android.settings.wifi.SavedAccessPointsWifiSettings;
85 import com.android.settings.wifi.WifiSettings;
87 import java.util.Collection;
88 import java.util.HashMap;
90 public final class SearchIndexableResources {
93 public static final int NO_DATA_RES_ID = 0;
95 @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
96 static final HashMap<String, SearchIndexableResource> sResMap = new HashMap<>();
99 static void addIndex(Class<?> indexClass, @XmlRes int xmlResId,
100 @DrawableRes int iconResId) {
101 String className = indexClass.getName();
102 int rank = Ranking.getRankForClassName(className);
103 sResMap.put(className, new SearchIndexableResource(rank, xmlResId, className, iconResId));
107 addIndex(WifiSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_wireless);
108 addIndex(NetworkDashboardFragment.class, NO_DATA_RES_ID, R.drawable.ic_settings_wireless);
109 addIndex(ConfigureWifiSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_wireless);
110 addIndex(SavedAccessPointsWifiSettings.class, NO_DATA_RES_ID,
111 R.drawable.ic_settings_wireless);
112 addIndex(BluetoothSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_bluetooth);
113 addIndex(SimSettings.class, NO_DATA_RES_ID, R.drawable.ic_sim_sd);
114 addIndex(DataUsageSummary.class, NO_DATA_RES_ID, R.drawable.ic_settings_data_usage);
115 addIndex(DataUsageMeteredSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_data_usage);
116 addIndex(WirelessSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_more);
117 addIndex(ScreenZoomSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_display);
118 addIndex(DisplaySettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_display);
119 addIndex(WallpaperTypeSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_display);
120 addIndex(ConfigureNotificationSettings.class,
121 R.xml.configure_notification_settings, R.drawable.ic_settings_notifications);
122 addIndex(AppAndNotificationDashboardFragment.class, NO_DATA_RES_ID,
123 R.drawable.ic_settings_applications);
124 addIndex(SoundSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_sound);
125 addIndex(OtherSoundSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_sound);
126 addIndex(ZenModeSettings.class,
127 R.xml.zen_mode_settings, R.drawable.ic_settings_notifications);
128 addIndex(ZenModePrioritySettings.class,
129 R.xml.zen_mode_priority_settings, R.drawable.ic_settings_notifications);
130 addIndex(StorageSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_storage);
131 addIndex(PowerUsageSummary.class,
132 R.xml.power_usage_summary, R.drawable.ic_settings_battery);
133 addIndex(PowerUsageDetail.class, NO_DATA_RES_ID, R.drawable.ic_settings_battery);
134 addIndex(PowerUsageAdvanced.class, NO_DATA_RES_ID, R.drawable.ic_settings_battery);
135 addIndex(BatterySaverSettings.class,
136 R.xml.battery_saver_settings, R.drawable.ic_settings_battery);
137 addIndex(AdvancedAppSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_applications);
138 addIndex(ManageAssist.class, NO_DATA_RES_ID, R.drawable.ic_settings_applications);
139 addIndex(SpecialAccessSettings.class,
140 R.xml.special_access, R.drawable.ic_settings_applications);
141 addIndex(UserSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_multiuser);
142 addIndex(GestureSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_gestures);
143 addIndex(AssistGestureSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_gestures);
144 addIndex(PickupGestureSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_gestures);
145 addIndex(DoubleTapScreenSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_gestures);
146 addIndex(DoubleTapPowerSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_gestures);
147 addIndex(DoubleTwistGestureSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_gestures);
148 addIndex(SwipeToNotificationSettings.class, NO_DATA_RES_ID,
149 R.drawable.ic_settings_gestures);
150 addIndex(LanguageAndInputSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_language);
151 addIndex(LocationSettings.class, R.xml.location_settings, R.drawable.ic_settings_location);
152 addIndex(ScanningSettings.class, R.xml.location_scanning, R.drawable.ic_settings_location);
153 addIndex(SecuritySettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_security);
154 addIndex(EncryptionAndCredential.class, R.xml.encryption_and_credential,
155 R.drawable.ic_settings_security);
156 addIndex(ScreenPinningSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_security);
157 addIndex(AccountSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_accounts);
158 addIndex(UserAndAccountDashboardFragment.class, NO_DATA_RES_ID,
159 R.drawable.ic_settings_accounts);
160 addIndex(InputMethodAndLanguageSettings.class,
161 NO_DATA_RES_ID, R.drawable.ic_settings_language);
162 addIndex(VirtualKeyboardFragment.class, NO_DATA_RES_ID, R.drawable.ic_settings_language);
163 addIndex(AvailableVirtualKeyboardFragment.class,
164 NO_DATA_RES_ID, R.drawable.ic_settings_language);
165 addIndex(PhysicalKeyboardFragment.class, NO_DATA_RES_ID, R.drawable.ic_settings_language);
166 addIndex(PrivacySettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_backup);
167 addIndex(BackupSettingsFragment.class, NO_DATA_RES_ID, R.drawable.ic_settings_backup);
168 addIndex(DateTimeSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_date_time);
169 addIndex(AccessibilitySettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_accessibility);
170 addIndex(PrintSettingsFragment.class, NO_DATA_RES_ID, R.drawable.ic_settings_print);
171 addIndex(DevelopmentSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_development);
172 addIndex(DeviceInfoSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_about);
173 addIndex(LegalSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_about);
174 addIndex(ZenModeVisualInterruptionSettings.class,
175 R.xml.zen_mode_visual_interruptions_settings,
176 R.drawable.ic_settings_notifications);
177 addIndex(SystemDashboardFragment.class, NO_DATA_RES_ID, R.drawable.ic_settings_about);
178 addIndex(StorageDashboardFragment.class, NO_DATA_RES_ID, R.drawable.ic_settings_storage);
179 addIndex(ConnectedDeviceDashboardFragment.class, NO_DATA_RES_ID, R.drawable.ic_bt_laptop);
180 addIndex(EnterprisePrivacySettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_about);
181 addIndex(PaymentSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_nfc_payment);
183 TtsEnginePreferenceFragment.class, NO_DATA_RES_ID, R.drawable.ic_settings_language);
184 addIndex(TtsSlidersFragment.class, NO_DATA_RES_ID, R.drawable.ic_settings_language);
187 private SearchIndexableResources() {
190 public static int size() {
191 return sResMap.size();
194 public static SearchIndexableResource getResourceByName(String className) {
195 return sResMap.get(className);
198 public static Collection<SearchIndexableResource> values() {
199 return sResMap.values();