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