Add Organization and Note kinds to Exchange viewing/editing

Also add placeholder "chat" string to show as label for exchange im
items.

Fixes bug 2072710 and 2092920

Change-Id: I5c3ba0c73160f93b6d06b5b6a2ca20a84f56da18
diff --git a/src/com/android/contacts/ViewContactActivity.java b/src/com/android/contacts/ViewContactActivity.java
index b29a44c..36d9ee6 100644
--- a/src/com/android/contacts/ViewContactActivity.java
+++ b/src/com/android/contacts/ViewContactActivity.java
@@ -22,6 +22,7 @@
 import com.android.contacts.model.ContactsSource;
 import com.android.contacts.model.Sources;
 import com.android.contacts.model.ContactsSource.DataKind;
+import com.android.contacts.model.HardCodedSources.SimpleInflater;
 import com.android.contacts.ui.FastTrackWindow;
 import com.android.contacts.util.NotifyingAsyncQueryHandler;
 import com.android.internal.telephony.ITelephony;
@@ -993,6 +994,13 @@
                             entry.secondaryIntent = new Intent(Intent.ACTION_SENDTO,
                                     Uri.fromParts("sms", entry.data, null));
                             entry.data = PhoneNumberUtils.stripSeparators(entry.data);
+
+                            // If data is empty, don't show it.
+                            if (TextUtils.isEmpty(entry.data)) {
+                                Log.w(TAG, "empty data for contact method " + id);
+                                continue;
+                            }
+
                             entry.isPrimary = isSuperPrimary;
                             mPhoneEntries.add(entry);
 
@@ -1007,6 +1015,10 @@
                             // Build email entries
                             entry.intent = new Intent(Intent.ACTION_SENDTO,
                                     Uri.fromParts("mailto", entry.data, null));
+                            // Temporary hack until we get real label resources for exchange.
+                            if (TextUtils.isEmpty(entry.label)) {
+                                entry.label = getString(R.string.email).toLowerCase();
+                            }
                             entry.isPrimary = isSuperPrimary;
                             mEmailEntries.add(entry);
                         } else if (CommonDataKinds.StructuredPostal.CONTENT_ITEM_TYPE.
@@ -1020,6 +1032,10 @@
                             Object protocolObj = entryValues.getAsInteger(Data.DATA5);
                             String host = null;
 
+                            if (TextUtils.isEmpty(entry.label)) {
+                                entry.label = getString(R.string.im).toLowerCase();
+                            }
+
                             if (protocolObj instanceof Number) {
                                 int protocol = ((Number) protocolObj).intValue();
                                 host = ContactsUtils.lookupProviderNameFromId(
diff --git a/src/com/android/contacts/model/HardCodedSources.java b/src/com/android/contacts/model/HardCodedSources.java
index 57b1465..3d9df8f 100644
--- a/src/com/android/contacts/model/HardCodedSources.java
+++ b/src/com/android/contacts/model/HardCodedSources.java
@@ -514,11 +514,11 @@
 
             kind.typeColumn = Email.TYPE;
             kind.typeList = Lists.newArrayList();
-            kind.typeList.add(new EditType(TYPE_EMAIL1, R.string.type_email_1, R.string.email_1)
+            kind.typeList.add(new EditType(TYPE_EMAIL1, R.string.type_email_1)
                     .setSpecificMax(1));
-            kind.typeList.add(new EditType(TYPE_EMAIL2, R.string.type_email_2, R.string.email_2)
+            kind.typeList.add(new EditType(TYPE_EMAIL2, R.string.type_email_2)
                     .setSpecificMax(1));
-            kind.typeList.add(new EditType(TYPE_EMAIL3, R.string.type_email_3, R.string.email_3)
+            kind.typeList.add(new EditType(TYPE_EMAIL3, R.string.type_email_3)
                     .setSpecificMax(1));
 
             kind.fieldList = Lists.newArrayList();
@@ -539,9 +539,12 @@
 
             kind.typeColumn = Im.TYPE;
             kind.typeList = new ArrayList<EditType>();
-            kind.typeList.add(new EditType(TYPE_IM1, R.string.type_im_1).setSpecificMax(1));
-            kind.typeList.add(new EditType(TYPE_IM2, R.string.type_im_2).setSpecificMax(1));
-            kind.typeList.add(new EditType(TYPE_IM3, R.string.type_im_3).setSpecificMax(1));
+            kind.typeList.add(new EditType(TYPE_IM1, R.string.type_im_1).
+                    setSpecificMax(1));
+            kind.typeList.add(new EditType(TYPE_IM2, R.string.type_im_2).
+                    setSpecificMax(1));
+            kind.typeList.add(new EditType(TYPE_IM3, R.string.type_im_3).
+                    setSpecificMax(1));
 
             kind.fieldList = Lists.newArrayList();
             kind.fieldList.add(new EditField(Im.DATA, R.string.imLabelsGroup, FLAGS_EMAIL));
@@ -581,6 +584,46 @@
 
             list.add(kind);
         }
+
+        {
+            // EXCHANGE: ORGANIZATION
+            DataKind kind = new DataKind(Organization.CONTENT_ITEM_TYPE,
+                    R.string.organizationLabelsGroup, R.drawable.sym_action_organization, 30, true);
+
+            kind.actionHeader = new SimpleInflater(list.resPackageName, R.string.organizationLabelsGroup);
+            // TODO: build body from multiple fields
+            kind.actionBody = new SimpleInflater(Organization.TITLE);
+
+            kind.typeColumn = Organization.TYPE;
+            kind.typeList = Lists.newArrayList();
+            kind.typeList.add(new EditType(Organization.TYPE_WORK, R.string.type_work));
+            kind.typeList.add(new EditType(Organization.TYPE_OTHER, R.string.type_other));
+            kind.typeList.add(new EditType(Organization.TYPE_CUSTOM, R.string.type_custom)
+                    .setSecondary(true).setCustomColumn(Organization.LABEL));
+
+            kind.fieldList = Lists.newArrayList();
+            kind.fieldList.add(new EditField(Organization.COMPANY, R.string.ghostData_company,
+                    FLAGS_GENERIC_NAME));
+            kind.fieldList.add(new EditField(Organization.TITLE, R.string.ghostData_title,
+                    FLAGS_GENERIC_NAME));
+
+            list.add(kind);
+        }
+
+        {
+            // EXCHANGE: NOTE
+            DataKind kind = new DataKind(Note.CONTENT_ITEM_TYPE,
+                    R.string.label_notes, R.drawable.sym_note, 110, true);
+            kind.secondary = true;
+
+            kind.actionHeader = new SimpleInflater(list.resPackageName, R.string.label_notes);
+            kind.actionBody = new SimpleInflater(Note.NOTE);
+
+            kind.fieldList = Lists.newArrayList();
+            kind.fieldList.add(new EditField(Note.NOTE, R.string.label_notes, FLAGS_NOTE));
+
+            list.add(kind);
+        }
     }
 
     /**