Add API and strings for the contact-field "Relation"

Bug:3134946
Change-Id: Ic2163abfaf0ca16cbd24ea68cbace5144b688eab
This commit is contained in:
Daniel Lehmann
2010-10-28 13:40:38 -07:00
parent 5164246d7e
commit 1fb39f0ffc
3 changed files with 102 additions and 0 deletions

View File

@@ -151841,6 +151841,36 @@
</implements>
<implements name="android.provider.ContactsContract.DataColumnsWithJoins">
</implements>
<method name="getTypeLabel"
return="java.lang.CharSequence"
abstract="false"
native="false"
synchronized="false"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
<parameter name="res" type="android.content.res.Resources">
</parameter>
<parameter name="type" type="int">
</parameter>
<parameter name="label" type="java.lang.CharSequence">
</parameter>
</method>
<method name="getTypeLabelResource"
return="int"
abstract="false"
native="false"
synchronized="false"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
<parameter name="type" type="int">
</parameter>
</method>
<field name="CONTENT_ITEM_TYPE"
type="java.lang.String"
transient="false"

View File

@@ -5127,6 +5127,47 @@ public final class ContactsContract {
* <P>Type: TEXT</P>
*/
public static final String NAME = DATA;
/**
* 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_ASSISTANT: return com.android.internal.R.string.relationTypeAssistant;
case TYPE_BROTHER: return com.android.internal.R.string.relationTypeBrother;
case TYPE_CHILD: return com.android.internal.R.string.relationTypeChild;
case TYPE_DOMESTIC_PARTNER:
return com.android.internal.R.string.relationTypeDomesticPartner;
case TYPE_FATHER: return com.android.internal.R.string.relationTypeFather;
case TYPE_FRIEND: return com.android.internal.R.string.relationTypeFriend;
case TYPE_MANAGER: return com.android.internal.R.string.relationTypeManager;
case TYPE_MOTHER: return com.android.internal.R.string.relationTypeMother;
case TYPE_PARENT: return com.android.internal.R.string.relationTypeParent;
case TYPE_PARTNER: return com.android.internal.R.string.relationTypePartner;
case TYPE_REFERRED_BY:
return com.android.internal.R.string.relationTypeReferredBy;
case TYPE_RELATIVE: return com.android.internal.R.string.relationTypeRelative;
case TYPE_SISTER: return com.android.internal.R.string.relationTypeSister;
case TYPE_SPOUSE: return com.android.internal.R.string.relationTypeSpouse;
default: return com.android.internal.R.string.orgTypeCustom;
}
}
/**
* 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);
}
}
}
/**

View File

@@ -1440,6 +1440,37 @@
<!-- Custom organization type -->
<string name="orgTypeCustom">Custom</string>
<!-- Custom relationship custom [CHAR LIMIT=20] -->
<string name="relationTypeCustom">Custom</string>
<!-- Assistant relationship type [CHAR LIMIT=20] -->
<string name="relationTypeAssistant">Assistant</string>
<!-- Brother relationship type [CHAR LIMIT=20] -->
<string name="relationTypeBrother">Brother</string>
<!-- Child relationship type [CHAR LIMIT=20] -->
<string name="relationTypeChild">Child</string>
<!-- Domestic Partner relationship type [CHAR LIMIT=20] -->
<string name="relationTypeDomesticPartner">Domestic Partner</string>
<!-- Father relationship type [CHAR LIMIT=20] -->
<string name="relationTypeFather">Father</string>
<!-- Friend relationship type [CHAR LIMIT=20] -->
<string name="relationTypeFriend">Friend</string>
<!-- Manager relationship type [CHAR LIMIT=20] -->
<string name="relationTypeManager">Manager</string>
<!-- Mother relationship type [CHAR LIMIT=20] -->
<string name="relationTypeMother">Mother</string>
<!-- Parent relationship type [CHAR LIMIT=20] -->
<string name="relationTypeParent">Parent</string>
<!-- Partner relationship type [CHAR LIMIT=20] -->
<string name="relationTypePartner">Partner</string>
<!-- Referred by relationship type [CHAR LIMIT=20] -->
<string name="relationTypeReferredBy">Referred by</string>
<!-- Relative relationship type [CHAR LIMIT=20] -->
<string name="relationTypeRelative">Relative</string>
<!-- Sister relationship type [CHAR LIMIT=20] -->
<string name="relationTypeSister">Sister</string>
<!-- Spouse relationship type [CHAR LIMIT=20] -->
<string name="relationTypeSpouse">Spouse</string>
<!-- Custom SIP address type -->
<string name="sipAddressTypeCustom">Custom</string>
<!-- Home SIP address type -->