Merge "Don't show edit option if group membership isn't editable"
diff --git a/src/com/android/contacts/group/GroupDetailFragment.java b/src/com/android/contacts/group/GroupDetailFragment.java
index 69d5165..834e2c3 100644
--- a/src/com/android/contacts/group/GroupDetailFragment.java
+++ b/src/com/android/contacts/group/GroupDetailFragment.java
@@ -115,10 +115,11 @@
     private String mAccountTypeString;
     private String mDataSet;
     private boolean mIsReadOnly;
+    private boolean mIsMembershipEditable;
 
     private boolean mShowGroupActionInActionBar;
     private boolean mOptionsMenuGroupDeletable;
-    private boolean mOptionsMenuGroupPresent;
+    private boolean mOptionsMenuGroupEditable;
     private boolean mCloseActivityAfterDelete;
 
     public GroupDetailFragment() {
@@ -338,8 +339,15 @@
      * (based on the result from the {@link Loader}), then we can display this to the user in 1 of
      * 2 ways depending on screen size and orientation: either as a button in the action bar or as
      * a button in a static header on the page.
+     * We also use isGroupMembershipEditable() of accountType to determine whether or not we should
+     * display the Edit option in the Actionbar.
      */
     private void updateAccountType(final String accountTypeString, final String dataSet) {
+        final AccountTypeManager manager = AccountTypeManager.getInstance(getActivity());
+        final AccountType accountType =
+                manager.getAccountType(accountTypeString, dataSet);
+
+        mIsMembershipEditable = accountType.isGroupMembershipEditable();
 
         // If the group action should be shown in the action bar, then pass the data to the
         // listener who will take care of setting up the view and click listener. There is nothing
@@ -349,10 +357,6 @@
             return;
         }
 
-        final AccountTypeManager manager = AccountTypeManager.getInstance(getActivity());
-        final AccountType accountType =
-                manager.getAccountType(accountTypeString, dataSet);
-
         // Otherwise, if the {@link Fragment} needs to create and setup the button, then first
         // verify that there is a valid action.
         if (!TextUtils.isEmpty(accountType.getViewGroupActivity())) {
@@ -406,24 +410,24 @@
 
     public boolean isOptionsMenuChanged() {
         return mOptionsMenuGroupDeletable != isGroupDeletable() &&
-                mOptionsMenuGroupPresent != isGroupPresent();
+                mOptionsMenuGroupEditable != isGroupEditableAndPresent();
     }
 
     public boolean isGroupDeletable() {
         return mGroupUri != null && !mIsReadOnly;
     }
 
-    public boolean isGroupPresent() {
-        return mGroupUri != null;
+    public boolean isGroupEditableAndPresent() {
+        return mGroupUri != null && mIsMembershipEditable;
     }
 
     @Override
     public void onPrepareOptionsMenu(Menu menu) {
         mOptionsMenuGroupDeletable = isGroupDeletable() && isVisible();
-        mOptionsMenuGroupPresent = isGroupPresent() && isVisible();
+        mOptionsMenuGroupEditable = isGroupEditableAndPresent() && isVisible();
 
         final MenuItem editMenu = menu.findItem(R.id.menu_edit_group);
-        editMenu.setVisible(mOptionsMenuGroupPresent);
+        editMenu.setVisible(mOptionsMenuGroupEditable);
 
         final MenuItem deleteMenu = menu.findItem(R.id.menu_delete_group);
         deleteMenu.setVisible(mOptionsMenuGroupDeletable);