Move join suggestion view to base contact edit fragment

So that we can keep setEnabled logic entirely within
the base fragment.

The rest of the join suggestion functionality will be
ported to the base so it can be shared with the compact
editor in a seperate CL.

Bug 19124091

Change-Id: I4d494c9b0c2db8a6dba6d9d752d049f48848f731
diff --git a/src/com/android/contacts/editor/CompactContactEditorFragment.java b/src/com/android/contacts/editor/CompactContactEditorFragment.java
index 98339a6..fbde8c9 100644
--- a/src/com/android/contacts/editor/CompactContactEditorFragment.java
+++ b/src/com/android/contacts/editor/CompactContactEditorFragment.java
@@ -51,18 +51,10 @@
         super.onActivityResult(requestCode, resultCode, data);
     }
 
-    //
-    // ContactEditorBaseFragment
-    //
-
     @Override
     protected void bindEditors() {
     }
 
-    @Override
-    protected void setEnabled(boolean enabled) {
-    }
-
     //
     // ContactEditor
     //
diff --git a/src/com/android/contacts/editor/ContactEditorBaseFragment.java b/src/com/android/contacts/editor/ContactEditorBaseFragment.java
index fcfb86d..e1a841a 100644
--- a/src/com/android/contacts/editor/ContactEditorBaseFragment.java
+++ b/src/com/android/contacts/editor/ContactEditorBaseFragment.java
@@ -69,6 +69,7 @@
 import android.view.Menu;
 import android.view.MenuInflater;
 import android.view.MenuItem;
+import android.view.View;
 import android.widget.LinearLayout;
 import android.widget.Toast;
 
@@ -195,6 +196,7 @@
     // Views
     //
     protected LinearLayout mContent;
+    protected View mAggregationSuggestionView;
 
     //
     // Parameters passed in on {@link #load}
@@ -721,7 +723,7 @@
             return true;
         }
 
-        maybeSetEnabled(false);
+        setEnabled(false);
 
         return doSaveAction(saveMode);
     }
@@ -900,7 +902,7 @@
      */
     protected void setStateForExistingContact(String displayName, boolean isUserProfile,
             ImmutableList<RawContact> rawContacts) {
-        maybeSetEnabled(true);
+        setEnabled(true);
         mDefaultDisplayName = displayName;
 
         mState.addAll(rawContacts.iterator());
@@ -933,8 +935,6 @@
     /**
      * Sets group metadata on all bound editors.
      */
-    // TODO: can this be private? Does it really need to be called from
-    // {@link ContactEditFragment#bindEdtiors}?  If not we can remove mGroupMetaData too.
     protected void setGroupMetaData() {
         if (mGroupMetaData == null) {
             return;
@@ -955,14 +955,31 @@
     /**
      * Set the enabled state of editors.
      */
-    // TODO: The implementation in ContactEditorFragment can be moved to this class when
-    // the aggregation Views are moved to the base and we can get rid of maybeSetEnabled
-    abstract void setEnabled(boolean enabled);
-
-    private void maybeSetEnabled(boolean enabled) {
+    private void setEnabled(boolean enabled) {
         if (mEnabled != enabled) {
             mEnabled = enabled;
-            setEnabled(mEnabled);
+
+            // Enable/disable editors
+            if (mContent != null) {
+                int count = mContent.getChildCount();
+                for (int i = 0; i < count; i++) {
+                    mContent.getChildAt(i).setEnabled(enabled);
+                }
+            }
+
+            // Enable/disable aggregation suggestion vies
+            if (mAggregationSuggestionView != null) {
+                LinearLayout itemList = (LinearLayout) mAggregationSuggestionView.findViewById(
+                        R.id.aggregation_suggestions);
+                int count = itemList.getChildCount();
+                for (int i = 0; i < count; i++) {
+                    itemList.getChildAt(i).setEnabled(enabled);
+                }
+            }
+
+            // Maybe invalidate the options menu
+            final Activity activity = getActivity();
+            if (activity != null) activity.invalidateOptionsMenu();
         }
     }
 
diff --git a/src/com/android/contacts/editor/ContactEditorFragment.java b/src/com/android/contacts/editor/ContactEditorFragment.java
index d78d171..dfa58ac 100644
--- a/src/com/android/contacts/editor/ContactEditorFragment.java
+++ b/src/com/android/contacts/editor/ContactEditorFragment.java
@@ -130,7 +130,6 @@
 
     // Aggregations
     private long mAggregationSuggestionsRawContactId;
-    private View mAggregationSuggestionView;
     private ListPopupWindow mAggregationSuggestionPopup;
 
     private static final class AggregationSuggestionAdapter extends BaseAdapter {
@@ -190,20 +189,6 @@
     public ContactEditorFragment() {
     }
 
-
-    @Override
-    protected void setEnabled(boolean enabled) {
-        if (mContent != null) {
-            int count = mContent.getChildCount();
-            for (int i = 0; i < count; i++) {
-                mContent.getChildAt(i).setEnabled(enabled);
-            }
-        }
-        setAggregationSuggestionViewEnabled(enabled);
-        final Activity activity = getActivity();
-        if (activity != null) activity.invalidateOptionsMenu();
-    }
-
     @Override
     public void onStop() {
         super.onStop();
@@ -889,19 +874,6 @@
         }
     }
 
-    public void setAggregationSuggestionViewEnabled(boolean enabled) {
-        if (mAggregationSuggestionView == null) {
-            return;
-        }
-
-        LinearLayout itemList = (LinearLayout) mAggregationSuggestionView.findViewById(
-                R.id.aggregation_suggestions);
-        int count = itemList.getChildCount();
-        for (int i = 0; i < count; i++) {
-            itemList.getChildAt(i).setEnabled(enabled);
-        }
-    }
-
     @Override
     public void onSaveInstanceState(Bundle outState) {
         // Joins