SearchIndexablesContract.java revision a8e8f3f647d6d55052d0faef53fc1eeb432f5bd6
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 references name.
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 name.
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     * Indexable xml resources colums.
59     */
60    public static final String[] INDEXABLES_XML_RES_COLUMNS = new String[] {
61            XmlResource.COLUMN_RANK,                    // 0
62            XmlResource.COLUMN_XML_RESID,               // 1
63            XmlResource.COLUMN_CLASS_NAME,              // 2
64            XmlResource.COLUMN_ICON_RESID,              // 3
65            XmlResource.COLUMN_INTENT_ACTION,           // 4
66            XmlResource.COLUMN_INTENT_TARGET_PACKAGE,   // 5
67            XmlResource.COLUMN_INTENT_TARGET_CLASS      // 6
68    };
69
70    /**
71     * Indexable xml resources colums indices.
72     */
73    public static final int COLUMN_INDEX_XML_RES_RANK = 0;
74    public static final int COLUMN_INDEX_XML_RES_RESID = 1;
75    public static final int COLUMN_INDEX_XML_RES_CLASS_NAME = 2;
76    public static final int COLUMN_INDEX_XML_RES_ICON_RESID = 3;
77    public static final int COLUMN_INDEX_XML_RES_INTENT_ACTION = 4;
78    public static final int COLUMN_INDEX_XML_RES_INTENT_TARGET_PACKAGE = 5;
79    public static final int COLUMN_INDEX_XML_RES_INTENT_TARGET_CLASS = 6;
80
81    /**
82     * Indexable raw data colums.
83     */
84    public static final String[] INDEXABLES_RAW_COLUMNS = new String[] {
85            RawData.COLUMN_RANK,                    // 0
86            RawData.COLUMN_TITLE,                   // 1
87            RawData.COLUMN_SUMMARY_ON,              // 2
88            RawData.COLUMN_SUMMARY_OFF,             // 3
89            RawData.COLUMN_ENTRIES,                 // 4
90            RawData.COLUMN_KEYWORDS,                // 5
91            RawData.COLUMN_SCREEN_TITLE,            // 6
92            RawData.COLUMN_CLASS_NAME,              // 7
93            RawData.COLUMN_ICON_RESID,              // 8
94            RawData.COLUMN_INTENT_ACTION,           // 9
95            RawData.COLUMN_INTENT_TARGET_PACKAGE,   // 10
96            RawData.COLUMN_INTENT_TARGET_CLASS,     // 11
97            RawData.COLUMN_KEY,                     // 12
98    };
99
100    /**
101     * Indexable raw data colums indices.
102     */
103    public static final int COLUMN_INDEX_RAW_RANK = 0;
104    public static final int COLUMN_INDEX_RAW_TITLE = 1;
105    public static final int COLUMN_INDEX_RAW_SUMMARY_ON = 2;
106    public static final int COLUMN_INDEX_RAW_SUMMARY_OFF = 3;
107    public static final int COLUMN_INDEX_RAW_ENTRIES = 4;
108    public static final int COLUMN_INDEX_RAW_KEYWORDS = 5;
109    public static final int COLUMN_INDEX_RAW_SCREEN_TITLE = 6;
110    public static final int COLUMN_INDEX_RAW_CLASS_NAME = 7;
111    public static final int COLUMN_INDEX_RAW_ICON_RESID = 8;
112    public static final int COLUMN_INDEX_RAW_INTENT_ACTION = 9;
113    public static final int COLUMN_INDEX_RAW_INTENT_TARGET_PACKAGE = 10;
114    public static final int COLUMN_INDEX_RAW_INTENT_TARGET_CLASS = 11;
115    public static final int COLUMN_INDEX_RAW_KEY = 12;
116
117
118    /**
119     * Constants related to a {@link SearchIndexableResource}.
120     *
121     * This is a description of
122     */
123    public static final class XmlResource extends BaseColumns {
124        private XmlResource() {
125        }
126
127        public static final String MIME_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE +
128                "/" + INDEXABLES_XML_RES;
129
130        /**
131         * XML resource ID for the {@link android.preference.PreferenceScreen} to load and index.
132         */
133        public static final String COLUMN_XML_RESID = "xmlResId";
134    }
135
136    /**
137     * Constants related to a {@link SearchIndexableData}.
138     *
139     * This is the raw data that is stored into an Index. This is related to
140     * {@link android.preference.Preference} and its attributes like
141     * {@link android.preference.Preference#getTitle()},
142     * {@link android.preference.Preference#getSummary()}, etc.
143     *
144     */
145    public static final class RawData extends BaseColumns {
146        private RawData() {
147        }
148
149        public static final String MIME_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE +
150                "/" + INDEXABLES_RAW;
151
152        /**
153         * Title's raw data.
154         */
155        public static final String COLUMN_TITLE = "title";
156
157        /**
158         * Summary's raw data when the data is "ON".
159         */
160        public static final String COLUMN_SUMMARY_ON = "summaryOn";
161
162        /**
163         * Summary's raw data when the data is "OFF".
164         */
165        public static final String COLUMN_SUMMARY_OFF = "summaryOff";
166
167        /**
168         * Entries associated with the raw data (when the data can have several values).
169         */
170        public static final String COLUMN_ENTRIES = "entries";
171
172        /**
173         * Keywords' raw data.
174         */
175        public static final String COLUMN_KEYWORDS = "keywords";
176
177        /**
178         * Fragment or Activity title associated with the raw data.
179         */
180        public static final String COLUMN_SCREEN_TITLE = "screenTitle";
181
182        /**
183         * Key associated with the raw data. The key needs to be unique.
184         */
185        public static final String COLUMN_KEY = "key";
186    }
187
188    /**
189     * The base columns.
190     */
191    private static class BaseColumns {
192        private BaseColumns() {
193        }
194
195        /**
196         * Rank of the data. This is an integer used for ranking the search results. This is
197         * application specific.
198         */
199        public static final String COLUMN_RANK = "rank";
200
201        /**
202         * Class name associated with the data (usually a Fragment class name).
203         */
204        public static final String COLUMN_CLASS_NAME = "className";
205
206        /**
207         * Icon resource ID for the data.
208         */
209        public static final String COLUMN_ICON_RESID = "iconResId";
210
211        /**
212         * Intent action associated with the data.
213         */
214        public static final String COLUMN_INTENT_ACTION = "intentAction";
215
216        /**
217         * Intent target package associated with the data.
218         */
219        public static final String COLUMN_INTENT_TARGET_PACKAGE = "intentTargetPackage";
220
221        /**
222         * Intent target class associated with the data.
223         */
224        public static final String COLUMN_INTENT_TARGET_CLASS = "intentTargetClass";
225    }
226}
227