Search in sources :

Example 36 with Account

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

the class ContactRequestsPresenter method updateList.

public void updateList(boolean clear) {
    if (getView() == null) {
        return;
    }
    Log.d(TAG, "updateList");
    Account currentAccount = ((mAccountID == null) ? mAccountService.getCurrentAccount() : mAccountService.getAccount(mAccountID));
    if (currentAccount == null) {
        return;
    }
    boolean hasPane = !currentAccount.equals(mAccountService.getCurrentAccount());
    if (clear) {
        mTrustRequests.clear();
        mTrustRequests.addAll(currentAccount.getRequests());
    }
    if (mContactRequestsViewModels == null) {
        mContactRequestsViewModels = new ArrayList<>();
    } else {
        mContactRequestsViewModels.clear();
    }
    for (TrustRequest request : mTrustRequests) {
        mContactRequestsViewModels.add(new PendingContactRequestsViewModel(currentAccount, request, hasPane));
    }
    getView().updateView(mContactRequestsViewModels);
    mNotificationService.cancelTrustRequestNotification(currentAccount.getAccountID());
}
Also used : Account(cx.ring.model.Account) TrustRequest(cx.ring.model.TrustRequest)

Example 37 with Account

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

the class TVProfileEditingFragment method showViewModel.

@Override
public void showViewModel(RingNavigationViewModel viewModel) {
    // displays account available info
    VCard vcard = viewModel.getVcard(getActivity().getFilesDir());
    Account account = viewModel.getAccount();
    if (account == null) {
        Log.e(TAG, "Not able to get current account");
        return;
    }
    if (!this.actions.isEmpty() && this.actions.get(0).getId() == USER_NAME) {
        this.actions.get(0).setEditDescription(account.getAlias());
    }
    if (vcard == null || vcard.getPhotos().isEmpty()) {
        getGuidanceStylist().getIconView().setImageDrawable(getActivity().getResources().getDrawable(R.drawable.ic_contact_picture_fallback));
        return;
    }
    Drawable contactPicture = AvatarFactory.getAvatar(getActivity(), vcard.getPhotos().get(0).getData(), account.getDisplayUsername(), account.getUri());
    Glide.with(getActivity()).load(contactPicture).apply(AvatarFactory.getGlideOptions(true, false)).transition(DrawableTransitionOptions.withCrossFade()).into(getGuidanceStylist().getIconView());
}
Also used : Account(cx.ring.model.Account) Drawable(android.graphics.drawable.Drawable) VCard(ezvcard.VCard)

Example 38 with Account

use of cx.ring.model.Account 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 39 with Account

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

the class ConversationFacade method startConversation.

/**
 * @return the started new conversation
 */
public Conversation startConversation(CallContact contact) {
    Conversation conversation = getConversationByContact(contact);
    if (conversation == null) {
        conversation = new Conversation(contact);
        mConversationMap.put(contact.getIds().get(0), conversation);
        Account account = mAccountService.getCurrentAccount();
        if (account != null && account.isRing()) {
            Uri number = contact.getPhones().get(0).getNumber();
            if (number.isRingId()) {
                mAccountService.lookupAddress(account.getAccountID(), "", number.getRawRingId());
            }
        }
        setChanged();
        ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.CONVERSATIONS_CHANGED);
        notifyObservers(event);
        updateTextNotifications();
    }
    return conversation;
}
Also used : Account(cx.ring.model.Account) ServiceEvent(cx.ring.model.ServiceEvent) Conversation(cx.ring.model.Conversation) Uri(cx.ring.model.Uri)

Aggregations

Account (cx.ring.model.Account)39 ServiceEvent (cx.ring.model.ServiceEvent)13 CallContact (cx.ring.model.CallContact)7 Uri (cx.ring.model.Uri)6 StringMap (cx.ring.daemon.StringMap)5 ArrayList (java.util.ArrayList)5 Conversation (cx.ring.model.Conversation)4 TrustRequest (cx.ring.model.TrustRequest)4 HashMap (java.util.HashMap)3 List (java.util.List)3 Map (java.util.Map)3 Conference (cx.ring.model.Conference)2 SecureSipCall (cx.ring.model.SecureSipCall)2 SipCall (cx.ring.model.SipCall)2 NameLookupInputHandler (cx.ring.utils.NameLookupInputHandler)2 Drawable (android.graphics.drawable.Drawable)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1