Fixed presence with phone numbers
This commit is contained in:
parent
62825a6171
commit
1612e4b376
7 changed files with 26 additions and 21 deletions
|
@ -99,7 +99,6 @@ import org.linphone.core.AuthInfo;
|
|||
import org.linphone.core.Call;
|
||||
import org.linphone.core.Call.State;
|
||||
import org.linphone.core.CallLog;
|
||||
import org.linphone.core.Call.Status;
|
||||
import org.linphone.core.ChatMessage;
|
||||
import org.linphone.core.ChatRoom;
|
||||
import org.linphone.core.Core;
|
||||
|
@ -689,7 +688,7 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
listUri.add(LinphoneManager.getLc().getDefaultProxyConfig().getIdentityAddress().asStringUriOnly());
|
||||
}
|
||||
for (ContactAddress ca : list) {
|
||||
listUri.add(ca.getAddress());
|
||||
listUri.add(ca.getAddressAsDisplayableString());
|
||||
}
|
||||
extras.putStringArrayList("contactsSelected", listUri);
|
||||
changeCurrentFragment(FragmentsAvailable.INFO_GROUP_CHAT, extras);
|
||||
|
|
|
@ -19,7 +19,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
|
||||
package org.linphone.chat;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.app.Fragment;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
|
@ -28,7 +27,6 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.HorizontalScrollView;
|
||||
import android.widget.ImageView;
|
||||
|
@ -45,7 +43,6 @@ import org.linphone.core.Address;
|
|||
import org.linphone.core.ChatRoom;
|
||||
import org.linphone.core.ChatRoomListenerStub;
|
||||
import org.linphone.core.Core;
|
||||
import org.linphone.core.Factory;
|
||||
import org.linphone.mediastream.Log;
|
||||
import org.linphone.ui.ContactSelectView;
|
||||
import org.linphone.contacts.ContactsUpdatedListener;
|
||||
|
@ -143,7 +140,7 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
|||
// We need to get all contacts not only sip
|
||||
for (String uri : savedInstanceState.getStringArrayList("mContactsSelected")) {
|
||||
for (ContactAddress ca : mSearchAdapter.getContactsList()) {
|
||||
if (ca.getAddress().compareTo(uri) == 0) {
|
||||
if (ca.getAddressAsDisplayableString().compareTo(uri) == 0) {
|
||||
ca.setView(null);
|
||||
addSelectedContactAddress(ca);
|
||||
break;
|
||||
|
@ -210,7 +207,7 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
|||
|
||||
private int getIndexOfCa(ContactAddress ca, List<ContactAddress> caList) {
|
||||
for (int i = 0 ; i < caList.size() ; i++) {
|
||||
if (caList.get(i).getAddress().compareTo(ca.getAddress()) == 0)
|
||||
if (caList.get(i).getAddressAsDisplayableString().compareTo(ca.getAddressAsDisplayableString()) == 0)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
|
@ -221,7 +218,7 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
|||
if (ca.getContact() != null) {
|
||||
((TextView) viewContact.findViewById(R.id.sipUri)).setText(ca.getContact().getFullName());
|
||||
} else {
|
||||
((TextView) viewContact.findViewById(R.id.sipUri)).setText(ca.getAddress());
|
||||
((TextView) viewContact.findViewById(R.id.sipUri)).setText(ca.getAddressAsDisplayableString());
|
||||
}
|
||||
View removeContact = viewContact.findViewById(R.id.contactChatDelete);
|
||||
removeContact.setTag(ca);
|
||||
|
@ -264,7 +261,7 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
|||
if (mContactsSelected != null && mContactsSelected.size() > 0) {
|
||||
ArrayList<String> listUri = new ArrayList<String>();
|
||||
for (ContactAddress ca : mContactsSelected) {
|
||||
listUri.add(ca.getAddress());
|
||||
listUri.add(ca.getAddressAsDisplayableString());
|
||||
}
|
||||
outState.putStringArrayList("mContactsSelected", listUri);
|
||||
}
|
||||
|
@ -300,7 +297,7 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
|||
mContactsSelectedLayout.removeAllViews();
|
||||
mWaitLayout.setVisibility(View.VISIBLE);
|
||||
Core lc = LinphoneManager.getLc();
|
||||
Address participant = Factory.instance().createAddress(mContactsSelected.get(0).getAddress());
|
||||
Address participant = mContactsSelected.get(0).getAddress();
|
||||
ChatRoom chatRoom = lc.findOneToOneChatRoom(lc.getDefaultProxyConfig().getContact(), participant);
|
||||
if (chatRoom == null) {
|
||||
chatRoom = lc.createClientGroupChatRoom(getString(R.string.dummy_group_chat_subject));
|
||||
|
|
|
@ -190,7 +190,7 @@ public class GroupInfoFragment extends Fragment implements ChatRoomListener {
|
|||
Address addresses[] = new Address[mParticipants.size()];
|
||||
int index = 0;
|
||||
for (ContactAddress ca : mParticipants) {
|
||||
addresses[index] = LinphoneManager.getLc().createAddress(ca.getAddress());
|
||||
addresses[index] = LinphoneManager.getLc().createAddress(ca.getAddressAsDisplayableString());
|
||||
index++;
|
||||
}
|
||||
chatRoom.addParticipants(addresses);
|
||||
|
@ -206,7 +206,7 @@ public class GroupInfoFragment extends Fragment implements ChatRoomListener {
|
|||
for (Participant p : mChatRoom.getParticipants()) {
|
||||
boolean found = false;
|
||||
for (ContactAddress c : mParticipants) {
|
||||
if (c.getAddress().equals(p.getAddress().asStringUriOnly())) {
|
||||
if (c.getAddressAsDisplayableString().equals(p.getAddress().asStringUriOnly())) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
@ -224,7 +224,7 @@ public class GroupInfoFragment extends Fragment implements ChatRoomListener {
|
|||
for (ContactAddress c : mParticipants) {
|
||||
boolean found = false;
|
||||
for (Participant p : mChatRoom.getParticipants()) {
|
||||
if (p.getAddress().asStringUriOnly().equals(c.getAddress())) {
|
||||
if (p.getAddress().asStringUriOnly().equals(c.getAddressAsDisplayableString())) {
|
||||
// Admin rights
|
||||
if (c.isAdmin() != p.isAdmin()) {
|
||||
mChatRoom.setParticipantAdminStatus(p, c.isAdmin());
|
||||
|
@ -234,7 +234,7 @@ public class GroupInfoFragment extends Fragment implements ChatRoomListener {
|
|||
}
|
||||
}
|
||||
if (!found) {
|
||||
Address addr = LinphoneManager.getLc().createAddress(c.getAddress());
|
||||
Address addr = LinphoneManager.getLc().createAddress(c.getAddressAsDisplayableString());
|
||||
if (addr != null) {
|
||||
toAdd.add(addr);
|
||||
} else {
|
||||
|
|
|
@ -21,6 +21,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
|
||||
import android.view.View;
|
||||
|
||||
import org.linphone.core.Address;
|
||||
import org.linphone.core.Factory;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class ContactAddress implements Serializable {
|
||||
|
@ -55,10 +58,15 @@ public class ContactAddress implements Serializable {
|
|||
return contact;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
public String getAddressAsDisplayableString() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public Address getAddress() {
|
||||
String presence = contact.getPresenceModelForUriOrTel(address);
|
||||
return Factory.instance().createAddress(presence != null ? presence : address);
|
||||
}
|
||||
|
||||
public void setSelect(boolean select) {
|
||||
isSelect = select;
|
||||
}
|
||||
|
@ -85,7 +93,7 @@ public class ContactAddress implements Serializable {
|
|||
if (other == null) return false;
|
||||
if (other == this) return true;
|
||||
if (!(other instanceof ContactAddress))return false;
|
||||
if (((ContactAddress)other).getAddress() == this.getAddress()) return true;
|
||||
if (((ContactAddress)other).getAddressAsDisplayableString() == this.getAddressAsDisplayableString()) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,6 +104,7 @@ public class ContactsManager extends ContentObserver {
|
|||
onChange(selfChange, null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onChange(boolean selfChange, Uri uri) {
|
||||
fetchContactsSync();
|
||||
|
|
|
@ -86,7 +86,7 @@ public class SearchContactsListAdapter extends BaseAdapter {
|
|||
|
||||
private boolean contactIsSelected(ContactAddress ca) {
|
||||
for (ContactAddress c : contactsSelected) {
|
||||
if (c.getAddress().compareTo(ca.getAddress()) == 0) return true;
|
||||
if (c.getAddressAsDisplayableString().compareTo(ca.getAddressAsDisplayableString()) == 0) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ public class SearchContactsListAdapter extends BaseAdapter {
|
|||
boolean searchFound = false;
|
||||
if (search != null) {
|
||||
for (ContactAddress c : (search.length() < oldSize) ? getContactsList() : getContacts()) {
|
||||
String address = c.getAddress();
|
||||
String address = c.getAddressAsDisplayableString();
|
||||
if (address.equals(searchAddress)) searchFound = true;
|
||||
if (address.startsWith("sip:")) address = address.substring(4);
|
||||
if (c.getContact() != null && c.getContact().getFullName() != null
|
||||
|
@ -204,7 +204,7 @@ public class SearchContactsListAdapter extends BaseAdapter {
|
|||
}
|
||||
|
||||
ContactAddress contact = getItem(position);
|
||||
final String a = contact.getAddress();
|
||||
final String a = contact.getAddressAsDisplayableString();
|
||||
LinphoneContact c = contact.getContact();
|
||||
|
||||
holder.avatar.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
|
||||
|
|
|
@ -49,8 +49,8 @@ public class ContactSelectView extends View {
|
|||
if (ca.getContact() != null) {
|
||||
contactName.setText(ca.getContact().getFirstName());
|
||||
} else {
|
||||
LinphoneManager.getLc().createFriendWithAddress(ca.getAddress()).getName();
|
||||
contactName.setText(ca.getAddress());
|
||||
LinphoneManager.getLc().createFriendWithAddress(ca.getAddressAsDisplayableString()).getName();
|
||||
contactName.setText(ca.getAddressAsDisplayableString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue