AI2 Component  (Version nb184)
HoneycombMR1Util.java
Go to the documentation of this file.
1 // -*- mode: java; c-basic-offset: 2; -*-
2 // Copyright 2009-2011 Google, All Rights reserved
3 // Copyright 2011-2014 MIT, All rights reserved
4 // Released under the Apache License, Version 2.0
5 // http://www.apache.org/licenses/LICENSE-2.0
6 package com.google.appinventor.components.runtime.util;
7 
9 
10 import android.app.Activity;
11 import android.content.ContentResolver;
12 import android.content.Context;
13 import android.content.DialogInterface;
14 
15 import android.database.Cursor;
16 import android.net.Uri;
17 import android.provider.ContactsContract;
18 import android.provider.ContactsContract.CommonDataKinds.Email;
19 import android.provider.ContactsContract.CommonDataKinds.Phone;
20 import android.provider.ContactsContract.Data;
21 
22 import java.io.InputStream;
23 
29 public class HoneycombMR1Util {
30 
31  private HoneycombMR1Util() {
32  }
33 
37  public static Uri getContentUri() {
38  return ContactsContract.Contacts.CONTENT_URI;
39  }
40 
44  public static Uri getPhoneContentUri() {
45  return Phone.CONTENT_URI;
46  }
47 
51  public static Uri getDataContentUri() {
52  return Data.CONTENT_URI;
53  }
54 
58  public static String[] getContactProjection() {
59  String[] contactProjection = {
60  ContactsContract.Contacts._ID,
61  ContactsContract.Contacts.DISPLAY_NAME_PRIMARY,
62  ContactsContract.Contacts.PHOTO_THUMBNAIL_URI,
63  ContactsContract.Contacts.PHOTO_URI,
64  };
65  return contactProjection;
66  }
67 
71  public static String[] getNameProjection() {
72  String[] nameProjection = {
73  Data.CONTACT_ID,
74  ContactsContract.Contacts.DISPLAY_NAME,
75  ContactsContract.Contacts.PHOTO_THUMBNAIL_URI,
76  Phone.NUMBER,
77  };
78  return nameProjection;
79  }
80 
84  public static String[] getDataProjection() {
85  String[] dataProjection = {
86  Data.MIMETYPE,
87  Email.ADDRESS,
88  Email.TYPE,
89  Phone.NUMBER,
90  Phone.TYPE,
91  };
92  return dataProjection;
93  }
94 
98  public static String[] getEmailAdapterProjection() {
99  String[] emailAdapterProjection = {
100  Data._ID,
101  Data.DISPLAY_NAME,
102  Email.ADDRESS,
103  Data.MIMETYPE,
104  };
105  return emailAdapterProjection;
106  }
107 
111  public static int getIdIndex(Cursor contactCursor) {
112  return contactCursor.getColumnIndex(ContactsContract.Contacts._ID);
113  }
114 
118  public static int getContactIdIndex(Cursor contactCursor) {
119  return contactCursor.getColumnIndex(Data.CONTACT_ID);
120  }
121 
125  public static int getNameIndex(Cursor contactCursor) {
126  return contactCursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME);
127  }
128 
132  public static int getThumbnailIndex(Cursor contactCursor) {
133  return contactCursor.getColumnIndex(ContactsContract.Contacts.PHOTO_THUMBNAIL_URI);
134  }
135 
139  public static int getPhotoIndex(Cursor contactCursor) {
140  return contactCursor.getColumnIndex(ContactsContract.Contacts.PHOTO_URI);
141  }
142 
143  public static int getPhoneIndex(Cursor dataCursor) {
144  return dataCursor.getColumnIndex(Phone.NUMBER);
145  }
146 
147  public static int getEmailIndex(Cursor dataCursor) {
148  return dataCursor.getColumnIndex(Email.ADDRESS);
149  }
150 
151  public static int getMimeIndex(Cursor dataCursor) {
152  return dataCursor.getColumnIndex(Data.MIMETYPE);
153  }
157  public static String getPhoneType() {
158  return Phone.CONTENT_ITEM_TYPE;
159  }
160 
164  public static String getEmailType() {
165  return Email.CONTENT_ITEM_TYPE;
166  }
167 
171  public static String getDisplayName() {
172  return Data.DISPLAY_NAME;
173  }
174 
178  public static String getEmailAddress() {
179  return Email.ADDRESS;
180  }
181 
185  public static String getDataMimeType() {
186  return Data.MIMETYPE;
187  }
188 
192  public static Cursor getDataCursor(String id, Activity activityContext, String[] dataProjection) {
193  Cursor dataCursor = activityContext.getContentResolver().query(
194  Data.CONTENT_URI,
195  dataProjection,
196  Data.CONTACT_ID + "=? AND (" + Data.MIMETYPE + "=? OR " + Data.MIMETYPE + "=?)",
197  new String[] {id, Phone.CONTENT_ITEM_TYPE, Email.CONTENT_ITEM_TYPE},
198  null);
199  return dataCursor;
200  }
201 
205  public static InputStream openContactPhotoInputStreamHelper(ContentResolver cr, Uri contactUri) {
206  return ContactsContract.Contacts.openContactPhotoInputStream(cr, contactUri);
207  }
208 
212  public static String getTimesContacted() {
213  return Data.TIMES_CONTACTED;
214  }
215 
216 }
com.google.appinventor.components.runtime.util.HoneycombMR1Util.getDataCursor
static Cursor getDataCursor(String id, Activity activityContext, String[] dataProjection)
Definition: HoneycombMR1Util.java:192
com.google.appinventor.components.runtime.util.HoneycombMR1Util.getDataMimeType
static String getDataMimeType()
Definition: HoneycombMR1Util.java:185
com.google.appinventor.components.runtime.util.HoneycombMR1Util.getDisplayName
static String getDisplayName()
Definition: HoneycombMR1Util.java:171
com.google.appinventor.components.runtime.util.HoneycombMR1Util.getContentUri
static Uri getContentUri()
Definition: HoneycombMR1Util.java:37
com.google.appinventor.components.runtime.util.HoneycombMR1Util.getDataProjection
static String[] getDataProjection()
Definition: HoneycombMR1Util.java:84
com.google.appinventor.components
com.google.appinventor.components.runtime.util.HoneycombMR1Util
Definition: HoneycombMR1Util.java:29
com.google.appinventor.components.runtime.util.HoneycombMR1Util.getPhotoIndex
static int getPhotoIndex(Cursor contactCursor)
Definition: HoneycombMR1Util.java:139
com.google.appinventor.components.runtime.util.HoneycombMR1Util.getEmailAdapterProjection
static String[] getEmailAdapterProjection()
Definition: HoneycombMR1Util.java:98
com.google.appinventor.components.runtime.util.HoneycombMR1Util.getNameProjection
static String[] getNameProjection()
Definition: HoneycombMR1Util.java:71
com.google.appinventor.components.runtime.util.HoneycombMR1Util.getEmailIndex
static int getEmailIndex(Cursor dataCursor)
Definition: HoneycombMR1Util.java:147
com.google.appinventor.components.runtime.util.HoneycombMR1Util.getPhoneContentUri
static Uri getPhoneContentUri()
Definition: HoneycombMR1Util.java:44
com.google.appinventor.components.runtime.util.HoneycombMR1Util.getDataContentUri
static Uri getDataContentUri()
Definition: HoneycombMR1Util.java:51
com.google.appinventor.components.runtime.util.HoneycombMR1Util.getContactIdIndex
static int getContactIdIndex(Cursor contactCursor)
Definition: HoneycombMR1Util.java:118
com.google.appinventor.components.runtime.util.HoneycombMR1Util.getTimesContacted
static String getTimesContacted()
Definition: HoneycombMR1Util.java:212
com.google.appinventor.components.runtime.util.HoneycombMR1Util.getThumbnailIndex
static int getThumbnailIndex(Cursor contactCursor)
Definition: HoneycombMR1Util.java:132
com.google.appinventor.components.runtime.WebViewer
Definition: WebViewer.java:107
com.google.appinventor.components.runtime
Copyright 2009-2011 Google, All Rights reserved.
Definition: AccelerometerSensor.java:8
com.google.appinventor.components.runtime.util.HoneycombMR1Util.getPhoneType
static String getPhoneType()
Definition: HoneycombMR1Util.java:157
com.google.appinventor.components.runtime.util.HoneycombMR1Util.getNameIndex
static int getNameIndex(Cursor contactCursor)
Definition: HoneycombMR1Util.java:125
com.google.appinventor.components.runtime.util.HoneycombMR1Util.getEmailType
static String getEmailType()
Definition: HoneycombMR1Util.java:164
com.google
com
com.google.appinventor.components.runtime.util.HoneycombMR1Util.getPhoneIndex
static int getPhoneIndex(Cursor dataCursor)
Definition: HoneycombMR1Util.java:143
com.google.appinventor.components.runtime.util.HoneycombMR1Util.getIdIndex
static int getIdIndex(Cursor contactCursor)
Definition: HoneycombMR1Util.java:111
com.google.appinventor.components.runtime.util.HoneycombMR1Util.getEmailAddress
static String getEmailAddress()
Definition: HoneycombMR1Util.java:178
com.google.appinventor.components.runtime.util.HoneycombMR1Util.openContactPhotoInputStreamHelper
static InputStream openContactPhotoInputStreamHelper(ContentResolver cr, Uri contactUri)
Definition: HoneycombMR1Util.java:205
com.google.appinventor
com.google.appinventor.components.runtime.util.HoneycombMR1Util.getMimeIndex
static int getMimeIndex(Cursor dataCursor)
Definition: HoneycombMR1Util.java:151
com.google.appinventor.components.runtime.util.HoneycombMR1Util.getContactProjection
static String[] getContactProjection()
Definition: HoneycombMR1Util.java:58