blob: 7b9d1ea316b3b2ba614d6158091d8be4ebc4c204 [file] [log] [blame]
Fabrice Di Megliob49995d2014-03-14 19:06:20 -07001/*
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/**
Fabrice Di Meglio16f81e72014-03-20 19:46:13 -070024 * The Indexable data for Search.
25 *
26 * This abstract class defines the common parts for all search indexable data.
Fabrice Di Megliob49995d2014-03-14 19:06:20 -070027 *
28 * @hide
29 */
30public abstract class SearchIndexableData {
31
32 /**
Fabrice Di Meglio16f81e72014-03-20 19:46:13 -070033 * The context for the data. Will usually allow retrieving some resources.
Fabrice Di Megliob49995d2014-03-14 19:06:20 -070034 *
35 * @see Context
36 */
37 public Context context;
38
39 /**
40 * The locale for the data
41 */
42 public Locale locale;
43
44 /**
Fabrice Di Meglio16f81e72014-03-20 19:46:13 -070045 * Tells if the data will be included into the search results. This is application specific.
46 */
47 public boolean enabled;
48
49 /**
Fabrice Di Megliob49995d2014-03-14 19:06:20 -070050 * The rank for the data. This is application specific.
51 */
52 public int rank;
53
54 /**
Fabrice Di Meglio738691d2014-04-04 19:14:46 -070055 * 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 /**
Fabrice Di Meglio2331e9e2014-07-09 19:12:26 -070061 * The UserID for the data (in a multi user context). This is application specific and -1 is the
62 * default non initialized value.
63 */
64 public int userId = -1;
65
66 /**
Fabrice Di Megliob49995d2014-03-14 19:06:20 -070067 * The class name associated with the data. Generally this is a Fragment class name for
68 * referring where the data is coming from and for launching the associated Fragment for
69 * displaying the data. This is used only when the data is provided "locally".
70 *
71 * If the data is provided "externally", the relevant information come from the
72 * {@link SearchIndexableData#intentAction} and {@link SearchIndexableData#intentTargetPackage}
73 * and {@link SearchIndexableData#intentTargetClass}.
74 *
75 * @see SearchIndexableData#intentAction
76 * @see SearchIndexableData#intentTargetPackage
77 * @see SearchIndexableData#intentTargetClass
78 */
79 public String className;
80
81 /**
82 * The package name for retrieving the icon associated with the data.
83 *
84 * @see SearchIndexableData#iconResId
85 */
86 public String packageName;
87
88 /**
89 * The icon resource ID associated with the data.
90 *
91 * @see SearchIndexableData#packageName
92 */
93 public int iconResId;
94
95 /**
96 * The Intent action associated with the data. This is used when the
97 * {@link SearchIndexableData#className} is not relevant.
98 *
99 * @see SearchIndexableData#intentTargetPackage
100 * @see SearchIndexableData#intentTargetClass
101 */
102 public String intentAction;
103
104 /**
105 * The Intent target package associated with the data.
106 *
107 * @see SearchIndexableData#intentAction
108 * @see SearchIndexableData#intentTargetClass
109 */
110 public String intentTargetPackage;
111
112 /**
113 * The Intent target class associated with the data.
114 *
115 * @see SearchIndexableData#intentAction
116 * @see SearchIndexableData#intentTargetPackage
117 */
118 public String intentTargetClass;
119
120 /**
121 * Default constructor.
122 */
123 public SearchIndexableData() {
Fabrice Di Meglio773a56b2014-04-11 15:15:34 -0700124 locale = Locale.getDefault();
Fabrice Di Meglio16f81e72014-03-20 19:46:13 -0700125 enabled = true;
Fabrice Di Megliob49995d2014-03-14 19:06:20 -0700126 }
127
128 /**
129 * Constructor with a {@link Context}.
130 *
131 * @param ctx the Context
132 */
133 public SearchIndexableData(Context ctx) {
Fabrice Di Meglio773a56b2014-04-11 15:15:34 -0700134 this();
Fabrice Di Megliob49995d2014-03-14 19:06:20 -0700135 context = ctx;
Fabrice Di Megliob49995d2014-03-14 19:06:20 -0700136 }
Fabrice Di Meglio71b39752014-04-10 19:24:15 -0700137
138 @Override
139 public String toString() {
140 final StringBuilder sb = new StringBuilder();
141 sb.append("SearchIndexableData[context: ");
142 sb.append(context);
143 sb.append(", ");
144 sb.append("locale: ");
145 sb.append(locale);
146 sb.append(", ");
147 sb.append("enabled: ");
148 sb.append(enabled);
149 sb.append(", ");
150 sb.append("rank: ");
151 sb.append(rank);
152 sb.append(", ");
153 sb.append("key: ");
154 sb.append(key);
155 sb.append(", ");
Fabrice Di Meglio2331e9e2014-07-09 19:12:26 -0700156 sb.append("userId: ");
157 sb.append(userId);
158 sb.append(", ");
Fabrice Di Meglio71b39752014-04-10 19:24:15 -0700159 sb.append("className: ");
160 sb.append(className);
161 sb.append(", ");
162 sb.append("packageName: ");
163 sb.append(packageName);
164 sb.append(", ");
165 sb.append("iconResId: ");
166 sb.append(iconResId);
167 sb.append(", ");
168 sb.append("intentAction: ");
169 sb.append(intentAction);
170 sb.append(", ");
171 sb.append("intentTargetPackage: ");
172 sb.append(intentTargetPackage);
173 sb.append(", ");
174 sb.append("intentTargetClass: ");
175 sb.append(intentTargetClass);
176 sb.append("]");
177
178 return sb.toString();
179 }
Fabrice Di Megliob49995d2014-03-14 19:06:20 -0700180}