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