diff options
-rw-r--r-- | api/current.txt | 4 | ||||
-rw-r--r-- | api/system-current.txt | 4 | ||||
-rw-r--r-- | core/java/android/provider/ContactsContract.java | 82 | ||||
-rw-r--r-- | core/java/android/widget/QuickContactBadge.java | 20 |
4 files changed, 104 insertions, 6 deletions
diff --git a/api/current.txt b/api/current.txt index 676a1cd..3d12275 100644 --- a/api/current.txt +++ b/api/current.txt @@ -25050,9 +25050,12 @@ package android.provider { ctor public ContactsContract.QuickContact(); method public static void showQuickContact(android.content.Context, android.view.View, android.net.Uri, int, java.lang.String[]); method public static void showQuickContact(android.content.Context, android.graphics.Rect, android.net.Uri, int, java.lang.String[]); + method public static void showQuickContact(android.content.Context, android.view.View, android.net.Uri, java.lang.String[], java.lang.String); + method public static void showQuickContact(android.content.Context, android.graphics.Rect, android.net.Uri, java.lang.String[], java.lang.String); field public static final java.lang.String ACTION_QUICK_CONTACT = "android.provider.action.QUICK_CONTACT"; field public static final java.lang.String EXTRA_EXCLUDE_MIMES = "android.provider.extra.EXCLUDE_MIMES"; field public static final java.lang.String EXTRA_MODE = "android.provider.extra.MODE"; + field public static final java.lang.String EXTRA_PRIORITIZED_MIMETYPE = "android.provider.extra.PRIORITIZED_MIMETYPE"; field public static final int MODE_LARGE = 3; // 0x3 field public static final int MODE_MEDIUM = 2; // 0x2 field public static final int MODE_SMALL = 1; // 0x1 @@ -38753,6 +38756,7 @@ package android.widget { method public void setImageToDefault(); method public void setMode(int); method public void setOverlay(android.graphics.drawable.Drawable); + method public void setPrioritizedMimeType(java.lang.String); field protected java.lang.String[] mExcludeMimes; } diff --git a/api/system-current.txt b/api/system-current.txt index 95e57c4..71a991a 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -26649,9 +26649,12 @@ package android.provider { ctor public ContactsContract.QuickContact(); method public static void showQuickContact(android.content.Context, android.view.View, android.net.Uri, int, java.lang.String[]); method public static void showQuickContact(android.content.Context, android.graphics.Rect, android.net.Uri, int, java.lang.String[]); + method public static void showQuickContact(android.content.Context, android.view.View, android.net.Uri, java.lang.String[], java.lang.String); + method public static void showQuickContact(android.content.Context, android.graphics.Rect, android.net.Uri, java.lang.String[], java.lang.String); field public static final java.lang.String ACTION_QUICK_CONTACT = "android.provider.action.QUICK_CONTACT"; field public static final java.lang.String EXTRA_EXCLUDE_MIMES = "android.provider.extra.EXCLUDE_MIMES"; field public static final java.lang.String EXTRA_MODE = "android.provider.extra.MODE"; + field public static final java.lang.String EXTRA_PRIORITIZED_MIMETYPE = "android.provider.extra.PRIORITIZED_MIMETYPE"; field public static final int MODE_LARGE = 3; // 0x3 field public static final int MODE_MEDIUM = 2; // 0x2 field public static final int MODE_SMALL = 1; // 0x1 @@ -41212,6 +41215,7 @@ package android.widget { method public void setImageToDefault(); method public void setMode(int); method public void setOverlay(android.graphics.drawable.Drawable); + method public void setPrioritizedMimeType(java.lang.String); field protected java.lang.String[] mExcludeMimes; } diff --git a/core/java/android/provider/ContactsContract.java b/core/java/android/provider/ContactsContract.java index 67ac043..9cc12b5 100644 --- a/core/java/android/provider/ContactsContract.java +++ b/core/java/android/provider/ContactsContract.java @@ -8069,6 +8069,14 @@ public final class ContactsContract { public static final String EXTRA_MODE = "android.provider.extra.MODE"; /** + * Extra used to specify which mimetype should be prioritized in the QuickContacts UI. + * For example, passing the value {@link CommonDataKinds.Phone#CONTENT_ITEM_TYPE} can + * cause phone numbers to be displayed more prominently in QuickContacts. + */ + public static final String EXTRA_PRIORITIZED_MIMETYPE + = "android.provider.extra.PRIORITIZED_MIMETYPE"; + + /** * Extra used to indicate a list of specific MIME-types to exclude and not display in the * QuickContacts dialog. Stored as a {@link String} array. */ @@ -8206,6 +8214,80 @@ public final class ContactsContract { startActivityWithErrorToast(context, intent); } + /** + * Trigger a dialog that lists the various methods of interacting with + * the requested {@link Contacts} entry. This may be based on available + * {@link ContactsContract.Data} rows under that contact, and may also + * include social status and presence details. + * + * @param context The parent {@link Context} that may be used as the + * parent for this dialog. + * @param target Specific {@link View} from your layout that this dialog + * should be centered around. In particular, if the dialog + * has a "callout" arrow, it will be pointed and centered + * around this {@link View}. + * @param lookupUri A + * {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style + * {@link Uri} that describes a specific contact to feature + * in this dialog. + * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types + * to exclude when showing this dialog. For example, when + * already viewing the contact details card, this can be used + * to omit the details entry from the dialog. + * @param prioritizedMimeType This mimetype should be prioritized in the QuickContacts UI. + * For example, passing the value + * {@link CommonDataKinds.Phone#CONTENT_ITEM_TYPE} can cause phone numbers to be + * displayed more prominently in QuickContacts. + */ + public static void showQuickContact(Context context, View target, Uri lookupUri, + String[] excludeMimes, String prioritizedMimeType) { + // Use MODE_LARGE instead of accepting mode as a parameter. The different mode + // values defined in ContactsContract only affect very old implementations + // of QuickContacts. + Intent intent = composeQuickContactsIntent(context, target, lookupUri, MODE_LARGE, + excludeMimes); + intent.putExtra(EXTRA_PRIORITIZED_MIMETYPE, prioritizedMimeType); + startActivityWithErrorToast(context, intent); + } + + /** + * Trigger a dialog that lists the various methods of interacting with + * the requested {@link Contacts} entry. This may be based on available + * {@link ContactsContract.Data} rows under that contact, and may also + * include social status and presence details. + * + * @param context The parent {@link Context} that may be used as the + * parent for this dialog. + * @param target Specific {@link Rect} that this dialog should be + * centered around, in screen coordinates. In particular, if + * the dialog has a "callout" arrow, it will be pointed and + * centered around this {@link Rect}. If you are running at a + * non-native density, you need to manually adjust using + * {@link DisplayMetrics#density} before calling. + * @param lookupUri A + * {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style + * {@link Uri} that describes a specific contact to feature + * in this dialog. + * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types + * to exclude when showing this dialog. For example, when + * already viewing the contact details card, this can be used + * to omit the details entry from the dialog. + * @param prioritizedMimeType This mimetype should be prioritized in the QuickContacts UI. + * For example, passing the value + * {@link CommonDataKinds.Phone#CONTENT_ITEM_TYPE} can cause phone numbers to be + * displayed more prominently in QuickContacts. + */ + public static void showQuickContact(Context context, Rect target, Uri lookupUri, + String[] excludeMimes, String prioritizedMimeType) { + // Use MODE_LARGE instead of accepting mode as a parameter. The different mode + // values defined in ContactsContract only affect very old implementations + // of QuickContacts. + Intent intent = composeQuickContactsIntent(context, target, lookupUri, MODE_LARGE, + excludeMimes); + intent.putExtra(EXTRA_PRIORITIZED_MIMETYPE, prioritizedMimeType); + startActivityWithErrorToast(context, intent); + } + private static void startActivityWithErrorToast(Context context, Intent intent) { try { context.startActivity(intent); diff --git a/core/java/android/widget/QuickContactBadge.java b/core/java/android/widget/QuickContactBadge.java index 3068de9..25b301f 100644 --- a/core/java/android/widget/QuickContactBadge.java +++ b/core/java/android/widget/QuickContactBadge.java @@ -37,8 +37,6 @@ import android.provider.ContactsContract.RawContacts; import android.util.AttributeSet; import android.view.View; import android.view.View.OnClickListener; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; /** * Widget used to show an image with the standard QuickContact badge @@ -52,6 +50,7 @@ public class QuickContactBadge extends ImageView implements OnClickListener { private QueryHandler mQueryHandler; private Drawable mDefaultAvatar; private Bundle mExtras = null; + private String mPrioritizedMimeType; protected String[] mExcludeMimes = null; @@ -126,6 +125,15 @@ public class QuickContactBadge extends ImageView implements OnClickListener { public void setMode(int size) { } + /** + * Set which mimetype should be prioritized in the QuickContacts UI. For example, passing the + * value {@link Email#CONTENT_ITEM_TYPE} can cause emails to be displayed more prominently in + * QuickContacts. + */ + public void setPrioritizedMimeType(String prioritizedMimeType) { + mPrioritizedMimeType = prioritizedMimeType; + } + @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); @@ -287,7 +295,7 @@ public class QuickContactBadge extends ImageView implements OnClickListener { final Bundle extras = (mExtras == null) ? new Bundle() : mExtras; if (mContactUri != null) { QuickContact.showQuickContact(getContext(), QuickContactBadge.this, mContactUri, - QuickContact.MODE_LARGE, mExcludeMimes); + mExcludeMimes, mPrioritizedMimeType); } else if (mContactEmail != null && mQueryHandler != null) { extras.putString(EXTRA_URI_CONTENT, mContactEmail); mQueryHandler.startQuery(TOKEN_EMAIL_LOOKUP_AND_TRIGGER, extras, @@ -370,10 +378,10 @@ public class QuickContactBadge extends ImageView implements OnClickListener { mContactUri = lookupUri; onContactUriChanged(); - if (trigger && lookupUri != null) { + if (trigger && mContactUri != null) { // Found contact, so trigger QuickContact - QuickContact.showQuickContact(getContext(), QuickContactBadge.this, lookupUri, - QuickContact.MODE_LARGE, mExcludeMimes); + QuickContact.showQuickContact(getContext(), QuickContactBadge.this, mContactUri, + mExcludeMimes, mPrioritizedMimeType); } else if (createUri != null) { // Prompt user to add this person to contacts final Intent intent = new Intent(Intents.SHOW_OR_CREATE_CONTACT, createUri); |