+ *
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 @@