Search in sources :

Example 1 with Conversation

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

the class DRingService method handleConvAction.

private void handleConvAction(String action, Bundle extras) {
    String ringId = extras.getString(ConversationFragment.KEY_CONTACT_RING_ID);
    if (ringId == null || ringId.isEmpty()) {
        return;
    }
    switch(action) {
        case ACTION_CONV_READ:
            Conversation conversation = mConversationFacade.getConversationById(ringId);
            if (conversation != null) {
                mHistoryService.readMessages(conversation);
                mNotificationService.cancelTextNotification(ringId);
            }
            break;
        case ACTION_CONV_DISMISS:
            break;
        case ACTION_CONV_ACCEPT:
            startActivity(new Intent(Intent.ACTION_VIEW).putExtras(extras).setClass(getApplicationContext(), ConversationActivity.class).setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK));
            break;
        default:
            break;
    }
}
Also used : Conversation(cx.ring.model.Conversation) Intent(android.content.Intent)

Example 2 with Conversation

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

the class ConversationFacade method addContacts.

private void addContacts(boolean acceptAllMessages) {
    ArrayList<CallContact> contacts;
    if (acceptAllMessages) {
        contacts = new ArrayList<>(mContactService.getContactsNoBanned());
    } else {
        contacts = new ArrayList<>(mContactService.getContactsDaemon());
    }
    for (CallContact contact : contacts) {
        String key = contact.getIds().get(0);
        String phone = contact.getPhones().get(0).getNumber().getRawUriString();
        if (!mConversationMap.containsKey(key) && !mConversationMap.containsKey(phone)) {
            mConversationMap.put(key, new Conversation(contact));
        }
    }
}
Also used : Conversation(cx.ring.model.Conversation) CallContact(cx.ring.model.CallContact)

Example 3 with Conversation

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

the class ConversationFacade method updateTextNotifications.

public void updateTextNotifications() {
    Log.d(TAG, "updateTextNotifications()");
    for (Conversation conversation : mConversationMap.values()) {
        TreeMap<Long, TextMessage> texts = conversation.getUnreadTextMessages();
        if (texts.isEmpty() || conversation.isVisible()) {
            mNotificationService.cancelTextNotification(conversation.getContact());
            continue;
        }
        if (texts.lastEntry().getValue().isNotified()) {
            continue;
        }
        CallContact contact = conversation.getContact();
        mNotificationService.showTextNotification(contact, conversation, texts);
    }
}
Also used : Conversation(cx.ring.model.Conversation) TextMessage(cx.ring.model.TextMessage) CallContact(cx.ring.model.CallContact)

Example 4 with Conversation

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

the class ConversationFacade method parseHistoryTransfers.

private void parseHistoryTransfers(List<DataTransfer> historyTexts, boolean acceptAllMessages) {
    for (DataTransfer htext : historyTexts) {
        CallContact contact = mContactService.findContactByNumber(htext.getPeerId());
        String key = contact.getIds().get(0);
        if (mConversationMap.containsKey(key)) {
            mConversationMap.get(key).addFileTransfer(htext);
        } else if (acceptAllMessages) {
            Conversation conversation = new Conversation(contact);
            conversation.addFileTransfer(htext);
            mConversationMap.put(key, conversation);
        }
    }
}
Also used : DataTransfer(cx.ring.model.DataTransfer) Conversation(cx.ring.model.Conversation) CallContact(cx.ring.model.CallContact)

Example 5 with Conversation

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

the class ConversationFacade method handleDataTransferEvent.

private void handleDataTransferEvent(DataTransfer transfer, DataTransferEventCode transferEventCode) {
    CallContact contact = mContactService.findContactByNumber(transfer.getPeerId());
    Conversation conversation = startConversation(contact);
    if (transferEventCode == DataTransferEventCode.CREATED) {
        if (transfer.isPicture() && !transfer.isOutgoing()) {
            File path = mDeviceRuntimeService.getConversationPath(transfer.getPeerId(), transfer.getStoragePath());
            mAccountService.acceptFileTransfer(transfer.getDataTransferId(), path.getAbsolutePath(), 0);
        }
        conversation.addFileTransfer(transfer);
        setChanged();
        notifyObservers(new ServiceEvent(ServiceEvent.EventType.DATA_TRANSFER));
    } else {
        conversation.updateFileTransfer(transfer, transferEventCode);
        setChanged();
        ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.DATA_TRANSFER_UPDATE);
        event.addEventInput(ServiceEvent.EventInput.TRANSFER_INFO, transfer);
        notifyObservers(event);
    }
    mNotificationService.showFileTransferNotification(transfer, transferEventCode, contact);
}
Also used : ServiceEvent(cx.ring.model.ServiceEvent) Conversation(cx.ring.model.Conversation) File(java.io.File) CallContact(cx.ring.model.CallContact)

Aggregations

Conversation (cx.ring.model.Conversation)12 CallContact (cx.ring.model.CallContact)8 Uri (cx.ring.model.Uri)5 Account (cx.ring.model.Account)4 HistoryText (cx.ring.model.HistoryText)3 ServiceEvent (cx.ring.model.ServiceEvent)3 TextMessage (cx.ring.model.TextMessage)3 Conference (cx.ring.model.Conference)2 DataTransfer (cx.ring.model.DataTransfer)2 HistoryCall (cx.ring.model.HistoryCall)2 SecureSipCall (cx.ring.model.SecureSipCall)2 SipCall (cx.ring.model.SipCall)2 ArrayList (java.util.ArrayList)2 Intent (android.content.Intent)1 DataTransferEventCode (cx.ring.model.DataTransferEventCode)1 AccountService (cx.ring.services.AccountService)1 CallService (cx.ring.services.CallService)1 ContactService (cx.ring.services.ContactService)1 HistoryService (cx.ring.services.HistoryService)1 File (java.io.File)1