SearchIndexableData.java revision 738691d610c918691b386f332548bbd6abc783f9
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.Context;
20
21import java.util.Locale;
22
23/**
24 * The Indexable data for Search.
25 *
26 * This abstract class defines the common parts for all search indexable data.
27 *
28 * @hide
29 */
30public abstract class SearchIndexableData {
31
32    /**
33     * The context for the data. Will usually allow retrieving some resources.
34     *
35     * @see Context
36     */
37    public Context context;
38
39    /**
40     * The locale for the data
41     */
42    public Locale locale;
43
44    /**
45     * Tells if the data will be included into the search results. This is application specific.
46     */
47    public boolean enabled;
48
49    /**
50     * The rank for the data. This is application specific.
51     */
52    public int rank;
53
54    /**
55     * The key for the data. This is application specific. Should be unique per data as the data
56     * should be able to be retrieved by the key.
57     */
58    public String key;
59
60    /**
61     * The class name associated with the data. Generally this is a Fragment class name for
62     * referring where the data is coming from and for launching the associated Fragment for
63     * displaying the data. This is used only when the data is provided "locally".
64     *
65     * If the data is provided "externally", the relevant information come from the
66     * {@link SearchIndexableData#intentAction} and {@link SearchIndexableData#intentTargetPackage}
67     * and {@link SearchIndexableData#intentTargetClass}.
68     *
69     * @see SearchIndexableData#intentAction
70     * @see SearchIndexableData#intentTargetPackage
71     * @see SearchIndexableData#intentTargetClass
72     */
73    public String className;
74
75    /**
76     * The package name for retrieving the icon associated with the data.
77     *
78     * @see SearchIndexableData#iconResId
79     */
80    public String packageName;
81
82    /**
83     * The icon resource ID associated with the data.
84     *
85     * @see SearchIndexableData#packageName
86     */
87    public int iconResId;
88
89    /**
90     * The Intent action associated with the data. This is used when the
91     * {@link SearchIndexableData#className} is not relevant.
92     *
93     * @see SearchIndexableData#intentTargetPackage
94     * @see SearchIndexableData#intentTargetClass
95     */
96    public String intentAction;
97
98    /**
99     * The Intent target package associated with the data.
100     *
101     * @see SearchIndexableData#intentAction
102     * @see SearchIndexableData#intentTargetClass
103     */
104    public String intentTargetPackage;
105
106    /**
107     * The Intent target class associated with the data.
108     *
109     * @see SearchIndexableData#intentAction
110     * @see SearchIndexableData#intentTargetPackage
111     */
112    public String intentTargetClass;
113
114    /**
115     * Default constructor.
116     */
117    public SearchIndexableData() {
118        enabled = true;
119    }
120
121    /**
122     * Constructor with a {@link Context}.
123     *
124     * @param ctx the Context
125     */
126    public SearchIndexableData(Context ctx) {
127        context = ctx;
128        locale = Locale.getDefault();
129        enabled = true;
130    }
131}
132