From b3f4fd0f62e11c273f9f1e008add38f56112e7cf Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Thu, 12 Oct 2017 15:32:28 +0200 Subject: [PATCH] Adding new views --- res/layout/group_contact_cell.xml | 72 +++++++------- .../org/linphone/ChatCreationFragment.java | 5 + src/android/org/linphone/ChatFragment.java | 6 +- src/android/org/linphone/ContactAddress.java | 9 ++ .../org/linphone/FragmentsAvailable.java | 4 +- .../org/linphone/GroupChatFragment.java | 43 +++++++++ .../linphone/GroupContactsListAdapter.java | 94 +++++++++++++++++++ .../org/linphone/InfoGroupChatFragment.java | 43 +++++++++ .../org/linphone/LinphoneActivity.java | 21 +++++ 9 files changed, 259 insertions(+), 38 deletions(-) create mode 100644 src/android/org/linphone/GroupChatFragment.java create mode 100644 src/android/org/linphone/GroupContactsListAdapter.java create mode 100644 src/android/org/linphone/InfoGroupChatFragment.java diff --git a/res/layout/group_contact_cell.xml b/res/layout/group_contact_cell.xml index 00770099f..87520762d 100644 --- a/res/layout/group_contact_cell.xml +++ b/res/layout/group_contact_cell.xml @@ -1,43 +1,49 @@ - + + + + + + + + - - - - - - + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:layout_marginLeft="10dp" /> + android:layout_toLeftOf="@id/remove"> 200) { showKeyboardVisibleMode(); } else { diff --git a/src/android/org/linphone/ContactAddress.java b/src/android/org/linphone/ContactAddress.java index 2af1799e9..0ff0b2b8b 100644 --- a/src/android/org/linphone/ContactAddress.java +++ b/src/android/org/linphone/ContactAddress.java @@ -28,8 +28,17 @@ public class ContactAddress implements Serializable { private String address; private boolean isLinphoneContact; private boolean isSelect = false; + private boolean isAdmin = false; private View view; + public boolean isAdmin() { + return isAdmin; + } + + public void setAdmin(boolean admin) { + isAdmin = admin; + } + public boolean isSelect() { return isSelect; } diff --git a/src/android/org/linphone/FragmentsAvailable.java b/src/android/org/linphone/FragmentsAvailable.java index 82c13a95a..65f07ba28 100644 --- a/src/android/org/linphone/FragmentsAvailable.java +++ b/src/android/org/linphone/FragmentsAvailable.java @@ -34,7 +34,9 @@ public enum FragmentsAvailable { SETTINGS, CHAT_LIST, CHAT, - CREATE_CHAT; + CREATE_CHAT, + INFO_GROUP_CHAT, + GROUP_CHAT; public boolean shouldAnimate() { return true; diff --git a/src/android/org/linphone/GroupChatFragment.java b/src/android/org/linphone/GroupChatFragment.java new file mode 100644 index 000000000..e71417de2 --- /dev/null +++ b/src/android/org/linphone/GroupChatFragment.java @@ -0,0 +1,43 @@ +package org.linphone; + +import android.app.Fragment; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +/* +GroupChatFragment.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. +*/ + +public class GroupChatFragment extends Fragment implements View.OnClickListener { + private LayoutInflater mInflater; + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + mInflater = inflater; + View view = inflater.inflate(R.layout.create_chat, container, false); + + return view; + } + + @Override + public void onClick(View view) { + + } +} diff --git a/src/android/org/linphone/GroupContactsListAdapter.java b/src/android/org/linphone/GroupContactsListAdapter.java new file mode 100644 index 000000000..31eef9dde --- /dev/null +++ b/src/android/org/linphone/GroupContactsListAdapter.java @@ -0,0 +1,94 @@ +package org.linphone; + +/* +GroupContactsListAdapter.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.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; +import android.widget.ImageView; +import android.widget.TextView; + +import java.util.List; + +public class GroupContactsListAdapter extends BaseAdapter { + private class ViewHolder { + public TextView name; + public TextView admin; + public ImageView linphoneContact; + public ImageView isAdmin; + public ImageView photo; + + public ViewHolder(View view) { + name = (TextView) view.findViewById(R.id.sip_uri); + linphoneContact = (ImageView) view.findViewById(R.id.contact_linphone); + isAdmin = (ImageView) view.findViewById(R.id.contact_is_select); + admin = (TextView) view.findViewById(R.id.admin); + photo = (ImageView) view.findViewById(R.id.contact_picture); + } + } + + public List getGroupContacts() { + return groupContacts; + } + + public void setGroupContacts(List groupContacts) { + this.groupContacts = groupContacts; + } + + private List groupContacts; + private LayoutInflater mInflater; + + public GroupContactsListAdapter(LayoutInflater inf) { + mInflater = inf; + } + + @Override + public int getCount() { + return groupContacts.size(); + } + + @Override + public Object getItem(int i) { + return groupContacts.get(i); + } + + @Override + public long getItemId(int i) { + return i; + } + + @Override + public View getView(int i, View convertView, ViewGroup parent) { + View view; + ViewHolder holder; + + if (convertView != null) { + view = convertView; + holder = (ViewHolder) view.getTag(); + } else { + view = mInflater.inflate(R.layout.search_contact_cell, parent, false); + holder = new ViewHolder(view); + view.setTag(holder); + } + + return view; + } +} diff --git a/src/android/org/linphone/InfoGroupChatFragment.java b/src/android/org/linphone/InfoGroupChatFragment.java new file mode 100644 index 000000000..9f691be6b --- /dev/null +++ b/src/android/org/linphone/InfoGroupChatFragment.java @@ -0,0 +1,43 @@ +package org.linphone; + +/* +InfoGroupChatFragment.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.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +public class InfoGroupChatFragment extends Fragment implements View.OnClickListener { + private LayoutInflater mInflater; + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + mInflater = inflater; + View view = inflater.inflate(R.layout.create_chat, container, false); + + return view; + } + + @Override + public void onClick(View view) { + + } +} diff --git a/src/android/org/linphone/LinphoneActivity.java b/src/android/org/linphone/LinphoneActivity.java index 2d0fb9f65..32e0afc14 100644 --- a/src/android/org/linphone/LinphoneActivity.java +++ b/src/android/org/linphone/LinphoneActivity.java @@ -409,6 +409,12 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick case CREATE_CHAT: fragment = new ChatCreationFragment(); break; + case INFO_GROUP_CHAT: + fragment = new InfoGroupChatFragment(); + break; + case GROUP_CHAT: + fragment = new GroupChatFragment(); + break; default: break; } @@ -650,6 +656,21 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick return count; } + public void displayInfoChat(List list) { + Bundle extras = new Bundle(); + ArrayList listUri = new ArrayList(); + if (LinphoneManager.isInstanciated() && LinphoneManager.getLc() != null + && LinphoneManager.getLc().getDefaultProxyConfig() != null + && LinphoneManager.getLc().getDefaultProxyConfig().getIdentity() != null) { + listUri.add(LinphoneManager.getLc().getDefaultProxyConfig().getAddress().asStringUriOnly()); + } + for (ContactAddress ca : list) { + listUri.add(ca.getAddress()); + } + extras.putStringArrayList("contactsSelected", listUri); + changeCurrentFragment(FragmentsAvailable.INFO_GROUP_CHAT, extras); + } + private void displayChat(String sipUri, String message, String fileUri, String pictureUri, String thumbnailUri, String displayName, LinphoneAddress lAddress) { Bundle extras = new Bundle(); extras.putString("SipUri", sipUri);