am 88a83d3f: Update getDisplayLabel() API to support new types.
Merge commit '88a83d3f108dcf01443b241439e14eedbd9615f5' into eclair-plus-aosp * commit '88a83d3f108dcf01443b241439e14eedbd9615f5': Update getDisplayLabel() API to support new types.
This commit is contained in:
@@ -899,33 +899,10 @@ public final class ContactsContract {
|
||||
*/
|
||||
public static final String PACKAGE_COMMON = "common";
|
||||
|
||||
/**
|
||||
* Columns common across the specific types.
|
||||
*/
|
||||
private interface BaseCommonColumns {
|
||||
/**
|
||||
* The package name to use when creating {@link Resources} objects for
|
||||
* this data row. This value is only designed for use when building user
|
||||
* interfaces, and should not be used to infer the owner.
|
||||
*/
|
||||
public static final String RES_PACKAGE = "res_package";
|
||||
|
||||
/**
|
||||
* The MIME type of the item represented by this row.
|
||||
*/
|
||||
public static final String MIMETYPE = "mimetype";
|
||||
|
||||
/**
|
||||
* The {@link RawContacts#_ID} that this data belongs to.
|
||||
*/
|
||||
public static final String RAW_CONTACT_ID = "raw_contact_id";
|
||||
}
|
||||
|
||||
/**
|
||||
* The base types that all "Typed" data kinds support.
|
||||
*/
|
||||
public interface BaseTypes {
|
||||
|
||||
/**
|
||||
* A custom type. The custom label should be supplied by user.
|
||||
*/
|
||||
@@ -935,7 +912,7 @@ public final class ContactsContract {
|
||||
/**
|
||||
* Columns common across the specific types.
|
||||
*/
|
||||
private interface CommonColumns extends BaseTypes{
|
||||
private interface CommonColumns extends BaseTypes {
|
||||
/**
|
||||
* The data for the contact method.
|
||||
* <P>Type: TEXT</P>
|
||||
@@ -1101,30 +1078,67 @@ public final class ContactsContract {
|
||||
*/
|
||||
public static final String NUMBER = DATA;
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final CharSequence getDisplayLabel(Context context, int type,
|
||||
CharSequence label, CharSequence[] labelArray) {
|
||||
CharSequence display = "";
|
||||
|
||||
if (type != Phone.TYPE_CUSTOM) {
|
||||
CharSequence[] labels = labelArray != null? labelArray
|
||||
: context.getResources().getTextArray(
|
||||
com.android.internal.R.array.phoneTypes);
|
||||
try {
|
||||
display = labels[type - 1];
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
display = labels[Phone.TYPE_CUSTOM];
|
||||
}
|
||||
} else {
|
||||
if (!TextUtils.isEmpty(label)) {
|
||||
display = label;
|
||||
}
|
||||
}
|
||||
return display;
|
||||
return getTypeLabel(context.getResources(), type, label);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final CharSequence getDisplayLabel(Context context, int type,
|
||||
CharSequence label) {
|
||||
return getDisplayLabel(context, type, label, null);
|
||||
return getTypeLabel(context.getResources(), type, label);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the string resource that best describes the given
|
||||
* {@link CommonColumns#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.phoneTypeHome;
|
||||
case TYPE_MOBILE: return com.android.internal.R.string.phoneTypeMobile;
|
||||
case TYPE_WORK: return com.android.internal.R.string.phoneTypeWork;
|
||||
case TYPE_FAX_WORK: return com.android.internal.R.string.phoneTypeFaxWork;
|
||||
case TYPE_FAX_HOME: return com.android.internal.R.string.phoneTypeFaxHome;
|
||||
case TYPE_PAGER: return com.android.internal.R.string.phoneTypePager;
|
||||
case TYPE_OTHER: return com.android.internal.R.string.phoneTypeOther;
|
||||
case TYPE_CALLBACK: return com.android.internal.R.string.phoneTypeCallback;
|
||||
case TYPE_CAR: return com.android.internal.R.string.phoneTypeCar;
|
||||
case TYPE_COMPANY_MAIN: return com.android.internal.R.string.phoneTypeCompanyMain;
|
||||
case TYPE_ISDN: return com.android.internal.R.string.phoneTypeIsdn;
|
||||
case TYPE_MAIN: return com.android.internal.R.string.phoneTypeMain;
|
||||
case TYPE_OTHER_FAX: return com.android.internal.R.string.phoneTypeOtherFax;
|
||||
case TYPE_RADIO: return com.android.internal.R.string.phoneTypeRadio;
|
||||
case TYPE_TELEX: return com.android.internal.R.string.phoneTypeTelex;
|
||||
case TYPE_TTY_TDD: return com.android.internal.R.string.phoneTypeTtyTdd;
|
||||
case TYPE_WORK_MOBILE: return com.android.internal.R.string.phoneTypeWorkMobile;
|
||||
case TYPE_WORK_PAGER: return com.android.internal.R.string.phoneTypeWorkPager;
|
||||
case TYPE_ASSISTANT: return com.android.internal.R.string.phoneTypeAssistant;
|
||||
case TYPE_MMS: return com.android.internal.R.string.phoneTypeMms;
|
||||
default: return com.android.internal.R.string.phoneTypeCustom;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a {@link CharSequence} that best describes the given type,
|
||||
* possibly substituting the given {@link CommonColumns#LABEL} value
|
||||
* for {@link BaseTypes#TYPE_CUSTOM}.
|
||||
*/
|
||||
public static final CharSequence getTypeLabel(Resources res, int type,
|
||||
CharSequence label) {
|
||||
if ((type == TYPE_CUSTOM || type == TYPE_ASSISTANT) && !TextUtils.isEmpty(label)) {
|
||||
return label;
|
||||
} else {
|
||||
final int labelRes = getTypeLabelResource(type);
|
||||
return res.getText(labelRes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1177,6 +1191,35 @@ public final class ContactsContract {
|
||||
* <P>Type: TEXT</P>
|
||||
*/
|
||||
public static final String DISPLAY_NAME = DATA4;
|
||||
|
||||
/**
|
||||
* Return the string resource that best describes the given
|
||||
* {@link CommonColumns#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.emailTypeHome;
|
||||
case TYPE_WORK: return com.android.internal.R.string.emailTypeWork;
|
||||
case TYPE_OTHER: return com.android.internal.R.string.emailTypeOther;
|
||||
case TYPE_MOBILE: return com.android.internal.R.string.emailTypeMobile;
|
||||
default: return com.android.internal.R.string.emailTypeCustom;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a {@link CharSequence} that best describes the given type,
|
||||
* possibly substituting the given {@link CommonColumns#LABEL} value
|
||||
* for {@link BaseTypes#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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1271,6 +1314,34 @@ public final class ContactsContract {
|
||||
* Type: TEXT
|
||||
*/
|
||||
public static final String COUNTRY = DATA10;
|
||||
|
||||
/**
|
||||
* Return the string resource that best describes the given
|
||||
* {@link CommonColumns#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.postalTypeHome;
|
||||
case TYPE_WORK: return com.android.internal.R.string.postalTypeWork;
|
||||
case TYPE_OTHER: return com.android.internal.R.string.postalTypeOther;
|
||||
default: return com.android.internal.R.string.postalTypeCustom;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a {@link CharSequence} that best describes the given type,
|
||||
* possibly substituting the given {@link CommonColumns#LABEL} value
|
||||
* for {@link BaseTypes#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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1309,6 +1380,68 @@ public final class ContactsContract {
|
||||
public static final int PROTOCOL_ICQ = 6;
|
||||
public static final int PROTOCOL_JABBER = 7;
|
||||
public static final int PROTOCOL_NETMEETING = 8;
|
||||
|
||||
/**
|
||||
* Return the string resource that best describes the given
|
||||
* {@link CommonColumns#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.imTypeHome;
|
||||
case TYPE_WORK: return com.android.internal.R.string.imTypeWork;
|
||||
case TYPE_OTHER: return com.android.internal.R.string.imTypeOther;
|
||||
default: return com.android.internal.R.string.imTypeCustom;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a {@link CharSequence} that best describes the given type,
|
||||
* possibly substituting the given {@link CommonColumns#LABEL} value
|
||||
* for {@link BaseTypes#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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the string resource that best describes the given
|
||||
* {@link Im#PROTOCOL}. Will always return a valid resource.
|
||||
*/
|
||||
public static final int getProtocolLabelResource(int type) {
|
||||
switch (type) {
|
||||
case PROTOCOL_AIM: return com.android.internal.R.string.imProtocolAim;
|
||||
case PROTOCOL_MSN: return com.android.internal.R.string.imProtocolMsn;
|
||||
case PROTOCOL_YAHOO: return com.android.internal.R.string.imProtocolYahoo;
|
||||
case PROTOCOL_SKYPE: return com.android.internal.R.string.imProtocolSkype;
|
||||
case PROTOCOL_QQ: return com.android.internal.R.string.imProtocolQq;
|
||||
case PROTOCOL_GOOGLE_TALK: return com.android.internal.R.string.imProtocolGoogleTalk;
|
||||
case PROTOCOL_ICQ: return com.android.internal.R.string.imProtocolIcq;
|
||||
case PROTOCOL_JABBER: return com.android.internal.R.string.imProtocolJabber;
|
||||
case PROTOCOL_NETMEETING: return com.android.internal.R.string.imProtocolNetMeeting;
|
||||
default: return com.android.internal.R.string.imProtocolCustom;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a {@link CharSequence} that best describes the given
|
||||
* protocol, possibly substituting the given
|
||||
* {@link #CUSTOM_PROTOCOL} value for {@link #PROTOCOL_CUSTOM}.
|
||||
*/
|
||||
public static final CharSequence getProtocolLabel(Resources res, int type,
|
||||
CharSequence label) {
|
||||
if (type == PROTOCOL_CUSTOM && !TextUtils.isEmpty(label)) {
|
||||
return label;
|
||||
} else {
|
||||
final int labelRes = getProtocolLabelResource(type);
|
||||
return res.getText(labelRes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1358,6 +1491,33 @@ public final class ContactsContract {
|
||||
* <P>Type: TEXT</P>
|
||||
*/
|
||||
public static final String PHONETIC_NAME = DATA8;
|
||||
|
||||
/**
|
||||
* Return the string resource that best describes the given
|
||||
* {@link CommonColumns#TYPE}. Will always return a valid resource.
|
||||
*/
|
||||
public static final int getTypeLabelResource(int type) {
|
||||
switch (type) {
|
||||
case TYPE_WORK: return com.android.internal.R.string.orgTypeWork;
|
||||
case TYPE_OTHER: return com.android.internal.R.string.orgTypeOther;
|
||||
default: return com.android.internal.R.string.orgTypeCustom;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a {@link CharSequence} that best describes the given type,
|
||||
* possibly substituting the given {@link CommonColumns#LABEL} value
|
||||
* for {@link BaseTypes#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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1200,6 +1200,106 @@
|
||||
<item>Jabber</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Custom phone number type -->
|
||||
<string name="phoneTypeCustom">Custom</string>
|
||||
<!-- Home phone number type -->
|
||||
<string name="phoneTypeHome">Home</string>
|
||||
<!-- Mobile phone number type -->
|
||||
<string name="phoneTypeMobile">Mobile</string>
|
||||
<!-- Work phone number type -->
|
||||
<string name="phoneTypeWork">Work</string>
|
||||
<!-- Work fax phone number type -->
|
||||
<string name="phoneTypeFaxWork">Work Fax</string>
|
||||
<!-- Home fax phone number type -->
|
||||
<string name="phoneTypeFaxHome">Home Fax</string>
|
||||
<!-- Pager phone number type -->
|
||||
<string name="phoneTypePager">Pager</string>
|
||||
<!-- Other phone number type -->
|
||||
<string name="phoneTypeOther">Other</string>
|
||||
<!-- Callback phone number type -->
|
||||
<string name="phoneTypeCallback">Callback</string>
|
||||
<!-- Car phone number type -->
|
||||
<string name="phoneTypeCar">Car</string>
|
||||
<!-- Company main phone number type -->
|
||||
<string name="phoneTypeCompanyMain">Company Main</string>
|
||||
<!-- ISDN phone number type -->
|
||||
<string name="phoneTypeIsdn">ISDN</string>
|
||||
<!-- Main phone number type -->
|
||||
<string name="phoneTypeMain">Main</string>
|
||||
<!-- Other fax phone number type -->
|
||||
<string name="phoneTypeOtherFax">Other Fax</string>
|
||||
<!-- Radio phone number type -->
|
||||
<string name="phoneTypeRadio">Radio</string>
|
||||
<!-- Telex phone number type -->
|
||||
<string name="phoneTypeTelex">Telex</string>
|
||||
<!-- TTY TDD phone number type -->
|
||||
<string name="phoneTypeTtyTdd">TTY TDD</string>
|
||||
<!-- Work mobile phone number type -->
|
||||
<string name="phoneTypeWorkMobile">Work Mobile</string>
|
||||
<!-- Work pager phone number type -->
|
||||
<string name="phoneTypeWorkPager">Work Pager</string>
|
||||
<!-- Assistant phone number type -->
|
||||
<string name="phoneTypeAssistant">Assistant</string>
|
||||
<!-- MMS phone number type -->
|
||||
<string name="phoneTypeMms">MMS</string>
|
||||
|
||||
<!-- Custom email type -->
|
||||
<string name="emailTypeCustom">Custom</string>
|
||||
<!-- Home email type -->
|
||||
<string name="emailTypeHome">Home</string>
|
||||
<!-- Work email type -->
|
||||
<string name="emailTypeWork">Work</string>
|
||||
<!-- Other email type -->
|
||||
<string name="emailTypeOther">Other</string>
|
||||
<!-- Mobile email type -->
|
||||
<string name="emailTypeMobile">Mobile</string>
|
||||
|
||||
<!-- Custom postal address type -->
|
||||
<string name="postalTypeCustom">Custom</string>
|
||||
<!-- Home postal address type -->
|
||||
<string name="postalTypeHome">Home</string>
|
||||
<!-- Work postal address type -->
|
||||
<string name="postalTypeWork">Work</string>
|
||||
<!-- Other postal address type -->
|
||||
<string name="postalTypeOther">Other</string>
|
||||
|
||||
<!-- Custom IM address type -->
|
||||
<string name="imTypeCustom">Custom</string>
|
||||
<!-- Home IM address type -->
|
||||
<string name="imTypeHome">Home</string>
|
||||
<!-- Work IM address type -->
|
||||
<string name="imTypeWork">Work</string>
|
||||
<!-- Other IM address type -->
|
||||
<string name="imTypeOther">Other</string>
|
||||
|
||||
<!-- Custom IM address type -->
|
||||
<string name="imProtocolCustom">Custom</string>
|
||||
<!-- AIM IM protocol type -->
|
||||
<string name="imProtocolAim">AIM</string>
|
||||
<!-- MSN IM protocol type -->
|
||||
<string name="imProtocolMsn">Windows Live</string>
|
||||
<!-- Yahoo IM protocol type -->
|
||||
<string name="imProtocolYahoo">Yahoo</string>
|
||||
<!-- Skype IM protocol type -->
|
||||
<string name="imProtocolSkype">Skype</string>
|
||||
<!-- QQ IM protocol type -->
|
||||
<string name="imProtocolQq">QQ</string>
|
||||
<!-- Google Talk IM protocol type -->
|
||||
<string name="imProtocolGoogleTalk">Google Talk</string>
|
||||
<!-- ICQ IM protocol type -->
|
||||
<string name="imProtocolIcq">ICQ</string>
|
||||
<!-- Jabber IM protocol type -->
|
||||
<string name="imProtocolJabber">Jabber</string>
|
||||
<!-- NetMeeting IM protocol type -->
|
||||
<string name="imProtocolNetMeeting">NetMeeting</string>
|
||||
|
||||
<!-- Work organization type -->
|
||||
<string name="orgTypeWork">Work</string>
|
||||
<!-- Other organization type -->
|
||||
<string name="orgTypeOther">Other</string>
|
||||
<!-- Custom organization type -->
|
||||
<string name="orgTypeCustom">Custom</string>
|
||||
|
||||
<!-- Instructions telling the user to enter their pin to unlock the keyguard.
|
||||
Displayed in one line in a large font. -->
|
||||
<string name="keyguard_password_enter_pin_code">Enter PIN code</string>
|
||||
|
||||
Reference in New Issue
Block a user