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 { ...@@ -80,7 +80,7 @@ public class ContactDetailsTask implements Runnable {
} }
public interface DetailsLoadedCallback { public interface DetailsLoadedCallback {
void onDetailsLoaded(String formattedName); void onDetailsLoaded(Bitmap bmp, String formattedName, String username);
} }
public ContactDetailsTask(Context context, ImageView element, CallContact item) { public ContactDetailsTask(Context context, ImageView element, CallContact item) {
...@@ -187,7 +187,7 @@ public class ContactDetailsTask implements Runnable { ...@@ -187,7 +187,7 @@ public class ContactDetailsTask implements Runnable {
mImageViewWeakRef.clear(); mImageViewWeakRef.clear();
if (v == null) { if (v == null) {
for (DetailsLoadedCallback cb : mCallbacks) { for (DetailsLoadedCallback cb : mCallbacks) {
cb.onDetailsLoaded(formattedName); cb.onDetailsLoaded(externalBMP, formattedName, mContact.getUsername());
} }
} else { } else {
v.post(new Runnable() { v.post(new Runnable() {
......
...@@ -322,10 +322,13 @@ public class ConversationFragment extends BaseFragment<ConversationPresenter> im ...@@ -322,10 +322,13 @@ public class ConversationFragment extends BaseFragment<ConversationPresenter> im
} }
@Override @Override
public void onDetailsLoaded(String formattedName) { public void onDetailsLoaded(Bitmap bmp, String formattedName, String username) {
ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar(); ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
if (actionBar != null && formattedName != null) { if (actionBar != null && formattedName != null) {
actionBar.setTitle(formattedName); actionBar.setTitle(formattedName);
if (username != null && !username.equals(formattedName)) {
actionBar.setSubtitle(username);
}
} }
} }
......
...@@ -222,8 +222,12 @@ public class ConversationFacade extends Observable implements Observer<ServiceEv ...@@ -222,8 +222,12 @@ public class ConversationFacade extends Observable implements Observer<ServiceEv
} }
CallContact contact = conversation.getContact(); CallContact contact = conversation.getContact();
if (contact == null || contact.getDisplayName().equals(newDisplayName) if (contact == null || contact.getDisplayName().equals(newDisplayName)) {
|| !contact.getDisplayName().contains(ringId)) { return;
}
if (!contact.getDisplayName().contains(ringId)) {
contact.setUsername(newDisplayName);
return; return;
} }
...@@ -231,6 +235,7 @@ public class ConversationFacade extends Observable implements Observer<ServiceEv ...@@ -231,6 +235,7 @@ public class ConversationFacade extends Observable implements Observer<ServiceEv
contact.getPhones().clear(); contact.getPhones().clear();
contact.getPhones().add(new cx.ring.model.Phone(ringIdUri, 0)); contact.getPhones().add(new cx.ring.model.Phone(ringIdUri, 0));
contact.setDisplayName(newDisplayName); contact.setDisplayName(newDisplayName);
contact.setUsername(newDisplayName);
setChanged(); setChanged();
ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.USERNAME_CHANGED); ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.USERNAME_CHANGED);
......
...@@ -35,6 +35,7 @@ public class CallContact { ...@@ -35,6 +35,7 @@ public class CallContact {
private long mId; private long mId;
private String mKey; private String mKey;
private String mDisplayName; private String mDisplayName;
private String mUsername;
private long mPhotoId; private long mPhotoId;
private final ArrayList<Phone> mPhones; private final ArrayList<Phone> mPhones;
private boolean isUser; private boolean isUser;
...@@ -55,6 +56,7 @@ public class CallContact { ...@@ -55,6 +56,7 @@ public class CallContact {
mId = cID; mId = cID;
mKey = k; mKey = k;
mDisplayName = displayName; mDisplayName = displayName;
mUsername = displayName;
mPhones = p; mPhones = p;
mPhotoId = photoID; mPhotoId = photoID;
isUser = user; isUser = user;
...@@ -97,6 +99,9 @@ public class CallContact { ...@@ -97,6 +99,9 @@ public class CallContact {
mKey = k; mKey = k;
mDisplayName = displayName; mDisplayName = displayName;
this.mPhotoId = photo_id; this.mPhotoId = photo_id;
if (mUsername == null && displayName.contains(PREFIX_RING)) {
mUsername = displayName;
}
} }
public static String canonicalNumber(String number) { public static String canonicalNumber(String number) {
...@@ -242,6 +247,14 @@ public class CallContact { ...@@ -242,6 +247,14 @@ public class CallContact {
mDisplayName = displayName; mDisplayName = displayName;
} }
public String getUsername() {
return mUsername;
}
public void setUsername(String mUsername) {
this.mUsername = mUsername;
}
//region Equals //region Equals
@Override @Override
public boolean equals(Object o) { 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