Fabrice Di Meglio | b49995d | 2014-03-14 19:06:20 -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 android.provider; |
| 18 | |
Fabrice Di Meglio | 27e1334 | 2015-03-09 16:49:00 -0700 | [diff] [blame] | 19 | import android.annotation.SystemApi; |
Fabrice Di Meglio | b49995d | 2014-03-14 19:06:20 -0700 | [diff] [blame] | 20 | import android.content.ContentResolver; |
| 21 | |
| 22 | /** |
| 23 | * Describe the contract for an Indexable data. |
| 24 | * |
| 25 | * @hide |
| 26 | */ |
Fabrice Di Meglio | 27e1334 | 2015-03-09 16:49:00 -0700 | [diff] [blame] | 27 | @SystemApi |
Fabrice Di Meglio | b49995d | 2014-03-14 19:06:20 -0700 | [diff] [blame] | 28 | public class SearchIndexablesContract { |
| 29 | |
| 30 | /** |
| 31 | * Intent action used to identify {@link SearchIndexablesProvider} |
| 32 | * instances. This is used in the {@code <intent-filter>} of a {@code <provider>}. |
| 33 | */ |
| 34 | public static final String PROVIDER_INTERFACE = |
| 35 | "android.content.action.SEARCH_INDEXABLES_PROVIDER"; |
| 36 | |
| 37 | private static final String SETTINGS = "settings"; |
| 38 | |
| 39 | /** |
Fabrice Di Meglio | 97babb1 | 2014-04-11 18:45:44 -0700 | [diff] [blame] | 40 | * Indexable reference names. |
Fabrice Di Meglio | b49995d | 2014-03-14 19:06:20 -0700 | [diff] [blame] | 41 | */ |
| 42 | public static final String INDEXABLES_XML_RES = "indexables_xml_res"; |
| 43 | |
| 44 | /** |
| 45 | * ContentProvider path for indexable xml resources. |
| 46 | */ |
| 47 | public static final String INDEXABLES_XML_RES_PATH = SETTINGS + "/" + INDEXABLES_XML_RES; |
| 48 | |
| 49 | /** |
Fabrice Di Meglio | 97babb1 | 2014-04-11 18:45:44 -0700 | [diff] [blame] | 50 | * Indexable raw data names. |
Fabrice Di Meglio | b49995d | 2014-03-14 19:06:20 -0700 | [diff] [blame] | 51 | */ |
| 52 | public static final String INDEXABLES_RAW = "indexables_raw"; |
| 53 | |
| 54 | /** |
| 55 | * ContentProvider path for indexable raw data. |
| 56 | */ |
| 57 | public static final String INDEXABLES_RAW_PATH = SETTINGS + "/" + INDEXABLES_RAW; |
| 58 | |
| 59 | /** |
Fabrice Di Meglio | 97babb1 | 2014-04-11 18:45:44 -0700 | [diff] [blame] | 60 | * Non indexable data keys. |
| 61 | */ |
| 62 | public static final String NON_INDEXABLES_KEYS = "non_indexables_key"; |
| 63 | |
| 64 | /** |
| 65 | * ContentProvider path for non indexable data keys. |
| 66 | */ |
| 67 | public static final String NON_INDEXABLES_KEYS_PATH = SETTINGS + "/" + NON_INDEXABLES_KEYS; |
| 68 | |
| 69 | /** |
Fabrice Di Meglio | 83c0fdd | 2014-07-10 12:11:47 -0700 | [diff] [blame] | 70 | * Indexable xml resources columns. |
Fabrice Di Meglio | b49995d | 2014-03-14 19:06:20 -0700 | [diff] [blame] | 71 | */ |
| 72 | public static final String[] INDEXABLES_XML_RES_COLUMNS = new String[] { |
Fabrice Di Meglio | 1ecde22 | 2014-04-09 13:17:42 -0700 | [diff] [blame] | 73 | XmlResource.COLUMN_RANK, // 0 |
| 74 | XmlResource.COLUMN_XML_RESID, // 1 |
| 75 | XmlResource.COLUMN_CLASS_NAME, // 2 |
| 76 | XmlResource.COLUMN_ICON_RESID, // 3 |
| 77 | XmlResource.COLUMN_INTENT_ACTION, // 4 |
| 78 | XmlResource.COLUMN_INTENT_TARGET_PACKAGE, // 5 |
| 79 | XmlResource.COLUMN_INTENT_TARGET_CLASS // 6 |
Fabrice Di Meglio | b49995d | 2014-03-14 19:06:20 -0700 | [diff] [blame] | 80 | }; |
| 81 | |
| 82 | /** |
Fabrice Di Meglio | 83c0fdd | 2014-07-10 12:11:47 -0700 | [diff] [blame] | 83 | * Indexable xml resources columns indices. |
Fabrice Di Meglio | 1ecde22 | 2014-04-09 13:17:42 -0700 | [diff] [blame] | 84 | */ |
| 85 | public static final int COLUMN_INDEX_XML_RES_RANK = 0; |
| 86 | public static final int COLUMN_INDEX_XML_RES_RESID = 1; |
| 87 | public static final int COLUMN_INDEX_XML_RES_CLASS_NAME = 2; |
| 88 | public static final int COLUMN_INDEX_XML_RES_ICON_RESID = 3; |
| 89 | public static final int COLUMN_INDEX_XML_RES_INTENT_ACTION = 4; |
| 90 | public static final int COLUMN_INDEX_XML_RES_INTENT_TARGET_PACKAGE = 5; |
| 91 | public static final int COLUMN_INDEX_XML_RES_INTENT_TARGET_CLASS = 6; |
| 92 | |
| 93 | /** |
Fabrice Di Meglio | 83c0fdd | 2014-07-10 12:11:47 -0700 | [diff] [blame] | 94 | * Indexable raw data columns. |
Fabrice Di Meglio | b49995d | 2014-03-14 19:06:20 -0700 | [diff] [blame] | 95 | */ |
| 96 | public static final String[] INDEXABLES_RAW_COLUMNS = new String[] { |
Fabrice Di Meglio | 1ecde22 | 2014-04-09 13:17:42 -0700 | [diff] [blame] | 97 | RawData.COLUMN_RANK, // 0 |
| 98 | RawData.COLUMN_TITLE, // 1 |
| 99 | RawData.COLUMN_SUMMARY_ON, // 2 |
| 100 | RawData.COLUMN_SUMMARY_OFF, // 3 |
| 101 | RawData.COLUMN_ENTRIES, // 4 |
| 102 | RawData.COLUMN_KEYWORDS, // 5 |
| 103 | RawData.COLUMN_SCREEN_TITLE, // 6 |
| 104 | RawData.COLUMN_CLASS_NAME, // 7 |
| 105 | RawData.COLUMN_ICON_RESID, // 8 |
| 106 | RawData.COLUMN_INTENT_ACTION, // 9 |
| 107 | RawData.COLUMN_INTENT_TARGET_PACKAGE, // 10 |
| 108 | RawData.COLUMN_INTENT_TARGET_CLASS, // 11 |
| 109 | RawData.COLUMN_KEY, // 12 |
Fabrice Di Meglio | 83c0fdd | 2014-07-10 12:11:47 -0700 | [diff] [blame] | 110 | RawData.COLUMN_USER_ID, // 13 |
Fabrice Di Meglio | b49995d | 2014-03-14 19:06:20 -0700 | [diff] [blame] | 111 | }; |
| 112 | |
| 113 | /** |
Fabrice Di Meglio | 83c0fdd | 2014-07-10 12:11:47 -0700 | [diff] [blame] | 114 | * Indexable raw data columns indices. |
Fabrice Di Meglio | 1ecde22 | 2014-04-09 13:17:42 -0700 | [diff] [blame] | 115 | */ |
| 116 | public static final int COLUMN_INDEX_RAW_RANK = 0; |
| 117 | public static final int COLUMN_INDEX_RAW_TITLE = 1; |
| 118 | public static final int COLUMN_INDEX_RAW_SUMMARY_ON = 2; |
| 119 | public static final int COLUMN_INDEX_RAW_SUMMARY_OFF = 3; |
| 120 | public static final int COLUMN_INDEX_RAW_ENTRIES = 4; |
| 121 | public static final int COLUMN_INDEX_RAW_KEYWORDS = 5; |
| 122 | public static final int COLUMN_INDEX_RAW_SCREEN_TITLE = 6; |
| 123 | public static final int COLUMN_INDEX_RAW_CLASS_NAME = 7; |
| 124 | public static final int COLUMN_INDEX_RAW_ICON_RESID = 8; |
| 125 | public static final int COLUMN_INDEX_RAW_INTENT_ACTION = 9; |
| 126 | public static final int COLUMN_INDEX_RAW_INTENT_TARGET_PACKAGE = 10; |
| 127 | public static final int COLUMN_INDEX_RAW_INTENT_TARGET_CLASS = 11; |
| 128 | public static final int COLUMN_INDEX_RAW_KEY = 12; |
Fabrice Di Meglio | 83c0fdd | 2014-07-10 12:11:47 -0700 | [diff] [blame] | 129 | public static final int COLUMN_INDEX_RAW_USER_ID = 13; |
Fabrice Di Meglio | 1ecde22 | 2014-04-09 13:17:42 -0700 | [diff] [blame] | 130 | |
Fabrice Di Meglio | 97babb1 | 2014-04-11 18:45:44 -0700 | [diff] [blame] | 131 | /** |
Fabrice Di Meglio | 83c0fdd | 2014-07-10 12:11:47 -0700 | [diff] [blame] | 132 | * Indexable raw data columns. |
Fabrice Di Meglio | 97babb1 | 2014-04-11 18:45:44 -0700 | [diff] [blame] | 133 | */ |
| 134 | public static final String[] NON_INDEXABLES_KEYS_COLUMNS = new String[] { |
| 135 | NonIndexableKey.COLUMN_KEY_VALUE // 0 |
| 136 | }; |
| 137 | |
| 138 | /** |
Fabrice Di Meglio | 83c0fdd | 2014-07-10 12:11:47 -0700 | [diff] [blame] | 139 | * Non indexable data keys columns indices. |
Fabrice Di Meglio | 97babb1 | 2014-04-11 18:45:44 -0700 | [diff] [blame] | 140 | */ |
| 141 | public static final int COLUMN_INDEX_NON_INDEXABLE_KEYS_KEY_VALUE = 0; |
Fabrice Di Meglio | 1ecde22 | 2014-04-09 13:17:42 -0700 | [diff] [blame] | 142 | |
| 143 | /** |
Fabrice Di Meglio | b49995d | 2014-03-14 19:06:20 -0700 | [diff] [blame] | 144 | * Constants related to a {@link SearchIndexableResource}. |
| 145 | * |
| 146 | * This is a description of |
| 147 | */ |
| 148 | public static final class XmlResource extends BaseColumns { |
| 149 | private XmlResource() { |
| 150 | } |
| 151 | |
| 152 | public static final String MIME_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE + |
| 153 | "/" + INDEXABLES_XML_RES; |
| 154 | |
| 155 | /** |
| 156 | * XML resource ID for the {@link android.preference.PreferenceScreen} to load and index. |
| 157 | */ |
| 158 | public static final String COLUMN_XML_RESID = "xmlResId"; |
| 159 | } |
| 160 | |
| 161 | /** |
| 162 | * Constants related to a {@link SearchIndexableData}. |
| 163 | * |
| 164 | * This is the raw data that is stored into an Index. This is related to |
| 165 | * {@link android.preference.Preference} and its attributes like |
| 166 | * {@link android.preference.Preference#getTitle()}, |
| 167 | * {@link android.preference.Preference#getSummary()}, etc. |
| 168 | * |
| 169 | */ |
| 170 | public static final class RawData extends BaseColumns { |
| 171 | private RawData() { |
| 172 | } |
| 173 | |
| 174 | public static final String MIME_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE + |
| 175 | "/" + INDEXABLES_RAW; |
| 176 | |
| 177 | /** |
| 178 | * Title's raw data. |
| 179 | */ |
| 180 | public static final String COLUMN_TITLE = "title"; |
| 181 | |
| 182 | /** |
Fabrice Di Meglio | 98274a9 | 2014-03-31 19:45:04 -0700 | [diff] [blame] | 183 | * Summary's raw data when the data is "ON". |
Fabrice Di Meglio | b49995d | 2014-03-14 19:06:20 -0700 | [diff] [blame] | 184 | */ |
Fabrice Di Meglio | 98274a9 | 2014-03-31 19:45:04 -0700 | [diff] [blame] | 185 | public static final String COLUMN_SUMMARY_ON = "summaryOn"; |
| 186 | |
| 187 | /** |
| 188 | * Summary's raw data when the data is "OFF". |
| 189 | */ |
| 190 | public static final String COLUMN_SUMMARY_OFF = "summaryOff"; |
Fabrice Di Meglio | b49995d | 2014-03-14 19:06:20 -0700 | [diff] [blame] | 191 | |
| 192 | /** |
Fabrice Di Meglio | a8e8f3f | 2014-04-11 17:24:02 -0700 | [diff] [blame] | 193 | * Entries associated with the raw data (when the data can have several values). |
Fabrice Di Meglio | 1ecde22 | 2014-04-09 13:17:42 -0700 | [diff] [blame] | 194 | */ |
| 195 | public static final String COLUMN_ENTRIES = "entries"; |
| 196 | |
| 197 | /** |
Fabrice Di Meglio | b49995d | 2014-03-14 19:06:20 -0700 | [diff] [blame] | 198 | * Keywords' raw data. |
| 199 | */ |
| 200 | public static final String COLUMN_KEYWORDS = "keywords"; |
| 201 | |
| 202 | /** |
Fabrice Di Meglio | a8e8f3f | 2014-04-11 17:24:02 -0700 | [diff] [blame] | 203 | * Fragment or Activity title associated with the raw data. |
Fabrice Di Meglio | b49995d | 2014-03-14 19:06:20 -0700 | [diff] [blame] | 204 | */ |
| 205 | public static final String COLUMN_SCREEN_TITLE = "screenTitle"; |
Fabrice Di Meglio | 1ecde22 | 2014-04-09 13:17:42 -0700 | [diff] [blame] | 206 | |
| 207 | /** |
| 208 | * Key associated with the raw data. The key needs to be unique. |
| 209 | */ |
| 210 | public static final String COLUMN_KEY = "key"; |
Fabrice Di Meglio | 83c0fdd | 2014-07-10 12:11:47 -0700 | [diff] [blame] | 211 | |
| 212 | /** |
| 213 | * UserId associated with the raw data. |
| 214 | */ |
| 215 | public static final String COLUMN_USER_ID = "user_id"; |
Fabrice Di Meglio | b49995d | 2014-03-14 19:06:20 -0700 | [diff] [blame] | 216 | } |
| 217 | |
| 218 | /** |
Fabrice Di Meglio | 97babb1 | 2014-04-11 18:45:44 -0700 | [diff] [blame] | 219 | * Constants related to a {@link SearchIndexableResource} and {@link SearchIndexableData}. |
| 220 | * |
| 221 | * This is a description of a data (thru its unique key) that cannot be indexed. |
| 222 | */ |
| 223 | public static final class NonIndexableKey extends BaseColumns { |
| 224 | private NonIndexableKey() { |
| 225 | } |
| 226 | |
| 227 | public static final String MIME_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE + |
| 228 | "/" + NON_INDEXABLES_KEYS; |
| 229 | |
| 230 | /** |
| 231 | * Key for the non indexable data. |
| 232 | */ |
| 233 | public static final String COLUMN_KEY_VALUE = "key"; |
| 234 | } |
| 235 | |
| 236 | /** |
Fabrice Di Meglio | b49995d | 2014-03-14 19:06:20 -0700 | [diff] [blame] | 237 | * The base columns. |
| 238 | */ |
Ying Wang | b67cd46 | 2015-03-30 15:46:30 -0700 | [diff] [blame] | 239 | public static class BaseColumns { |
Fabrice Di Meglio | b49995d | 2014-03-14 19:06:20 -0700 | [diff] [blame] | 240 | private BaseColumns() { |
| 241 | } |
| 242 | |
| 243 | /** |
| 244 | * Rank of the data. This is an integer used for ranking the search results. This is |
| 245 | * application specific. |
| 246 | */ |
| 247 | public static final String COLUMN_RANK = "rank"; |
| 248 | |
| 249 | /** |
| 250 | * Class name associated with the data (usually a Fragment class name). |
| 251 | */ |
| 252 | public static final String COLUMN_CLASS_NAME = "className"; |
| 253 | |
| 254 | /** |
| 255 | * Icon resource ID for the data. |
| 256 | */ |
| 257 | public static final String COLUMN_ICON_RESID = "iconResId"; |
| 258 | |
| 259 | /** |
| 260 | * Intent action associated with the data. |
| 261 | */ |
| 262 | public static final String COLUMN_INTENT_ACTION = "intentAction"; |
| 263 | |
| 264 | /** |
| 265 | * Intent target package associated with the data. |
| 266 | */ |
| 267 | public static final String COLUMN_INTENT_TARGET_PACKAGE = "intentTargetPackage"; |
| 268 | |
| 269 | /** |
| 270 | * Intent target class associated with the data. |
| 271 | */ |
| 272 | public static final String COLUMN_INTENT_TARGET_CLASS = "intentTargetClass"; |
| 273 | } |
| 274 | } |