Merge "Update compact editor photo to full res when possible"
diff --git a/src/com/android/contacts/editor/EventFieldEditorView.java b/src/com/android/contacts/editor/EventFieldEditorView.java
index d38940a..bab6e88 100644
--- a/src/com/android/contacts/editor/EventFieldEditorView.java
+++ b/src/com/android/contacts/editor/EventFieldEditorView.java
@@ -82,6 +82,9 @@
         mDateView.setOnClickListener(new OnClickListener() {
             @Override
             public void onClick(View v) {
+                if (!isTypeVisible()) {
+                    showType();
+                }
                 showDialog(R.id.dialog_event_date_picker);
             }
         });
@@ -129,6 +132,9 @@
             mDateView.setText(data);
             mDateView.setTextColor(mPrimaryTextColor);
             setDeleteButtonVisible(true);
+            if (!isTypeVisible()) {
+                showType();
+            }
         }
     }
 
diff --git a/src/com/android/contacts/editor/KindSectionView.java b/src/com/android/contacts/editor/KindSectionView.java
index 081efaa..56c81a0 100644
--- a/src/com/android/contacts/editor/KindSectionView.java
+++ b/src/com/android/contacts/editor/KindSectionView.java
@@ -194,6 +194,10 @@
                     layoutResId + " for MIME type " + mKind.mimeType +
                     " with error " + e.toString());
         }
+        // Hide the types drop downs until the associated edit field is focused
+        if (view instanceof LabeledEditorView) {
+            ((LabeledEditorView) view).setHideTypeInitially(true);
+        }
 
         view.setEnabled(isEnabled());
 
diff --git a/src/com/android/contacts/editor/LabeledEditorView.java b/src/com/android/contacts/editor/LabeledEditorView.java
index 5996fa6..b60ae5c 100644
--- a/src/com/android/contacts/editor/LabeledEditorView.java
+++ b/src/com/android/contacts/editor/LabeledEditorView.java
@@ -79,6 +79,8 @@
     private boolean mWasEmpty = true;
     private boolean mIsDeletable = true;
     private boolean mIsAttachedToWindow;
+    private boolean mHideTypeInitially;
+    private boolean mHasTypes;
 
     private EditType mType;
 
@@ -232,6 +234,30 @@
         }
     }
 
+    /**
+     * Whether to hide the type dropdown after values have been set.
+     * By default the drop down is always displayed if there are types to display.
+     */
+    public void setHideTypeInitially(boolean hideTypeInitially) {
+        mHideTypeInitially = hideTypeInitially;
+    }
+
+    /**
+     * Whether the type drop down is visible.
+     */
+    public boolean isTypeVisible() {
+        return mLabel == null ? false : mLabel.getVisibility() == View.VISIBLE;
+    }
+
+    /**
+     * Makes the type drop down visible if it is not already so, and there are types to display.
+     */
+    public void showType() {
+        if (mHasTypes && mLabel != null && mLabel.getVisibility() != View.VISIBLE) {
+            mLabel.setVisibility(View.VISIBLE);
+        }
+    }
+
     protected void onOptionalFieldVisibilityChange() {
         if (mListener != null) {
             mListener.onRequest(EditorListener.EDITOR_FORM_CHANGED);
@@ -379,12 +405,15 @@
         setVisibility(View.VISIBLE);
 
         // Display label selector if multiple types available
-        final boolean hasTypes = RawContactModifier.hasEditTypes(kind);
-        setupLabelButton(hasTypes);
+        mHasTypes = RawContactModifier.hasEditTypes(kind);
+        setupLabelButton(mHasTypes);
         mLabel.setEnabled(!readOnly && isEnabled());
-        if (hasTypes) {
+        if (mHasTypes) {
             mType = RawContactModifier.getCurrentType(entry, kind);
             rebuildLabel();
+            if (mHideTypeInitially) {
+                mLabel.setVisibility(View.GONE);
+            }
         }
     }
 
diff --git a/src/com/android/contacts/editor/TextFieldsEditorView.java b/src/com/android/contacts/editor/TextFieldsEditorView.java
index 1798b0f..4c7a322 100644
--- a/src/com/android/contacts/editor/TextFieldsEditorView.java
+++ b/src/com/android/contacts/editor/TextFieldsEditorView.java
@@ -153,10 +153,14 @@
         public void onFocusChange(View v, boolean hasFocus) {
             // Check whether this field contains focus by calling findFocus() instead of
             // hasFocus(). The hasFocus() value is not necessarily up to date.
-            setHintColorDark(TextFieldsEditorView.this.findFocus() != null);
+            final boolean foundFocus = TextFieldsEditorView.this.findFocus() != null;
+            setHintColorDark(foundFocus);
             if (getEditorListener() != null) {
                 getEditorListener().onRequest(EditorListener.EDITOR_FOCUS_CHANGED);
             }
+            if (foundFocus && !isTypeVisible()) {
+                showType();
+            }
             // Rebuild the label spinner using the new colors.
             rebuildLabel();
         }
@@ -266,6 +270,11 @@
             final String value = entry.getAsString(column);
             fieldView.setText(value);
 
+            // Show the type drop down if we have a non-empty value.
+            if (!isTypeVisible() && !TextUtils.isEmpty(value)) {
+                showType();
+            }
+
             // Show the delete button if we have a non-null value
             setDeleteButtonVisible(value != null);