diff --git a/res/drawable/chat_room_creation_confirm.xml b/res/drawable/chat_room_creation_confirm.xml new file mode 100644 index 000000000..4ed8dd63b --- /dev/null +++ b/res/drawable/chat_room_creation_confirm.xml @@ -0,0 +1,8 @@ + + + + + + diff --git a/res/layout/create_chat.xml b/res/layout/create_chat.xml index b61eae178..dd5eae08a 100644 --- a/res/layout/create_chat.xml +++ b/res/layout/create_chat.xml @@ -1,7 +1,8 @@ - + + @@ -83,7 +95,6 @@ @@ -112,11 +123,31 @@ + + + + + + - - \ No newline at end of file + \ No newline at end of file diff --git a/res/layout/create_chat_group.xml b/res/layout/create_chat_group.xml deleted file mode 100644 index 3166b097d..000000000 --- a/res/layout/create_chat_group.xml +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index 36a3d5242..86d53c7f7 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -191,6 +191,7 @@ Resend Conversation Infos Admin + Name your group Registered @@ -489,4 +490,5 @@ Exit conference Linphone Service Linphone Notification + Group chat room subject diff --git a/src/android/org/linphone/activities/LinphoneActivity.java b/src/android/org/linphone/activities/LinphoneActivity.java index 6fb63df29..a0845a57a 100644 --- a/src/android/org/linphone/activities/LinphoneActivity.java +++ b/src/android/org/linphone/activities/LinphoneActivity.java @@ -830,6 +830,8 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick break; case CHAT_LIST: case CREATE_CHAT: + case GROUP_CHAT: + case INFO_GROUP_CHAT: case CHAT: chat_selected.setVisibility(View.VISIBLE); break; diff --git a/src/android/org/linphone/chat/ChatCreationFragment.java b/src/android/org/linphone/chat/ChatCreationFragment.java index 4abe723ca..ee3a27207 100644 --- a/src/android/org/linphone/chat/ChatCreationFragment.java +++ b/src/android/org/linphone/chat/ChatCreationFragment.java @@ -22,7 +22,9 @@ package org.linphone.chat; import android.app.Fragment; import android.os.Bundle; import android.text.Editable; +import android.text.Layout; import android.text.TextWatcher; +import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -33,6 +35,7 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ListView; import android.widget.ProgressBar; +import android.widget.RelativeLayout; import android.widget.TextView; import org.linphone.contacts.ContactAddress; @@ -49,26 +52,26 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen private ListView contactsList; private LinearLayout contactsSelectedLayout; private HorizontalScrollView contactsSelectLayout; - private TextView noSipContact, noContact; private List contactsSelected; private ImageView allContacts, linphoneContacts; private boolean onlyDisplayLinphoneContacts; private View allContactsSelected, linphoneContactsSelected; + private RelativeLayout searchLayout, subjectLayout; private ImageView clearSearchField; - private EditText searchField; + private EditText searchField, subjectField; private ProgressBar contactsFetchInProgress; private SearchContactsListAdapter searchAdapter; - private ImageView back, next; + private ImageView back, next, confirm; + private boolean displayChatGroupCreation; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + displayChatGroupCreation = false; + mInflater = inflater; View view = inflater.inflate(R.layout.create_chat, container, false); contactsSelected = new ArrayList<>(); - noSipContact = view.findViewById(R.id.noSipContact); - noContact = view.findViewById(R.id.noContact); - contactsList = view.findViewById(R.id.contactsList); contactsSelectedLayout = view.findViewById(R.id.contactsSelected); contactsSelectLayout = view.findViewById(R.id.layoutContactsSelected); @@ -89,6 +92,31 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen next.setOnClickListener(this); next.setEnabled(false); + confirm = view.findViewById(R.id.confirm); + confirm.setOnClickListener(this); + confirm.setEnabled(false); + + searchLayout = view.findViewById(R.id.layoutSearchField); + + subjectLayout = view.findViewById(R.id.layoutSubjectField); + subjectField = view.findViewById(R.id.subjectField); + subjectField.addTextChangedListener(new TextWatcher() { + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + + } + + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + + } + + @Override + public void afterTextChanged(Editable s) { + confirm.setEnabled(subjectField.getText().length() > 0); + } + }); + clearSearchField = view.findViewById(R.id.clearSearchField); clearSearchField.setOnClickListener(this); @@ -133,23 +161,53 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen if (savedInstanceState != null ) { onlyDisplayLinphoneContacts = savedInstanceState.getBoolean("onlySipContact"); - if (onlyDisplayLinphoneContacts) { - allContactsSelected.setVisibility(View.INVISIBLE); - linphoneContactsSelected.setVisibility(View.VISIBLE); - } else { - allContactsSelected.setVisibility(View.VISIBLE); - linphoneContactsSelected.setVisibility(View.INVISIBLE); - } updateList(); } - searchAdapter.setOnlySipContact(onlyDisplayLinphoneContacts); - allContacts.setEnabled(onlyDisplayLinphoneContacts); - linphoneContacts.setEnabled(!allContacts.isEnabled()); + + displayChatCreation(); return view; } + private void displayChatGroupCreation() { + displayChatGroupCreation = true; + confirm.setVisibility(View.VISIBLE); + confirm.setEnabled(subjectField.getText().length() > 0); + next.setVisibility(View.GONE); + + subjectLayout.setVisibility(View.VISIBLE); + contactsList.setVisibility(View.GONE); + searchLayout.setVisibility(View.GONE); + allContacts.setVisibility(View.INVISIBLE); + linphoneContacts.setVisibility(View.INVISIBLE); + allContactsSelected.setVisibility(View.INVISIBLE); + linphoneContactsSelected.setVisibility(View.INVISIBLE); + } + + private void displayChatCreation() { + displayChatGroupCreation = false; + next.setVisibility(View.VISIBLE); + next.setEnabled(contactsSelected.size() > 0); + confirm.setVisibility(View.GONE); + + subjectLayout.setVisibility(View.GONE); + contactsList.setVisibility(View.VISIBLE); + searchLayout.setVisibility(View.VISIBLE); + allContacts.setVisibility(View.VISIBLE); + linphoneContacts.setVisibility(View.VISIBLE); + if (onlyDisplayLinphoneContacts) { + allContactsSelected.setVisibility(View.INVISIBLE); + linphoneContactsSelected.setVisibility(View.VISIBLE); + } else { + allContactsSelected.setVisibility(View.VISIBLE); + linphoneContactsSelected.setVisibility(View.INVISIBLE); + } + + allContacts.setEnabled(onlyDisplayLinphoneContacts); + linphoneContacts.setEnabled(!allContacts.isEnabled()); + } + private void updateList() { searchAdapter.searchContacts(searchField.getText().toString(), contactsList); searchAdapter.notifyDataSetChanged(); @@ -240,14 +298,19 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen allContactsSelected.setVisibility(View.INVISIBLE); updateList(); } else if (id == R.id.back) { - getFragmentManager().popBackStackImmediate(); + if (displayChatGroupCreation) { + displayChatCreation(); + } else { + getFragmentManager().popBackStackImmediate(); + } } else if (id == R.id.next) { - //TODO aller selon le nombre de selectionner en chat ou en groupe if (contactsSelected.size() == 1) { LinphoneActivity.instance().displayChat(contactsSelected.get(0).getAddress(), "", ""); } else { - + displayChatGroupCreation(); } + } else if (id == R.id.confirm) { + //TODO } else if (id == R.id.clearSearchField) { searchField.setText(""); searchAdapter.searchContacts("", contactsList); @@ -259,7 +322,6 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen @Override public void onItemClick(AdapterView adapterView, View view, int i, long l) { - // Get contact ContactAddress ca = searchAdapter.getContacts().get(i); removeContactFromSelection(ca); } diff --git a/src/android/org/linphone/chat/ChatGroupCreationFragment.java b/src/android/org/linphone/chat/ChatGroupCreationFragment.java deleted file mode 100644 index ca36a29c8..000000000 --- a/src/android/org/linphone/chat/ChatGroupCreationFragment.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.linphone.chat; - -/* -ChatGroupCreationFragment.java -Copyright (C) 2017 Belledonne Communications, Grenoble, France - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -import android.app.Fragment; -import android.view.View; - -public class ChatGroupCreationFragment extends Fragment implements View.OnClickListener { - - @Override - public void onClick(View view) { - - } -} diff --git a/src/android/org/linphone/fragments/FragmentsAvailable.java b/src/android/org/linphone/fragments/FragmentsAvailable.java index 70fa3a5d8..f6c3d5a4b 100644 --- a/src/android/org/linphone/fragments/FragmentsAvailable.java +++ b/src/android/org/linphone/fragments/FragmentsAvailable.java @@ -72,9 +72,9 @@ public enum FragmentsAvailable { return SETTINGS.isRightOf(fragment) || fragment == SETTINGS; case CHAT: - return CHAT_LIST.isRightOf(fragment) || fragment == CHAT_LIST; - case CREATE_CHAT: + case GROUP_CHAT: + case INFO_GROUP_CHAT: return CHAT_LIST.isRightOf(fragment) || fragment == CHAT_LIST; default: