diff --git a/app/src/main/java/org/communiquons/android/comunic/client/fragments/UpdateConversationFragment.java b/app/src/main/java/org/communiquons/android/comunic/client/fragments/UpdateConversationFragment.java index f0e99b0..fd194b9 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/fragments/UpdateConversationFragment.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/fragments/UpdateConversationFragment.java @@ -7,9 +7,13 @@ import android.os.AsyncTask; import android.os.Bundle; import android.support.annotation.Nullable; import android.util.ArrayMap; +import android.view.ContextMenu; import android.view.LayoutInflater; +import android.view.MenuInflater; +import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; +import android.widget.AdapterView; import android.widget.Button; import android.widget.CheckBox; import android.widget.ListView; @@ -166,8 +170,23 @@ public class UpdateConversationFragment extends Fragment { //Initialize the form init_form(); + //Set members list context menu + membersList.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() { + @Override + public void onCreateContextMenu(ContextMenu menu, View v, + ContextMenu.ContextMenuInfo menuInfo) { + + //Create menu + MenuInflater menuInflater = getActivity().getMenuInflater(); + menuInflater.inflate(R.menu.menu_fragment_update_conversation_memberslist, menu); + + } + }); + + } + @Override public void onResume() { super.onResume(); @@ -291,6 +310,31 @@ public class UpdateConversationFragment extends Fragment { membersAdapter.notifyDataSetChanged(); } + /** + * Handles the context menu actions of the friends list + * + * @param item The selected item + * @return TRUE if the action was handled, false else + */ + @Override + public boolean onContextItemSelected(MenuItem item) { + + //Get the selected opition + int option = item.getItemId(); + + //Check if we have to remove a member of the conversation + if(option == R.id.update_conversationmembers_delete){ + + //Remove the member from the list + membersID.remove(((AdapterView.AdapterContextMenuInfo) item.getMenuInfo()).position); + membersAdapter.notifyDataSetChanged(); + + return true; + } + + return super.onContextItemSelected(item); + } + /** * Submit creation form */ diff --git a/app/src/main/res/menu/menu_fragment_update_conversation_memberslist.xml b/app/src/main/res/menu/menu_fragment_update_conversation_memberslist.xml new file mode 100644 index 0000000..f546624 --- /dev/null +++ b/app/src/main/res/menu/menu_fragment_update_conversation_memberslist.xml @@ -0,0 +1,9 @@ + +
\ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9fd0517..68e8909 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -86,4 +86,5 @@