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