From 747c61535281b4d2958e293e83245a19ba58f6a0 Mon Sep 17 00:00:00 2001 From: David Brown Date: Wed, 15 Sep 2010 13:34:13 -0700 Subject: [PATCH] ContactsContract: update SipAddress to be multi-valued This is step (1) of the device-side changes to deal with SIP addresses becoming first-class objects in focus. It'll be multi-valued in focus, so make it multi-valued on the device (just like Phone, Email, Im, etc.) Possible types are CUSTOM, HOME, WORK, and OTHER. Also while I was in there, fixed the typo in "TYPE_MAINDEN_NAME" in the Nickname class. (I can't remove it, since it's public API, so I added a new constant with the correct spelling and deprecated the misspelled one.) Bug: 3004838 TESTED: on passion: - Flashed this change onto a device that already had a contact with a SipAddress, verified that it still shows up fine in the UI. - Wiped data, rerean SetupWizard and logged in, made sure that SIP addresses got synced down properly. - Edited SIP address on the device, made sure it got correctly synced up to the SIP user-defined field. Change-Id: I6ecf551b64f87de03a7807e6212297d91f9e3981 --- api/current.xml | 78 ++++++++++++++++++- .../android/provider/ContactsContract.java | 69 +++++++++++++--- core/res/res/values/strings.xml | 11 ++- 3 files changed, 146 insertions(+), 12 deletions(-) diff --git a/api/current.xml b/api/current.xml index d22f9b9483b3a..81090a45085ac 100644 --- a/api/current.xml +++ b/api/current.xml @@ -136919,7 +136919,7 @@ visibility="public" > - + + + + + + + + + + + + + + + + + + + + + + {@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}. *
  • {@link #TYPE_DEFAULT}
  • *
  • {@link #TYPE_OTHER_NAME}
  • - *
  • {@link #TYPE_MAINDEN_NAME}
  • + *
  • {@link #TYPE_MAIDEN_NAME}
  • *
  • {@link #TYPE_SHORT_NAME}
  • *
  • {@link #TYPE_INITIALS}
  • * @@ -3578,6 +3578,9 @@ public final class ContactsContract { public static final int TYPE_DEFAULT = 1; public static final int TYPE_OTHER_NAME = 2; + public static final int TYPE_MAIDEN_NAME = 3; + /** @deprecated Use TYPE_MAIDEN_NAME instead. */ + @Deprecated public static final int TYPE_MAINDEN_NAME = 3; public static final int TYPE_SHORT_NAME = 4; public static final int TYPE_INITIALS = 5; @@ -4882,17 +4885,30 @@ public final class ContactsContract { * {@link #DATA1} * * + * + * int + * {@link #TYPE} + * {@link #DATA2} + * Allowed values are: + *

    + *

      + *
    • {@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.
    • + *
    • {@link #TYPE_HOME}
    • + *
    • {@link #TYPE_WORK}
    • + *
    • {@link #TYPE_OTHER}
    • + *
    + *

    + * + * + * + * String + * {@link #LABEL} + * {@link #DATA3} + * + * * */ - public static final class SipAddress implements DataColumnsWithJoins { - // TODO: Ultimately this class will probably implement - // CommonColumns too (in addition to DataColumnsWithJoins) - // since it may make sense to have multiple SIP addresses with - // different types+labels, just like with phone numbers. - // - // But that can be extended in the future without breaking any - // public API, so let's keep this class ultra-simple for now. - + public static final class SipAddress implements DataColumnsWithJoins, CommonColumns { /** * This utility class cannot be instantiated */ @@ -4901,11 +4917,44 @@ public final class ContactsContract { /** MIME type used when storing this in data table. */ public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/sip_address"; + public static final int TYPE_HOME = 1; + public static final int TYPE_WORK = 2; + public static final int TYPE_OTHER = 3; + /** * The SIP address. *

    Type: TEXT

    */ public static final String SIP_ADDRESS = DATA1; + // ...and TYPE and LABEL come from the CommonColumns interface. + + /** + * Return the string resource that best describes the given + * {@link #TYPE}. Will always return a valid resource. + */ + public static final int getTypeLabelResource(int type) { + switch (type) { + case TYPE_HOME: return com.android.internal.R.string.sipAddressTypeHome; + case TYPE_WORK: return com.android.internal.R.string.sipAddressTypeWork; + case TYPE_OTHER: return com.android.internal.R.string.sipAddressTypeOther; + default: return com.android.internal.R.string.sipAddressTypeCustom; + } + } + + /** + * Return a {@link CharSequence} that best describes the given type, + * possibly substituting the given {@link #LABEL} value + * for {@link #TYPE_CUSTOM}. + */ + public static final CharSequence getTypeLabel(Resources res, int type, + CharSequence label) { + if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) { + return label; + } else { + final int labelRes = getTypeLabelResource(type); + return res.getText(labelRes); + } + } } } diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index dc89acb24f969..808b371f93374 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -1379,7 +1379,7 @@ Other - + Custom AIM @@ -1407,6 +1407,15 @@ Custom + + Custom + + Home + + Work + + Other + via %1$s