Fix username and displayname for none contact in chat group
This commit is contained in:
parent
e97429174f
commit
facac17734
4 changed files with 32 additions and 6 deletions
|
@ -288,7 +288,11 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
||||||
private void addSelectedContactAddress(ContactAddress ca) {
|
private void addSelectedContactAddress(ContactAddress ca) {
|
||||||
View viewContact = LayoutInflater.from(LinphoneActivity.instance()).inflate(R.layout.contact_selected, null);
|
View viewContact = LayoutInflater.from(LinphoneActivity.instance()).inflate(R.layout.contact_selected, null);
|
||||||
if (ca.getContact() != null) {
|
if (ca.getContact() != null) {
|
||||||
((TextView) viewContact.findViewById(R.id.sipUri)).setText(ca.getContact().getFullName());
|
String name = (ca.getContact().getFullName() != null && !ca.getContact().getFullName().isEmpty()) ?
|
||||||
|
ca.getContact().getFullName() : (ca.getDisplayName() != null) ?
|
||||||
|
ca.getDisplayName() : (ca.getUsername() != null) ?
|
||||||
|
ca.getUsername() : "";
|
||||||
|
((TextView) viewContact.findViewById(R.id.sipUri)).setText(name);
|
||||||
} else {
|
} else {
|
||||||
((TextView) viewContact.findViewById(R.id.sipUri)).setText(ca.getAddressAsDisplayableString());
|
((TextView) viewContact.findViewById(R.id.sipUri)).setText(ca.getAddressAsDisplayableString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,8 @@ public class GroupInfoAdapter extends BaseAdapter {
|
||||||
final LinearLayout isAdmin = view.findViewById(R.id.isAdminLayout);
|
final LinearLayout isAdmin = view.findViewById(R.id.isAdminLayout);
|
||||||
final LinearLayout isNotAdmin = view.findViewById(R.id.isNotAdminLayout);
|
final LinearLayout isNotAdmin = view.findViewById(R.id.isNotAdminLayout);
|
||||||
|
|
||||||
name.setText(c.getFullName());
|
name.setText((c.getFullName() != null) ? c.getFullName() :
|
||||||
|
(ca.getDisplayName() != null) ? ca.getDisplayName() : ca.getUsername());
|
||||||
if (c.hasPhoto()) {
|
if (c.hasPhoto()) {
|
||||||
LinphoneUtils.setThumbnailPictureFromUri(LinphoneActivity.instance(), avatar, c.getThumbnailUri());
|
LinphoneUtils.setThumbnailPictureFromUri(LinphoneActivity.instance(), avatar, c.getThumbnailUri());
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,6 +85,26 @@ public class ContactAddress implements Serializable {
|
||||||
return addr;
|
return addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDisplayName() {
|
||||||
|
if (address != null) {
|
||||||
|
Address addr = Factory.instance().createAddress(address);
|
||||||
|
if (addr != null) {
|
||||||
|
return addr.getDisplayName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
if (address != null) {
|
||||||
|
Address addr = Factory.instance().createAddress(address);
|
||||||
|
if (addr != null) {
|
||||||
|
return addr.getUsername();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public String getPhoneNumber() {
|
public String getPhoneNumber() {
|
||||||
return phoneNumber;
|
return phoneNumber;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.linphone.LinphoneUtils;
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
import org.linphone.activities.LinphoneActivity;
|
import org.linphone.activities.LinphoneActivity;
|
||||||
import org.linphone.core.Address;
|
import org.linphone.core.Address;
|
||||||
|
import org.linphone.core.Factory;
|
||||||
import org.linphone.core.ProxyConfig;
|
import org.linphone.core.ProxyConfig;
|
||||||
import org.linphone.core.SearchResult;
|
import org.linphone.core.SearchResult;
|
||||||
|
|
||||||
|
@ -63,7 +64,6 @@ public class SearchContactsListAdapter extends BaseAdapter {
|
||||||
private ProgressBar progressBar;
|
private ProgressBar progressBar;
|
||||||
private boolean mOnlySipContact = false;
|
private boolean mOnlySipContact = false;
|
||||||
private View.OnClickListener listener;
|
private View.OnClickListener listener;
|
||||||
private int oldSize;
|
|
||||||
|
|
||||||
public List<ContactAddress> getContacts() {
|
public List<ContactAddress> getContacts() {
|
||||||
return contacts;
|
return contacts;
|
||||||
|
@ -82,7 +82,6 @@ public class SearchContactsListAdapter extends BaseAdapter {
|
||||||
progressBar = pB;
|
progressBar = pB;
|
||||||
setContactsSelectedList(null);
|
setContactsSelectedList(null);
|
||||||
setContactsList(contactsList);
|
setContactsList(contactsList);
|
||||||
oldSize = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean contactIsSelected(ContactAddress ca) {
|
private boolean contactIsSelected(ContactAddress ca) {
|
||||||
|
@ -172,7 +171,6 @@ public class SearchContactsListAdapter extends BaseAdapter {
|
||||||
if (ContactsManager.getInstance() != null) {
|
if (ContactsManager.getInstance() != null) {
|
||||||
ContactsManager.getInstance().getMagicSearch().resetSearchCache();
|
ContactsManager.getInstance().getMagicSearch().resetSearchCache();
|
||||||
}
|
}
|
||||||
oldSize = 0;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,7 +211,6 @@ public class SearchContactsListAdapter extends BaseAdapter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
oldSize = search.length();
|
|
||||||
contacts = result;
|
contacts = result;
|
||||||
resultContactsSearch.setAdapter(this);
|
resultContactsSearch.setAdapter(this);
|
||||||
this.notifyDataSetChanged();
|
this.notifyDataSetChanged();
|
||||||
|
@ -256,6 +253,10 @@ public class SearchContactsListAdapter extends BaseAdapter {
|
||||||
holder.name.setVisibility(View.VISIBLE);
|
holder.name.setVisibility(View.VISIBLE);
|
||||||
holder.name.setText(contact.getAddress().getDisplayName());
|
holder.name.setText(contact.getAddress().getDisplayName());
|
||||||
}
|
}
|
||||||
|
} else if (address != null) {
|
||||||
|
Address tmpAddr = Factory.instance().createAddress(address);
|
||||||
|
holder.name.setVisibility(View.VISIBLE);
|
||||||
|
holder.name.setText((tmpAddr.getDisplayName() != null) ? tmpAddr.getDisplayName() : tmpAddr.getUsername()) ;
|
||||||
} else {
|
} else {
|
||||||
holder.name.setVisibility(View.GONE);
|
holder.name.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue