Merged createChat and createGroupChat views

This commit is contained in:
Sylvain Berfini 2017-10-23 11:02:41 +02:00
parent 6bf535ab37
commit 9a703ded12
8 changed files with 132 additions and 128 deletions

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="true"
android:drawable="@drawable/valid" />
<item android:state_enabled="false"
android:drawable="@drawable/valid_disabled" />
</selector>

View file

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/colorH" >
<LinearLayout
@ -75,7 +76,18 @@
android:layout_height="match_parent"
android:layout_weight="0.2"
android:background="@drawable/toolbar_button"
android:contentDescription="@string/content_description_back"
android:contentDescription="@string/content_description_valid"
android:padding="18dp"
android:layout_gravity="right"/>
<ImageView
android:id="@+id/confirm"
android:src="@drawable/chat_room_creation_confirm"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:background="@drawable/toolbar_button"
android:contentDescription="@string/content_description_valid"
android:padding="18dp"
android:layout_gravity="right"/>
@ -83,7 +95,6 @@
<RelativeLayout
android:id="@+id/layoutSearchField"
android:layout_below="@+id/top_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp">
@ -112,11 +123,31 @@
</RelativeLayout>
<RelativeLayout
android:id="@+id/layoutSubjectField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp">
<EditText
android:id="@+id/subjectField"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="@drawable/resizable_textfield"
android:contentDescription="@string/content_description_conversation_subject"
android:hint="@string/conversation_subject_hint"
android:gravity="center"
android:inputType="textEmailSubject"
android:paddingRight="5dp"
android:textColor="@android:color/black"
android:textCursorDrawable="@null"/>
</RelativeLayout>
<HorizontalScrollView
android:id="@+id/layoutContactsSelected"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_below="@+id/layoutSearchField"
android:layout_marginTop="5dp"
android:background="@drawable/resizable_textfield"
android:lines="1"
@ -180,5 +211,4 @@
</RelativeLayout>
</RelativeLayout>
</LinearLayout>

View file

@ -1,69 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorH" >
<LinearLayout
android:id="@+id/top_bar"
android:orientation="horizontal"
android:layout_gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_height="60dp">
<ImageView
android:id="@+id/back"
android:src="@drawable/back"
android:background="@drawable/toolbar_button"
android:contentDescription="@string/content_description_back"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:padding="18dp"/>
<TextView
style="@style/font6"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.6"
android:background="@drawable/toolbar_button"
android:gravity="center"
android:text="@string/conversation_information"/>
<ImageView
android:id="@+id/valid"
android:src="@drawable/valid_disabled"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:background="@drawable/toolbar_button"
android:contentDescription="@string/content_description_back"
android:padding="18dp"
android:layout_gravity="end"/>
</LinearLayout>
<RelativeLayout
android:id="@+id/layoutSearchField"
android:layout_below="@+id/top_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp">
<EditText
android:id="@+id/searchField"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="@drawable/resizable_textfield"
android:contentDescription="@string/content_description_search_contact"
android:gravity="center"
android:inputType="textPersonName"
android:paddingRight="5dp"
android:textColor="@android:color/black"
android:textCursorDrawable="@null"/>
</RelativeLayout>
</RelativeLayout>

View file

@ -191,6 +191,7 @@
<string name="resend">Resend</string>
<string name="conversation_information">Conversation Infos</string>
<string name="administrator">Admin</string>
<string name="conversation_subject_hint">Name your group</string>
<!-- Status Bar -->
<string name="status_connected">Registered</string>
@ -489,4 +490,5 @@
<string name="content_description_exit_conference">Exit conference</string>
<string name="content_title_notification_service">Linphone Service</string>
<string name="content_title_notification">Linphone Notification</string>
<string name="content_description_conversation_subject">Group chat room subject</string>
</resources>

View file

@ -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;

View file

@ -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<ContactAddress> 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);
}

View file

@ -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) {
}
}

View file

@ -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: