UI fixes & improvements

This commit is contained in:
Sylvain Berfini 2017-11-02 10:52:22 +01:00
parent 9473655068
commit b4acb1b794
3 changed files with 26 additions and 57 deletions

View file

@ -136,16 +136,17 @@ public final class LinphoneUtils {
return getAddressDisplayName(lAddress); return getAddressDisplayName(lAddress);
} }
public static String getAddressDisplayName(Address address){ public static String getAddressDisplayName(Address address) {
if(address.getDisplayName() != null) { if (address == null) return null;
return address.getDisplayName();
} else { String displayName = address.getDisplayName();
if(address.getUsername() != null){ if (displayName == null || displayName.isEmpty()) {
return address.getUsername(); displayName = address.getUsername();
} else {
return address.asStringUriOnly();
}
} }
if (displayName == null || displayName.isEmpty()) {
displayName = address.asStringUriOnly();
}
return displayName;
} }
public static String getUsernameFromAddress(String address) { public static String getUsernameFromAddress(String address) {

View file

@ -157,10 +157,7 @@ public class ChatEventsAdapter extends BaseAdapter implements ChatMessageListene
String displayName; String displayName;
if (message.isOutgoing()) { if (message.isOutgoing()) {
displayName = remoteSender.getDisplayName(); displayName = LinphoneUtils.getAddressDisplayName(remoteSender);
if (displayName == null || displayName.isEmpty()) {
displayName = remoteSender.getUsername();
}
if (status == ChatMessage.State.InProgress) { if (status == ChatMessage.State.InProgress) {
holder.messageSendingInProgress.setVisibility(View.VISIBLE); holder.messageSendingInProgress.setVisibility(View.VISIBLE);
@ -207,10 +204,7 @@ public class ChatEventsAdapter extends BaseAdapter implements ChatMessageListene
if (contact.getFullName() != null) { if (contact.getFullName() != null) {
displayName = contact.getFullName(); displayName = contact.getFullName();
} else { } else {
displayName = remoteSender.getDisplayName(); displayName = LinphoneUtils.getAddressDisplayName(remoteSender);
if (displayName == null || displayName.isEmpty()) {
displayName = remoteSender.getUsername();
}
} }
holder.contactPicture.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap()); holder.contactPicture.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
@ -218,11 +212,7 @@ public class ChatEventsAdapter extends BaseAdapter implements ChatMessageListene
LinphoneUtils.setThumbnailPictureFromUri(LinphoneActivity.instance(), holder.contactPicture, contact.getThumbnailUri()); LinphoneUtils.setThumbnailPictureFromUri(LinphoneActivity.instance(), holder.contactPicture, contact.getThumbnailUri());
} }
} else { } else {
displayName = remoteSender.getDisplayName(); displayName = LinphoneUtils.getAddressDisplayName(remoteSender);
if (displayName == null || displayName.isEmpty()) {
displayName = remoteSender.getUsername();
}
holder.contactPicture.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap()); holder.contactPicture.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
} }
@ -312,14 +302,10 @@ public class ChatEventsAdapter extends BaseAdapter implements ChatMessageListene
if (contact != null) { if (contact != null) {
displayName = contact.getFullName(); displayName = contact.getFullName();
} else { } else {
displayName = address.getDisplayName(); displayName = LinphoneUtils.getAddressDisplayName(address);
if (displayName == null || displayName.isEmpty()) {
displayName = address.getUsername();
}
} }
} }
//TODO
switch (event.getType()) { switch (event.getType()) {
case ConferenceCreated: case ConferenceCreated:
holder.eventMessage.setText(mContext.getString(R.string.conference_created)); holder.eventMessage.setText(mContext.getString(R.string.conference_created));

View file

@ -146,12 +146,8 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
LinphoneContact c = ContactsManager.getInstance().findContactFromAddress(a); LinphoneContact c = ContactsManager.getInstance().findContactFromAddress(a);
if (c == null) { if (c == null) {
c = new LinphoneContact(); c = new LinphoneContact();
String displayName = a.getDisplayName(); String displayName = LinphoneUtils.getAddressDisplayName(a);
if (displayName == null || displayName.isEmpty()) { c.setFullName(displayName);
c.setFullName(a.getUsername());
} else {
c.setFullName(displayName);
}
} }
ContactAddress ca = new ContactAddress(c, a.asString(), c.isFriend()); ContactAddress ca = new ContactAddress(c, a.asString(), c.isFriend());
participants.add(ca); participants.add(ca);
@ -307,7 +303,6 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
} else if (fileToUploadPath.contains("com.android.contacts/contacts/")) { } else if (fileToUploadPath.contains("com.android.contacts/contacts/")) {
fileToUploadPath = getCVSPathFromLookupUri(fileToUploadPath).toString(); fileToUploadPath = getCVSPathFromLookupUri(fileToUploadPath).toString();
} }
Log.e("FILE PATH IS " + fileToUploadPath);
addFileToPendingList(fileToUploadPath); addFileToPendingList(fileToUploadPath);
} }
} else { } else {
@ -389,16 +384,13 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
mParticipants.add(c); mParticipants.add(c);
participantsLabel.append(c.getFullName()); participantsLabel.append(c.getFullName());
} else { } else {
String displayName = p.getAddress().getDisplayName(); String displayName = LinphoneUtils.getAddressDisplayName(p.getAddress());
if (displayName != null && !displayName.isEmpty()) { participantsLabel.append(displayName);
participantsLabel.append(displayName);
} else {
participantsLabel.append(p.getAddress().getUsername());
}
} }
index++; index++;
if (index != mChatRoom.getNbParticipants()) participantsLabel.append(";"); if (index != mChatRoom.getNbParticipants()) participantsLabel.append(", ");
} }
mParticipantsLabel.setText(participantsLabel.toString());
} else { } else {
LinphoneContact c = ContactsManager.getInstance().findContactFromAddress(mRemoteSipAddress); LinphoneContact c = ContactsManager.getInstance().findContactFromAddress(mRemoteSipAddress);
if (c != null) { if (c != null) {
@ -441,6 +433,7 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
mGroupInfosButton.setVisibility(View.VISIBLE); mGroupInfosButton.setVisibility(View.VISIBLE);
mRoomLabel.setText(mChatRoom.getSubject()); mRoomLabel.setText(mChatRoom.getSubject());
mParticipantsLabel.setVisibility(View.VISIBLE); mParticipantsLabel.setVisibility(View.VISIBLE);
} else { } else {
mCallButton.setVisibility(View.VISIBLE); mCallButton.setVisibility(View.VISIBLE);
mGroupInfosButton.setVisibility(View.GONE); mGroupInfosButton.setVisibility(View.GONE);
@ -448,12 +441,8 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
if (mParticipants.size() == 0) { if (mParticipants.size() == 0) {
// Contact not found // Contact not found
String displayName = mRemoteSipAddress.getDisplayName(); String displayName = LinphoneUtils.getAddressDisplayName(mRemoteSipAddress);
if (displayName == null || displayName.isEmpty()) { mRoomLabel.setText(displayName);
mRoomLabel.setText(mRemoteSipAddress.getUsername());
} else {
mRoomLabel.setText(displayName);
}
} else { } else {
mRoomLabel.setText(mParticipants.get(0).getFullName()); mRoomLabel.setText(mParticipants.get(0).getFullName());
} }
@ -699,12 +688,8 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
} }
} }
if (!found) { if (!found) {
String displayName = a.getDisplayName(); String displayName = LinphoneUtils.getAddressDisplayName(a);
if (displayName != null && !displayName.isEmpty()) { composing.add(displayName);
composing.add(displayName);
} else {
composing.add(a.getUsername());
}
} }
} }
@ -732,10 +717,7 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
if (mParticipants.size() > 0) { if (mParticipants.size() > 0) {
displayName = mParticipants.get(0).getFullName(); displayName = mParticipants.get(0).getFullName();
} else { } else {
displayName = remoteAddr.getDisplayName(); displayName = LinphoneUtils.getAddressDisplayName(remoteAddr);
if (displayName == null || displayName.isEmpty()) {
displayName = remoteAddr.getUsername();
}
} }
mRemoteComposing.setText(getString(R.string.remote_composing_single).replace("%s", displayName)); mRemoteComposing.setText(getString(R.string.remote_composing_single).replace("%s", displayName));
mRemoteComposing.setVisibility(View.VISIBLE); mRemoteComposing.setVisibility(View.VISIBLE);