Skip to content
Snippets Groups Projects
Commit 5ed22a06 authored by Aline Bonnet's avatar Aline Bonnet Committed by gerrit2
Browse files

conversation: fix the historyCall display

Since the a3162160 commit, the call messages could be displayed several
times. This commit checks if a call message is already displayed.

Change-Id: I72b74ccd9e9d454d603009de4de1595a6f89279f
Tuleap: #1470
parent df493bd3
Branches
Tags
No related merge requests found
...@@ -909,27 +909,11 @@ public class LocalService extends Service implements Observer<DaemonEvent> { ...@@ -909,27 +909,11 @@ public class LocalService extends Service implements Observer<DaemonEvent> {
for (HistoryCall call : history) { for (HistoryCall call : history) {
CallContact contact = getCreateContact(call.getContactID(), call.getContactKey(), call.getNumber()); CallContact contact = getCreateContact(call.getContactID(), call.getContactKey(), call.getNumber());
Map.Entry<String, Conversation> merge = null;
for (Map.Entry<String, Conversation> ce : conversations.entrySet()) {
Conversation conversation = ce.getValue();
if ((contact.getId() > 0 && contact.getId() == conversation.getContact().getId()) || conversation.getContact().hasNumber(call.getNumber())) {
merge = ce;
break;
}
}
if (merge != null) {
Conversation conversation = merge.getValue();
if (conversation.getContact().getId() <= 0 && contact.getId() > 0) {
conversation.setContact(contact);
conversations.remove(merge.getKey());
conversations.put(contact.getIds().get(0), conversation);
}
conversation.addHistoryCall(call);
continue;
}
String key = contact.getIds().get(0); String key = contact.getIds().get(0);
if (conversations.containsKey(key)) { if (conversations.containsKey(key)) {
if (!conversations.get(key).getHistoryCalls().contains(call)) {
conversations.get(key).addHistoryCall(call); conversations.get(key).addHistoryCall(call);
}
} else { } else {
Conversation conversation = new Conversation(contact); Conversation conversation = new Conversation(contact);
conversation.addHistoryCall(call); conversation.addHistoryCall(call);
......
...@@ -238,6 +238,14 @@ public class Conversation { ...@@ -238,6 +238,14 @@ public class Conversation {
return texts.values(); return texts.values();
} }
public Collection<HistoryCall> getHistoryCalls() {
TreeMap<Long, HistoryCall> calls = new TreeMap<>();
for (HistoryEntry historyEntry : mHistory.values()) {
calls.putAll(historyEntry.getCalls());
}
return calls.values();
}
public TreeMap<Long, TextMessage> getUnreadTextMessages() { public TreeMap<Long, TextMessage> getUnreadTextMessages() {
TreeMap<Long, TextMessage> texts = new TreeMap<>(); TreeMap<Long, TextMessage> texts = new TreeMap<>();
for (HistoryEntry h : mHistory.values()) { for (HistoryEntry h : mHistory.values()) {
......
...@@ -169,4 +169,30 @@ public class HistoryCall implements Serializable { ...@@ -169,4 +169,30 @@ public class HistoryCall implements Serializable {
return callID; return callID;
} }
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
HistoryCall that = (HistoryCall) o;
if (call_start != that.call_start || call_end != that.call_end || contactID != that.contactID) {
return false;
}
return callID != null ? callID.equals(that.callID) : that.callID == null;
}
@Override
public int hashCode() {
int result = (int) (call_start ^ (call_start >>> 32));
result = 31 * result + (int) (call_end ^ (call_end >>> 32));
result = 31 * result + (int) (contactID ^ (contactID >>> 32));
result = 31 * result + (callID != null ? callID.hashCode() : 0);
return result;
}
} }
...@@ -80,7 +80,7 @@ public class HistoryEntry { ...@@ -80,7 +80,7 @@ public class HistoryEntry {
* @param linkedTo The associated CallContact * @param linkedTo The associated CallContact
*/ */
public void addHistoryCall(HistoryCall historyCall, CallContact linkedTo) { public void addHistoryCall(HistoryCall historyCall, CallContact linkedTo) {
mCalls.put(historyCall.call_start, historyCall); mCalls.put(historyCall.call_end, historyCall);
if (historyCall.isIncoming()) { if (historyCall.isIncoming()) {
++mIncomingCount; ++mIncomingCount;
} else { } else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment