SearchIndexablesContract.java revision 98274a9714dbfb5982c6e85152610c624e08d8c3
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,
62            XmlResource.COLUMN_XML_RESID,
63            XmlResource.COLUMN_CLASS_NAME,
64            XmlResource.COLUMN_ICON_RESID,
65            XmlResource.COLUMN_INTENT_ACTION,
66            XmlResource.COLUMN_INTENT_TARGET_PACKAGE,
67            XmlResource.COLUMN_INTENT_TARGET_CLASS
68    };
69
70    /**
71     * Indexable raw data colums.
72     */
73    public static final String[] INDEXABLES_RAW_COLUMNS = new String[] {
74            RawData.COLUMN_RANK,
75            RawData.COLUMN_TITLE,
76            RawData.COLUMN_SUMMARY_ON,
77            RawData.COLUMN_SUMMARY_OFF,
78            RawData.COLUMN_KEYWORDS,
79            RawData.COLUMN_SCREEN_TITLE,
80            RawData.COLUMN_CLASS_NAME,
81            RawData.COLUMN_ICON_RESID,
82            RawData.COLUMN_INTENT_ACTION,
83            RawData.COLUMN_INTENT_TARGET_PACKAGE,
84            RawData.COLUMN_INTENT_TARGET_CLASS,
85    };
86
87    /**
88     * Constants related to a {@link SearchIndexableResource}.
89     *
90     * This is a description of
91     */
92    public static final class XmlResource extends BaseColumns {
93        private XmlResource() {
94        }
95
96        public static final String MIME_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE +
97                "/" + INDEXABLES_XML_RES;
98
99        /**
100         * XML resource ID for the {@link android.preference.PreferenceScreen} to load and index.
101         */
102        public static final String COLUMN_XML_RESID = "xmlResId";
103    }
104
105    /**
106     * Constants related to a {@link SearchIndexableData}.
107     *
108     * This is the raw data that is stored into an Index. This is related to
109     * {@link android.preference.Preference} and its attributes like
110     * {@link android.preference.Preference#getTitle()},
111     * {@link android.preference.Preference#getSummary()}, etc.
112     *
113     */
114    public static final class RawData extends BaseColumns {
115        private RawData() {
116        }
117
118        public static final String MIME_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE +
119                "/" + INDEXABLES_RAW;
120
121        /**
122         * Title's raw data.
123         */
124        public static final String COLUMN_TITLE = "title";
125
126        /**
127         * Summary's raw data when the data is "ON".
128         */
129        public static final String COLUMN_SUMMARY_ON = "summaryOn";
130
131        /**
132         * Summary's raw data when the data is "OFF".
133         */
134        public static final String COLUMN_SUMMARY_OFF = "summaryOff";
135
136        /**
137         * Keywords' raw data.
138         */
139        public static final String COLUMN_KEYWORDS = "keywords";
140
141        /**
142         * Fragment's title associated with the raw data.
143         */
144        public static final String COLUMN_SCREEN_TITLE = "screenTitle";
145    }
146
147    /**
148     * The base columns.
149     */
150    private static class BaseColumns {
151        private BaseColumns() {
152        }
153
154        /**
155         * Rank of the data. This is an integer used for ranking the search results. This is
156         * application specific.
157         */
158        public static final String COLUMN_RANK = "rank";
159
160        /**
161         * Class name associated with the data (usually a Fragment class name).
162         */
163        public static final String COLUMN_CLASS_NAME = "className";
164
165        /**
166         * Icon resource ID for the data.
167         */
168        public static final String COLUMN_ICON_RESID = "iconResId";
169
170        /**
171         * Intent action associated with the data.
172         */
173        public static final String COLUMN_INTENT_ACTION = "intentAction";
174
175        /**
176         * Intent target package associated with the data.
177         */
178        public static final String COLUMN_INTENT_TARGET_PACKAGE = "intentTargetPackage";
179
180        /**
181         * Intent target class associated with the data.
182         */
183        public static final String COLUMN_INTENT_TARGET_CLASS = "intentTargetClass";
184    }
185}
186