Search in sources :

Example 36 with CallContact

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

the class MainPresenter method reloadConversations.

public void reloadConversations() {
    getView().showLoading(true);
    Account currentAccount = mAccountService.getCurrentAccount();
    if (currentAccount == null) {
        Log.e(TAG, "reloadConversations: Not able to get currentAccount");
        return;
    }
    final Collection<CallContact> contacts = currentAccount.getContacts().values();
    // Get all non-ban contact and then get last message and last call to create a smartList entry
    mCompositeDisposable.add(io.reactivex.Observable.fromIterable(contacts).filter(callContact -> !callContact.isBanned()).map(this::modelToViewModel).toSortedList().subscribeOn(Schedulers.computation()).observeOn(mMainScheduler).subscribeWith(new DisposableSingleObserver<List<TVListViewModel>>() {

        @Override
        public void onSuccess(List<TVListViewModel> tvListViewModels) {
            MainPresenter.this.mTvListViewModels = tvListViewModels;
            getView().showContacts(tvListViewModels);
            getView().showLoading(false);
            subscribePresence();
        }

        @Override
        public void onError(Throwable throwable) {
            Log.e(TAG, throwable.toString());
            getView().showLoading(false);
        }
    }));
}
Also used : Account(cx.ring.model.Account) TVListViewModel(cx.ring.tv.model.TVListViewModel) DisposableSingleObserver(io.reactivex.observers.DisposableSingleObserver) ArrayList(java.util.ArrayList) List(java.util.List) CallContact(cx.ring.model.CallContact)

Example 37 with CallContact

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

the class ActionHelper method launchCopyNumberToClipboardFromContact.

public static void launchCopyNumberToClipboardFromContact(final Context context, final CallContact callContact, final Conversation.ConversationActionCallback callback) {
    if (callContact == null) {
        Log.d(TAG, "launchCopyNumberToClipboardFromContact: callContact is null");
        return;
    }
    if (context == null) {
        Log.d(TAG, "launchCopyNumberToClipboardFromContact: activity is null");
        return;
    }
    if (callContact.getPhones().isEmpty()) {
        Log.d(TAG, "launchCopyNumberToClipboardFromContact: no number to copy");
        return;
    }
    if (callContact.getPhones().size() == 1 && callback != null) {
        String number = callContact.getPhones().get(0).getNumber().toString();
        callback.copyContactNumberToClipboard(number);
    } else {
        final NumberAdapter adapter = new NumberAdapter(context, callContact, true);
        AlertDialog alertDialog = new AlertDialog.Builder(context).setTitle(R.string.conversation_action_select_peer_number).setAdapter(adapter, (dialog, which) -> {
            if (callback != null) {
                Phone selectedPhone = (Phone) adapter.getItem(which);
                callback.copyContactNumberToClipboard(selectedPhone.getNumber().toString());
            }
        }).create();
        final int listViewSidePadding = (int) context.getResources().getDimension(R.dimen.alert_dialog_side_padding_list_view);
        alertDialog.getListView().setPadding(listViewSidePadding, 0, listViewSidePadding, 0);
        alertDialog.show();
    }
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) Context(android.content.Context) Uri(cx.ring.model.Uri) Intent(android.content.Intent) R(cx.ring.R) ArrayList(java.util.ArrayList) AlertDialog(android.support.v7.app.AlertDialog) ContactsContract(android.provider.ContactsContract) Phone(cx.ring.model.Phone) ActivityNotFoundException(android.content.ActivityNotFoundException) CallContact(cx.ring.model.CallContact) ContentValues(android.content.ContentValues) NumberAdapter(cx.ring.adapters.NumberAdapter) Conversation(cx.ring.model.Conversation) NumberAdapter(cx.ring.adapters.NumberAdapter) Phone(cx.ring.model.Phone)

Example 38 with CallContact

use of cx.ring.model.CallContact 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

CallContact (cx.ring.model.CallContact)38 Conversation (cx.ring.model.Conversation)9 Uri (cx.ring.model.Uri)8 Account (cx.ring.model.Account)7 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)5 ContentResolver (android.content.ContentResolver)4 Cursor (android.database.Cursor)4 SipCall (cx.ring.model.SipCall)4 ServiceEvent (cx.ring.model.ServiceEvent)3 Settings (cx.ring.model.Settings)3 TextMessage (cx.ring.model.TextMessage)3 IOException (java.io.IOException)3 Map (java.util.Map)3 Intent (android.content.Intent)2 StringMap (cx.ring.daemon.StringMap)2 TrustRequest (cx.ring.model.TrustRequest)2 TVListViewModel (cx.ring.tv.model.TVListViewModel)2 List (java.util.List)2 PendingIntent (android.app.PendingIntent)1