Search in sources :

Example 6 with HistoryCall

use of cx.ring.model.HistoryCall in project ring-client-android by savoirfairelinux.

the class SmartListPresenter method modelToViewModel.

private SmartListViewModel modelToViewModel(String ringId, CallContact callContact, @NonNull List<HistoryText> lastTexts, @NonNull List<HistoryCall> lastCalls) {
    HistoryText lastText = lastTexts.size() > 0 ? lastTexts.get(0) : null;
    HistoryCall lastCall = lastCalls.size() > 0 ? lastCalls.get(0) : null;
    long lastInteractionLong = 0;
    int lastEntryType = 0;
    String lastInteraction = "";
    boolean hasUnreadMessage = lastText != null && !lastText.isRead();
    long lastTextTimestamp = lastText != null ? lastText.getDate() : 0;
    long lastCallTimestamp = lastCall != null ? lastCall.getEndDate().getTime() : 0;
    if (lastTextTimestamp > 0 && lastTextTimestamp > lastCallTimestamp) {
        String msgString = lastText.getMessage();
        if (msgString != null && !msgString.isEmpty() && msgString.contains("\n")) {
            int lastIndexOfChar = msgString.lastIndexOf("\n");
            if (lastIndexOfChar + 1 < msgString.length()) {
                msgString = msgString.substring(msgString.lastIndexOf("\n") + 1);
            }
        }
        lastInteractionLong = lastTextTimestamp;
        lastEntryType = lastText.isIncoming() ? SmartListViewModel.TYPE_INCOMING_MESSAGE : SmartListViewModel.TYPE_OUTGOING_MESSAGE;
        lastInteraction = msgString;
    } else if (lastCallTimestamp > 0) {
        lastInteractionLong = lastCallTimestamp;
        lastEntryType = lastCall.isIncoming() ? SmartListViewModel.TYPE_INCOMING_CALL : SmartListViewModel.TYPE_OUTGOING_CALL;
        lastInteraction = lastCall.getDurationString();
    }
    SmartListViewModel smartListViewModel;
    mContactService.loadContactData(callContact);
    smartListViewModel = new SmartListViewModel(ringId, callContact.getStatus(), callContact.getDisplayName() != null ? callContact.getDisplayName() : callContact.getUsername(), callContact.getPhoto(), lastInteractionLong, lastEntryType, lastInteraction, hasUnreadMessage);
    smartListViewModel.setOnline(mPresenceService.isBuddyOnline(callContact.getIds().get(0)));
    return smartListViewModel;
}
Also used : HistoryText(cx.ring.model.HistoryText) HistoryCall(cx.ring.model.HistoryCall)

Example 7 with HistoryCall

use of cx.ring.model.HistoryCall in project ring-client-android by savoirfairelinux.

the class ConversationFacade method parseHistoryCalls.

private void parseHistoryCalls(List<HistoryCall> historyCalls, boolean acceptAllMessages) {
    for (HistoryCall call : historyCalls) {
        CallContact contact = mContactService.findContact(call.getContactID(), call.getContactKey(), new Uri(call.getNumber()));
        String key = contact.getIds().get(0);
        String phone = contact.getPhones().get(0).getNumber().getRawUriString();
        if (mConversationMap.containsKey(key) || mConversationMap.containsKey(phone)) {
            mConversationMap.get(key).addHistoryCall(call);
        } else if (acceptAllMessages) {
            Conversation conversation = new Conversation(contact);
            conversation.addHistoryCall(call);
            mConversationMap.put(key, conversation);
        }
    }
}
Also used : Conversation(cx.ring.model.Conversation) Uri(cx.ring.model.Uri) CallContact(cx.ring.model.CallContact) HistoryCall(cx.ring.model.HistoryCall)

Aggregations

HistoryCall (cx.ring.model.HistoryCall)7 HistoryText (cx.ring.model.HistoryText)4 DataTransfer (cx.ring.model.DataTransfer)3 ServiceEvent (cx.ring.model.ServiceEvent)3 SQLException (java.sql.SQLException)3 Conversation (cx.ring.model.Conversation)2 SipCall (cx.ring.model.SipCall)2 TextMessage (cx.ring.model.TextMessage)2 Uri (cx.ring.model.Uri)2 ArrayList (java.util.ArrayList)2 Context (android.content.Context)1 StringMap (cx.ring.daemon.StringMap)1 Account (cx.ring.model.Account)1 CallContact (cx.ring.model.CallContact)1 Conference (cx.ring.model.Conference)1 DataTransferEventCode (cx.ring.model.DataTransferEventCode)1 HistoryEntry (cx.ring.model.HistoryEntry)1 SecureSipCall (cx.ring.model.SecureSipCall)1 AccountService (cx.ring.services.AccountService)1 CallService (cx.ring.services.CallService)1