Contacts: Device Contacts: Add relation

* Taken from GoogleAccountType

Change-Id: I1bf888c3c9c03e4cca9fc4c14a757e5e3432e947
diff --git a/src/com/android/contacts/model/account/DeviceLocalAccountType.java b/src/com/android/contacts/model/account/DeviceLocalAccountType.java
index a4c228d..ac190af 100644
--- a/src/com/android/contacts/model/account/DeviceLocalAccountType.java
+++ b/src/com/android/contacts/model/account/DeviceLocalAccountType.java
@@ -18,6 +18,7 @@
 import android.content.ContentValues;
 import android.content.Context;
 import android.provider.ContactsContract.CommonDataKinds.Event;
+import android.provider.ContactsContract.CommonDataKinds.Relation;
 
 import com.android.contacts.R;
 import com.android.contacts.model.dataitem.DataKind;
@@ -36,6 +37,7 @@
         super(context);
 
         try {
+            addDataKindRelation(context);
             addDataKindEvent(context);
         } catch (DefinitionException e) {
             FeedbackHelper.sendFeedback(context, TAG, "Failed to build fallback account type", e);
@@ -62,6 +64,41 @@
                         getDisplayIcon(context), true), this);
     }
 
+    private DataKind addDataKindRelation(Context context) throws DefinitionException {
+        DataKind kind = addKind(new DataKind(Relation.CONTENT_ITEM_TYPE,
+                R.string.relationLabelsGroup, Weight.RELATIONSHIP, true));
+        kind.actionHeader = new RelationActionInflater();
+        kind.actionBody = new SimpleInflater(Relation.NAME);
+
+        kind.typeColumn = Relation.TYPE;
+        kind.typeList = Lists.newArrayList();
+        kind.typeList.add(buildRelationType(Relation.TYPE_ASSISTANT));
+        kind.typeList.add(buildRelationType(Relation.TYPE_BROTHER));
+        kind.typeList.add(buildRelationType(Relation.TYPE_CHILD));
+        kind.typeList.add(buildRelationType(Relation.TYPE_DOMESTIC_PARTNER));
+        kind.typeList.add(buildRelationType(Relation.TYPE_FATHER));
+        kind.typeList.add(buildRelationType(Relation.TYPE_FRIEND));
+        kind.typeList.add(buildRelationType(Relation.TYPE_MANAGER));
+        kind.typeList.add(buildRelationType(Relation.TYPE_MOTHER));
+        kind.typeList.add(buildRelationType(Relation.TYPE_PARENT));
+        kind.typeList.add(buildRelationType(Relation.TYPE_PARTNER));
+        kind.typeList.add(buildRelationType(Relation.TYPE_REFERRED_BY));
+        kind.typeList.add(buildRelationType(Relation.TYPE_RELATIVE));
+        kind.typeList.add(buildRelationType(Relation.TYPE_SISTER));
+        kind.typeList.add(buildRelationType(Relation.TYPE_SPOUSE));
+        kind.typeList.add(buildRelationType(Relation.TYPE_CUSTOM).setSecondary(true)
+                .setCustomColumn(Relation.LABEL));
+
+        kind.defaultValues = new ContentValues();
+        kind.defaultValues.put(Relation.TYPE, Relation.TYPE_SPOUSE);
+
+        kind.fieldList = Lists.newArrayList();
+        kind.fieldList.add(new EditField(Relation.DATA, R.string.relationLabelsGroup,
+                FLAGS_RELATION));
+
+        return kind;
+    }
+
     private DataKind addDataKindEvent(Context context) throws DefinitionException {
         DataKind kind = addKind(new DataKind(Event.CONTENT_ITEM_TYPE,
                     R.string.eventLabelsGroup, Weight.EVENT, true));