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;
}
}
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));
}
}
}
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);
}
}
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);
}
}
}
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);
}
Aggregations