Moved chat related fragments to specific folder + fixed issue in resources + fixed click on remove icon which wasn't working

This commit is contained in:
Sylvain Berfini 2017-10-20 14:24:31 +02:00
parent 9097519b0f
commit 15cc7cf89e
17 changed files with 101 additions and 61 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

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/next" />
<item android:state_enabled="false"
android:drawable="@drawable/dialer_alt_next" />
</selector>

View file

@ -70,7 +70,7 @@
<ImageView
android:id="@+id/next"
android:src="@drawable/dialer_alt_next"
android:src="@drawable/chat_room_creation_next"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"

View file

@ -1,11 +1,5 @@
package org.linphone;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
/*
ContactSelectView.java
Copyright (C) 2017 Belledonne Communications, Grenoble, France
@ -25,15 +19,17 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
* Created by Erwan Croze.
*/
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
public class ContactSelectView extends View {
private TextView contactName;
private ImageView deleteContact;
ContactSelectView(Context context) {
public ContactSelectView(Context context) {
super(context);
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE );

View file

@ -53,10 +53,6 @@ import java.util.Locale;
import java.util.Set;
import java.util.concurrent.TimeUnit;
interface ContactsUpdatedListener {
void onContactsUpdated();
}
public class ContactsManager extends ContentObserver {
private static ContactsManager instance;

View file

@ -0,0 +1,24 @@
package org.linphone;
/*
ContactsUpdatedListener.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 interface ContactsUpdatedListener {
void onContactsUpdated();
}

View file

@ -65,8 +65,10 @@ import android.widget.Toast;
import org.linphone.LinphoneManager.AddressType;
import org.linphone.assistant.AssistantActivity;
import org.linphone.assistant.RemoteProvisioningLoginActivity;
import org.linphone.chat.ChatCreationFragment;
import org.linphone.chat.ChatFragment;
import org.linphone.chat.ChatListFragment;
import org.linphone.compatibility.Compatibility;
import org.linphone.core.Call.Dir;
import org.linphone.core.Address;
import org.linphone.core.AuthInfo;
import org.linphone.core.Call;
@ -77,7 +79,6 @@ import org.linphone.core.ChatMessage;
import org.linphone.core.ChatRoom;
import org.linphone.core.Core;
import org.linphone.core.Core.RegistrationState;
import org.linphone.core.CoreException;
import org.linphone.core.Factory;
import org.linphone.core.CoreListenerStub;
import org.linphone.core.ProxyConfig;
@ -144,7 +145,7 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
public String mAddressWaitingToBeCalled;
static final boolean isInstanciated() {
static public final boolean isInstanciated() {
return instance != null;
}

View file

@ -74,7 +74,7 @@ public class SearchContactsListAdapter extends BaseAdapter {
this.listener = listener;
}
SearchContactsListAdapter(List<ContactAddress> contactsList, LayoutInflater inflater, ProgressBar pB) {
public SearchContactsListAdapter(List<ContactAddress> contactsList, LayoutInflater inflater, ProgressBar pB) {
mInflater = inflater;
progressBar = pB;
setContactsSelectedList(null);

View file

@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package org.linphone;
package org.linphone.chat;
import android.app.Fragment;
import android.os.Bundle;
@ -35,13 +35,16 @@ import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
import org.linphone.ContactAddress;
import org.linphone.ContactSelectView;
import org.linphone.ContactsUpdatedListener;
import org.linphone.LinphoneActivity;
import org.linphone.R;
import org.linphone.SearchContactsListAdapter;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Erwan Croze.
*/
public class ChatCreationFragment extends Fragment implements View.OnClickListener, AdapterView.OnItemClickListener, ContactsUpdatedListener {
private LayoutInflater mInflater;
private ListView contactsList;
@ -62,39 +65,40 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mInflater = inflater;
View view = inflater.inflate(R.layout.create_chat, container, false);
contactsSelected = new ArrayList<ContactAddress>();
contactsSelected = new ArrayList<>();
noSipContact = (TextView) view.findViewById(R.id.noSipContact);
noContact = (TextView) view.findViewById(R.id.noContact);
noSipContact = view.findViewById(R.id.noSipContact);
noContact = view.findViewById(R.id.noContact);
contactsList = (ListView) view.findViewById(R.id.contactsList);
contactsSelectedLayout = (LinearLayout) view.findViewById(R.id.contactsSelected);
contactsSelectLayout = (HorizontalScrollView) view.findViewById(R.id.layoutContactsSelected);
contactsList = view.findViewById(R.id.contactsList);
contactsSelectedLayout = view.findViewById(R.id.contactsSelected);
contactsSelectLayout = view.findViewById(R.id.layoutContactsSelected);
allContacts = (ImageView) view.findViewById(R.id.all_contacts);
allContacts = view.findViewById(R.id.all_contacts);
allContacts.setOnClickListener(this);
linphoneContacts = (ImageView) view.findViewById(R.id.linphone_contacts);
linphoneContacts = view.findViewById(R.id.linphone_contacts);
linphoneContacts.setOnClickListener(this);
allContactsSelected = view.findViewById(R.id.all_contacts_select);
linphoneContactsSelected = view.findViewById(R.id.linphone_contacts_select);
back = (ImageView) view.findViewById(R.id.back);
back = view.findViewById(R.id.back);
back.setOnClickListener(this);
next = (ImageView) view.findViewById(R.id.next);
next = view.findViewById(R.id.next);
next.setOnClickListener(this);
next.setEnabled(false);
clearSearchField = (ImageView) view.findViewById(R.id.clearSearchField);
clearSearchField = view.findViewById(R.id.clearSearchField);
clearSearchField.setOnClickListener(this);
contactsFetchInProgress = (ProgressBar) view.findViewById(R.id.contactsFetchInProgress);
contactsFetchInProgress = view.findViewById(R.id.contactsFetchInProgress);
contactsFetchInProgress.setVisibility(View.VISIBLE);
searchAdapter = new SearchContactsListAdapter(null, mInflater, contactsFetchInProgress);
searchField = (EditText) view.findViewById(R.id.searchField);
searchField = view.findViewById(R.id.searchField);
searchField.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
@ -102,8 +106,7 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@ -157,9 +160,9 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
if (contactsSelected.size() > 0) {
contactsSelectLayout.setVisibility(View.VISIBLE);
contactsSelectLayout.invalidate();
next.setImageResource(R.drawable.next);
next.setEnabled(true);
} else {
next.setImageResource(R.drawable.dialer_alt_next);
next.setEnabled(false);
contactsSelectLayout.setVisibility(View.GONE);
}
}
@ -174,14 +177,16 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
private void updateContactsClick(ContactAddress ca, List<ContactAddress> caSelectedList) {
ca.setSelect((getIndexOfCa(ca, caSelectedList) == -1));
if(ca.isSelect()) {
if (ca.isSelect()) {
ContactSelectView csv = new ContactSelectView(LinphoneActivity.instance());
csv.setListener(this);
csv.setContactName(ca);
contactsSelected.add(ca);
View viewContact = LayoutInflater.from(LinphoneActivity.instance()).inflate(R.layout.contact_selected, null);
((TextView)viewContact.findViewById(R.id.sipUri)).setText(ca.getContact().getFullName());
viewContact.findViewById(R.id.contactChatDelete).setOnClickListener(this);
View removeContact = viewContact.findViewById(R.id.contactChatDelete);
removeContact.setTag(ca);
removeContact.setOnClickListener(this);
viewContact.setOnClickListener(this);
ca.setView(viewContact);
contactsSelectedLayout.addView(viewContact);
@ -197,13 +202,10 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
contactsSelectedLayout.invalidate();
}
private void removeContactFromView(View v) {
for (ContactAddress ca : contactsSelected) {
if (ca.getView() == v) {
ca.setSelect(false);
updateContactsClick(ca, searchAdapter.getContactsSelectedList());
}
}
private void removeContactFromSelection(ContactAddress ca) {
updateContactsClick(ca, searchAdapter.getContactsSelectedList());
updateList();
updateListSelected();
}
@Override
@ -250,9 +252,9 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
} else if (id == R.id.clearSearchField) {
searchField.setText("");
searchAdapter.searchContacts("", contactsList);
} else if (id == R.id.deleteContact) {
//TODO
removeContactFromView(view);
} else if (id == R.id.contactChatDelete) {
ContactAddress ca = (ContactAddress) view.getTag();
removeContactFromSelection(ca);
}
}
@ -260,9 +262,7 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
// Get contact
ContactAddress ca = searchAdapter.getContacts().get(i);
updateContactsClick(ca, searchAdapter.getContactsSelectedList());
updateList();
updateListSelected();
removeContactFromSelection(ca);
}
@Override

View file

@ -1,4 +1,4 @@
package org.linphone;
package org.linphone.chat;
/*
ChatFragment.java
@ -76,6 +76,15 @@ import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import org.linphone.ContactsManager;
import org.linphone.ContactsUpdatedListener;
import org.linphone.LinphoneActivity;
import org.linphone.LinphoneContact;
import org.linphone.LinphoneManager;
import org.linphone.LinphoneService;
import org.linphone.LinphoneUtils;
import org.linphone.R;
import org.linphone.SearchContactsListAdapter;
import org.linphone.compatibility.Compatibility;
import org.linphone.core.Address;
import org.linphone.core.Buffer;

View file

@ -1,4 +1,4 @@
package org.linphone;
package org.linphone.chat;
/*
ChatGroupCreationFragment.java

View file

@ -1,4 +1,4 @@
package org.linphone;
package org.linphone.chat;
/*
ChatListFragment.java
@ -43,14 +43,20 @@ import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import org.linphone.ContactsManager;
import org.linphone.ContactsUpdatedListener;
import org.linphone.FragmentsAvailable;
import org.linphone.LinphoneActivity;
import org.linphone.LinphoneContact;
import org.linphone.LinphoneManager;
import org.linphone.LinphoneUtils;
import org.linphone.R;
import org.linphone.core.Address;
import org.linphone.core.ChatMessage;
import org.linphone.core.ChatRoom;
import org.linphone.core.Core;
import org.linphone.core.CoreException;
import org.linphone.core.Factory;
import org.linphone.core.CoreListenerStub;
import org.linphone.mediastream.Log;
import java.util.List;