Skip to content
Snippets Groups Projects
Commit 108f3137 authored by Aline Bonnet's avatar Aline Bonnet
Browse files

conversation: display the username or the ringID


If a contact has a profile name, we can't see his ringID or username
in the conversation screen. It's a security problem because a profile
name can be changed and is not unique.
Now, the username (or the ringID if it does not exists) is always
displayed in the toolbar.

Tuleap: #1345
Change-Id: I7fbc585eb35e708254d77bb998a31e57078461c1
Reviewed-by: default avatarAlexandre Lision <alexandre.lision@savoirfairelinux.com>
parent a95732e2
No related branches found
No related tags found
No related merge requests found
......@@ -80,7 +80,7 @@ public class ContactDetailsTask implements Runnable {
}
public interface DetailsLoadedCallback {
void onDetailsLoaded(String formattedName);
void onDetailsLoaded(Bitmap bmp, String formattedName, String username);
}
public ContactDetailsTask(Context context, ImageView element, CallContact item) {
......@@ -187,7 +187,7 @@ public class ContactDetailsTask implements Runnable {
mImageViewWeakRef.clear();
if (v == null) {
for (DetailsLoadedCallback cb : mCallbacks) {
cb.onDetailsLoaded(formattedName);
cb.onDetailsLoaded(externalBMP, formattedName, mContact.getUsername());
}
} else {
v.post(new Runnable() {
......
......@@ -322,10 +322,13 @@ public class ConversationFragment extends BaseFragment<ConversationPresenter> im
}
@Override
public void onDetailsLoaded(String formattedName) {
public void onDetailsLoaded(Bitmap bmp, String formattedName, String username) {
ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
if (actionBar != null && formattedName != null) {
actionBar.setTitle(formattedName);
if (username != null && !username.equals(formattedName)) {
actionBar.setSubtitle(username);
}
}
}
......
......@@ -222,8 +222,12 @@ public class ConversationFacade extends Observable implements Observer<ServiceEv
}
CallContact contact = conversation.getContact();
if (contact == null || contact.getDisplayName().equals(newDisplayName)
|| !contact.getDisplayName().contains(ringId)) {
if (contact == null || contact.getDisplayName().equals(newDisplayName)) {
return;
}
if (!contact.getDisplayName().contains(ringId)) {
contact.setUsername(newDisplayName);
return;
}
......@@ -231,6 +235,7 @@ public class ConversationFacade extends Observable implements Observer<ServiceEv
contact.getPhones().clear();
contact.getPhones().add(new cx.ring.model.Phone(ringIdUri, 0));
contact.setDisplayName(newDisplayName);
contact.setUsername(newDisplayName);
setChanged();
ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.USERNAME_CHANGED);
......
......@@ -35,6 +35,7 @@ public class CallContact {
private long mId;
private String mKey;
private String mDisplayName;
private String mUsername;
private long mPhotoId;
private final ArrayList<Phone> mPhones;
private boolean isUser;
......@@ -55,6 +56,7 @@ public class CallContact {
mId = cID;
mKey = k;
mDisplayName = displayName;
mUsername = displayName;
mPhones = p;
mPhotoId = photoID;
isUser = user;
......@@ -97,6 +99,9 @@ public class CallContact {
mKey = k;
mDisplayName = displayName;
this.mPhotoId = photo_id;
if (mUsername == null && displayName.contains(PREFIX_RING)) {
mUsername = displayName;
}
}
public static String canonicalNumber(String number) {
......@@ -242,6 +247,14 @@ public class CallContact {
mDisplayName = displayName;
}
public String getUsername() {
return mUsername;
}
public void setUsername(String mUsername) {
this.mUsername = mUsername;
}
//region Equals
@Override
public boolean equals(Object o) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment