diff --git a/app/src/main/java/org/communiquons/android/comunic/client/MainActivity.java b/app/src/main/java/org/communiquons/android/comunic/client/MainActivity.java
index 76c916c..4596252 100644
--- a/app/src/main/java/org/communiquons/android/comunic/client/MainActivity.java
+++ b/app/src/main/java/org/communiquons/android/comunic/client/MainActivity.java
@@ -21,6 +21,7 @@ import org.communiquons.android.comunic.client.data.friendsList.FriendRefreshLoo
import org.communiquons.android.comunic.client.fragments.ConversationFragment;
import org.communiquons.android.comunic.client.fragments.ConversationsListFragment;
import org.communiquons.android.comunic.client.fragments.FriendsListFragment;
+import org.communiquons.android.comunic.client.fragments.UpdateConversationFragment;
import org.communiquons.android.comunic.client.fragments.UserInfosFragment;
@@ -30,7 +31,8 @@ import org.communiquons.android.comunic.client.fragments.UserInfosFragment;
* @author Pierre HUBERT
*/
public class MainActivity extends AppCompatActivity
- implements ConversationsListHelper.openConversationListener {
+ implements ConversationsListHelper.openConversationListener,
+ ConversationsListHelper.updateConversationListener {
/**
* Account object
@@ -276,4 +278,26 @@ public class MainActivity extends AppCompatActivity
transaction.commit();
}
+
+ @Override
+ public void createConversation() {
+ updateConversation(0);
+ }
+
+ @Override
+ public void updateConversation(int convID) {
+
+ //Set the arguments of the fragment
+ Bundle args = new Bundle();
+
+ //Create the fragment
+ UpdateConversationFragment updateConversationFragment = new UpdateConversationFragment();
+ updateConversationFragment.setArguments(args);
+
+ //Display the fragment
+ FragmentTransaction transaction = getFragmentManager().beginTransaction();
+ transaction.replace(R.id.main_fragment, updateConversationFragment);
+ transaction.addToBackStack(null);
+ transaction.commit();
+ }
}
diff --git a/app/src/main/java/org/communiquons/android/comunic/client/data/conversations/ConversationsListHelper.java b/app/src/main/java/org/communiquons/android/comunic/client/data/conversations/ConversationsListHelper.java
index 92acadd..5f2d079 100644
--- a/app/src/main/java/org/communiquons/android/comunic/client/data/conversations/ConversationsListHelper.java
+++ b/app/src/main/java/org/communiquons/android/comunic/client/data/conversations/ConversationsListHelper.java
@@ -298,4 +298,22 @@ public class ConversationsListHelper {
}
+ /**
+ * Handles the creation and / or the update of a conversation
+ */
+ public interface updateConversationListener {
+
+ /**
+ * This method is called when a user wants to create a new conversation
+ */
+ void createConversation();
+
+ /**
+ * This method is called when the user want to open a conversation
+ *
+ * @param convID The ID of the conversation to open
+ */
+ void updateConversation(int convID);
+ }
+
}
diff --git a/app/src/main/java/org/communiquons/android/comunic/client/fragments/ConversationsListFragment.java b/app/src/main/java/org/communiquons/android/comunic/client/fragments/ConversationsListFragment.java
index 1d99f51..9af7533 100644
--- a/app/src/main/java/org/communiquons/android/comunic/client/fragments/ConversationsListFragment.java
+++ b/app/src/main/java/org/communiquons/android/comunic/client/fragments/ConversationsListFragment.java
@@ -1,9 +1,7 @@
package org.communiquons.android.comunic.client.fragments;
-import android.app.Activity;
import android.app.AlertDialog;
import android.app.Fragment;
-import android.content.Context;
import android.content.DialogInterface;
import android.os.AsyncTask;
import android.os.Bundle;
@@ -30,8 +28,8 @@ import org.communiquons.android.comunic.client.data.UsersInfo.UserInfo;
import org.communiquons.android.comunic.client.data.conversations.ConversationsInfo;
import org.communiquons.android.comunic.client.data.conversations.ConversationsListAdapter;
import org.communiquons.android.comunic.client.data.conversations.ConversationsListHelper;
-import org.communiquons.android.comunic.client.data.conversations.ConversationsListHelper
- .openConversationListener;
+import org.communiquons.android.comunic.client.data.conversations.ConversationsListHelper.openConversationListener;
+import org.communiquons.android.comunic.client.data.conversations.ConversationsListHelper.updateConversationListener;
import java.util.ArrayList;
@@ -76,6 +74,11 @@ public class ConversationsListFragment extends Fragment implements AdapterView.O
*/
private openConversationListener openConvListener;
+ /**
+ * Conversation updater
+ */
+ private updateConversationListener updateConversationListener;
+
/**
* Conversation list adapter
*/
@@ -114,13 +117,23 @@ public class ConversationsListFragment extends Fragment implements AdapterView.O
//Refresh conversations list
refresh_conversations_list();
- //Set the open conversation listener
+ //Set the open and update conversation listener
try {
openConvListener = (openConversationListener) getActivity();
+ updateConversationListener = (updateConversationListener) getActivity();
} catch (ClassCastException e){
throw new ClassCastException(getActivity().toString() +
- " must implement OpenConversationListener");
+ " must implement OpenConversationListener and updateConversationListener");
}
+
+ //Set create conversation button listener
+ view.findViewById(R.id.fragment_conversationslist_create)
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ updateConversationListener.createConversation();
+ }
+ });
}
@Override
@@ -287,7 +300,7 @@ public class ConversationsListFragment extends Fragment implements AdapterView.O
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
MenuInflater inflater = getActivity().getMenuInflater();
- inflater.inflate(R.menu.menu_fragment_conserationslist_item, menu);
+ inflater.inflate(R.menu.menu_fragment_conversationslist_item, menu);
}
});
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
new file mode 100644
index 0000000..b9fbafa
--- /dev/null
+++ b/app/src/main/java/org/communiquons/android/comunic/client/fragments/UpdateConversationFragment.java
@@ -0,0 +1,94 @@
+package org.communiquons.android.comunic.client.fragments;
+
+import android.app.Fragment;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.CheckBox;
+import android.widget.ListView;
+import android.widget.TextView;
+
+import org.communiquons.android.comunic.client.MainActivity;
+import org.communiquons.android.comunic.client.R;
+
+/**
+ * Create and / or update a conversation fragment
+ *
+ * @author Pierre HUBERT
+ * Created by pierre on 1/1/18.
+ */
+
+public class UpdateConversationFragment extends Fragment {
+
+ /**
+ * The name of the conversation
+ */
+ private TextView nameView;
+
+ /**
+ * Follow a conversation checkbox
+ */
+ private CheckBox followCheckbox;
+
+ /**
+ * Members listview
+ */
+ private ListView membersList;
+
+ /**
+ * Add a member button
+ */
+ private Button addMember;
+
+ /**
+ * Submit the conversation button
+ */
+ private Button submitButton;
+
+ @Nullable
+ @Override
+ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
+ return inflater.inflate(R.layout.fragment_update_conversation, container, false);
+ }
+
+ @Override
+ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+
+ //Get the view
+ nameView = view.findViewById(R.id.fragment_update_conversation_name);
+ followCheckbox = view.findViewById(R.id.fragment_update_conversation_follow);
+ membersList = view.findViewById(R.id.fragment_update_conversation_members);
+ addMember = view.findViewById(R.id.fragment_update_conversation_addmember);
+ submitButton = view.findViewById(R.id.fragment_update_conversation_submit);
+
+ //Make add button lives
+ addMember.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ requestAddMember();
+ }
+ });
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+
+ //Update title and dock
+ getActivity().setTitle(R.string.fragment_update_conversation_title_create);
+ ((MainActivity) getActivity()).setSelectedNavigationItem(
+ R.id.main_bottom_navigation_conversations);
+ }
+
+ /**
+ * Create and submit an intent to add a user to the members list
+ */
+ private void requestAddMember(){
+
+ }
+
+}
diff --git a/app/src/main/res/layout/fragment_conversationslist.xml b/app/src/main/res/layout/fragment_conversationslist.xml
index b3f9fd3..e14df51 100644
--- a/app/src/main/res/layout/fragment_conversationslist.xml
+++ b/app/src/main/res/layout/fragment_conversationslist.xml
@@ -23,8 +23,9 @@
+ android:enabled="true" />
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_update_conversation.xml b/app/src/main/res/layout/fragment_update_conversation.xml
new file mode 100644
index 0000000..f940462
--- /dev/null
+++ b/app/src/main/res/layout/fragment_update_conversation.xml
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/menu/menu_fragment_conserationslist_item.xml b/app/src/main/res/menu/menu_fragment_conversationslist_item.xml
similarity index 100%
rename from app/src/main/res/menu/menu_fragment_conserationslist_item.xml
rename to app/src/main/res/menu/menu_fragment_conversationslist_item.xml
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index c176917..f0ee986 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -74,4 +74,9 @@
Cancel
Could not delete conversation !
No message yet.
+ Create a conversation
+ Conversation name
+ Create
+ Follow the conversation
+ Add a member