Home | History | Annotate | Download | only in provider
      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 
     19 import android.content.ContentResolver;
     20 
     21 /**
     22  * Describe the contract for an Indexable data.
     23  *
     24  * @hide
     25  */
     26 public 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 columns.
     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 columns 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 columns.
     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             RawData.COLUMN_USER_ID,                 // 13
    109     };
    110 
    111     /**
    112      * Indexable raw data columns indices.
    113      */
    114     public static final int COLUMN_INDEX_RAW_RANK = 0;
    115     public static final int COLUMN_INDEX_RAW_TITLE = 1;
    116     public static final int COLUMN_INDEX_RAW_SUMMARY_ON = 2;
    117     public static final int COLUMN_INDEX_RAW_SUMMARY_OFF = 3;
    118     public static final int COLUMN_INDEX_RAW_ENTRIES = 4;
    119     public static final int COLUMN_INDEX_RAW_KEYWORDS = 5;
    120     public static final int COLUMN_INDEX_RAW_SCREEN_TITLE = 6;
    121     public static final int COLUMN_INDEX_RAW_CLASS_NAME = 7;
    122     public static final int COLUMN_INDEX_RAW_ICON_RESID = 8;
    123     public static final int COLUMN_INDEX_RAW_INTENT_ACTION = 9;
    124     public static final int COLUMN_INDEX_RAW_INTENT_TARGET_PACKAGE = 10;
    125     public static final int COLUMN_INDEX_RAW_INTENT_TARGET_CLASS = 11;
    126     public static final int COLUMN_INDEX_RAW_KEY = 12;
    127     public static final int COLUMN_INDEX_RAW_USER_ID = 13;
    128 
    129     /**
    130      * Indexable raw data columns.
    131      */
    132     public static final String[] NON_INDEXABLES_KEYS_COLUMNS = new String[] {
    133             NonIndexableKey.COLUMN_KEY_VALUE      // 0
    134     };
    135 
    136     /**
    137      * Non indexable data keys columns indices.
    138      */
    139     public static final int COLUMN_INDEX_NON_INDEXABLE_KEYS_KEY_VALUE = 0;
    140 
    141     /**
    142      * Constants related to a {@link SearchIndexableResource}.
    143      *
    144      * This is a description of
    145      */
    146     public static final class XmlResource extends BaseColumns {
    147         private XmlResource() {
    148         }
    149 
    150         public static final String MIME_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE +
    151                 "/" + INDEXABLES_XML_RES;
    152 
    153         /**
    154          * XML resource ID for the {@link android.preference.PreferenceScreen} to load and index.
    155          */
    156         public static final String COLUMN_XML_RESID = "xmlResId";
    157     }
    158 
    159     /**
    160      * Constants related to a {@link SearchIndexableData}.
    161      *
    162      * This is the raw data that is stored into an Index. This is related to
    163      * {@link android.preference.Preference} and its attributes like
    164      * {@link android.preference.Preference#getTitle()},
    165      * {@link android.preference.Preference#getSummary()}, etc.
    166      *
    167      */
    168     public static final class RawData extends BaseColumns {
    169         private RawData() {
    170         }
    171 
    172         public static final String MIME_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE +
    173                 "/" + INDEXABLES_RAW;
    174 
    175         /**
    176          * Title's raw data.
    177          */
    178         public static final String COLUMN_TITLE = "title";
    179 
    180         /**
    181          * Summary's raw data when the data is "ON".
    182          */
    183         public static final String COLUMN_SUMMARY_ON = "summaryOn";
    184 
    185         /**
    186          * Summary's raw data when the data is "OFF".
    187          */
    188         public static final String COLUMN_SUMMARY_OFF = "summaryOff";
    189 
    190         /**
    191          * Entries associated with the raw data (when the data can have several values).
    192          */
    193         public static final String COLUMN_ENTRIES = "entries";
    194 
    195         /**
    196          * Keywords' raw data.
    197          */
    198         public static final String COLUMN_KEYWORDS = "keywords";
    199 
    200         /**
    201          * Fragment or Activity title associated with the raw data.
    202          */
    203         public static final String COLUMN_SCREEN_TITLE = "screenTitle";
    204 
    205         /**
    206          * Key associated with the raw data. The key needs to be unique.
    207          */
    208         public static final String COLUMN_KEY = "key";
    209 
    210         /**
    211          * UserId associated with the raw data.
    212          */
    213         public static final String COLUMN_USER_ID = "user_id";
    214     }
    215 
    216     /**
    217      * Constants related to a {@link SearchIndexableResource} and {@link SearchIndexableData}.
    218      *
    219      * This is a description of a data (thru its unique key) that cannot be indexed.
    220      */
    221     public static final class NonIndexableKey extends BaseColumns {
    222         private NonIndexableKey() {
    223         }
    224 
    225         public static final String MIME_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE +
    226                 "/" + NON_INDEXABLES_KEYS;
    227 
    228         /**
    229          * Key for the non indexable data.
    230          */
    231         public static final String COLUMN_KEY_VALUE = "key";
    232     }
    233 
    234     /**
    235      * The base columns.
    236      */
    237     private static class BaseColumns {
    238         private BaseColumns() {
    239         }
    240 
    241         /**
    242          * Rank of the data. This is an integer used for ranking the search results. This is
    243          * application specific.
    244          */
    245         public static final String COLUMN_RANK = "rank";
    246 
    247         /**
    248          * Class name associated with the data (usually a Fragment class name).
    249          */
    250         public static final String COLUMN_CLASS_NAME = "className";
    251 
    252         /**
    253          * Icon resource ID for the data.
    254          */
    255         public static final String COLUMN_ICON_RESID = "iconResId";
    256 
    257         /**
    258          * Intent action associated with the data.
    259          */
    260         public static final String COLUMN_INTENT_ACTION = "intentAction";
    261 
    262         /**
    263          * Intent target package associated with the data.
    264          */
    265         public static final String COLUMN_INTENT_TARGET_PACKAGE = "intentTargetPackage";
    266 
    267         /**
    268          * Intent target class associated with the data.
    269          */
    270         public static final String COLUMN_INTENT_TARGET_CLASS = "intentTargetClass";
    271     }
    272 }
    273