Added thin object layer around contact data

This refactoring abstracts out the need to directly
refer to Contacts database columns throughout the code.  Instead,
all of this information is retained in getter/setter methods
within the Contact, RawContact, and DataItem classes and
sub-classes.

ContactLoader.Result class has been pulled to the top level as
the Contact class.

The Entity class has been removed and replaced with a RawContact
class, with getters/setters to raw contact information.
Renamed EntityDelta to RawContactDelta for better understandability
as well as adding getters/setters for specific fields in the
ValuesDelta nested class within EntityDelta.  EntityDeltaList
and EntityModifier have been renamed to RawContactDeltaList and
RawContactModifier with the methods using the RawContact class
directly rather than the Entity class.

Data items for a raw contact are represented by a DataItem object
with specialized getters/setters for subclasses of DataItem.
(e.g., EmailDataItem, PhoneDataItem. etc.).  DataItem is a wrapper
around ContentValues.  This abstracts away the ContactsContract
column fields into getters/setters.

The above refactoring is accompanied with changes throughout the
codebase to use the new Contact, RawContact, and DataItem classes.

Change-Id: I31c1dccd724e9652f9d0af78ca81feb6c5acd71d
diff --git a/src/com/android/contacts/editor/PhoneticNameEditorView.java b/src/com/android/contacts/editor/PhoneticNameEditorView.java
index 1700817..8cbb921 100644
--- a/src/com/android/contacts/editor/PhoneticNameEditorView.java
+++ b/src/com/android/contacts/editor/PhoneticNameEditorView.java
@@ -16,15 +16,15 @@
 
 package com.android.contacts.editor;
 
-import android.content.ContentValues;
 import android.content.Context;
 import android.provider.ContactsContract.CommonDataKinds.StructuredName;
 import android.text.TextUtils;
 import android.util.AttributeSet;
 
-import com.android.contacts.model.DataKind;
-import com.android.contacts.model.EntityDelta;
-import com.android.contacts.model.EntityDelta.ValuesDelta;
+import com.android.contacts.model.RawContactDelta;
+import com.android.contacts.model.RawContactDelta.ValuesDelta;
+import com.android.contacts.model.dataitem.DataKind;
+import com.android.contacts.model.dataitem.StructuredNameDataItem;
 
 /**
  * A dedicated editor for phonetic name. It is similar to {@link StructuredNameEditorView}.
@@ -61,19 +61,16 @@
         }
 
         private void parsePhoneticName(String value) {
-            ContentValues values = PhoneticNameEditorView.parsePhoneticName(value, null);
-            mValues.put(StructuredName.PHONETIC_FAMILY_NAME,
-                    values.getAsString(StructuredName.PHONETIC_FAMILY_NAME));
-            mValues.put(StructuredName.PHONETIC_MIDDLE_NAME,
-                    values.getAsString(StructuredName.PHONETIC_MIDDLE_NAME));
-            mValues.put(StructuredName.PHONETIC_GIVEN_NAME,
-                    values.getAsString(StructuredName.PHONETIC_GIVEN_NAME));
+            StructuredNameDataItem dataItem = PhoneticNameEditorView.parsePhoneticName(value, null);
+            mValues.setPhoneticFamilyName(dataItem.getPhoneticFamilyName());
+            mValues.setPhoneticMiddleName(dataItem.getPhoneticMiddleName());
+            mValues.setPhoneticGivenName(dataItem.getPhoneticGivenName());
         }
 
         private void buildPhoneticName() {
-            String family = mValues.getAsString(StructuredName.PHONETIC_FAMILY_NAME);
-            String middle = mValues.getAsString(StructuredName.PHONETIC_MIDDLE_NAME);
-            String given = mValues.getAsString(StructuredName.PHONETIC_GIVEN_NAME);
+            String family = mValues.getPhoneticFamilyName();
+            String middle = mValues.getPhoneticMiddleName();
+            String given = mValues.getPhoneticGivenName();
             mPhoneticName = PhoneticNameEditorView.buildPhoneticName(family, middle, given);
         }
 
@@ -100,7 +97,8 @@
      * created.
      * @return ContentValues with parsed data. Those data can be null.
      */
-    public static ContentValues parsePhoneticName(String phoneticName, ContentValues values) {
+    public static StructuredNameDataItem parsePhoneticName(String phoneticName,
+            StructuredNameDataItem item) {
         String family = null;
         String middle = null;
         String given = null;
@@ -123,13 +121,13 @@
             }
         }
 
-        if (values == null) {
-            values = new ContentValues();
+        if (item == null) {
+            item = new StructuredNameDataItem();
         }
-        values.put(StructuredName.PHONETIC_FAMILY_NAME, family);
-        values.put(StructuredName.PHONETIC_MIDDLE_NAME, middle);
-        values.put(StructuredName.PHONETIC_GIVEN_NAME, given);
-        return values;
+        item.setPhoneticFamilyName(family);
+        item.setPhoneticMiddleName(middle);
+        item.setPhoneticGivenName(given);
+        return item;
     }
 
     /**
@@ -172,7 +170,7 @@
     }
 
     @Override
-    public void setValues(DataKind kind, ValuesDelta entry, EntityDelta state, boolean readOnly,
+    public void setValues(DataKind kind, ValuesDelta entry, RawContactDelta state, boolean readOnly,
             ViewIdGenerator vig) {
         if (!(entry instanceof PhoneticValuesDelta)) {
             entry = new PhoneticValuesDelta(entry);
@@ -213,9 +211,9 @@
     public boolean hasData() {
         ValuesDelta entry = getEntry();
 
-        String family = entry.getAsString(StructuredName.PHONETIC_FAMILY_NAME);
-        String middle = entry.getAsString(StructuredName.PHONETIC_MIDDLE_NAME);
-        String given = entry.getAsString(StructuredName.PHONETIC_GIVEN_NAME);
+        String family = entry.getPhoneticFamilyName();
+        String middle = entry.getPhoneticMiddleName();
+        String given = entry.getPhoneticGivenName();
 
         return !TextUtils.isEmpty(family) || !TextUtils.isEmpty(middle)
                 || !TextUtils.isEmpty(given);