Merge "Log Edit Raw Contacts modal (1/2)" into ub-contactsdialer-h-dev
diff --git a/src/com/android/contacts/activities/ContactEditorSpringBoardActivity.java b/src/com/android/contacts/activities/ContactEditorSpringBoardActivity.java
index 3d47b8f..9e39c5b 100644
--- a/src/com/android/contacts/activities/ContactEditorSpringBoardActivity.java
+++ b/src/com/android/contacts/activities/ContactEditorSpringBoardActivity.java
@@ -15,6 +15,8 @@
 import com.android.contacts.AppCompatContactsActivity;
 import com.android.contacts.R;
 import com.android.contacts.common.activity.RequestPermissionsActivity;
+import com.android.contacts.common.logging.EditorEvent;
+import com.android.contacts.common.logging.Logger;
 import com.android.contacts.common.model.AccountTypeManager;
 import com.android.contacts.common.util.ImplicitIntentsUtil;
 import com.android.contacts.common.util.MaterialColorMapUtils.MaterialPalette;
@@ -108,6 +110,8 @@
         // Go straight to editor if we're passed a raw contact Uri.
         if (ContactsContract.AUTHORITY.equals(authority) &&
                 RawContacts.CONTENT_ITEM_TYPE.equals(type)) {
+            Logger.logEditorEvent(
+                    EditorEvent.EventType.SHOW_RAW_CONTACT_PICKER, /* numberRawContacts */ 0);
             final long rawContactId = ContentUris.parseId(mUri);
             startEditorAndForwardExtras(getIntentForRawContact(rawContactId));
         } else if (android.provider.Contacts.AUTHORITY.equals(authority)) {
@@ -169,6 +173,8 @@
      * the editor is started normally and handles creation of a new writable raw contact.
      */
     private void loadEditor() {
+        Logger.logEditorEvent(
+                EditorEvent.EventType.SHOW_RAW_CONTACT_PICKER, /* numberRawContacts */ 0);
         final Intent intent;
         if (mHasWritableAccount) {
             intent = getIntentForRawContact(mResult.rawContacts.get(mWritableAccountPosition).id);
diff --git a/src/com/android/contacts/common/logging/EditorEvent.java b/src/com/android/contacts/common/logging/EditorEvent.java
new file mode 100644
index 0000000..e5b42f8
--- /dev/null
+++ b/src/com/android/contacts/common/logging/EditorEvent.java
@@ -0,0 +1,40 @@
+/*
+ * 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.logging;
+
+import com.google.common.base.MoreObjects;
+
+public class EditorEvent {
+
+    /** The editor event type that is logged. */
+    public int eventType;
+
+    /** The number of raw contacts shown in the raw contacts picker. */
+    public int numberRawContacts;
+
+    public static final class EventType {
+        public static final int UNKNOWN = 0;
+        public static final int SHOW_RAW_CONTACT_PICKER = 1;
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(this)
+                .add("eventType", eventType)
+                .add("numberRawContacts", numberRawContacts)
+                .toString();
+    }
+}
diff --git a/src/com/android/contacts/common/logging/Logger.java b/src/com/android/contacts/common/logging/Logger.java
index 68cbbbb..cb75ca9 100644
--- a/src/com/android/contacts/common/logging/Logger.java
+++ b/src/com/android/contacts/common/logging/Logger.java
@@ -96,8 +96,19 @@
         }
     }
 
+    public static void logEditorEvent(int eventType, int numberRawContacts) {
+        final Logger logger = getInstance();
+        if (logger != null) {
+            final EditorEvent event = new EditorEvent();
+            event.eventType = eventType;
+            event.numberRawContacts = numberRawContacts;
+            logger.logEditorEventImpl(event);
+        }
+    }
+
     public abstract void logScreenViewImpl(int screenType, int previousScreenType);
     public abstract void logSearchEventImpl(SearchState searchState);
     public abstract void logListEventImpl(ListEvent event);
     public abstract void logQuickContactEventImpl(QuickContactEvent event);
+    public abstract void logEditorEventImpl(EditorEvent event);
 }
diff --git a/src/com/android/contacts/editor/PickRawContactDialogFragment.java b/src/com/android/contacts/editor/PickRawContactDialogFragment.java
index dd4eb30..1136f82 100644
--- a/src/com/android/contacts/editor/PickRawContactDialogFragment.java
+++ b/src/com/android/contacts/editor/PickRawContactDialogFragment.java
@@ -17,6 +17,8 @@
 
 import com.android.contacts.R;
 import com.android.contacts.common.ContactPhotoManager;
+import com.android.contacts.common.logging.EditorEvent;
+import com.android.contacts.common.logging.Logger;
 import com.android.contacts.common.model.AccountTypeManager;
 import com.android.contacts.common.model.account.AccountDisplayInfo;
 import com.android.contacts.common.model.account.AccountDisplayInfoFactory;
@@ -181,6 +183,10 @@
             }
         });
         builder.setCancelable(true);
+        if (savedInstanceState == null) {
+            Logger.logEditorEvent(EditorEvent.EventType.SHOW_RAW_CONTACT_PICKER,
+                    /* numberRawContacts */ mAdapter.getCount());
+        }
         return builder.create();
     }