Loading res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -1212,6 +1212,9 @@ about a contact --> <string name="label_notes">Notes</string> <!-- The label describing the custom field of a contact. [CHAR LIMIT=20] --> <string name="label_custom_field">Custom</string> <!-- The label describing the SIP address field of a contact. [CHAR LIMIT=20] --> <string name="label_sip_address">SIP</string> Loading src/com/android/contacts/common/model/account/BaseAccountType.java +9 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.contacts.common.model.account; import android.content.ContentValues; import android.content.Context; import android.content.res.Resources; import android.provider.ContactsContract.Data; import android.provider.ContactsContract.CommonDataKinds.BaseTypes; import android.provider.ContactsContract.CommonDataKinds.Email; import android.provider.ContactsContract.CommonDataKinds.Event; Loading @@ -39,6 +40,7 @@ import android.util.Log; import android.view.inputmethod.EditorInfo; import com.android.contacts.common.R; import com.android.contacts.common.model.dataitem.CustomDataItem; import com.android.contacts.common.model.dataitem.DataKind; import com.android.contacts.common.testing.NeededForTesting; import com.android.contacts.common.util.CommonDateUtils; Loading Loading @@ -445,6 +447,13 @@ public abstract class BaseAccountType extends AccountType { return kind; } protected DataKind addDataKindCustomField(Context context) throws DefinitionException { final DataKind kind = addKind(new DataKind(CustomDataItem.MIMETYPE_CUSTOM_FIELD, R.string.label_custom_field, Weight.NONE, /* editable */ false)); kind.actionBody = new SimpleInflater(Data.DATA2); return kind; } /** * Simple inflater that assumes a string resource has a "%s" that will be * filled from the given column. Loading src/com/android/contacts/common/model/account/GoogleAccountType.java +1 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,7 @@ public class GoogleAccountType extends BaseAccountType { addDataKindGroupMembership(context); addDataKindRelation(context); addDataKindEvent(context); addDataKindCustomField(context); mIsInitialized = true; } catch (DefinitionException e) { Loading src/com/android/contacts/common/model/dataitem/CustomDataItem.java 0 → 100644 +42 −0 Original line number Diff line number Diff line /* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License */ package com.android.contacts.common.model.dataitem; import android.content.ContentValues; import android.provider.ContactsContract.Data; /** * Represents a custom field data item. */ public class CustomDataItem extends DataItem { /** * MIME type for custom field data defined in Contact Provider. */ public static final String MIMETYPE_CUSTOM_FIELD = "vnd.com.google.cursor.item/contact_user_defined_field"; CustomDataItem(ContentValues values) {super(values);} public String getSummary() { return getContentValues().getAsString(Data.DATA1); } public String getContent() { return getContentValues().getAsString(Data.DATA2); } } src/com/android/contacts/common/model/dataitem/DataItem.java +2 −0 Original line number Diff line number Diff line Loading @@ -88,6 +88,8 @@ public class DataItem implements Collapser.Collapsible<DataItem> { return new IdentityDataItem(values); } else if (Photo.CONTENT_ITEM_TYPE.equals(mimeType)) { return new PhotoDataItem(values); } else if (CustomDataItem.MIMETYPE_CUSTOM_FIELD.equals(mimeType)) { return new CustomDataItem(values); } // generic Loading Loading
res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -1212,6 +1212,9 @@ about a contact --> <string name="label_notes">Notes</string> <!-- The label describing the custom field of a contact. [CHAR LIMIT=20] --> <string name="label_custom_field">Custom</string> <!-- The label describing the SIP address field of a contact. [CHAR LIMIT=20] --> <string name="label_sip_address">SIP</string> Loading
src/com/android/contacts/common/model/account/BaseAccountType.java +9 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.contacts.common.model.account; import android.content.ContentValues; import android.content.Context; import android.content.res.Resources; import android.provider.ContactsContract.Data; import android.provider.ContactsContract.CommonDataKinds.BaseTypes; import android.provider.ContactsContract.CommonDataKinds.Email; import android.provider.ContactsContract.CommonDataKinds.Event; Loading @@ -39,6 +40,7 @@ import android.util.Log; import android.view.inputmethod.EditorInfo; import com.android.contacts.common.R; import com.android.contacts.common.model.dataitem.CustomDataItem; import com.android.contacts.common.model.dataitem.DataKind; import com.android.contacts.common.testing.NeededForTesting; import com.android.contacts.common.util.CommonDateUtils; Loading Loading @@ -445,6 +447,13 @@ public abstract class BaseAccountType extends AccountType { return kind; } protected DataKind addDataKindCustomField(Context context) throws DefinitionException { final DataKind kind = addKind(new DataKind(CustomDataItem.MIMETYPE_CUSTOM_FIELD, R.string.label_custom_field, Weight.NONE, /* editable */ false)); kind.actionBody = new SimpleInflater(Data.DATA2); return kind; } /** * Simple inflater that assumes a string resource has a "%s" that will be * filled from the given column. Loading
src/com/android/contacts/common/model/account/GoogleAccountType.java +1 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,7 @@ public class GoogleAccountType extends BaseAccountType { addDataKindGroupMembership(context); addDataKindRelation(context); addDataKindEvent(context); addDataKindCustomField(context); mIsInitialized = true; } catch (DefinitionException e) { Loading
src/com/android/contacts/common/model/dataitem/CustomDataItem.java 0 → 100644 +42 −0 Original line number Diff line number Diff line /* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License */ package com.android.contacts.common.model.dataitem; import android.content.ContentValues; import android.provider.ContactsContract.Data; /** * Represents a custom field data item. */ public class CustomDataItem extends DataItem { /** * MIME type for custom field data defined in Contact Provider. */ public static final String MIMETYPE_CUSTOM_FIELD = "vnd.com.google.cursor.item/contact_user_defined_field"; CustomDataItem(ContentValues values) {super(values);} public String getSummary() { return getContentValues().getAsString(Data.DATA1); } public String getContent() { return getContentValues().getAsString(Data.DATA2); } }
src/com/android/contacts/common/model/dataitem/DataItem.java +2 −0 Original line number Diff line number Diff line Loading @@ -88,6 +88,8 @@ public class DataItem implements Collapser.Collapsible<DataItem> { return new IdentityDataItem(values); } else if (Photo.CONTENT_ITEM_TYPE.equals(mimeType)) { return new PhotoDataItem(values); } else if (CustomDataItem.MIMETYPE_CUSTOM_FIELD.equals(mimeType)) { return new CustomDataItem(values); } // generic Loading