Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1bd8826c authored by yaolu's avatar yaolu
Browse files

Show custom contact fields in Contact card About card

bug 3457984

Change-Id: Id1963a258842f665123c63a75fb2726f48ddc552
parent 1ce6ad92
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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>

+9 −0
Original line number Diff line number Diff line
@@ -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;
@@ -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;
@@ -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.
+1 −0
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ public class GoogleAccountType extends BaseAccountType {
            addDataKindGroupMembership(context);
            addDataKindRelation(context);
            addDataKindEvent(context);
            addDataKindCustomField(context);

            mIsInitialized = true;
        } catch (DefinitionException e) {
+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);
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -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