Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 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 | |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 19 | import android.accounts.Account; |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 20 | import android.content.ContentProviderClient; |
| 21 | import android.content.ContentProviderOperation; |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 22 | import android.content.ContentResolver; |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 23 | import android.content.ContentUris; |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 24 | import android.content.ContentValues; |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 25 | import android.content.Context; |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 26 | import android.content.Intent; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 27 | import android.content.res.Resources; |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 28 | import android.database.Cursor; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 29 | import android.graphics.Rect; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 30 | import android.net.Uri; |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 31 | import android.os.RemoteException; |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 32 | import android.text.TextUtils; |
Fred Quintana | c4516a7 | 2009-09-03 12:14:06 -0700 | [diff] [blame] | 33 | import android.util.Pair; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 34 | import android.view.View; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 35 | |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 36 | import java.io.ByteArrayInputStream; |
| 37 | import java.io.InputStream; |
| 38 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 39 | /** |
| 40 | * The contract between the contacts provider and applications. Contains definitions |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 41 | * for the supported URIs and columns. These APIs supersede {@link Contacts}. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 42 | */ |
Jeff Hamilton | 0c23212 | 2009-09-24 00:26:50 -0500 | [diff] [blame] | 43 | @SuppressWarnings("unused") |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 44 | public final class ContactsContract { |
| 45 | /** The authority for the contacts provider */ |
| 46 | public static final String AUTHORITY = "com.android.contacts"; |
| 47 | /** A content:// style uri to the authority for the contacts provider */ |
| 48 | public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY); |
| 49 | |
Fred Quintana | 33f889a | 2009-09-14 17:31:26 -0700 | [diff] [blame] | 50 | /** |
| 51 | * An optional insert, update or delete URI parameter that allows the caller |
| 52 | * to specify that it is a sync adapter. The default value is false. If true |
| 53 | * the dirty flag is not automatically set and the "syncToNetwork" parameter |
| 54 | * is set to false when calling |
| 55 | * {@link ContentResolver#notifyChange(android.net.Uri, android.database.ContentObserver, boolean)}. |
| 56 | */ |
| 57 | public static final String CALLER_IS_SYNCADAPTER = "caller_is_syncadapter"; |
| 58 | |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 59 | /** |
| 60 | * @hide should be removed when users are updated to refer to SyncState |
| 61 | * @deprecated use SyncState instead |
| 62 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 63 | @Deprecated |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 64 | public interface SyncStateColumns extends SyncStateContract.Columns { |
| 65 | } |
| 66 | |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 67 | /** |
| 68 | * A table provided for sync adapters to use for storing private sync state data. |
| 69 | * |
| 70 | * @see SyncStateContract |
| 71 | */ |
| 72 | public static final class SyncState implements SyncStateContract.Columns { |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 73 | /** |
| 74 | * This utility class cannot be instantiated |
| 75 | */ |
| 76 | private SyncState() {} |
| 77 | |
| 78 | public static final String CONTENT_DIRECTORY = |
| 79 | SyncStateContract.Constants.CONTENT_DIRECTORY; |
| 80 | |
| 81 | /** |
| 82 | * The content:// style URI for this table |
| 83 | */ |
| 84 | public static final Uri CONTENT_URI = |
| 85 | Uri.withAppendedPath(AUTHORITY_URI, CONTENT_DIRECTORY); |
| 86 | |
| 87 | /** |
| 88 | * @see android.provider.SyncStateContract.Helpers#get |
| 89 | */ |
| 90 | public static byte[] get(ContentProviderClient provider, Account account) |
| 91 | throws RemoteException { |
| 92 | return SyncStateContract.Helpers.get(provider, CONTENT_URI, account); |
| 93 | } |
| 94 | |
| 95 | /** |
Fred Quintana | c4516a7 | 2009-09-03 12:14:06 -0700 | [diff] [blame] | 96 | * @see android.provider.SyncStateContract.Helpers#get |
| 97 | */ |
| 98 | public static Pair<Uri, byte[]> getWithUri(ContentProviderClient provider, Account account) |
| 99 | throws RemoteException { |
| 100 | return SyncStateContract.Helpers.getWithUri(provider, CONTENT_URI, account); |
| 101 | } |
| 102 | |
| 103 | /** |
Fred Quintana | 0f4e1ab | 2009-07-09 17:20:59 -0700 | [diff] [blame] | 104 | * @see android.provider.SyncStateContract.Helpers#set |
| 105 | */ |
| 106 | public static void set(ContentProviderClient provider, Account account, byte[] data) |
| 107 | throws RemoteException { |
| 108 | SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data); |
| 109 | } |
| 110 | |
| 111 | /** |
| 112 | * @see android.provider.SyncStateContract.Helpers#newSetOperation |
| 113 | */ |
| 114 | public static ContentProviderOperation newSetOperation(Account account, byte[] data) { |
| 115 | return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data); |
| 116 | } |
| 117 | } |
| 118 | |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 119 | /** |
| 120 | * Generic columns for use by sync adapters. The specific functions of |
| 121 | * these columns are private to the sync adapter. Other clients of the API |
| 122 | * should not attempt to either read or write this column. |
| 123 | */ |
| 124 | private interface BaseSyncColumns { |
| 125 | |
| 126 | /** Generic column for use by sync adapters. */ |
| 127 | public static final String SYNC1 = "sync1"; |
| 128 | /** Generic column for use by sync adapters. */ |
| 129 | public static final String SYNC2 = "sync2"; |
| 130 | /** Generic column for use by sync adapters. */ |
| 131 | public static final String SYNC3 = "sync3"; |
| 132 | /** Generic column for use by sync adapters. */ |
| 133 | public static final String SYNC4 = "sync4"; |
| 134 | } |
| 135 | |
| 136 | /** |
| 137 | * Columns that appear when each row of a table belongs to a specific |
| 138 | * account, including sync information that an account may need. |
| 139 | */ |
| 140 | private interface SyncColumns extends BaseSyncColumns { |
| 141 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 142 | * The name of the account instance to which this row belongs, which when paired with |
| 143 | * {@link #ACCOUNT_TYPE} identifies a specific account. |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 144 | * <P>Type: TEXT</P> |
| 145 | */ |
| 146 | public static final String ACCOUNT_NAME = "account_name"; |
| 147 | |
| 148 | /** |
| 149 | * The type of account to which this row belongs, which when paired with |
| 150 | * {@link #ACCOUNT_NAME} identifies a specific account. |
| 151 | * <P>Type: TEXT</P> |
| 152 | */ |
| 153 | public static final String ACCOUNT_TYPE = "account_type"; |
| 154 | |
| 155 | /** |
| 156 | * String that uniquely identifies this row to its source account. |
| 157 | * <P>Type: TEXT</P> |
| 158 | */ |
| 159 | public static final String SOURCE_ID = "sourceid"; |
| 160 | |
| 161 | /** |
| 162 | * Version number that is updated whenever this row or its related data |
| 163 | * changes. |
| 164 | * <P>Type: INTEGER</P> |
| 165 | */ |
| 166 | public static final String VERSION = "version"; |
| 167 | |
| 168 | /** |
| 169 | * Flag indicating that {@link #VERSION} has changed, and this row needs |
| 170 | * to be synchronized by its owning account. |
| 171 | * <P>Type: INTEGER (boolean)</P> |
| 172 | */ |
| 173 | public static final String DIRTY = "dirty"; |
| 174 | } |
| 175 | |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 176 | private interface ContactOptionsColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 177 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 178 | * The number of times a contact has been contacted |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 179 | * <P>Type: INTEGER</P> |
| 180 | */ |
| 181 | public static final String TIMES_CONTACTED = "times_contacted"; |
| 182 | |
| 183 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 184 | * The last time a contact was contacted. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 185 | * <P>Type: INTEGER</P> |
| 186 | */ |
| 187 | public static final String LAST_TIME_CONTACTED = "last_time_contacted"; |
| 188 | |
| 189 | /** |
| 190 | * Is the contact starred? |
| 191 | * <P>Type: INTEGER (boolean)</P> |
| 192 | */ |
| 193 | public static final String STARRED = "starred"; |
| 194 | |
| 195 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 196 | * A custom ringtone associated with a contact. Not always present. |
Dmitri Plotnikov | 693d50e | 2009-06-22 14:57:31 -0700 | [diff] [blame] | 197 | * <P>Type: TEXT (URI to the ringtone)</P> |
| 198 | */ |
| 199 | public static final String CUSTOM_RINGTONE = "custom_ringtone"; |
| 200 | |
| 201 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 202 | * Whether the contact should always be sent to voicemail. Not always |
Dmitri Plotnikov | 693d50e | 2009-06-22 14:57:31 -0700 | [diff] [blame] | 203 | * present. |
| 204 | * <P>Type: INTEGER (0 for false, 1 for true)</P> |
| 205 | */ |
| 206 | public static final String SEND_TO_VOICEMAIL = "send_to_voicemail"; |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 207 | } |
| 208 | |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 209 | private interface ContactsColumns { |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 210 | /** |
| 211 | * The display name for the contact. |
| 212 | * <P>Type: TEXT</P> |
| 213 | */ |
| 214 | public static final String DISPLAY_NAME = "display_name"; |
Dmitri Plotnikov | 693d50e | 2009-06-22 14:57:31 -0700 | [diff] [blame] | 215 | |
| 216 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 217 | * Reference to the row in the data table holding the photo. |
| 218 | * <P>Type: INTEGER REFERENCES data(_id)</P> |
| 219 | */ |
| 220 | public static final String PHOTO_ID = "photo_id"; |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 221 | |
| 222 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 223 | * Lookup value that reflects the {@link Groups#GROUP_VISIBLE} state of |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 224 | * any {@link CommonDataKinds.GroupMembership} for this contact. |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 225 | */ |
| 226 | public static final String IN_VISIBLE_GROUP = "in_visible_group"; |
Dmitri Plotnikov | 55048a9 | 2009-07-24 10:25:34 -0700 | [diff] [blame] | 227 | |
| 228 | /** |
Dmitri Plotnikov | 074fbfe | 2009-08-11 13:50:21 -0700 | [diff] [blame] | 229 | * An indicator of whether this contact has at least one phone number. "1" if there is |
| 230 | * at least one phone number, "0" otherwise. |
Dmitri Plotnikov | 55048a9 | 2009-07-24 10:25:34 -0700 | [diff] [blame] | 231 | * <P>Type: INTEGER</P> |
| 232 | */ |
Dmitri Plotnikov | 074fbfe | 2009-08-11 13:50:21 -0700 | [diff] [blame] | 233 | public static final String HAS_PHONE_NUMBER = "has_phone_number"; |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 234 | |
| 235 | /** |
| 236 | * An opaque value that contains hints on how to find the contact if |
| 237 | * its row id changed as a result of a sync or aggregation. |
| 238 | */ |
| 239 | public static final String LOOKUP_KEY = "lookup"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 240 | } |
| 241 | |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 242 | private interface ContactStatusColumns { |
| 243 | /** |
| 244 | * Contact presence status. See {@link StatusUpdates} for individual status |
| 245 | * definitions. |
| 246 | * <p>Type: NUMBER</p> |
| 247 | */ |
| 248 | public static final String CONTACT_PRESENCE = "contact_presence"; |
| 249 | |
| 250 | /** |
| 251 | * Contact's latest status update. |
| 252 | * <p>Type: TEXT</p> |
| 253 | */ |
| 254 | public static final String CONTACT_STATUS = "contact_status"; |
| 255 | |
| 256 | /** |
| 257 | * The absolute time in milliseconds when the latest status was |
| 258 | * inserted/updated. |
| 259 | * <p>Type: NUMBER</p> |
| 260 | */ |
| 261 | public static final String CONTACT_STATUS_TIMESTAMP = "contact_status_ts"; |
| 262 | |
| 263 | /** |
| 264 | * The package containing resources for this status: label and icon. |
| 265 | * <p>Type: NUMBER</p> |
| 266 | */ |
| 267 | public static final String CONTACT_STATUS_RES_PACKAGE = "contact_status_res_package"; |
| 268 | |
| 269 | /** |
| 270 | * The resource ID of the label describing the source of contact |
| 271 | * status, e.g. "Google Talk". This resource is scoped by the |
| 272 | * {@link #CONTACT_STATUS_RES_PACKAGE}. |
| 273 | * <p>Type: NUMBER</p> |
| 274 | */ |
| 275 | public static final String CONTACT_STATUS_LABEL = "contact_status_label"; |
| 276 | |
| 277 | /** |
| 278 | * The resource ID of the icon for the source of contact status. This |
| 279 | * resource is scoped by the {@link #CONTACT_STATUS_RES_PACKAGE}. |
| 280 | * <p>Type: NUMBER</p> |
| 281 | */ |
| 282 | public static final String CONTACT_STATUS_ICON = "contact_status_icon"; |
| 283 | } |
| 284 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 285 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 286 | * Constants for the contacts table, which contains a record per group |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 287 | * of raw contacts representing the same person. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 288 | */ |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 289 | public static class Contacts implements BaseColumns, ContactsColumns, |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 290 | ContactOptionsColumns, ContactStatusColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 291 | /** |
| 292 | * This utility class cannot be instantiated |
| 293 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 294 | private Contacts() {} |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 295 | |
| 296 | /** |
| 297 | * The content:// style URI for this table |
| 298 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 299 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "contacts"); |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 300 | |
| 301 | /** |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 302 | * A content:// style URI for this table that should be used to create |
| 303 | * shortcuts or otherwise create long-term links to contacts. This URI |
| 304 | * should always be followed by a "/" and the contact's {@link #LOOKUP_KEY}. |
| 305 | * It can optionally also have a "/" and last known contact ID appended after |
| 306 | * that. This "complete" format is an important optimization and is highly recommended. |
| 307 | * <p> |
| 308 | * As long as the contact's row ID remains the same, this URI is |
| 309 | * equivalent to {@link #CONTENT_URI}. If the contact's row ID changes |
| 310 | * as a result of a sync or aggregation, this URI will look up the |
| 311 | * contact using indirect information (sync IDs or constituent raw |
| 312 | * contacts). |
| 313 | * <p> |
| 314 | * Lookup key should be appended unencoded - it is stored in the encoded |
| 315 | * form, ready for use in a URI. |
| 316 | */ |
| 317 | public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI, |
| 318 | "lookup"); |
| 319 | |
| 320 | /** |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 321 | * Builds a {@link #CONTENT_LOOKUP_URI} style {@link Uri} describing the |
| 322 | * requested {@link Contacts} entry. |
| 323 | * |
| 324 | * @param contactUri A {@link #CONTENT_URI} row, or an existing |
| 325 | * {@link #CONTENT_LOOKUP_URI} to attempt refreshing. |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 326 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 327 | public static Uri getLookupUri(ContentResolver resolver, Uri contactUri) { |
| 328 | final Cursor c = resolver.query(contactUri, new String[] { |
| 329 | Contacts.LOOKUP_KEY, Contacts._ID |
| 330 | }, null, null, null); |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 331 | if (c == null) { |
| 332 | return null; |
| 333 | } |
| 334 | |
| 335 | try { |
| 336 | if (c.moveToFirst()) { |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 337 | final String lookupKey = c.getString(0); |
| 338 | final long contactId = c.getLong(1); |
| 339 | return getLookupUri(contactId, lookupKey); |
Dmitri Plotnikov | f35bce4 | 2009-08-28 19:52:50 -0700 | [diff] [blame] | 340 | } |
| 341 | } finally { |
| 342 | c.close(); |
| 343 | } |
| 344 | return null; |
| 345 | } |
| 346 | |
| 347 | /** |
Jeff Sharkey | f46a9cf | 2009-09-09 13:17:44 -0700 | [diff] [blame] | 348 | * Build a {@link #CONTENT_LOOKUP_URI} lookup {@link Uri} using the |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 349 | * given {@link android.provider.ContactsContract.Contacts#_ID} and {@link #LOOKUP_KEY}. |
Jeff Sharkey | f46a9cf | 2009-09-09 13:17:44 -0700 | [diff] [blame] | 350 | */ |
| 351 | public static Uri getLookupUri(long contactId, String lookupKey) { |
| 352 | return ContentUris.withAppendedId(Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI, |
| 353 | lookupKey), contactId); |
| 354 | } |
| 355 | |
| 356 | /** |
Dmitri Plotnikov | b5759b5 | 2009-09-01 15:58:40 -0700 | [diff] [blame] | 357 | * Computes a content URI (see {@link #CONTENT_URI}) given a lookup URI. |
| 358 | * <p> |
| 359 | * Returns null if the contact cannot be found. |
| 360 | */ |
| 361 | public static Uri lookupContact(ContentResolver resolver, Uri lookupUri) { |
| 362 | if (lookupUri == null) { |
| 363 | return null; |
| 364 | } |
| 365 | |
| 366 | Cursor c = resolver.query(lookupUri, new String[]{Contacts._ID}, null, null, null); |
| 367 | if (c == null) { |
| 368 | return null; |
| 369 | } |
| 370 | |
| 371 | try { |
| 372 | if (c.moveToFirst()) { |
| 373 | long contactId = c.getLong(0); |
| 374 | return ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId); |
| 375 | } |
| 376 | } finally { |
| 377 | c.close(); |
| 378 | } |
| 379 | return null; |
| 380 | } |
| 381 | |
| 382 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 383 | * Mark a contact as having been contacted. |
| 384 | * |
| 385 | * @param resolver the ContentResolver to use |
| 386 | * @param contactId the person who was contacted |
| 387 | */ |
| 388 | public static void markAsContacted(ContentResolver resolver, long contactId) { |
| 389 | Uri uri = ContentUris.withAppendedId(CONTENT_URI, contactId); |
| 390 | ContentValues values = new ContentValues(); |
| 391 | // TIMES_CONTACTED will be incremented when LAST_TIME_CONTACTED is modified. |
| 392 | values.put(LAST_TIME_CONTACTED, System.currentTimeMillis()); |
| 393 | resolver.update(uri, values, null, null); |
| 394 | } |
| 395 | |
| 396 | /** |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 397 | * The content:// style URI used for "type-to-filter" functionality on the |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 398 | * {@link #CONTENT_URI} URI. The filter string will be used to match |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 399 | * various parts of the contact name. The filter argument should be passed |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 400 | * as an additional path segment after this URI. |
| 401 | */ |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 402 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath( |
| 403 | CONTENT_URI, "filter"); |
| 404 | |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 405 | /** |
| 406 | * The content:// style URI for this table joined with useful data from |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 407 | * {@link Data}, filtered to include only starred contacts |
| 408 | * and the most frequently contacted contacts. |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 409 | */ |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 410 | public static final Uri CONTENT_STREQUENT_URI = Uri.withAppendedPath( |
| 411 | CONTENT_URI, "strequent"); |
| 412 | |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 413 | /** |
| 414 | * The content:// style URI used for "type-to-filter" functionality on the |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 415 | * {@link #CONTENT_STREQUENT_URI} URI. The filter string will be used to match |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 416 | * various parts of the contact name. The filter argument should be passed |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 417 | * as an additional path segment after this URI. |
| 418 | */ |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 419 | public static final Uri CONTENT_STREQUENT_FILTER_URI = Uri.withAppendedPath( |
| 420 | CONTENT_STREQUENT_URI, "filter"); |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 421 | |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 422 | public static final Uri CONTENT_GROUP_URI = Uri.withAppendedPath( |
| 423 | CONTENT_URI, "group"); |
| 424 | |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 425 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 426 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
| 427 | * people. |
| 428 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 429 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 430 | |
| 431 | /** |
| 432 | * The MIME type of a {@link #CONTENT_URI} subdirectory of a single |
| 433 | * person. |
| 434 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 435 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 436 | |
| 437 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 438 | * A sub-directory of a single contact that contains all of the constituent raw contact |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 439 | * {@link Data} rows. |
| 440 | */ |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 441 | public static final class Data implements BaseColumns, DataColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 442 | /** |
| 443 | * no public constructor since this is a utility class |
| 444 | */ |
| 445 | private Data() {} |
| 446 | |
| 447 | /** |
| 448 | * The directory twig for this sub-table |
| 449 | */ |
| 450 | public static final String CONTENT_DIRECTORY = "data"; |
| 451 | } |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 452 | |
| 453 | /** |
| 454 | * A sub-directory of a single contact aggregate that contains all aggregation suggestions |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 455 | * (other contacts). The aggregation suggestions are computed based on approximate |
| 456 | * data matches with this contact. |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 457 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 458 | public static final class AggregationSuggestions implements BaseColumns, ContactsColumns { |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 459 | /** |
| 460 | * No public constructor since this is a utility class |
| 461 | */ |
| 462 | private AggregationSuggestions() {} |
| 463 | |
| 464 | /** |
Dmitri Plotnikov | 0fc0244 | 2009-09-21 13:26:28 -0700 | [diff] [blame] | 465 | * The directory twig for this sub-table. The URI can be followed by an optional |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 466 | * type-to-filter, similar to |
| 467 | * {@link android.provider.ContactsContract.Contacts#CONTENT_FILTER_URI}. |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 468 | */ |
| 469 | public static final String CONTENT_DIRECTORY = "suggestions"; |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 470 | } |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 471 | |
| 472 | /** |
Dmitri Plotnikov | eb1a2ec | 2009-08-21 11:11:19 -0700 | [diff] [blame] | 473 | * A sub-directory of a single contact that contains the contact's primary photo. |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 474 | */ |
Dmitri Plotnikov | eb1a2ec | 2009-08-21 11:11:19 -0700 | [diff] [blame] | 475 | public static final class Photo implements BaseColumns, DataColumns { |
| 476 | /** |
| 477 | * no public constructor since this is a utility class |
| 478 | */ |
| 479 | private Photo() {} |
Dmitri Plotnikov | 1c1629d | 2009-08-20 08:13:46 -0700 | [diff] [blame] | 480 | |
Dmitri Plotnikov | eb1a2ec | 2009-08-21 11:11:19 -0700 | [diff] [blame] | 481 | /** |
| 482 | * The directory twig for this sub-table |
| 483 | */ |
| 484 | public static final String CONTENT_DIRECTORY = "photo"; |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 485 | } |
| 486 | |
| 487 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 488 | * Opens an InputStream for the contacts's default photo and returns the |
| 489 | * photo as a byte stream. If there is not photo null will be returned. |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 490 | * |
| 491 | * @param contactUri the contact whose photo should be used |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 492 | * @return an InputStream of the photo, or null if no photo is present |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 493 | */ |
| 494 | public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri) { |
Dmitri Plotnikov | eb1a2ec | 2009-08-21 11:11:19 -0700 | [diff] [blame] | 495 | Uri photoUri = Uri.withAppendedPath(contactUri, Photo.CONTENT_DIRECTORY); |
Dmitri Plotnikov | 1c1629d | 2009-08-20 08:13:46 -0700 | [diff] [blame] | 496 | if (photoUri == null) { |
| 497 | return null; |
| 498 | } |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 499 | Cursor cursor = cr.query(photoUri, |
| 500 | new String[]{ContactsContract.CommonDataKinds.Photo.PHOTO}, null, null, null); |
| 501 | try { |
Mike Lockwood | 7d6eb9a | 2009-08-24 18:12:51 -0700 | [diff] [blame] | 502 | if (cursor == null || !cursor.moveToNext()) { |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 503 | return null; |
| 504 | } |
| 505 | byte[] data = cursor.getBlob(0); |
| 506 | if (data == null) { |
| 507 | return null; |
| 508 | } |
| 509 | return new ByteArrayInputStream(data); |
| 510 | } finally { |
Mike Lockwood | 7d6eb9a | 2009-08-24 18:12:51 -0700 | [diff] [blame] | 511 | if (cursor != null) { |
| 512 | cursor.close(); |
| 513 | } |
Dmitri Plotnikov | 3c513ed | 2009-08-19 15:56:30 -0700 | [diff] [blame] | 514 | } |
| 515 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 516 | } |
| 517 | |
Dmitri Plotnikov | 2365ded | 2009-07-27 09:36:09 -0700 | [diff] [blame] | 518 | private interface RawContactsColumns { |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 519 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 520 | * A reference to the {@link android.provider.ContactsContract.Contacts#_ID} that this |
| 521 | * data belongs to. |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 522 | * <P>Type: INTEGER</P> |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 523 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 524 | public static final String CONTACT_ID = "contact_id"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 525 | |
| 526 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 527 | * Flag indicating that this {@link RawContacts} entry and its children have |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 528 | * been restricted to specific platform apps. |
| 529 | * <P>Type: INTEGER (boolean)</P> |
| 530 | * |
| 531 | * @hide until finalized in future platform release |
| 532 | */ |
| 533 | public static final String IS_RESTRICTED = "is_restricted"; |
| 534 | |
| 535 | /** |
| 536 | * The aggregation mode for this contact. |
| 537 | * <P>Type: INTEGER</P> |
| 538 | */ |
| 539 | public static final String AGGREGATION_MODE = "aggregation_mode"; |
Dmitri Plotnikov | d5f56d1 | 2009-07-27 09:26:05 -0700 | [diff] [blame] | 540 | |
| 541 | /** |
| 542 | * The "deleted" flag: "0" by default, "1" if the row has been marked |
| 543 | * for deletion. When {@link android.content.ContentResolver#delete} is |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 544 | * called on a raw contact, it is marked for deletion and removed from its |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 545 | * aggregate contact. The sync adaptor deletes the raw contact on the server and |
Dmitri Plotnikov | d5f56d1 | 2009-07-27 09:26:05 -0700 | [diff] [blame] | 546 | * then calls ContactResolver.delete once more, this time passing the |
Fred Quintana | 33f889a | 2009-09-14 17:31:26 -0700 | [diff] [blame] | 547 | * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize |
| 548 | * the data removal. |
Dmitri Plotnikov | d5f56d1 | 2009-07-27 09:26:05 -0700 | [diff] [blame] | 549 | * <P>Type: INTEGER</P> |
| 550 | */ |
| 551 | public static final String DELETED = "deleted"; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 552 | } |
| 553 | |
| 554 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 555 | * Constants for the raw contacts table, which contains the base contact |
Dmitri Plotnikov | 2365ded | 2009-07-27 09:36:09 -0700 | [diff] [blame] | 556 | * information per sync source. Sync adapters and contact management apps |
| 557 | * are the primary consumers of this API. |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 558 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 559 | public static final class RawContacts implements BaseColumns, RawContactsColumns, |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 560 | ContactOptionsColumns, SyncColumns { |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 561 | /** |
| 562 | * This utility class cannot be instantiated |
| 563 | */ |
Dmitri Plotnikov | 2365ded | 2009-07-27 09:36:09 -0700 | [diff] [blame] | 564 | private RawContacts() { |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 565 | } |
| 566 | |
| 567 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 568 | * The content:// style URI for this table |
| 569 | */ |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 570 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "raw_contacts"); |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 571 | |
| 572 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 573 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
| 574 | * people. |
| 575 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 576 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 577 | |
| 578 | /** |
| 579 | * The MIME type of a {@link #CONTENT_URI} subdirectory of a single |
| 580 | * person. |
| 581 | */ |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 582 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/raw_contact"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 583 | |
| 584 | /** |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 585 | * Aggregation mode: aggregate asynchronously. |
| 586 | */ |
| 587 | public static final int AGGREGATION_MODE_DEFAULT = 0; |
| 588 | |
| 589 | /** |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 590 | * Aggregation mode: aggregate at the time the raw contact is inserted/updated. |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 591 | */ |
Omari Stephens | bc9aa77 | 2009-09-08 19:10:53 -0700 | [diff] [blame] | 592 | public static final int AGGREGATION_MODE_IMMEDIATE = 1; |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 593 | |
| 594 | /** |
Dmitri Plotnikov | 5223b16 | 2009-08-25 15:15:06 -0700 | [diff] [blame] | 595 | * If {@link #AGGREGATION_MODE} is {@link #AGGREGATION_MODE_SUSPENDED}, changes |
| 596 | * to the raw contact do not cause its aggregation to be revisited. Note that changing |
| 597 | * {@link #AGGREGATION_MODE} from {@link #AGGREGATION_MODE_SUSPENDED} to |
| 598 | * {@link #AGGREGATION_MODE_DEFAULT} does not trigger an aggregation pass. Any subsequent |
| 599 | * change to the raw contact's data will. |
| 600 | */ |
| 601 | public static final int AGGREGATION_MODE_SUSPENDED = 2; |
| 602 | |
| 603 | /** |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 604 | * Aggregation mode: never aggregate this raw contact (note that the raw contact will not |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 605 | * have a corresponding Aggregate and therefore will not be included in Aggregates |
| 606 | * query results.) |
| 607 | */ |
Dmitri Plotnikov | 5223b16 | 2009-08-25 15:15:06 -0700 | [diff] [blame] | 608 | public static final int AGGREGATION_MODE_DISABLED = 3; |
Dmitri Plotnikov | c991bfc | 2009-07-14 17:27:31 -0700 | [diff] [blame] | 609 | |
| 610 | /** |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 611 | * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI} |
| 612 | * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts} |
| 613 | * entry of the given {@link RawContacts} entry. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 614 | */ |
| 615 | public static Uri getContactLookupUri(ContentResolver resolver, Uri rawContactUri) { |
| 616 | // TODO: use a lighter query by joining rawcontacts with contacts in provider |
| 617 | final Uri dataUri = Uri.withAppendedPath(rawContactUri, Data.CONTENT_DIRECTORY); |
| 618 | final Cursor cursor = resolver.query(dataUri, new String[] { |
| 619 | RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY |
| 620 | }, null, null, null); |
| 621 | |
| 622 | Uri lookupUri = null; |
| 623 | try { |
| 624 | if (cursor != null && cursor.moveToFirst()) { |
| 625 | final long contactId = cursor.getLong(0); |
| 626 | final String lookupKey = cursor.getString(1); |
| 627 | return Contacts.getLookupUri(contactId, lookupKey); |
| 628 | } |
| 629 | } finally { |
| 630 | if (cursor != null) cursor.close(); |
| 631 | } |
| 632 | return lookupUri; |
| 633 | } |
| 634 | |
| 635 | /** |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 636 | * A sub-directory of a single raw contact that contains all of their {@link Data} rows. |
Dmitri Plotnikov | 5223b16 | 2009-08-25 15:15:06 -0700 | [diff] [blame] | 637 | * To access this directory append {@link Data#CONTENT_DIRECTORY} to the contact URI. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 638 | */ |
| 639 | public static final class Data implements BaseColumns, DataColumns { |
| 640 | /** |
| 641 | * no public constructor since this is a utility class |
| 642 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 643 | private Data() { |
| 644 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 645 | |
| 646 | /** |
| 647 | * The directory twig for this sub-table |
| 648 | */ |
| 649 | public static final String CONTENT_DIRECTORY = "data"; |
| 650 | } |
| 651 | } |
| 652 | |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 653 | private interface StatusColumns extends Im.CommonPresenceColumns { |
| 654 | /** |
Dmitri Plotnikov | a60479d | 2009-09-27 20:16:31 -0700 | [diff] [blame] | 655 | * Contact's latest presence level. |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 656 | * <P>Type: INTEGER (one of the values below)</P> |
| 657 | */ |
| 658 | public static final String PRESENCE = PRESENCE_STATUS; |
| 659 | |
| 660 | /** |
| 661 | * Contact latest status update. |
| 662 | * <p>Type: TEXT</p> |
| 663 | */ |
| 664 | public static final String STATUS = PRESENCE_CUSTOM_STATUS; |
| 665 | |
| 666 | /** |
| 667 | * The absolute time in milliseconds when the latest status was inserted/updated. |
| 668 | * <p>Type: NUMBER</p> |
| 669 | */ |
| 670 | public static final String STATUS_TIMESTAMP = "status_ts"; |
| 671 | |
| 672 | /** |
| 673 | * The package containing resources for this status: label and icon. |
| 674 | * <p>Type: NUMBER</p> |
| 675 | */ |
| 676 | public static final String STATUS_RES_PACKAGE = "status_res_package"; |
| 677 | |
| 678 | /** |
| 679 | * The resource ID of the label describing the source of the status update, e.g. "Google |
| 680 | * Talk". This resource should be scoped by the {@link #STATUS_RES_PACKAGE}. |
| 681 | * <p>Type: NUMBER</p> |
| 682 | */ |
| 683 | public static final String STATUS_LABEL = "status_label"; |
| 684 | |
| 685 | /** |
| 686 | * The resource ID of the icon for the source of the status update. |
| 687 | * This resource should be scoped by the {@link #STATUS_RES_PACKAGE}. |
| 688 | * <p>Type: NUMBER</p> |
| 689 | */ |
| 690 | public static final String STATUS_ICON = "status_icon"; |
| 691 | } |
| 692 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 693 | private interface DataColumns { |
| 694 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 695 | * The package name to use when creating {@link Resources} objects for |
| 696 | * this data row. This value is only designed for use when building user |
| 697 | * interfaces, and should not be used to infer the owner. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 698 | * |
| 699 | * @hide |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 700 | */ |
| 701 | public static final String RES_PACKAGE = "res_package"; |
| 702 | |
| 703 | /** |
| 704 | * The MIME type of the item represented by this row. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 705 | */ |
| 706 | public static final String MIMETYPE = "mimetype"; |
| 707 | |
| 708 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 709 | * A reference to the {@link RawContacts#_ID} |
Dmitri Plotnikov | 5692777 | 2009-05-28 17:23:39 -0700 | [diff] [blame] | 710 | * that this data belongs to. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 711 | */ |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 712 | public static final String RAW_CONTACT_ID = "raw_contact_id"; |
| 713 | |
Evan Millar | ab5742d | 2009-06-02 16:21:45 -0700 | [diff] [blame] | 714 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 715 | * Whether this is the primary entry of its kind for the raw contact it belongs to |
Evan Millar | ab5742d | 2009-06-02 16:21:45 -0700 | [diff] [blame] | 716 | * <P>Type: INTEGER (if set, non-0 means true)</P> |
| 717 | */ |
| 718 | public static final String IS_PRIMARY = "is_primary"; |
| 719 | |
| 720 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 721 | * Whether this is the primary entry of its kind for the aggregate |
| 722 | * contact it belongs to. Any data record that is "super primary" must |
| 723 | * also be "primary". |
Evan Millar | ab5742d | 2009-06-02 16:21:45 -0700 | [diff] [blame] | 724 | * <P>Type: INTEGER (if set, non-0 means true)</P> |
| 725 | */ |
| 726 | public static final String IS_SUPER_PRIMARY = "is_super_primary"; |
| 727 | |
Jeff Sharkey | 28b68e5 | 2009-06-10 15:26:58 -0700 | [diff] [blame] | 728 | /** |
Fred Quintana | c933fb6 | 2009-06-11 12:14:40 -0700 | [diff] [blame] | 729 | * The version of this data record. This is a read-only value. The data column is |
| 730 | * guaranteed to not change without the version going up. This value is monotonically |
| 731 | * increasing. |
| 732 | * <P>Type: INTEGER</P> |
| 733 | */ |
| 734 | public static final String DATA_VERSION = "data_version"; |
| 735 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 736 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 737 | public static final String DATA1 = "data1"; |
| 738 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 739 | public static final String DATA2 = "data2"; |
| 740 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 741 | public static final String DATA3 = "data3"; |
| 742 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 743 | public static final String DATA4 = "data4"; |
| 744 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 745 | public static final String DATA5 = "data5"; |
| 746 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 747 | public static final String DATA6 = "data6"; |
| 748 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 749 | public static final String DATA7 = "data7"; |
| 750 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 751 | public static final String DATA8 = "data8"; |
| 752 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 753 | public static final String DATA9 = "data9"; |
| 754 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 755 | public static final String DATA10 = "data10"; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 756 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 757 | public static final String DATA11 = "data11"; |
| 758 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 759 | public static final String DATA12 = "data12"; |
| 760 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 761 | public static final String DATA13 = "data13"; |
| 762 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 763 | public static final String DATA14 = "data14"; |
| 764 | /** Generic data column, the meaning is {@link #MIMETYPE} specific */ |
| 765 | public static final String DATA15 = "data15"; |
Dmitri Plotnikov | 91e4e85 | 2009-08-03 18:06:29 -0700 | [diff] [blame] | 766 | |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 767 | /** Generic column for use by sync adapters. */ |
| 768 | public static final String SYNC1 = "data_sync1"; |
| 769 | /** Generic column for use by sync adapters. */ |
| 770 | public static final String SYNC2 = "data_sync2"; |
| 771 | /** Generic column for use by sync adapters. */ |
| 772 | public static final String SYNC3 = "data_sync3"; |
| 773 | /** Generic column for use by sync adapters. */ |
| 774 | public static final String SYNC4 = "data_sync4"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 775 | } |
| 776 | |
| 777 | /** |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 778 | * Combines all columns returned by {@link Data} table queries. |
| 779 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 780 | private interface DataColumnsWithJoins extends BaseColumns, DataColumns, StatusColumns, |
| 781 | RawContactsColumns, ContactsColumns, ContactOptionsColumns, ContactStatusColumns { |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 782 | |
| 783 | } |
| 784 | |
| 785 | /** |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 786 | * Constants for the data table, which contains data points tied to a raw contact. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 787 | * For example, a phone number or email address. Each row in this table contains a type |
| 788 | * definition and some generic columns. Each data type can define the meaning for each of |
| 789 | * the generic columns. |
| 790 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 791 | public final static class Data implements DataColumnsWithJoins { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 792 | /** |
| 793 | * This utility class cannot be instantiated |
| 794 | */ |
| 795 | private Data() {} |
| 796 | |
| 797 | /** |
| 798 | * The content:// style URI for this table |
| 799 | */ |
| 800 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "data"); |
| 801 | |
| 802 | /** |
| 803 | * The MIME type of {@link #CONTENT_URI} providing a directory of data. |
| 804 | */ |
| 805 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/data"; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 806 | |
| 807 | /** |
Daisuke Miyakawa | f2e0d7b | 2009-09-28 06:28:26 -0700 | [diff] [blame^] | 808 | * If {@link #FOR_EXPORT_ONLY} is explicitly set to "1", returned Cursor toward |
| 809 | * Data.CONTENT_URI contains only exportable data. |
| 810 | * |
| 811 | * This flag is useful (currently) only for vCard exporter in Contacts app, which |
| 812 | * needs to exclude "un-exportable" data from available data to export, while |
| 813 | * Contacts app itself has priviledge to access all data including "un-expotable" |
| 814 | * ones and providers return all of them regardless of the callers' intention. |
| 815 | * <P>Type: INTEGER</p> |
| 816 | * |
| 817 | * @hide Maybe available only in Eclair and not really ready for public use. |
| 818 | * TODO: remove, or implement this feature completely. As of now (Eclair), |
| 819 | * we only use this flag in queryEntities(), not query(). |
| 820 | */ |
| 821 | public static final String FOR_EXPORT_ONLY = "for_export_only"; |
| 822 | |
| 823 | /** |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 824 | * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI} |
| 825 | * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts} |
| 826 | * entry of the given {@link Data} entry. |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 827 | */ |
| 828 | public static Uri getContactLookupUri(ContentResolver resolver, Uri dataUri) { |
| 829 | final Cursor cursor = resolver.query(dataUri, new String[] { |
| 830 | RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY |
| 831 | }, null, null, null); |
| 832 | |
| 833 | Uri lookupUri = null; |
| 834 | try { |
| 835 | if (cursor != null && cursor.moveToFirst()) { |
| 836 | final long contactId = cursor.getLong(0); |
| 837 | final String lookupKey = cursor.getString(1); |
| 838 | return Contacts.getLookupUri(contactId, lookupKey); |
| 839 | } |
| 840 | } finally { |
| 841 | if (cursor != null) cursor.close(); |
| 842 | } |
| 843 | return lookupUri; |
| 844 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 845 | } |
| 846 | |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 847 | private interface PhoneLookupColumns { |
| 848 | /** |
| 849 | * The phone number as the user entered it. |
| 850 | * <P>Type: TEXT</P> |
| 851 | */ |
| 852 | public static final String NUMBER = "number"; |
| 853 | |
| 854 | /** |
| 855 | * The type of phone number, for example Home or Work. |
| 856 | * <P>Type: INTEGER</P> |
| 857 | */ |
| 858 | public static final String TYPE = "type"; |
| 859 | |
| 860 | /** |
| 861 | * The user defined label for the phone number. |
| 862 | * <P>Type: TEXT</P> |
| 863 | */ |
| 864 | public static final String LABEL = "label"; |
| 865 | } |
| 866 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 867 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 868 | * A table that represents the result of looking up a phone number, for |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 869 | * example for caller ID. To perform a lookup you must append the number you |
| 870 | * want to find to {@link #CONTENT_FILTER_URI}. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 871 | */ |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 872 | public static final class PhoneLookup implements BaseColumns, PhoneLookupColumns, |
| 873 | ContactsColumns, ContactOptionsColumns { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 874 | /** |
| 875 | * This utility class cannot be instantiated |
| 876 | */ |
| 877 | private PhoneLookup() {} |
| 878 | |
| 879 | /** |
| 880 | * The content:// style URI for this table. Append the phone number you want to lookup |
| 881 | * to this URI and query it to perform a lookup. For example: |
| 882 | * |
| 883 | * {@code |
| 884 | * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_URI, phoneNumber); |
| 885 | * } |
| 886 | */ |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 887 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 888 | "phone_lookup"); |
| 889 | } |
| 890 | |
| 891 | /** |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 892 | * Additional data mixed in with {@link StatusColumns} to link |
| 893 | * back to specific {@link ContactsContract.Data#_ID} entries. |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 894 | */ |
| 895 | private interface PresenceColumns { |
Dmitri Plotnikov | 55048a9 | 2009-07-24 10:25:34 -0700 | [diff] [blame] | 896 | |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 897 | /** |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 898 | * Reference to the {@link Data#_ID} entry that owns this presence. |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 899 | * <P>Type: INTEGER</P> |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 900 | */ |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 901 | public static final String DATA_ID = "presence_data_id"; |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 902 | |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 903 | /** |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 904 | * <p>Type: NUMBER</p> |
| 905 | */ |
| 906 | public static final String PROTOCOL = "protocol"; |
| 907 | |
| 908 | /** |
| 909 | * Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value |
| 910 | * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or |
| 911 | * omitted if {@link #PROTOCOL} value is not |
| 912 | * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. |
| 913 | * |
| 914 | * <p>Type: NUMBER</p> |
| 915 | */ |
| 916 | public static final String CUSTOM_PROTOCOL = "custom_protocol"; |
| 917 | |
| 918 | /** |
| 919 | * The IM handle the presence item is for. The handle is scoped to |
| 920 | * {@link #PROTOCOL}. |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 921 | * <P>Type: TEXT</P> |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 922 | */ |
| 923 | public static final String IM_HANDLE = "im_handle"; |
| 924 | |
| 925 | /** |
| 926 | * The IM account for the local user that the presence data came from. |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 927 | * <P>Type: TEXT</P> |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 928 | */ |
| 929 | public static final String IM_ACCOUNT = "im_account"; |
| 930 | } |
| 931 | |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 932 | /** |
| 933 | * A status update is linked to a {@link Data} row and captures the user's latest status |
| 934 | * update via the corresponding source, e.g. "Having lunch" via "Google Talk". |
| 935 | */ |
| 936 | // TODO make final as soon as Presence is removed |
| 937 | public static /*final*/ class StatusUpdates implements StatusColumns, PresenceColumns { |
Dmitri Plotnikov | f22fc12 | 2009-09-22 13:46:11 -0700 | [diff] [blame] | 938 | |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 939 | /** |
| 940 | * This utility class cannot be instantiated |
| 941 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 942 | private StatusUpdates() {} |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 943 | |
| 944 | /** |
| 945 | * The content:// style URI for this table |
| 946 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 947 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "status_updates"); |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 948 | |
| 949 | /** |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 950 | * Gets the resource ID for the proper presence icon. |
| 951 | * |
| 952 | * @param status the status to get the icon for |
| 953 | * @return the resource ID for the proper presence icon |
| 954 | */ |
| 955 | public static final int getPresenceIconResourceId(int status) { |
| 956 | switch (status) { |
| 957 | case AVAILABLE: |
| 958 | return android.R.drawable.presence_online; |
| 959 | case IDLE: |
| 960 | case AWAY: |
| 961 | return android.R.drawable.presence_away; |
| 962 | case DO_NOT_DISTURB: |
| 963 | return android.R.drawable.presence_busy; |
| 964 | case INVISIBLE: |
| 965 | return android.R.drawable.presence_invisible; |
| 966 | case OFFLINE: |
| 967 | default: |
| 968 | return android.R.drawable.presence_offline; |
| 969 | } |
| 970 | } |
| 971 | |
| 972 | /** |
Evan Millar | c043752 | 2009-06-23 17:31:05 -0700 | [diff] [blame] | 973 | * Returns the precedence of the status code the higher number being the higher precedence. |
| 974 | * |
| 975 | * @param status The status code. |
| 976 | * @return An integer representing the precedence, 0 being the lowest. |
| 977 | */ |
| 978 | public static final int getPresencePrecedence(int status) { |
| 979 | // Keep this function here incase we want to enforce a different precedence than the |
| 980 | // natural order of the status constants. |
| 981 | return status; |
| 982 | } |
| 983 | |
| 984 | /** |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 985 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 986 | * status update details. |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 987 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 988 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/status-update"; |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 989 | |
| 990 | /** |
| 991 | * The MIME type of a {@link #CONTENT_URI} subdirectory of a single |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 992 | * status update detail. |
Jeff Sharkey | d530b3c | 2009-06-01 20:23:57 -0700 | [diff] [blame] | 993 | */ |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 994 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/status-update"; |
| 995 | } |
Dmitri Plotnikov | f22fc12 | 2009-09-22 13:46:11 -0700 | [diff] [blame] | 996 | |
Dmitri Plotnikov | 879664e | 2009-09-27 08:52:56 -0700 | [diff] [blame] | 997 | @Deprecated |
| 998 | public static final class Presence extends StatusUpdates { |
| 999 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1000 | } |
| 1001 | |
| 1002 | /** |
| 1003 | * Container for definitions of common data types stored in the {@link Data} table. |
| 1004 | */ |
| 1005 | public static final class CommonDataKinds { |
| 1006 | /** |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1007 | * This utility class cannot be instantiated |
| 1008 | */ |
| 1009 | private CommonDataKinds() {} |
| 1010 | |
| 1011 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1012 | * The {@link Data#RES_PACKAGE} value for common data that should be |
| 1013 | * shown using a default style. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1014 | * |
| 1015 | * @hide RES_PACKAGE is hidden |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1016 | */ |
| 1017 | public static final String PACKAGE_COMMON = "common"; |
| 1018 | |
| 1019 | /** |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 1020 | * The base types that all "Typed" data kinds support. |
| 1021 | */ |
| 1022 | public interface BaseTypes { |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 1023 | /** |
| 1024 | * A custom type. The custom label should be supplied by user. |
| 1025 | */ |
| 1026 | public static int TYPE_CUSTOM = 0; |
| 1027 | } |
| 1028 | |
| 1029 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1030 | * Columns common across the specific types. |
| 1031 | */ |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 1032 | private interface CommonColumns extends BaseTypes { |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1033 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1034 | * The data for the contact method. |
| 1035 | * <P>Type: TEXT</P> |
| 1036 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 1037 | public static final String DATA = DataColumns.DATA1; |
| 1038 | |
| 1039 | /** |
| 1040 | * The type of data, for example Home or Work. |
| 1041 | * <P>Type: INTEGER</P> |
| 1042 | */ |
| 1043 | public static final String TYPE = DataColumns.DATA2; |
Dmitri Plotnikov | c926054 | 2009-05-28 17:55:12 -0700 | [diff] [blame] | 1044 | |
| 1045 | /** |
| 1046 | * The user defined label for the the contact method. |
| 1047 | * <P>Type: TEXT</P> |
| 1048 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 1049 | public static final String LABEL = DataColumns.DATA3; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1050 | } |
| 1051 | |
| 1052 | /** |
| 1053 | * Parts of the name. |
| 1054 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 1055 | public static final class StructuredName implements DataColumnsWithJoins { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1056 | /** |
| 1057 | * This utility class cannot be instantiated |
| 1058 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1059 | private StructuredName() {} |
| 1060 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1061 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1062 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/name"; |
| 1063 | |
| 1064 | /** |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1065 | * The name that should be used to display the contact. |
Jeff Sharkey | 62b83b7 | 2009-08-11 17:33:48 -0700 | [diff] [blame] | 1066 | * <i>Unstructured component of the name should be consistent with |
| 1067 | * its structured representation.</i> |
| 1068 | * <p> |
| 1069 | * Type: TEXT |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1070 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 1071 | public static final String DISPLAY_NAME = DATA1; |
| 1072 | |
| 1073 | /** |
| 1074 | * The given name for the contact. |
| 1075 | * <P>Type: TEXT</P> |
| 1076 | */ |
| 1077 | public static final String GIVEN_NAME = DATA2; |
| 1078 | |
| 1079 | /** |
| 1080 | * The family name for the contact. |
| 1081 | * <P>Type: TEXT</P> |
| 1082 | */ |
| 1083 | public static final String FAMILY_NAME = DATA3; |
| 1084 | |
| 1085 | /** |
| 1086 | * The contact's honorific prefix, e.g. "Sir" |
| 1087 | * <P>Type: TEXT</P> |
| 1088 | */ |
| 1089 | public static final String PREFIX = DATA4; |
| 1090 | |
| 1091 | /** |
| 1092 | * The contact's middle name |
| 1093 | * <P>Type: TEXT</P> |
| 1094 | */ |
| 1095 | public static final String MIDDLE_NAME = DATA5; |
| 1096 | |
| 1097 | /** |
| 1098 | * The contact's honorific suffix, e.g. "Jr" |
| 1099 | */ |
| 1100 | public static final String SUFFIX = DATA6; |
| 1101 | |
| 1102 | /** |
| 1103 | * The phonetic version of the given name for the contact. |
| 1104 | * <P>Type: TEXT</P> |
| 1105 | */ |
| 1106 | public static final String PHONETIC_GIVEN_NAME = DATA7; |
| 1107 | |
| 1108 | /** |
| 1109 | * The phonetic version of the additional name for the contact. |
| 1110 | * <P>Type: TEXT</P> |
| 1111 | */ |
| 1112 | public static final String PHONETIC_MIDDLE_NAME = DATA8; |
| 1113 | |
| 1114 | /** |
| 1115 | * The phonetic version of the family name for the contact. |
| 1116 | * <P>Type: TEXT</P> |
| 1117 | */ |
| 1118 | public static final String PHONETIC_FAMILY_NAME = DATA9; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1119 | } |
| 1120 | |
| 1121 | /** |
| 1122 | * A nickname. |
| 1123 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 1124 | public static final class Nickname implements DataColumnsWithJoins, CommonColumns { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1125 | /** |
| 1126 | * This utility class cannot be instantiated |
| 1127 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1128 | private Nickname() {} |
| 1129 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1130 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1131 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/nickname"; |
| 1132 | |
Evan Millar | 78e79ad | 2009-06-08 10:24:44 -0700 | [diff] [blame] | 1133 | public static final int TYPE_DEFAULT = 1; |
| 1134 | public static final int TYPE_OTHER_NAME = 2; |
| 1135 | public static final int TYPE_MAINDEN_NAME = 3; |
| 1136 | public static final int TYPE_SHORT_NAME = 4; |
| 1137 | public static final int TYPE_INITIALS = 5; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1138 | |
| 1139 | /** |
Dmitri Plotnikov | c926054 | 2009-05-28 17:55:12 -0700 | [diff] [blame] | 1140 | * The name itself |
| 1141 | */ |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 1142 | public static final String NAME = DATA; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1143 | } |
| 1144 | |
| 1145 | /** |
| 1146 | * Common data definition for telephone numbers. |
| 1147 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 1148 | public static final class Phone implements DataColumnsWithJoins, CommonColumns { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1149 | /** |
| 1150 | * This utility class cannot be instantiated |
| 1151 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1152 | private Phone() {} |
| 1153 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1154 | /** MIME type used when storing this in data table. */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 1155 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/phone_v2"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1156 | |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 1157 | /** |
| 1158 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
| 1159 | * phones. |
| 1160 | */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 1161 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_v2"; |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 1162 | |
| 1163 | /** |
| 1164 | * The content:// style URI for all data records of the |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 1165 | * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1166 | * associated raw contact and aggregate contact data. |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 1167 | */ |
| 1168 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 1169 | "phones"); |
| 1170 | |
| 1171 | /** |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 1172 | * The content:// style URL for phone lookup using a filter. The filter returns |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 1173 | * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 1174 | * to display names as well as phone numbers. The filter argument should be passed |
| 1175 | * as an additional path segment after this URI. |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 1176 | */ |
| 1177 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, |
| 1178 | "filter"); |
| 1179 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1180 | public static final int TYPE_HOME = 1; |
| 1181 | public static final int TYPE_MOBILE = 2; |
| 1182 | public static final int TYPE_WORK = 3; |
| 1183 | public static final int TYPE_FAX_WORK = 4; |
| 1184 | public static final int TYPE_FAX_HOME = 5; |
| 1185 | public static final int TYPE_PAGER = 6; |
| 1186 | public static final int TYPE_OTHER = 7; |
Fred Quintana | 3f86715 | 2009-08-03 11:43:16 -0700 | [diff] [blame] | 1187 | public static final int TYPE_CALLBACK = 8; |
| 1188 | public static final int TYPE_CAR = 9; |
| 1189 | public static final int TYPE_COMPANY_MAIN = 10; |
| 1190 | public static final int TYPE_ISDN = 11; |
| 1191 | public static final int TYPE_MAIN = 12; |
| 1192 | public static final int TYPE_OTHER_FAX = 13; |
| 1193 | public static final int TYPE_RADIO = 14; |
| 1194 | public static final int TYPE_TELEX = 15; |
| 1195 | public static final int TYPE_TTY_TDD = 16; |
| 1196 | public static final int TYPE_WORK_MOBILE = 17; |
| 1197 | public static final int TYPE_WORK_PAGER = 18; |
| 1198 | public static final int TYPE_ASSISTANT = 19; |
Jeff Sharkey | d5abd46 | 2009-09-16 19:54:29 -0700 | [diff] [blame] | 1199 | public static final int TYPE_MMS = 20; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1200 | |
| 1201 | /** |
| 1202 | * The phone number as the user entered it. |
| 1203 | * <P>Type: TEXT</P> |
| 1204 | */ |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 1205 | public static final String NUMBER = DATA; |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 1206 | |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 1207 | /** |
| 1208 | * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1209 | * @hide |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 1210 | */ |
| 1211 | @Deprecated |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 1212 | public static final CharSequence getDisplayLabel(Context context, int type, |
| 1213 | CharSequence label, CharSequence[] labelArray) { |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 1214 | return getTypeLabel(context.getResources(), type, label); |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 1215 | } |
| 1216 | |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 1217 | /** |
| 1218 | * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1219 | * @hide |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 1220 | */ |
| 1221 | @Deprecated |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 1222 | public static final CharSequence getDisplayLabel(Context context, int type, |
| 1223 | CharSequence label) { |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 1224 | return getTypeLabel(context.getResources(), type, label); |
| 1225 | } |
| 1226 | |
| 1227 | /** |
| 1228 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 1229 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 1230 | */ |
| 1231 | public static final int getTypeLabelResource(int type) { |
| 1232 | switch (type) { |
| 1233 | case TYPE_HOME: return com.android.internal.R.string.phoneTypeHome; |
| 1234 | case TYPE_MOBILE: return com.android.internal.R.string.phoneTypeMobile; |
| 1235 | case TYPE_WORK: return com.android.internal.R.string.phoneTypeWork; |
| 1236 | case TYPE_FAX_WORK: return com.android.internal.R.string.phoneTypeFaxWork; |
| 1237 | case TYPE_FAX_HOME: return com.android.internal.R.string.phoneTypeFaxHome; |
| 1238 | case TYPE_PAGER: return com.android.internal.R.string.phoneTypePager; |
| 1239 | case TYPE_OTHER: return com.android.internal.R.string.phoneTypeOther; |
| 1240 | case TYPE_CALLBACK: return com.android.internal.R.string.phoneTypeCallback; |
| 1241 | case TYPE_CAR: return com.android.internal.R.string.phoneTypeCar; |
| 1242 | case TYPE_COMPANY_MAIN: return com.android.internal.R.string.phoneTypeCompanyMain; |
| 1243 | case TYPE_ISDN: return com.android.internal.R.string.phoneTypeIsdn; |
| 1244 | case TYPE_MAIN: return com.android.internal.R.string.phoneTypeMain; |
| 1245 | case TYPE_OTHER_FAX: return com.android.internal.R.string.phoneTypeOtherFax; |
| 1246 | case TYPE_RADIO: return com.android.internal.R.string.phoneTypeRadio; |
| 1247 | case TYPE_TELEX: return com.android.internal.R.string.phoneTypeTelex; |
| 1248 | case TYPE_TTY_TDD: return com.android.internal.R.string.phoneTypeTtyTdd; |
| 1249 | case TYPE_WORK_MOBILE: return com.android.internal.R.string.phoneTypeWorkMobile; |
| 1250 | case TYPE_WORK_PAGER: return com.android.internal.R.string.phoneTypeWorkPager; |
| 1251 | case TYPE_ASSISTANT: return com.android.internal.R.string.phoneTypeAssistant; |
| 1252 | case TYPE_MMS: return com.android.internal.R.string.phoneTypeMms; |
| 1253 | default: return com.android.internal.R.string.phoneTypeCustom; |
| 1254 | } |
| 1255 | } |
| 1256 | |
| 1257 | /** |
| 1258 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 1259 | * possibly substituting the given {@link #LABEL} value |
| 1260 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 1261 | */ |
| 1262 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 1263 | CharSequence label) { |
| 1264 | if ((type == TYPE_CUSTOM || type == TYPE_ASSISTANT) && !TextUtils.isEmpty(label)) { |
| 1265 | return label; |
| 1266 | } else { |
| 1267 | final int labelRes = getTypeLabelResource(type); |
| 1268 | return res.getText(labelRes); |
| 1269 | } |
Dmitri Plotnikov | 9303295 | 2009-08-19 11:26:57 -0700 | [diff] [blame] | 1270 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1271 | } |
| 1272 | |
| 1273 | /** |
| 1274 | * Common data definition for email addresses. |
| 1275 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 1276 | public static final class Email implements DataColumnsWithJoins, CommonColumns { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1277 | /** |
| 1278 | * This utility class cannot be instantiated |
| 1279 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1280 | private Email() {} |
| 1281 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1282 | /** MIME type used when storing this in data table. */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 1283 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/email_v2"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1284 | |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 1285 | /** |
Dmitri Plotnikov | abf15c3 | 2009-09-18 20:29:11 -0700 | [diff] [blame] | 1286 | * The MIME type of {@link #CONTENT_URI} providing a directory of email addresses. |
| 1287 | */ |
| 1288 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/email_v2"; |
| 1289 | |
| 1290 | /** |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 1291 | * The content:// style URI for all data records of the |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 1292 | * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 1293 | * associated raw contact and aggregate contact data. |
| 1294 | */ |
| 1295 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 1296 | "emails"); |
| 1297 | |
| 1298 | /** |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 1299 | * The content:// style URL for looking up data rows by email address. The |
| 1300 | * lookup argument, an email address, should be passed as an additional path segment |
| 1301 | * after this URI. |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 1302 | */ |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 1303 | public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI, |
| 1304 | "lookup"); |
| 1305 | |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 1306 | /** |
| 1307 | * The content:// style URL for email lookup using a filter. The filter returns |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 1308 | * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied |
Dmitri Plotnikov | 989f263 | 2009-09-06 12:22:24 -0700 | [diff] [blame] | 1309 | * to display names as well as email addresses. The filter argument should be passed |
| 1310 | * as an additional path segment after this URI. |
| 1311 | */ |
| 1312 | public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI, |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 1313 | "filter"); |
| 1314 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1315 | public static final int TYPE_HOME = 1; |
| 1316 | public static final int TYPE_WORK = 2; |
| 1317 | public static final int TYPE_OTHER = 3; |
Jeff Sharkey | 14fb153 | 2009-08-29 15:54:26 -0700 | [diff] [blame] | 1318 | public static final int TYPE_MOBILE = 4; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 1319 | |
| 1320 | /** |
| 1321 | * The display name for the email address |
| 1322 | * <P>Type: TEXT</P> |
| 1323 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 1324 | public static final String DISPLAY_NAME = DATA4; |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 1325 | |
| 1326 | /** |
| 1327 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 1328 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 1329 | */ |
| 1330 | public static final int getTypeLabelResource(int type) { |
| 1331 | switch (type) { |
| 1332 | case TYPE_HOME: return com.android.internal.R.string.emailTypeHome; |
| 1333 | case TYPE_WORK: return com.android.internal.R.string.emailTypeWork; |
| 1334 | case TYPE_OTHER: return com.android.internal.R.string.emailTypeOther; |
| 1335 | case TYPE_MOBILE: return com.android.internal.R.string.emailTypeMobile; |
| 1336 | default: return com.android.internal.R.string.emailTypeCustom; |
| 1337 | } |
| 1338 | } |
| 1339 | |
| 1340 | /** |
| 1341 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 1342 | * possibly substituting the given {@link #LABEL} value |
| 1343 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 1344 | */ |
| 1345 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 1346 | CharSequence label) { |
| 1347 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 1348 | return label; |
| 1349 | } else { |
| 1350 | final int labelRes = getTypeLabelResource(type); |
| 1351 | return res.getText(labelRes); |
| 1352 | } |
| 1353 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1354 | } |
| 1355 | |
| 1356 | /** |
| 1357 | * Common data definition for postal addresses. |
| 1358 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 1359 | public static final class StructuredPostal implements DataColumnsWithJoins, CommonColumns { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1360 | /** |
| 1361 | * This utility class cannot be instantiated |
| 1362 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1363 | private StructuredPostal() { |
| 1364 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1365 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1366 | /** MIME type used when storing this in data table. */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 1367 | public static final String CONTENT_ITEM_TYPE = |
| 1368 | "vnd.android.cursor.item/postal-address_v2"; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1369 | |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 1370 | /** |
| 1371 | * The MIME type of {@link #CONTENT_URI} providing a directory of |
| 1372 | * postal addresses. |
| 1373 | */ |
Evan Millar | b3c4998 | 2009-09-01 11:38:04 -0700 | [diff] [blame] | 1374 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/postal-address_v2"; |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 1375 | |
| 1376 | /** |
| 1377 | * The content:// style URI for all data records of the |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1378 | * {@link StructuredPostal#CONTENT_ITEM_TYPE} MIME type. |
Evan Millar | 161dd86 | 2009-06-12 16:02:43 -0700 | [diff] [blame] | 1379 | */ |
| 1380 | public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI, |
| 1381 | "postals"); |
| 1382 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1383 | public static final int TYPE_HOME = 1; |
| 1384 | public static final int TYPE_WORK = 2; |
| 1385 | public static final int TYPE_OTHER = 3; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1386 | |
| 1387 | /** |
Jeff Sharkey | 62b83b7 | 2009-08-11 17:33:48 -0700 | [diff] [blame] | 1388 | * The full, unstructured postal address. <i>This field must be |
| 1389 | * consistent with any structured data.</i> |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1390 | * <p> |
| 1391 | * Type: TEXT |
| 1392 | */ |
| 1393 | public static final String FORMATTED_ADDRESS = DATA; |
| 1394 | |
| 1395 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1396 | * Can be street, avenue, road, etc. This element also includes the |
| 1397 | * house number and room/apartment/flat/floor number. |
| 1398 | * <p> |
| 1399 | * Type: TEXT |
| 1400 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 1401 | public static final String STREET = DATA4; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1402 | |
| 1403 | /** |
| 1404 | * Covers actual P.O. boxes, drawers, locked bags, etc. This is |
| 1405 | * usually but not always mutually exclusive with street. |
| 1406 | * <p> |
| 1407 | * Type: TEXT |
| 1408 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 1409 | public static final String POBOX = DATA5; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1410 | |
| 1411 | /** |
| 1412 | * This is used to disambiguate a street address when a city |
| 1413 | * contains more than one street with the same name, or to specify a |
| 1414 | * small place whose mail is routed through a larger postal town. In |
| 1415 | * China it could be a county or a minor city. |
| 1416 | * <p> |
| 1417 | * Type: TEXT |
| 1418 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 1419 | public static final String NEIGHBORHOOD = DATA6; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1420 | |
| 1421 | /** |
| 1422 | * Can be city, village, town, borough, etc. This is the postal town |
| 1423 | * and not necessarily the place of residence or place of business. |
| 1424 | * <p> |
| 1425 | * Type: TEXT |
| 1426 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 1427 | public static final String CITY = DATA7; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1428 | |
| 1429 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1430 | * A state, province, county (in Ireland), Land (in Germany), |
| 1431 | * departement (in France), etc. |
| 1432 | * <p> |
| 1433 | * Type: TEXT |
| 1434 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 1435 | public static final String REGION = DATA8; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1436 | |
| 1437 | /** |
Jeff Sharkey | ef348c7 | 2009-07-26 14:14:34 -0700 | [diff] [blame] | 1438 | * Postal code. Usually country-wide, but sometimes specific to the |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1439 | * city (e.g. "2" in "Dublin 2, Ireland" addresses). |
| 1440 | * <p> |
| 1441 | * Type: TEXT |
| 1442 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 1443 | public static final String POSTCODE = DATA9; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1444 | |
| 1445 | /** |
| 1446 | * The name or code of the country. |
| 1447 | * <p> |
| 1448 | * Type: TEXT |
| 1449 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 1450 | public static final String COUNTRY = DATA10; |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 1451 | |
| 1452 | /** |
| 1453 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 1454 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 1455 | */ |
| 1456 | public static final int getTypeLabelResource(int type) { |
| 1457 | switch (type) { |
| 1458 | case TYPE_HOME: return com.android.internal.R.string.postalTypeHome; |
| 1459 | case TYPE_WORK: return com.android.internal.R.string.postalTypeWork; |
| 1460 | case TYPE_OTHER: return com.android.internal.R.string.postalTypeOther; |
| 1461 | default: return com.android.internal.R.string.postalTypeCustom; |
| 1462 | } |
| 1463 | } |
| 1464 | |
| 1465 | /** |
| 1466 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 1467 | * possibly substituting the given {@link #LABEL} value |
| 1468 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 1469 | */ |
| 1470 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 1471 | CharSequence label) { |
| 1472 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 1473 | return label; |
| 1474 | } else { |
| 1475 | final int labelRes = getTypeLabelResource(type); |
| 1476 | return res.getText(labelRes); |
| 1477 | } |
| 1478 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1479 | } |
| 1480 | |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 1481 | /** |
| 1482 | * Common data definition for IM addresses. |
| 1483 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 1484 | public static final class Im implements DataColumnsWithJoins, CommonColumns { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1485 | /** |
| 1486 | * This utility class cannot be instantiated |
| 1487 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1488 | private Im() {} |
| 1489 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1490 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1491 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im"; |
| 1492 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1493 | public static final int TYPE_HOME = 1; |
| 1494 | public static final int TYPE_WORK = 2; |
| 1495 | public static final int TYPE_OTHER = 3; |
Dmitri Plotnikov | 5692777 | 2009-05-28 17:23:39 -0700 | [diff] [blame] | 1496 | |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 1497 | /** |
| 1498 | * This column should be populated with one of the defined |
| 1499 | * constants, e.g. {@link #PROTOCOL_YAHOO}. If the value of this |
| 1500 | * column is {@link #PROTOCOL_CUSTOM}, the {@link #CUSTOM_PROTOCOL} |
| 1501 | * should contain the name of the custom protocol. |
| 1502 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 1503 | public static final String PROTOCOL = DATA5; |
Dmitri Plotnikov | 5692777 | 2009-05-28 17:23:39 -0700 | [diff] [blame] | 1504 | |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 1505 | public static final String CUSTOM_PROTOCOL = DATA6; |
Jeff Sharkey | 732da92 | 2009-07-30 09:59:31 -0700 | [diff] [blame] | 1506 | |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 1507 | /* |
| 1508 | * The predefined IM protocol types. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1509 | */ |
Jeff Sharkey | 732da92 | 2009-07-30 09:59:31 -0700 | [diff] [blame] | 1510 | public static final int PROTOCOL_CUSTOM = -1; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1511 | public static final int PROTOCOL_AIM = 0; |
| 1512 | public static final int PROTOCOL_MSN = 1; |
| 1513 | public static final int PROTOCOL_YAHOO = 2; |
| 1514 | public static final int PROTOCOL_SKYPE = 3; |
| 1515 | public static final int PROTOCOL_QQ = 4; |
| 1516 | public static final int PROTOCOL_GOOGLE_TALK = 5; |
| 1517 | public static final int PROTOCOL_ICQ = 6; |
| 1518 | public static final int PROTOCOL_JABBER = 7; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 1519 | public static final int PROTOCOL_NETMEETING = 8; |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 1520 | |
| 1521 | /** |
| 1522 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 1523 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 1524 | */ |
| 1525 | public static final int getTypeLabelResource(int type) { |
| 1526 | switch (type) { |
| 1527 | case TYPE_HOME: return com.android.internal.R.string.imTypeHome; |
| 1528 | case TYPE_WORK: return com.android.internal.R.string.imTypeWork; |
| 1529 | case TYPE_OTHER: return com.android.internal.R.string.imTypeOther; |
| 1530 | default: return com.android.internal.R.string.imTypeCustom; |
| 1531 | } |
| 1532 | } |
| 1533 | |
| 1534 | /** |
| 1535 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 1536 | * possibly substituting the given {@link #LABEL} value |
| 1537 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 1538 | */ |
| 1539 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 1540 | CharSequence label) { |
| 1541 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 1542 | return label; |
| 1543 | } else { |
| 1544 | final int labelRes = getTypeLabelResource(type); |
| 1545 | return res.getText(labelRes); |
| 1546 | } |
| 1547 | } |
| 1548 | |
| 1549 | /** |
| 1550 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 1551 | * {@link #PROTOCOL}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 1552 | */ |
| 1553 | public static final int getProtocolLabelResource(int type) { |
| 1554 | switch (type) { |
| 1555 | case PROTOCOL_AIM: return com.android.internal.R.string.imProtocolAim; |
| 1556 | case PROTOCOL_MSN: return com.android.internal.R.string.imProtocolMsn; |
| 1557 | case PROTOCOL_YAHOO: return com.android.internal.R.string.imProtocolYahoo; |
| 1558 | case PROTOCOL_SKYPE: return com.android.internal.R.string.imProtocolSkype; |
| 1559 | case PROTOCOL_QQ: return com.android.internal.R.string.imProtocolQq; |
| 1560 | case PROTOCOL_GOOGLE_TALK: return com.android.internal.R.string.imProtocolGoogleTalk; |
| 1561 | case PROTOCOL_ICQ: return com.android.internal.R.string.imProtocolIcq; |
| 1562 | case PROTOCOL_JABBER: return com.android.internal.R.string.imProtocolJabber; |
| 1563 | case PROTOCOL_NETMEETING: return com.android.internal.R.string.imProtocolNetMeeting; |
| 1564 | default: return com.android.internal.R.string.imProtocolCustom; |
| 1565 | } |
| 1566 | } |
| 1567 | |
| 1568 | /** |
| 1569 | * Return a {@link CharSequence} that best describes the given |
| 1570 | * protocol, possibly substituting the given |
| 1571 | * {@link #CUSTOM_PROTOCOL} value for {@link #PROTOCOL_CUSTOM}. |
| 1572 | */ |
| 1573 | public static final CharSequence getProtocolLabel(Resources res, int type, |
| 1574 | CharSequence label) { |
| 1575 | if (type == PROTOCOL_CUSTOM && !TextUtils.isEmpty(label)) { |
| 1576 | return label; |
| 1577 | } else { |
| 1578 | final int labelRes = getProtocolLabelResource(type); |
| 1579 | return res.getText(labelRes); |
| 1580 | } |
| 1581 | } |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1582 | } |
| 1583 | |
| 1584 | /** |
| 1585 | * Common data definition for organizations. |
| 1586 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 1587 | public static final class Organization implements DataColumnsWithJoins, CommonColumns { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1588 | /** |
| 1589 | * This utility class cannot be instantiated |
| 1590 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1591 | private Organization() {} |
| 1592 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1593 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1594 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/organization"; |
| 1595 | |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 1596 | public static final int TYPE_WORK = 1; |
| 1597 | public static final int TYPE_OTHER = 2; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1598 | |
| 1599 | /** |
| 1600 | * The company as the user entered it. |
| 1601 | * <P>Type: TEXT</P> |
| 1602 | */ |
Dmitri Plotnikov | 761ef2a | 2009-07-17 10:51:06 -0700 | [diff] [blame] | 1603 | public static final String COMPANY = DATA; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1604 | |
| 1605 | /** |
| 1606 | * The position title at this company as the user entered it. |
| 1607 | * <P>Type: TEXT</P> |
| 1608 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 1609 | public static final String TITLE = DATA4; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 1610 | |
| 1611 | /** |
| 1612 | * The department at this company as the user entered it. |
| 1613 | * <P>Type: TEXT</P> |
| 1614 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 1615 | public static final String DEPARTMENT = DATA5; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 1616 | |
| 1617 | /** |
| 1618 | * The job description at this company as the user entered it. |
| 1619 | * <P>Type: TEXT</P> |
| 1620 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 1621 | public static final String JOB_DESCRIPTION = DATA6; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 1622 | |
| 1623 | /** |
| 1624 | * The symbol of this company as the user entered it. |
| 1625 | * <P>Type: TEXT</P> |
| 1626 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 1627 | public static final String SYMBOL = DATA7; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 1628 | |
| 1629 | /** |
| 1630 | * The phonetic name of this company as the user entered it. |
| 1631 | * <P>Type: TEXT</P> |
| 1632 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 1633 | public static final String PHONETIC_NAME = DATA8; |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 1634 | |
| 1635 | /** |
| 1636 | * Return the string resource that best describes the given |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 1637 | * {@link #TYPE}. Will always return a valid resource. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 1638 | */ |
| 1639 | public static final int getTypeLabelResource(int type) { |
| 1640 | switch (type) { |
| 1641 | case TYPE_WORK: return com.android.internal.R.string.orgTypeWork; |
| 1642 | case TYPE_OTHER: return com.android.internal.R.string.orgTypeOther; |
| 1643 | default: return com.android.internal.R.string.orgTypeCustom; |
| 1644 | } |
| 1645 | } |
| 1646 | |
| 1647 | /** |
| 1648 | * Return a {@link CharSequence} that best describes the given type, |
Jeff Hamilton | f852698 | 2009-09-24 11:34:58 -0500 | [diff] [blame] | 1649 | * possibly substituting the given {@link #LABEL} value |
| 1650 | * for {@link #TYPE_CUSTOM}. |
Jeff Sharkey | 88a83d3 | 2009-09-20 17:10:47 -0700 | [diff] [blame] | 1651 | */ |
| 1652 | public static final CharSequence getTypeLabel(Resources res, int type, |
| 1653 | CharSequence label) { |
| 1654 | if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { |
| 1655 | return label; |
| 1656 | } else { |
| 1657 | final int labelRes = getTypeLabelResource(type); |
| 1658 | return res.getText(labelRes); |
| 1659 | } |
| 1660 | } |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 1661 | } |
| 1662 | |
| 1663 | /** |
Fred Quintana | f580841 | 2009-09-24 15:37:39 -0700 | [diff] [blame] | 1664 | * Common data definition for birthdays. |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 1665 | */ |
Fred Quintana | f580841 | 2009-09-24 15:37:39 -0700 | [diff] [blame] | 1666 | public static final class Birthday implements DataColumnsWithJoins { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1667 | /** |
| 1668 | * This utility class cannot be instantiated |
| 1669 | */ |
Fred Quintana | f580841 | 2009-09-24 15:37:39 -0700 | [diff] [blame] | 1670 | private Birthday() {} |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 1671 | |
| 1672 | /** MIME type used when storing this in data table. */ |
Fred Quintana | f580841 | 2009-09-24 15:37:39 -0700 | [diff] [blame] | 1673 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/birthday"; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 1674 | |
| 1675 | /** |
Fred Quintana | f580841 | 2009-09-24 15:37:39 -0700 | [diff] [blame] | 1676 | * The birthday. This must be of the form YYYY-MM-DD or YYYY-MM-DDThh:mm:ss |
| 1677 | * These are xs:date and xs:dateTime |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 1678 | * <P>Type: TEXT</P> |
| 1679 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 1680 | public static final String BIRTHDAY = DATA1; |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 1681 | } |
| 1682 | |
| 1683 | /** |
| 1684 | * Common data definition for relations. |
| 1685 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 1686 | public static final class Relation implements DataColumnsWithJoins, CommonColumns { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1687 | /** |
| 1688 | * This utility class cannot be instantiated |
| 1689 | */ |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 1690 | private Relation() {} |
| 1691 | |
| 1692 | /** MIME type used when storing this in data table. */ |
| 1693 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/relation"; |
| 1694 | |
| 1695 | public static final int TYPE_ASSISTANT = 1; |
| 1696 | public static final int TYPE_BROTHER = 2; |
| 1697 | public static final int TYPE_CHILD = 3; |
| 1698 | public static final int TYPE_DOMESTIC_PARTNER = 4; |
| 1699 | public static final int TYPE_FATHER = 5; |
| 1700 | public static final int TYPE_FRIEND = 6; |
| 1701 | public static final int TYPE_MANAGER = 7; |
| 1702 | public static final int TYPE_MOTHER = 8; |
| 1703 | public static final int TYPE_PARENT = 9; |
| 1704 | public static final int TYPE_PARTNER = 10; |
| 1705 | public static final int TYPE_REFERRED_BY = 11; |
| 1706 | public static final int TYPE_RELATIVE = 12; |
| 1707 | public static final int TYPE_SISTER = 13; |
| 1708 | public static final int TYPE_SPOUSE = 14; |
| 1709 | |
| 1710 | /** |
| 1711 | * The name of the relative as the user entered it. |
| 1712 | * <P>Type: TEXT</P> |
| 1713 | */ |
| 1714 | public static final String NAME = DATA; |
| 1715 | } |
| 1716 | |
| 1717 | /** |
| 1718 | * Common data definition for events. |
| 1719 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 1720 | public static final class Event implements DataColumnsWithJoins, CommonColumns { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1721 | /** |
| 1722 | * This utility class cannot be instantiated |
| 1723 | */ |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 1724 | private Event() {} |
| 1725 | |
| 1726 | /** MIME type used when storing this in data table. */ |
| 1727 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/event"; |
| 1728 | |
| 1729 | public static final int TYPE_ANNIVERSARY = 1; |
| 1730 | public static final int TYPE_OTHER = 2; |
Dmitri Plotnikov | d4e0b57 | 2009-08-06 20:19:29 -0700 | [diff] [blame] | 1731 | |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 1732 | /** |
| 1733 | * The event start date as the user entered it. |
| 1734 | * <P>Type: TEXT</P> |
| 1735 | */ |
| 1736 | public static final String START_DATE = DATA; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1737 | } |
| 1738 | |
| 1739 | /** |
| 1740 | * Photo of the contact. |
| 1741 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 1742 | public static final class Photo implements DataColumnsWithJoins { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1743 | /** |
| 1744 | * This utility class cannot be instantiated |
| 1745 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1746 | private Photo() {} |
| 1747 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1748 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1749 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/photo"; |
| 1750 | |
| 1751 | /** |
Dmitri Plotnikov | facbbb3 | 2009-07-27 15:18:19 -0700 | [diff] [blame] | 1752 | * Thumbnail photo of the raw contact. This is the raw bytes of an image |
Dmitri Plotnikov | f22fc12 | 2009-09-22 13:46:11 -0700 | [diff] [blame] | 1753 | * that could be inflated using {@link android.graphics.BitmapFactory}. |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1754 | * <p> |
| 1755 | * Type: BLOB |
| 1756 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 1757 | public static final String PHOTO = DATA15; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1758 | } |
| 1759 | |
| 1760 | /** |
| 1761 | * Notes about the contact. |
| 1762 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 1763 | public static final class Note implements DataColumnsWithJoins { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1764 | /** |
| 1765 | * This utility class cannot be instantiated |
| 1766 | */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1767 | private Note() {} |
| 1768 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1769 | /** MIME type used when storing this in data table. */ |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1770 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/note"; |
| 1771 | |
| 1772 | /** |
| 1773 | * The note text. |
| 1774 | * <P>Type: TEXT</P> |
| 1775 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 1776 | public static final String NOTE = DATA1; |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 1777 | } |
Dmitri Plotnikov | 5692777 | 2009-05-28 17:23:39 -0700 | [diff] [blame] | 1778 | |
Dmitri Plotnikov | c926054 | 2009-05-28 17:55:12 -0700 | [diff] [blame] | 1779 | /** |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 1780 | * Group Membership. |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 1781 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 1782 | public static final class GroupMembership implements DataColumnsWithJoins { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1783 | /** |
| 1784 | * This utility class cannot be instantiated |
| 1785 | */ |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 1786 | private GroupMembership() {} |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 1787 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1788 | /** MIME type used when storing this in data table. */ |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 1789 | public static final String CONTENT_ITEM_TYPE = |
| 1790 | "vnd.android.cursor.item/group_membership"; |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 1791 | |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 1792 | /** |
Fred Quintana | ffc34c1 | 2009-07-14 16:02:58 -0700 | [diff] [blame] | 1793 | * The row id of the group that this group membership refers to. Exactly one of |
| 1794 | * this or {@link #GROUP_SOURCE_ID} must be set when inserting a row. |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 1795 | * <P>Type: INTEGER</P> |
| 1796 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 1797 | public static final String GROUP_ROW_ID = DATA1; |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 1798 | |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 1799 | /** |
Fred Quintana | ffc34c1 | 2009-07-14 16:02:58 -0700 | [diff] [blame] | 1800 | * The sourceid of the group that this group membership refers to. Exactly one of |
| 1801 | * this or {@link #GROUP_ROW_ID} must be set when inserting a row. |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1802 | * <P>Type: TEXT</P> |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 1803 | */ |
Fred Quintana | ffc34c1 | 2009-07-14 16:02:58 -0700 | [diff] [blame] | 1804 | public static final String GROUP_SOURCE_ID = "group_sourceid"; |
Fred Quintana | d8dfeb5 | 2009-06-04 10:28:49 -0700 | [diff] [blame] | 1805 | } |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1806 | |
| 1807 | /** |
| 1808 | * Website related to the contact. |
| 1809 | */ |
Dmitri Plotnikov | 0dc9841 | 2009-09-18 17:47:53 -0700 | [diff] [blame] | 1810 | public static final class Website implements DataColumnsWithJoins, CommonColumns { |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1811 | /** |
| 1812 | * This utility class cannot be instantiated |
| 1813 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1814 | private Website() {} |
| 1815 | |
| 1816 | /** MIME type used when storing this in data table. */ |
| 1817 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/website"; |
| 1818 | |
Fred Quintana | 8851e16 | 2009-08-05 21:06:45 -0700 | [diff] [blame] | 1819 | public static final int TYPE_HOMEPAGE = 1; |
| 1820 | public static final int TYPE_BLOG = 2; |
| 1821 | public static final int TYPE_PROFILE = 3; |
| 1822 | public static final int TYPE_HOME = 4; |
| 1823 | public static final int TYPE_WORK = 5; |
| 1824 | public static final int TYPE_FTP = 6; |
| 1825 | public static final int TYPE_OTHER = 7; |
| 1826 | |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1827 | /** |
| 1828 | * The website URL string. |
| 1829 | * <P>Type: TEXT</P> |
| 1830 | */ |
Dmitri Plotnikov | 15e2669 | 2009-09-20 07:56:06 -0700 | [diff] [blame] | 1831 | public static final String URL = DATA; |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1832 | } |
Dmitri Plotnikov | ceaafa5 | 2009-06-03 10:46:44 -0700 | [diff] [blame] | 1833 | } |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 1834 | |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1835 | private interface GroupsColumns { |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 1836 | /** |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 1837 | * The display title of this group. |
| 1838 | * <p> |
| 1839 | * Type: TEXT |
| 1840 | */ |
| 1841 | public static final String TITLE = "title"; |
| 1842 | |
| 1843 | /** |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1844 | * The package name to use when creating {@link Resources} objects for |
| 1845 | * this group. This value is only designed for use when building user |
| 1846 | * interfaces, and should not be used to infer the owner. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1847 | * |
| 1848 | * @hide |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 1849 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1850 | public static final String RES_PACKAGE = "res_package"; |
| 1851 | |
| 1852 | /** |
| 1853 | * The display title of this group to load as a resource from |
| 1854 | * {@link #RES_PACKAGE}, which may be localized. |
| 1855 | * <P>Type: TEXT</P> |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 1856 | * |
| 1857 | * @hide |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1858 | */ |
| 1859 | public static final String TITLE_RES = "title_res"; |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 1860 | |
| 1861 | /** |
Dmitri Plotnikov | 02c5b45 | 2009-07-22 15:13:08 -0700 | [diff] [blame] | 1862 | * Notes about the group. |
| 1863 | * <p> |
| 1864 | * Type: TEXT |
| 1865 | */ |
| 1866 | public static final String NOTES = "notes"; |
| 1867 | |
| 1868 | /** |
| 1869 | * The ID of this group if it is a System Group, i.e. a group that has a special meaning |
| 1870 | * to the sync adapter, null otherwise. |
| 1871 | * <P>Type: TEXT</P> |
| 1872 | */ |
| 1873 | public static final String SYSTEM_ID = "system_id"; |
| 1874 | |
| 1875 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1876 | * The total number of {@link Contacts} that have |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 1877 | * {@link CommonDataKinds.GroupMembership} in this group. Read-only value that is only |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 1878 | * present when querying {@link Groups#CONTENT_SUMMARY_URI}. |
| 1879 | * <p> |
| 1880 | * Type: INTEGER |
| 1881 | */ |
| 1882 | public static final String SUMMARY_COUNT = "summ_count"; |
| 1883 | |
| 1884 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 1885 | * The total number of {@link Contacts} that have both |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 1886 | * {@link CommonDataKinds.GroupMembership} in this group, and also have phone numbers. |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 1887 | * Read-only value that is only present when querying |
| 1888 | * {@link Groups#CONTENT_SUMMARY_URI}. |
| 1889 | * <p> |
| 1890 | * Type: INTEGER |
| 1891 | */ |
| 1892 | public static final String SUMMARY_WITH_PHONES = "summ_phones"; |
| 1893 | |
| 1894 | /** |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 1895 | * Flag indicating if the contacts belonging to this group should be |
| 1896 | * visible in any user interface. |
| 1897 | * <p> |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 1898 | * Type: INTEGER (boolean) |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 1899 | */ |
| 1900 | public static final String GROUP_VISIBLE = "group_visible"; |
Fred Quintana | 00c89f6 | 2009-08-10 14:43:24 -0700 | [diff] [blame] | 1901 | |
| 1902 | /** |
| 1903 | * The "deleted" flag: "0" by default, "1" if the row has been marked |
| 1904 | * for deletion. When {@link android.content.ContentResolver#delete} is |
| 1905 | * called on a raw contact, it is marked for deletion and removed from its |
| 1906 | * aggregate contact. The sync adaptor deletes the raw contact on the server and |
Fred Quintana | 33f889a | 2009-09-14 17:31:26 -0700 | [diff] [blame] | 1907 | * then calls ContactResolver.delete once more, this time setting the the |
Jeff Sharkey | 97bda4c | 2009-09-15 23:15:23 -0700 | [diff] [blame] | 1908 | * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize |
Fred Quintana | 33f889a | 2009-09-14 17:31:26 -0700 | [diff] [blame] | 1909 | * the data removal. |
Fred Quintana | 00c89f6 | 2009-08-10 14:43:24 -0700 | [diff] [blame] | 1910 | * <P>Type: INTEGER</P> |
| 1911 | */ |
| 1912 | public static final String DELETED = "deleted"; |
Jeff Sharkey | 403d7ac | 2009-08-16 16:34:35 -0700 | [diff] [blame] | 1913 | |
| 1914 | /** |
| 1915 | * Whether this group should be synced if the SYNC_EVERYTHING settings |
| 1916 | * is false for this group's account. |
| 1917 | * <p> |
| 1918 | * Type: INTEGER (boolean) |
| 1919 | */ |
| 1920 | public static final String SHOULD_SYNC = "should_sync"; |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 1921 | } |
| 1922 | |
| 1923 | /** |
| 1924 | * Constants for the groups table. |
| 1925 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1926 | public static final class Groups implements BaseColumns, GroupsColumns, SyncColumns { |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 1927 | /** |
| 1928 | * This utility class cannot be instantiated |
| 1929 | */ |
Jeff Sharkey | 8a0193e | 2009-07-20 23:28:23 -0700 | [diff] [blame] | 1930 | private Groups() { |
| 1931 | } |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 1932 | |
| 1933 | /** |
| 1934 | * The content:// style URI for this table |
| 1935 | */ |
| 1936 | public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "groups"); |
| 1937 | |
| 1938 | /** |
| 1939 | * The content:// style URI for this table joined with details data from |
Dmitri Plotnikov | 02c5b45 | 2009-07-22 15:13:08 -0700 | [diff] [blame] | 1940 | * {@link Data}. |
Jeff Sharkey | b2909eb | 2009-06-16 16:55:31 -0700 | [diff] [blame] | 1941 | */ |
| 1942 | public static final Uri CONTENT_SUMMARY_URI = Uri.withAppendedPath(AUTHORITY_URI, |
| 1943 | "groups_summary"); |
| 1944 | |
| 1945 | /** |
| 1946 | * The MIME type of a directory of groups. |
| 1947 | */ |
| 1948 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/group"; |
| 1949 | |
| 1950 | /** |
| 1951 | * The MIME type of a single group. |
| 1952 | */ |
| 1953 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/group"; |
| 1954 | } |
| 1955 | |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 1956 | /** |
| 1957 | * Constants for the contact aggregation exceptions table, which contains |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 1958 | * aggregation rules overriding those used by automatic aggregation. This type only |
| 1959 | * supports query and update. Neither insert nor delete are supported. |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 1960 | */ |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1961 | public static final class AggregationExceptions implements BaseColumns { |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 1962 | /** |
| 1963 | * This utility class cannot be instantiated |
| 1964 | */ |
| 1965 | private AggregationExceptions() {} |
| 1966 | |
| 1967 | /** |
| 1968 | * The content:// style URI for this table |
| 1969 | */ |
| 1970 | public static final Uri CONTENT_URI = |
| 1971 | Uri.withAppendedPath(AUTHORITY_URI, "aggregation_exceptions"); |
| 1972 | |
| 1973 | /** |
| 1974 | * The MIME type of {@link #CONTENT_URI} providing a directory of data. |
| 1975 | */ |
| 1976 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/aggregation_exception"; |
| 1977 | |
| 1978 | /** |
Dmitri Plotnikov | 0918bf0 | 2009-06-10 16:13:08 -0700 | [diff] [blame] | 1979 | * The MIME type of a {@link #CONTENT_URI} subdirectory of an aggregation exception |
| 1980 | */ |
| 1981 | public static final String CONTENT_ITEM_TYPE = |
| 1982 | "vnd.android.cursor.item/aggregation_exception"; |
| 1983 | |
| 1984 | /** |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 1985 | * The type of exception: {@link #TYPE_KEEP_TOGETHER}, {@link #TYPE_KEEP_SEPARATE} or |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 1986 | * {@link #TYPE_AUTOMATIC}. |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 1987 | * |
| 1988 | * <P>Type: INTEGER</P> |
| 1989 | */ |
| 1990 | public static final String TYPE = "type"; |
| 1991 | |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 1992 | /** |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 1993 | * Allows the provider to automatically decide whether the specified raw contacts should |
| 1994 | * be included in the same aggregate contact or not. |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 1995 | */ |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 1996 | public static final int TYPE_AUTOMATIC = 0; |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 1997 | |
| 1998 | /** |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 1999 | * Makes sure that the specified raw contacts are included in the same |
| 2000 | * aggregate contact. |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 2001 | */ |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 2002 | public static final int TYPE_KEEP_TOGETHER = 1; |
| 2003 | |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 2004 | /** |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 2005 | * Makes sure that the specified raw contacts are NOT included in the same |
| 2006 | * aggregate contact. |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 2007 | */ |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 2008 | public static final int TYPE_KEEP_SEPARATE = 2; |
| 2009 | |
Dmitri Plotnikov | 9d04451 | 2009-06-16 13:21:23 -0700 | [diff] [blame] | 2010 | /** |
Dmitri Plotnikov | 7cca5f8 | 2009-07-27 20:25:59 -0700 | [diff] [blame] | 2011 | * A reference to the {@link RawContacts#_ID} of the raw contact that the rule applies to. |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 2012 | */ |
Dmitri Plotnikov | 84ba065 | 2009-09-04 15:59:05 -0700 | [diff] [blame] | 2013 | public static final String RAW_CONTACT_ID1 = "raw_contact_id1"; |
| 2014 | |
| 2015 | /** |
| 2016 | * A reference to the other {@link RawContacts#_ID} of the raw contact that the rule |
| 2017 | * applies to. |
| 2018 | */ |
| 2019 | public static final String RAW_CONTACT_ID2 = "raw_contact_id2"; |
Fred Quintana | 435e427 | 2009-06-04 17:30:28 -0700 | [diff] [blame] | 2020 | } |
Jeff Sharkey | 28b68e5 | 2009-06-10 15:26:58 -0700 | [diff] [blame] | 2021 | |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 2022 | private interface SettingsColumns { |
| 2023 | /** |
| 2024 | * The name of the account instance to which this row belongs. |
| 2025 | * <P>Type: TEXT</P> |
| 2026 | */ |
| 2027 | public static final String ACCOUNT_NAME = "account_name"; |
| 2028 | |
| 2029 | /** |
| 2030 | * The type of account to which this row belongs, which when paired with |
| 2031 | * {@link #ACCOUNT_NAME} identifies a specific account. |
| 2032 | * <P>Type: TEXT</P> |
| 2033 | */ |
| 2034 | public static final String ACCOUNT_TYPE = "account_type"; |
| 2035 | |
| 2036 | /** |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 2037 | * Depending on the mode defined by the sync-adapter, this flag controls |
| 2038 | * the top-level sync behavior for this data source. |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 2039 | * <p> |
| 2040 | * Type: INTEGER (boolean) |
| 2041 | */ |
| 2042 | public static final String SHOULD_SYNC = "should_sync"; |
| 2043 | |
| 2044 | /** |
Dmitri Plotnikov | 31f5dd3 | 2009-08-21 13:44:47 -0700 | [diff] [blame] | 2045 | * Flag indicating if contacts without any {@link CommonDataKinds.GroupMembership} |
Jeff Sharkey | a659744 | 2009-08-19 09:23:33 -0700 | [diff] [blame] | 2046 | * entries should be visible in any user interface. |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 2047 | * <p> |
| 2048 | * Type: INTEGER (boolean) |
| 2049 | */ |
| 2050 | public static final String UNGROUPED_VISIBLE = "ungrouped_visible"; |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 2051 | |
| 2052 | /** |
Jeff Sharkey | 97bda4c | 2009-09-15 23:15:23 -0700 | [diff] [blame] | 2053 | * Read-only flag indicating if this {@link #SHOULD_SYNC} or any |
| 2054 | * {@link Groups#SHOULD_SYNC} under this account have been marked as |
| 2055 | * unsynced. |
| 2056 | */ |
| 2057 | public static final String ANY_UNSYNCED = "any_unsynced"; |
| 2058 | |
| 2059 | /** |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 2060 | * Read-only count of {@link Contacts} from a specific source that have |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 2061 | * no {@link CommonDataKinds.GroupMembership} entries. |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 2062 | * <p> |
| 2063 | * Type: INTEGER |
| 2064 | */ |
| 2065 | public static final String UNGROUPED_COUNT = "summ_count"; |
| 2066 | |
| 2067 | /** |
| 2068 | * Read-only count of {@link Contacts} from a specific source that have |
Dmitri Plotnikov | b87d0e0 | 2009-08-27 10:38:14 -0700 | [diff] [blame] | 2069 | * no {@link CommonDataKinds.GroupMembership} entries, and also have phone numbers. |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 2070 | * <p> |
| 2071 | * Type: INTEGER |
| 2072 | */ |
| 2073 | public static final String UNGROUPED_WITH_PHONES = "summ_phones"; |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 2074 | } |
| 2075 | |
| 2076 | /** |
| 2077 | * Contacts-specific settings for various {@link Account}. |
| 2078 | */ |
Jeff Sharkey | 06a0323 | 2009-08-21 17:37:56 -0700 | [diff] [blame] | 2079 | public static final class Settings implements SettingsColumns { |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 2080 | /** |
| 2081 | * This utility class cannot be instantiated |
| 2082 | */ |
| 2083 | private Settings() { |
| 2084 | } |
| 2085 | |
| 2086 | /** |
| 2087 | * The content:// style URI for this table |
| 2088 | */ |
| 2089 | public static final Uri CONTENT_URI = |
| 2090 | Uri.withAppendedPath(AUTHORITY_URI, "settings"); |
| 2091 | |
| 2092 | /** |
| 2093 | * The MIME-type of {@link #CONTENT_URI} providing a directory of |
| 2094 | * settings. |
| 2095 | */ |
| 2096 | public static final String CONTENT_TYPE = "vnd.android.cursor.dir/setting"; |
| 2097 | |
| 2098 | /** |
| 2099 | * The MIME-type of {@link #CONTENT_URI} providing a single setting. |
| 2100 | */ |
| 2101 | public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/setting"; |
Jeff Sharkey | 7b6771a | 2009-08-17 01:59:54 -0700 | [diff] [blame] | 2102 | } |
| 2103 | |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 2104 | /** |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 2105 | * Helper methods to display FastTrack dialogs that allow users to pivot on |
| 2106 | * a specific {@link Contacts} entry. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 2107 | * |
| 2108 | * @hide |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 2109 | */ |
| 2110 | public static final class FastTrack { |
| 2111 | /** |
| 2112 | * Action used to trigger person pivot dialog. |
| 2113 | * @hide |
| 2114 | */ |
| 2115 | public static final String ACTION_FAST_TRACK = |
Jeff Sharkey | 0050ee3 | 2009-09-17 16:11:32 -0700 | [diff] [blame] | 2116 | "com.android.contacts.action.FAST_TRACK"; |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 2117 | |
| 2118 | /** |
| 2119 | * Extra used to specify pivot dialog location in screen coordinates. |
| 2120 | * @hide |
| 2121 | */ |
| 2122 | public static final String EXTRA_TARGET_RECT = "target_rect"; |
| 2123 | |
| 2124 | /** |
| 2125 | * Extra used to specify size of pivot dialog. |
| 2126 | * @hide |
| 2127 | */ |
| 2128 | public static final String EXTRA_MODE = "mode"; |
| 2129 | |
| 2130 | /** |
| 2131 | * Extra used to indicate a list of specific MIME-types to exclude and |
| 2132 | * not display. Stored as a {@link String} array. |
| 2133 | * @hide |
| 2134 | */ |
| 2135 | public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes"; |
| 2136 | |
| 2137 | /** |
| 2138 | * Small FastTrack mode, usually presented with minimal actions. |
| 2139 | */ |
| 2140 | public static final int MODE_SMALL = 1; |
| 2141 | |
| 2142 | /** |
| 2143 | * Medium FastTrack mode, includes actions and light summary describing |
| 2144 | * the {@link Contacts} entry being shown. This may include social |
| 2145 | * status and presence details. |
| 2146 | */ |
| 2147 | public static final int MODE_MEDIUM = 2; |
| 2148 | |
| 2149 | /** |
| 2150 | * Large FastTrack mode, includes actions and larger, card-like summary |
| 2151 | * of the {@link Contacts} entry being shown. This may include detailed |
| 2152 | * information, such as a photo. |
| 2153 | */ |
| 2154 | public static final int MODE_LARGE = 3; |
| 2155 | |
| 2156 | /** |
| 2157 | * Trigger a dialog that lists the various methods of interacting with |
| 2158 | * the requested {@link Contacts} entry. This may be based on available |
| 2159 | * {@link Data} rows under that contact, and may also include social |
| 2160 | * status and presence details. |
| 2161 | * |
| 2162 | * @param context The parent {@link Context} that may be used as the |
| 2163 | * parent for this dialog. |
| 2164 | * @param target Specific {@link View} from your layout that this dialog |
| 2165 | * should be centered around. In particular, if the dialog |
| 2166 | * has a "callout" arrow, it will be pointed and centered |
| 2167 | * around this {@link View}. |
| 2168 | * @param lookupUri A {@link Contacts#CONTENT_LOOKUP_URI} style |
| 2169 | * {@link Uri} that describes a specific contact to feature |
| 2170 | * in this dialog. |
| 2171 | * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or |
| 2172 | * {@link #MODE_LARGE}, indicating the desired dialog size, |
| 2173 | * when supported. |
| 2174 | * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types |
| 2175 | * to exclude when showing this dialog. For example, when |
| 2176 | * already viewing the contact details card, this can be used |
| 2177 | * to omit the details entry from the dialog. |
| 2178 | */ |
| 2179 | public static void showFastTrack(Context context, View target, Uri lookupUri, int mode, |
| 2180 | String[] excludeMimes) { |
| 2181 | // Find location and bounds of target view |
| 2182 | final int[] location = new int[2]; |
| 2183 | target.getLocationOnScreen(location); |
| 2184 | |
| 2185 | final Rect rect = new Rect(); |
| 2186 | rect.left = location[0]; |
| 2187 | rect.top = location[1]; |
| 2188 | rect.right = rect.left + target.getWidth(); |
| 2189 | rect.bottom = rect.top + target.getHeight(); |
| 2190 | |
| 2191 | // Trigger with obtained rectangle |
| 2192 | showFastTrack(context, rect, lookupUri, mode, excludeMimes); |
| 2193 | } |
| 2194 | |
| 2195 | /** |
| 2196 | * Trigger a dialog that lists the various methods of interacting with |
| 2197 | * the requested {@link Contacts} entry. This may be based on available |
| 2198 | * {@link Data} rows under that contact, and may also include social |
| 2199 | * status and presence details. |
| 2200 | * |
| 2201 | * @param context The parent {@link Context} that may be used as the |
| 2202 | * parent for this dialog. |
| 2203 | * @param target Specific {@link Rect} that this dialog should be |
| 2204 | * centered around, in screen coordinates. In particular, if |
| 2205 | * the dialog has a "callout" arrow, it will be pointed and |
| 2206 | * centered around this {@link Rect}. |
| 2207 | * @param lookupUri A {@link Contacts#CONTENT_LOOKUP_URI} style |
| 2208 | * {@link Uri} that describes a specific contact to feature |
| 2209 | * in this dialog. |
| 2210 | * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or |
| 2211 | * {@link #MODE_LARGE}, indicating the desired dialog size, |
| 2212 | * when supported. |
| 2213 | * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types |
| 2214 | * to exclude when showing this dialog. For example, when |
| 2215 | * already viewing the contact details card, this can be used |
| 2216 | * to omit the details entry from the dialog. |
| 2217 | */ |
| 2218 | public static void showFastTrack(Context context, Rect target, Uri lookupUri, int mode, |
| 2219 | String[] excludeMimes) { |
| 2220 | // Launch pivot dialog through intent for now |
| 2221 | final Intent intent = new Intent(ACTION_FAST_TRACK); |
| 2222 | intent.setData(lookupUri); |
| 2223 | intent.putExtra(EXTRA_TARGET_RECT, target); |
| 2224 | intent.putExtra(EXTRA_MODE, mode); |
| 2225 | intent.putExtra(EXTRA_EXCLUDE_MIMES, excludeMimes); |
| 2226 | context.startActivity(intent); |
| 2227 | } |
| 2228 | } |
| 2229 | |
| 2230 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 2231 | * Contains helper classes used to create or manage {@link android.content.Intent Intents} |
| 2232 | * that involve contacts. |
| 2233 | */ |
| 2234 | public static final class Intents { |
| 2235 | /** |
| 2236 | * This is the intent that is fired when a search suggestion is clicked on. |
| 2237 | */ |
| 2238 | public static final String SEARCH_SUGGESTION_CLICKED = |
| 2239 | "android.provider.Contacts.SEARCH_SUGGESTION_CLICKED"; |
| 2240 | |
| 2241 | /** |
| 2242 | * This is the intent that is fired when a search suggestion for dialing a number |
| 2243 | * is clicked on. |
| 2244 | */ |
| 2245 | public static final String SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED = |
| 2246 | "android.provider.Contacts.SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED"; |
| 2247 | |
| 2248 | /** |
| 2249 | * This is the intent that is fired when a search suggestion for creating a contact |
| 2250 | * is clicked on. |
| 2251 | */ |
| 2252 | public static final String SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED = |
| 2253 | "android.provider.Contacts.SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED"; |
| 2254 | |
| 2255 | /** |
| 2256 | * Starts an Activity that lets the user pick a contact to attach an image to. |
| 2257 | * After picking the contact it launches the image cropper in face detection mode. |
| 2258 | */ |
| 2259 | public static final String ATTACH_IMAGE = |
| 2260 | "com.android.contacts.action.ATTACH_IMAGE"; |
| 2261 | |
| 2262 | /** |
| 2263 | * Takes as input a data URI with a mailto: or tel: scheme. If a single |
| 2264 | * contact exists with the given data it will be shown. If no contact |
| 2265 | * exists, a dialog will ask the user if they want to create a new |
| 2266 | * contact with the provided details filled in. If multiple contacts |
| 2267 | * share the data the user will be prompted to pick which contact they |
| 2268 | * want to view. |
| 2269 | * <p> |
| 2270 | * For <code>mailto:</code> URIs, the scheme specific portion must be a |
| 2271 | * raw email address, such as one built using |
| 2272 | * {@link Uri#fromParts(String, String, String)}. |
| 2273 | * <p> |
| 2274 | * For <code>tel:</code> URIs, the scheme specific portion is compared |
| 2275 | * to existing numbers using the standard caller ID lookup algorithm. |
| 2276 | * The number must be properly encoded, for example using |
| 2277 | * {@link Uri#fromParts(String, String, String)}. |
| 2278 | * <p> |
| 2279 | * Any extras from the {@link Insert} class will be passed along to the |
| 2280 | * create activity if there are no contacts to show. |
| 2281 | * <p> |
| 2282 | * Passing true for the {@link #EXTRA_FORCE_CREATE} extra will skip |
| 2283 | * prompting the user when the contact doesn't exist. |
| 2284 | */ |
| 2285 | public static final String SHOW_OR_CREATE_CONTACT = |
| 2286 | "com.android.contacts.action.SHOW_OR_CREATE_CONTACT"; |
| 2287 | |
| 2288 | /** |
| 2289 | * Used with {@link #SHOW_OR_CREATE_CONTACT} to force creating a new |
| 2290 | * contact if no matching contact found. Otherwise, default behavior is |
| 2291 | * to prompt user with dialog before creating. |
| 2292 | * <p> |
| 2293 | * Type: BOOLEAN |
| 2294 | */ |
| 2295 | public static final String EXTRA_FORCE_CREATE = |
| 2296 | "com.android.contacts.action.FORCE_CREATE"; |
| 2297 | |
| 2298 | /** |
| 2299 | * Used with {@link #SHOW_OR_CREATE_CONTACT} to specify an exact |
| 2300 | * description to be shown when prompting user about creating a new |
| 2301 | * contact. |
| 2302 | * <p> |
| 2303 | * Type: STRING |
| 2304 | */ |
| 2305 | public static final String EXTRA_CREATE_DESCRIPTION = |
| 2306 | "com.android.contacts.action.CREATE_DESCRIPTION"; |
| 2307 | |
| 2308 | /** |
Jeff Sharkey | 1132200 | 2009-06-04 17:25:51 -0700 | [diff] [blame] | 2309 | * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a |
| 2310 | * dialog location using screen coordinates. When not specified, the |
| 2311 | * dialog will be centered. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 2312 | * |
| 2313 | * @hide |
Jeff Sharkey | 1132200 | 2009-06-04 17:25:51 -0700 | [diff] [blame] | 2314 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 2315 | @Deprecated |
Jeff Sharkey | 1132200 | 2009-06-04 17:25:51 -0700 | [diff] [blame] | 2316 | public static final String EXTRA_TARGET_RECT = "target_rect"; |
| 2317 | |
| 2318 | /** |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 2319 | * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a |
| 2320 | * desired dialog style, usually a variation on size. One of |
| 2321 | * {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 2322 | * |
| 2323 | * @hide |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 2324 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 2325 | @Deprecated |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 2326 | public static final String EXTRA_MODE = "mode"; |
| 2327 | |
| 2328 | /** |
| 2329 | * Value for {@link #EXTRA_MODE} to show a small-sized dialog. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 2330 | * |
| 2331 | * @hide |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 2332 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 2333 | @Deprecated |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 2334 | public static final int MODE_SMALL = 1; |
| 2335 | |
| 2336 | /** |
| 2337 | * Value for {@link #EXTRA_MODE} to show a medium-sized dialog. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 2338 | * |
| 2339 | * @hide |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 2340 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 2341 | @Deprecated |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 2342 | public static final int MODE_MEDIUM = 2; |
| 2343 | |
| 2344 | /** |
| 2345 | * Value for {@link #EXTRA_MODE} to show a large-sized dialog. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 2346 | * |
| 2347 | * @hide |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 2348 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 2349 | @Deprecated |
Jeff Sharkey | 6bfe14d | 2009-08-05 15:49:48 -0700 | [diff] [blame] | 2350 | public static final int MODE_LARGE = 3; |
| 2351 | |
| 2352 | /** |
Jeff Sharkey | 84235ee | 2009-08-23 14:07:02 -0700 | [diff] [blame] | 2353 | * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to indicate |
| 2354 | * a list of specific MIME-types to exclude and not display. Stored as a |
| 2355 | * {@link String} array. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 2356 | * |
| 2357 | * @hide |
Jeff Sharkey | 84235ee | 2009-08-23 14:07:02 -0700 | [diff] [blame] | 2358 | */ |
Jeff Sharkey | 6449eb0 | 2009-09-16 21:41:51 -0700 | [diff] [blame] | 2359 | @Deprecated |
Jeff Sharkey | 84235ee | 2009-08-23 14:07:02 -0700 | [diff] [blame] | 2360 | public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes"; |
| 2361 | |
| 2362 | /** |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 2363 | * Intents related to the Contacts app UI. |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 2364 | * |
| 2365 | * @hide |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 2366 | */ |
| 2367 | public static final class UI { |
| 2368 | /** |
| 2369 | * The action for the default contacts list tab. |
| 2370 | */ |
| 2371 | public static final String LIST_DEFAULT = |
| 2372 | "com.android.contacts.action.LIST_DEFAULT"; |
| 2373 | |
| 2374 | /** |
| 2375 | * The action for the contacts list tab. |
| 2376 | */ |
| 2377 | public static final String LIST_GROUP_ACTION = |
| 2378 | "com.android.contacts.action.LIST_GROUP"; |
| 2379 | |
| 2380 | /** |
| 2381 | * When in LIST_GROUP_ACTION mode, this is the group to display. |
| 2382 | */ |
| 2383 | public static final String GROUP_NAME_EXTRA_KEY = "com.android.contacts.extra.GROUP"; |
| 2384 | |
| 2385 | /** |
| 2386 | * The action for the all contacts list tab. |
| 2387 | */ |
| 2388 | public static final String LIST_ALL_CONTACTS_ACTION = |
| 2389 | "com.android.contacts.action.LIST_ALL_CONTACTS"; |
| 2390 | |
| 2391 | /** |
| 2392 | * The action for the contacts with phone numbers list tab. |
| 2393 | */ |
| 2394 | public static final String LIST_CONTACTS_WITH_PHONES_ACTION = |
| 2395 | "com.android.contacts.action.LIST_CONTACTS_WITH_PHONES"; |
| 2396 | |
| 2397 | /** |
| 2398 | * The action for the starred contacts list tab. |
| 2399 | */ |
| 2400 | public static final String LIST_STARRED_ACTION = |
| 2401 | "com.android.contacts.action.LIST_STARRED"; |
| 2402 | |
| 2403 | /** |
| 2404 | * The action for the frequent contacts list tab. |
| 2405 | */ |
| 2406 | public static final String LIST_FREQUENT_ACTION = |
| 2407 | "com.android.contacts.action.LIST_FREQUENT"; |
| 2408 | |
| 2409 | /** |
| 2410 | * The action for the "strequent" contacts list tab. It first lists the starred |
| 2411 | * contacts in alphabetical order and then the frequent contacts in descending |
| 2412 | * order of the number of times they have been contacted. |
| 2413 | */ |
| 2414 | public static final String LIST_STREQUENT_ACTION = |
| 2415 | "com.android.contacts.action.LIST_STREQUENT"; |
| 2416 | |
| 2417 | /** |
| 2418 | * A key for to be used as an intent extra to set the activity |
| 2419 | * title to a custom String value. |
| 2420 | */ |
| 2421 | public static final String TITLE_EXTRA_KEY = |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 2422 | "com.android.contacts.extra.TITLE_EXTRA"; |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 2423 | |
| 2424 | /** |
| 2425 | * Activity Action: Display a filtered list of contacts |
| 2426 | * <p> |
| 2427 | * Input: Extra field {@link #FILTER_TEXT_EXTRA_KEY} is the text to use for |
| 2428 | * filtering |
| 2429 | * <p> |
| 2430 | * Output: Nothing. |
| 2431 | */ |
| 2432 | public static final String FILTER_CONTACTS_ACTION = |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 2433 | "com.android.contacts.action.FILTER_CONTACTS"; |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 2434 | |
| 2435 | /** |
| 2436 | * Used as an int extra field in {@link #FILTER_CONTACTS_ACTION} |
| 2437 | * intents to supply the text on which to filter. |
| 2438 | */ |
| 2439 | public static final String FILTER_TEXT_EXTRA_KEY = |
Jeff Hamilton | 85abdc5 | 2009-09-22 12:41:45 -0500 | [diff] [blame] | 2440 | "com.android.contacts.extra.FILTER_TEXT"; |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 2441 | } |
| 2442 | |
| 2443 | /** |
| 2444 | * Convenience class that contains string constants used |
| 2445 | * to create contact {@link android.content.Intent Intents}. |
| 2446 | */ |
| 2447 | public static final class Insert { |
| 2448 | /** The action code to use when adding a contact */ |
| 2449 | public static final String ACTION = Intent.ACTION_INSERT; |
| 2450 | |
| 2451 | /** |
| 2452 | * If present, forces a bypass of quick insert mode. |
| 2453 | */ |
| 2454 | public static final String FULL_MODE = "full_mode"; |
| 2455 | |
| 2456 | /** |
| 2457 | * The extra field for the contact name. |
| 2458 | * <P>Type: String</P> |
| 2459 | */ |
| 2460 | public static final String NAME = "name"; |
| 2461 | |
| 2462 | // TODO add structured name values here. |
| 2463 | |
| 2464 | /** |
| 2465 | * The extra field for the contact phonetic name. |
| 2466 | * <P>Type: String</P> |
| 2467 | */ |
| 2468 | public static final String PHONETIC_NAME = "phonetic_name"; |
| 2469 | |
| 2470 | /** |
| 2471 | * The extra field for the contact company. |
| 2472 | * <P>Type: String</P> |
| 2473 | */ |
| 2474 | public static final String COMPANY = "company"; |
| 2475 | |
| 2476 | /** |
| 2477 | * The extra field for the contact job title. |
| 2478 | * <P>Type: String</P> |
| 2479 | */ |
| 2480 | public static final String JOB_TITLE = "job_title"; |
| 2481 | |
| 2482 | /** |
| 2483 | * The extra field for the contact notes. |
| 2484 | * <P>Type: String</P> |
| 2485 | */ |
| 2486 | public static final String NOTES = "notes"; |
| 2487 | |
| 2488 | /** |
| 2489 | * The extra field for the contact phone number. |
| 2490 | * <P>Type: String</P> |
| 2491 | */ |
| 2492 | public static final String PHONE = "phone"; |
| 2493 | |
| 2494 | /** |
| 2495 | * The extra field for the contact phone number type. |
| 2496 | * <P>Type: Either an integer value from |
| 2497 | * {@link android.provider.Contacts.PhonesColumns PhonesColumns}, |
| 2498 | * or a string specifying a custom label.</P> |
| 2499 | */ |
| 2500 | public static final String PHONE_TYPE = "phone_type"; |
| 2501 | |
| 2502 | /** |
| 2503 | * The extra field for the phone isprimary flag. |
| 2504 | * <P>Type: boolean</P> |
| 2505 | */ |
| 2506 | public static final String PHONE_ISPRIMARY = "phone_isprimary"; |
| 2507 | |
| 2508 | /** |
| 2509 | * The extra field for an optional second contact phone number. |
| 2510 | * <P>Type: String</P> |
| 2511 | */ |
| 2512 | public static final String SECONDARY_PHONE = "secondary_phone"; |
| 2513 | |
| 2514 | /** |
| 2515 | * The extra field for an optional second contact phone number type. |
| 2516 | * <P>Type: Either an integer value from |
| 2517 | * {@link android.provider.Contacts.PhonesColumns PhonesColumns}, |
| 2518 | * or a string specifying a custom label.</P> |
| 2519 | */ |
| 2520 | public static final String SECONDARY_PHONE_TYPE = "secondary_phone_type"; |
| 2521 | |
| 2522 | /** |
| 2523 | * The extra field for an optional third contact phone number. |
| 2524 | * <P>Type: String</P> |
| 2525 | */ |
| 2526 | public static final String TERTIARY_PHONE = "tertiary_phone"; |
| 2527 | |
| 2528 | /** |
| 2529 | * The extra field for an optional third contact phone number type. |
| 2530 | * <P>Type: Either an integer value from |
| 2531 | * {@link android.provider.Contacts.PhonesColumns PhonesColumns}, |
| 2532 | * or a string specifying a custom label.</P> |
| 2533 | */ |
| 2534 | public static final String TERTIARY_PHONE_TYPE = "tertiary_phone_type"; |
| 2535 | |
| 2536 | /** |
| 2537 | * The extra field for the contact email address. |
| 2538 | * <P>Type: String</P> |
| 2539 | */ |
| 2540 | public static final String EMAIL = "email"; |
| 2541 | |
| 2542 | /** |
| 2543 | * The extra field for the contact email type. |
| 2544 | * <P>Type: Either an integer value from |
| 2545 | * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns} |
| 2546 | * or a string specifying a custom label.</P> |
| 2547 | */ |
| 2548 | public static final String EMAIL_TYPE = "email_type"; |
| 2549 | |
| 2550 | /** |
| 2551 | * The extra field for the email isprimary flag. |
| 2552 | * <P>Type: boolean</P> |
| 2553 | */ |
| 2554 | public static final String EMAIL_ISPRIMARY = "email_isprimary"; |
| 2555 | |
| 2556 | /** |
| 2557 | * The extra field for an optional second contact email address. |
| 2558 | * <P>Type: String</P> |
| 2559 | */ |
| 2560 | public static final String SECONDARY_EMAIL = "secondary_email"; |
| 2561 | |
| 2562 | /** |
| 2563 | * The extra field for an optional second contact email type. |
| 2564 | * <P>Type: Either an integer value from |
| 2565 | * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns} |
| 2566 | * or a string specifying a custom label.</P> |
| 2567 | */ |
| 2568 | public static final String SECONDARY_EMAIL_TYPE = "secondary_email_type"; |
| 2569 | |
| 2570 | /** |
| 2571 | * The extra field for an optional third contact email address. |
| 2572 | * <P>Type: String</P> |
| 2573 | */ |
| 2574 | public static final String TERTIARY_EMAIL = "tertiary_email"; |
| 2575 | |
| 2576 | /** |
| 2577 | * The extra field for an optional third contact email type. |
| 2578 | * <P>Type: Either an integer value from |
| 2579 | * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns} |
| 2580 | * or a string specifying a custom label.</P> |
| 2581 | */ |
| 2582 | public static final String TERTIARY_EMAIL_TYPE = "tertiary_email_type"; |
| 2583 | |
| 2584 | /** |
| 2585 | * The extra field for the contact postal address. |
| 2586 | * <P>Type: String</P> |
| 2587 | */ |
| 2588 | public static final String POSTAL = "postal"; |
| 2589 | |
| 2590 | /** |
| 2591 | * The extra field for the contact postal address type. |
| 2592 | * <P>Type: Either an integer value from |
| 2593 | * {@link android.provider.Contacts.ContactMethodsColumns ContactMethodsColumns} |
| 2594 | * or a string specifying a custom label.</P> |
| 2595 | */ |
| 2596 | public static final String POSTAL_TYPE = "postal_type"; |
| 2597 | |
| 2598 | /** |
| 2599 | * The extra field for the postal isprimary flag. |
| 2600 | * <P>Type: boolean</P> |
| 2601 | */ |
| 2602 | public static final String POSTAL_ISPRIMARY = "postal_isprimary"; |
| 2603 | |
| 2604 | /** |
| 2605 | * The extra field for an IM handle. |
| 2606 | * <P>Type: String</P> |
| 2607 | */ |
| 2608 | public static final String IM_HANDLE = "im_handle"; |
| 2609 | |
| 2610 | /** |
| 2611 | * The extra field for the IM protocol |
Evan Millar | dc2da5f | 2009-06-18 16:07:13 -0700 | [diff] [blame] | 2612 | */ |
| 2613 | public static final String IM_PROTOCOL = "im_protocol"; |
| 2614 | |
| 2615 | /** |
| 2616 | * The extra field for the IM isprimary flag. |
| 2617 | * <P>Type: boolean</P> |
| 2618 | */ |
| 2619 | public static final String IM_ISPRIMARY = "im_isprimary"; |
| 2620 | } |
| 2621 | } |
| 2622 | |
Evan Millar | 088b291 | 2009-05-28 15:24:37 -0700 | [diff] [blame] | 2623 | } |