Search in sources :

Example 1 with UserEntity

use of com.nextcloud.talk.models.database.UserEntity in project talk-android by nextcloud.

the class ContactsController method fetchData.

private void fetchData() {
    dispose(null);
    Set<Sharee> shareeHashSet = new HashSet<>();
    contactItems = new ArrayList<>();
    userHeaderItems = new HashMap<>();
    RetrofitBucket retrofitBucket = ApiUtils.getRetrofitBucketForContactsSearch(userEntity.getBaseUrl(), "");
    contactsQueryDisposable = ncApi.getContactsWithSearchParam(ApiUtils.getCredentials(userEntity.getUsername(), userEntity.getToken()), retrofitBucket.getUrl(), retrofitBucket.getQueryMap()).subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread()).subscribe((ShareesOverall shareesOverall) -> {
        if (shareesOverall != null) {
            if (shareesOverall.getOcs().getData().getUsers() != null) {
                shareeHashSet.addAll(shareesOverall.getOcs().getData().getUsers());
            }
            if (shareesOverall.getOcs().getData().getExactUsers() != null && shareesOverall.getOcs().getData().getExactUsers().getExactSharees() != null) {
                shareeHashSet.addAll(shareesOverall.getOcs().getData().getExactUsers().getExactSharees());
            }
            Participant participant;
            for (Sharee sharee : shareeHashSet) {
                if (!sharee.getValue().getShareWith().equals(userEntity.getUsername())) {
                    participant = new Participant();
                    participant.setName(sharee.getLabel());
                    String headerTitle;
                    headerTitle = sharee.getLabel().substring(0, 1).toUpperCase();
                    UserHeaderItem userHeaderItem;
                    if (!userHeaderItems.containsKey(headerTitle)) {
                        userHeaderItem = new UserHeaderItem(headerTitle);
                        userHeaderItems.put(headerTitle, userHeaderItem);
                    }
                    participant.setUserId(sharee.getValue().getShareWith());
                    contactItems.add(new UserItem(participant, userEntity, userHeaderItems.get(headerTitle)));
                }
            }
            userHeaderItems = new HashMap<>();
            Collections.sort(contactItems, (o1, o2) -> {
                String firstName;
                String secondName;
                if (o1 instanceof UserItem) {
                    firstName = ((UserItem) o1).getModel().getName();
                } else {
                    firstName = ((UserHeaderItem) o1).getModel();
                }
                if (o2 instanceof UserItem) {
                    secondName = ((UserItem) o2).getModel().getName();
                } else {
                    secondName = ((UserHeaderItem) o2).getModel();
                }
                return firstName.compareToIgnoreCase(secondName);
            });
            if (isNewConversationView) {
                contactItems.add(0, new NewCallHeaderItem());
            }
            adapter.updateDataSet(contactItems, true);
            searchItem.setVisible(contactItems.size() > 0);
            swipeRefreshLayout.setRefreshing(false);
            if (isNewConversationView) {
                checkAndHandleBottomButtons();
            }
        }
    }, throwable -> {
        if (searchItem != null) {
            searchItem.setVisible(false);
        }
        if (throwable instanceof HttpException) {
            HttpException exception = (HttpException) throwable;
            switch(exception.code()) {
                case 401:
                    if (getParentController() != null && getParentController().getRouter() != null) {
                        getParentController().getRouter().pushController((RouterTransaction.with(new WebViewLoginController(userEntity.getBaseUrl(), true)).pushChangeHandler(new VerticalChangeHandler()).popChangeHandler(new VerticalChangeHandler())));
                    }
                    break;
                default:
                    break;
            }
        }
        swipeRefreshLayout.setRefreshing(false);
        dispose(contactsQueryDisposable);
    }, () -> {
        swipeRefreshLayout.setRefreshing(false);
        dispose(contactsQueryDisposable);
    });
}
Also used : AutoInjector(autodagger.AutoInjector) Bundle(android.os.Bundle) UserUtils(com.nextcloud.talk.utils.database.user.UserUtils) EntryMenuController(com.nextcloud.talk.controllers.bottomsheet.EntryMenuController) IFlexible(eu.davidea.flexibleadapter.items.IFlexible) SearchView(android.support.v7.widget.SearchView) RetrofitBucket(com.nextcloud.talk.models.RetrofitBucket) UserItem(com.nextcloud.talk.adapters.items.UserItem) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) OnClick(butterknife.OnClick) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration) BindView(butterknife.BindView) ApiUtils(com.nextcloud.talk.utils.ApiUtils) ViewHidingBehaviourAnimation(com.nextcloud.talk.utils.animations.ViewHidingBehaviourAnimation) BottomSheet(com.kennyc.bottomsheet.BottomSheet) Handler(android.os.Handler) View(android.view.View) Button(android.widget.Button) UserHeaderItem(com.nextcloud.talk.adapters.items.UserHeaderItem) Schedulers(io.reactivex.schedulers.Schedulers) Sharee(com.nextcloud.talk.models.json.sharees.Sharee) SelectableAdapter(eu.davidea.flexibleadapter.SelectableAdapter) VerticalChangeHandler(com.bluelinelabs.conductor.changehandler.VerticalChangeHandler) Participant(com.nextcloud.talk.models.json.participants.Participant) MenuItemCompat(android.support.v4.view.MenuItemCompat) Optional(butterknife.Optional) HttpException(retrofit2.HttpException) InputType(android.text.InputType) Set(java.util.Set) FlexibleAdapter(eu.davidea.flexibleadapter.FlexibleAdapter) ThreadMode(org.greenrobot.eventbus.ThreadMode) ViewGroup(android.view.ViewGroup) BundleKeys(com.nextcloud.talk.utils.bundle.BundleKeys) List(java.util.List) Disposable(io.reactivex.disposables.Disposable) Parcels(org.parceler.Parcels) FastScroller(eu.davidea.fastscroller.FastScroller) AbstractFlexibleItem(eu.davidea.flexibleadapter.items.AbstractFlexibleItem) Nullable(android.support.annotation.Nullable) SearchManager(android.app.SearchManager) EditorInfo(android.view.inputmethod.EditorInfo) Context(android.content.Context) CoordinatorLayout(android.support.design.widget.CoordinatorLayout) UserEntity(com.nextcloud.talk.models.database.UserEntity) SmoothScrollLinearLayoutManager(eu.davidea.flexibleadapter.common.SmoothScrollLinearLayoutManager) Intent(android.content.Intent) HashMap(java.util.HashMap) NonNull(android.support.annotation.NonNull) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) BottomSheetLockEvent(com.nextcloud.talk.events.BottomSheetLockEvent) HashSet(java.util.HashSet) Inject(javax.inject.Inject) BaseController(com.nextcloud.talk.controllers.base.BaseController) MenuInflater(android.view.MenuInflater) EventBus(org.greenrobot.eventbus.EventBus) Menu(android.view.Menu) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) NcApi(com.nextcloud.talk.api.NcApi) BottomNavigationView(android.support.design.widget.BottomNavigationView) R(com.nextcloud.talk.R) Room(com.nextcloud.talk.models.json.rooms.Room) LayoutInflater(android.view.LayoutInflater) NewCallHeaderItem(com.nextcloud.talk.adapters.items.NewCallHeaderItem) TextUtils(android.text.TextUtils) FlipView(eu.davidea.flipview.FlipView) ShareesOverall(com.nextcloud.talk.models.json.sharees.ShareesOverall) HorizontalChangeHandler(com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler) RecyclerView(android.support.v7.widget.RecyclerView) Subscribe(org.greenrobot.eventbus.Subscribe) KeyboardUtils(com.nextcloud.talk.utils.KeyboardUtils) CallActivity(com.nextcloud.talk.activities.CallActivity) Observer(io.reactivex.Observer) ViewTreeObserver(android.view.ViewTreeObserver) RoomOverall(com.nextcloud.talk.models.json.rooms.RoomOverall) Collections(java.util.Collections) NextcloudTalkApplication(com.nextcloud.talk.application.NextcloudTalkApplication) RouterTransaction(com.bluelinelabs.conductor.RouterTransaction) RetrofitBucket(com.nextcloud.talk.models.RetrofitBucket) HashMap(java.util.HashMap) NewCallHeaderItem(com.nextcloud.talk.adapters.items.NewCallHeaderItem) VerticalChangeHandler(com.bluelinelabs.conductor.changehandler.VerticalChangeHandler) UserItem(com.nextcloud.talk.adapters.items.UserItem) Sharee(com.nextcloud.talk.models.json.sharees.Sharee) UserHeaderItem(com.nextcloud.talk.adapters.items.UserHeaderItem) Participant(com.nextcloud.talk.models.json.participants.Participant) ShareesOverall(com.nextcloud.talk.models.json.sharees.ShareesOverall) HttpException(retrofit2.HttpException) HashSet(java.util.HashSet)

Example 2 with UserEntity

use of com.nextcloud.talk.models.database.UserEntity in project talk-android by nextcloud.

the class SettingsController method onAttach.

@Override
protected void onAttach(@NonNull View view) {
    super.onAttach(view);
    if (getActionBar() != null) {
        getActionBar().show();
    }
    dispose(null);
    userEntity = userUtils.getCurrentUser();
    if ("No proxy".equals(appPreferences.getProxyType()) || appPreferences.getProxyType() == null) {
        hideProxySettings();
    } else {
        showProxySettings();
    }
    if (appPreferences.getProxyCredentials()) {
        showProxyCredentials();
    } else {
        hideProxyCredentials();
    }
    if (userEntity != null) {
        baseUrlTextView.setText(userEntity.getBaseUrl());
        reauthorizeButton.addPreferenceClickListener(view14 -> {
            getParentController().getRouter().pushController(RouterTransaction.with(new WebViewLoginController(userEntity.getBaseUrl(), true)).pushChangeHandler(new VerticalChangeHandler()).popChangeHandler(new VerticalChangeHandler()));
        });
        if (userEntity.getDisplayName() != null) {
            displayNameTextView.setText(userEntity.getDisplayName());
        }
        loadAvatarImage();
        profileQueryDisposable = ncApi.getUserProfile(ApiUtils.getCredentials(userEntity.getUsername(), userEntity.getToken()), ApiUtils.getUrlForUserProfile(userEntity.getBaseUrl())).subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread()).subscribe(userProfileOverall -> {
            String displayName = null;
            if (!TextUtils.isEmpty(userProfileOverall.getOcs().getData().getDisplayName())) {
                displayName = userProfileOverall.getOcs().getData().getDisplayName();
            } else if (!TextUtils.isEmpty(userProfileOverall.getOcs().getData().getDisplayNameAlt())) {
                displayName = userProfileOverall.getOcs().getData().getDisplayNameAlt();
            }
            boolean needsToUpdateUserId = !TextUtils.isEmpty(userProfileOverall.getOcs().getData().getUserId()) && !userProfileOverall.getOcs().getData().getUserId().equals(userEntity.getUserId());
            if ((!TextUtils.isEmpty(displayName) && !displayName.equals(userEntity.getDisplayName())) || needsToUpdateUserId) {
                dbQueryDisposable = userUtils.createOrUpdateUser(null, null, null, displayName, null, true, userProfileOverall.getOcs().getData().getUserId(), userEntity.getId(), null).subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread()).subscribe(userEntityResult -> {
                    displayNameTextView.setText(userEntityResult.getDisplayName());
                    if (needsToUpdateUserId) {
                        loadAvatarImage();
                    }
                }, throwable -> {
                    dispose(dbQueryDisposable);
                }, () -> dispose(dbQueryDisposable));
            }
        }, throwable -> {
            dispose(profileQueryDisposable);
        }, () -> dispose(profileQueryDisposable));
        removeAccountButton.addPreferenceClickListener(view1 -> {
            cookieManager.getCookieStore().removeAll();
            boolean otherUserExists = userUtils.scheduleUserForDeletionWithId(userEntity.getId());
            new JobRequest.Builder(AccountRemovalJob.TAG).setUpdateCurrent(true).startNow().build().schedule();
            if (otherUserExists && getView() != null) {
                onViewBound(getView());
                onAttach(getView());
            } else if (!otherUserExists) {
                if (getParentController() == null || getParentController().getRouter() == null) {
                    if (getActivity() != null) {
                        // Something went very wrong, finish the app
                        getActivity().finish();
                    }
                } else {
                    getParentController().getRouter().setRoot(RouterTransaction.with(new ServerSelectionController()).pushChangeHandler(new VerticalChangeHandler()).popChangeHandler(new VerticalChangeHandler()));
                }
            }
        });
    }
    if (userUtils.getUsers().size() <= 1) {
        switchAccountButton.setVisibility(View.GONE);
    }
    if (ApplicationWideMessageHolder.getInstance().getMessageType() != null) {
        switch(ApplicationWideMessageHolder.getInstance().getMessageType()) {
            case ACCOUNT_UPDATED_NOT_ADDED:
                messageText.setTextColor(getResources().getColor(R.color.colorPrimary));
                messageText.setText(getResources().getString(R.string.nc_settings_account_updated));
                messageView.setVisibility(View.VISIBLE);
                break;
            case WRONG_ACCOUNT:
                messageText.setTextColor(getResources().getColor(R.color.nc_darkRed));
                messageText.setText(getResources().getString(R.string.nc_settings_wrong_account));
                messageView.setVisibility(View.VISIBLE);
                break;
            case SERVER_WITHOUT_TALK:
                messageText.setTextColor(getResources().getColor(R.color.nc_darkRed));
                messageText.setText(getResources().getString(R.string.nc_settings_wrong_account));
                messageView.setVisibility(View.VISIBLE);
            case ACCOUNT_WAS_IMPORTED:
                messageText.setTextColor(getResources().getColor(R.color.colorPrimary));
                messageText.setText(getResources().getString(R.string.nc_Server_account_imported));
                messageView.setVisibility(View.VISIBLE);
                break;
            case FAILED_TO_IMPORT_ACCOUNT:
                messageText.setTextColor(getResources().getColor(R.color.nc_darkRed));
                messageText.setText(getResources().getString(R.string.nc_server_failed_to_import_account));
                messageView.setVisibility(View.VISIBLE);
                break;
            default:
                messageView.setVisibility(View.GONE);
                break;
        }
        ApplicationWideMessageHolder.getInstance().setMessageType(null);
        messageView.animate().translationY(0).alpha(0.0f).setDuration(2500).setStartDelay(5000).setListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                if (messageView != null) {
                    messageView.setVisibility(View.GONE);
                }
            }
        });
    } else {
        if (messageView != null) {
            messageView.setVisibility(View.GONE);
        }
    }
}
Also used : AutoInjector(autodagger.AutoInjector) Arrays(java.util.Arrays) UserUtils(com.nextcloud.talk.utils.database.user.UserUtils) Uri(android.net.Uri) ImageView(android.widget.ImageView) MaterialPreferenceCategory(com.yarolegovich.mp.MaterialPreferenceCategory) Animator(android.animation.Animator) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) BindView(butterknife.BindView) AppPreferences(com.nextcloud.talk.utils.preferences.AppPreferences) ApiUtils(com.nextcloud.talk.utils.ApiUtils) GlideApp(com.nextcloud.talk.utils.glide.GlideApp) View(android.view.View) Schedulers(io.reactivex.schedulers.Schedulers) GlideUrl(com.bumptech.glide.load.model.GlideUrl) AccountRemovalJob(com.nextcloud.talk.jobs.AccountRemovalJob) VerticalChangeHandler(com.bluelinelabs.conductor.changehandler.VerticalChangeHandler) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ViewGroup(android.view.ViewGroup) MaterialPreferenceScreen(com.yarolegovich.mp.MaterialPreferenceScreen) List(java.util.List) Disposable(io.reactivex.disposables.Disposable) TextView(android.widget.TextView) CookieManager(java.net.CookieManager) Nullable(android.support.annotation.Nullable) JobRequest(com.evernote.android.job.JobRequest) UserEntity(com.nextcloud.talk.models.database.UserEntity) Intent(android.content.Intent) NonNull(android.support.annotation.NonNull) CircleCrop(com.bumptech.glide.load.resource.bitmap.CircleCrop) MaterialEditTextPreference(com.yarolegovich.mp.MaterialEditTextPreference) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) BuildConfig(com.nextcloud.talk.BuildConfig) BaseController(com.nextcloud.talk.controllers.base.BaseController) EventBus(org.greenrobot.eventbus.EventBus) OnPreferenceValueChangedListener(net.orange_box.storebox.listeners.OnPreferenceValueChangedListener) MaterialChoicePreference(com.yarolegovich.mp.MaterialChoicePreference) NcApi(com.nextcloud.talk.api.NcApi) R(com.nextcloud.talk.R) RequestOptions(com.bumptech.glide.request.RequestOptions) LayoutInflater(android.view.LayoutInflater) MaterialStandardPreference(com.yarolegovich.mp.MaterialStandardPreference) TextUtils(android.text.TextUtils) MagicUserInputModule(com.nextcloud.talk.utils.preferences.MagicUserInputModule) LazyHeaders(com.bumptech.glide.load.model.LazyHeaders) ApplicationWideMessageHolder(com.nextcloud.talk.utils.ApplicationWideMessageHolder) NextcloudTalkApplication(com.nextcloud.talk.application.NextcloudTalkApplication) RouterTransaction(com.bluelinelabs.conductor.RouterTransaction) Animator(android.animation.Animator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) VerticalChangeHandler(com.bluelinelabs.conductor.changehandler.VerticalChangeHandler)

Example 3 with UserEntity

use of com.nextcloud.talk.models.database.UserEntity in project talk-android by nextcloud.

the class WebViewLoginController method parseAndLoginFromWebView.

private void parseAndLoginFromWebView(String dataString) {
    LoginData loginData = parseLoginData(assembledPrefix, dataString);
    if (loginData != null) {
        dispose();
        UserEntity currentUser = userUtils.getCurrentUser();
        ApplicationWideMessageHolder.MessageType messageType = null;
        if (currentUser != null && isPasswordUpdate && !currentUser.getUsername().equals(loginData.getUsername())) {
            ApplicationWideMessageHolder.getInstance().setMessageType(ApplicationWideMessageHolder.MessageType.WRONG_ACCOUNT);
            getRouter().popToRoot();
        } else {
            if (!isPasswordUpdate && userUtils.getIfUserWithUsernameAndServer(loginData.getUsername(), baseUrl)) {
                messageType = ApplicationWideMessageHolder.MessageType.ACCOUNT_UPDATED_NOT_ADDED;
            }
            if (userUtils.checkIfUserIsScheduledForDeletion(loginData.getUsername(), baseUrl)) {
                ApplicationWideMessageHolder.getInstance().setMessageType(ApplicationWideMessageHolder.MessageType.ACCOUNT_SCHEDULED_FOR_DELETION);
                getRouter().popToRoot();
            }
            ApplicationWideMessageHolder.MessageType finalMessageType = messageType;
            cookieManager.getCookieStore().removeAll();
            if (!isPasswordUpdate && finalMessageType == null) {
                Bundle bundle = new Bundle();
                bundle.putString(BundleKeys.KEY_USERNAME, loginData.getUsername());
                bundle.putString(BundleKeys.KEY_TOKEN, loginData.getToken());
                bundle.putString(BundleKeys.KEY_BASE_URL, loginData.getServerUrl());
                String protocol = "";
                if (baseUrl.startsWith("http://")) {
                    protocol = "http://";
                } else if (baseUrl.startsWith("https://")) {
                    protocol = "https://";
                }
                if (!TextUtils.isEmpty(protocol)) {
                    bundle.putString(BundleKeys.KEY_ORIGINAL_PROTOCOL, protocol);
                }
                getRouter().pushController(RouterTransaction.with(new AccountVerificationController(bundle)).pushChangeHandler(new HorizontalChangeHandler()).popChangeHandler(new HorizontalChangeHandler()));
            } else {
                if (isPasswordUpdate) {
                    if (currentUser != null) {
                        userQueryDisposable = userUtils.createOrUpdateUser(null, null, null, null, null, true, null, currentUser.getId(), null).subscribe(userEntity -> {
                            if (finalMessageType != null) {
                                ApplicationWideMessageHolder.getInstance().setMessageType(finalMessageType);
                            }
                            getRouter().popToRoot();
                        }, throwable -> dispose(), this::dispose);
                    }
                } else {
                    if (finalMessageType != null) {
                        ApplicationWideMessageHolder.getInstance().setMessageType(finalMessageType);
                    }
                    getRouter().popToRoot();
                }
            }
        }
    }
}
Also used : X509Certificate(java.security.cert.X509Certificate) AutoInjector(autodagger.AutoInjector) Bundle(android.os.Bundle) KeyChain(android.security.KeyChain) UserUtils(com.nextcloud.talk.utils.database.user.UserUtils) URLDecoder(java.net.URLDecoder) ProgressBar(android.widget.ProgressBar) URL(java.net.URL) BindView(butterknife.BindView) SslErrorHandler(android.webkit.SslErrorHandler) Locale(java.util.Locale) Map(java.util.Map) ActivityInfo(android.content.pm.ActivityInfo) WebViewClient(android.webkit.WebViewClient) View(android.view.View) CookieSyncManager(android.webkit.CookieSyncManager) WebView(android.webkit.WebView) Persistable(io.requery.Persistable) Log(android.util.Log) ReactiveEntityStore(io.requery.reactivex.ReactiveEntityStore) ViewGroup(android.view.ViewGroup) BundleKeys(com.nextcloud.talk.utils.bundle.BundleKeys) Disposable(io.reactivex.disposables.Disposable) ClientCertRequest(android.webkit.ClientCertRequest) LoginData(com.nextcloud.talk.models.LoginData) PrivateKey(java.security.PrivateKey) UserEntity(com.nextcloud.talk.models.database.UserEntity) HashMap(java.util.HashMap) NonNull(android.support.annotation.NonNull) CertificateEvent(com.nextcloud.talk.events.CertificateEvent) MagicTrustManager(com.nextcloud.talk.utils.ssl.MagicTrustManager) Inject(javax.inject.Inject) WebSettings(android.webkit.WebSettings) BaseController(com.nextcloud.talk.controllers.base.BaseController) EventBus(org.greenrobot.eventbus.EventBus) Build(android.os.Build) SslError(android.net.http.SslError) R(com.nextcloud.talk.R) MalformedURLException(java.net.MalformedURLException) LayoutInflater(android.view.LayoutInflater) TextUtils(android.text.TextUtils) CertificateException(java.security.cert.CertificateException) Field(java.lang.reflect.Field) HorizontalChangeHandler(com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler) KeyChainException(android.security.KeyChainException) SslCertificate(android.net.http.SslCertificate) ApplicationWideMessageHolder(com.nextcloud.talk.utils.ApplicationWideMessageHolder) NextcloudTalkApplication(com.nextcloud.talk.application.NextcloudTalkApplication) RouterTransaction(com.bluelinelabs.conductor.RouterTransaction) ApplicationWideMessageHolder(com.nextcloud.talk.utils.ApplicationWideMessageHolder) LoginData(com.nextcloud.talk.models.LoginData) Bundle(android.os.Bundle) HorizontalChangeHandler(com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler) UserEntity(com.nextcloud.talk.models.database.UserEntity)

Example 4 with UserEntity

use of com.nextcloud.talk.models.database.UserEntity in project talk-android by nextcloud.

the class UserUtils method getAnyUserAndSetAsActive.

public UserEntity getAnyUserAndSetAsActive() {
    Result findUserQueryResult = dataStore.select(User.class).where(UserEntity.SCHEDULED_FOR_DELETION.notEqual(true)).limit(1).get();
    UserEntity userEntity;
    if ((userEntity = (UserEntity) findUserQueryResult.firstOrNull()) != null) {
        userEntity.setCurrent(true);
        dataStore.update(userEntity).blockingGet();
        return userEntity;
    }
    return null;
}
Also used : User(com.nextcloud.talk.models.database.User) UserEntity(com.nextcloud.talk.models.database.UserEntity) Result(io.requery.query.Result)

Example 5 with UserEntity

use of com.nextcloud.talk.models.database.UserEntity in project talk-android by nextcloud.

the class UserUtils method disableAllUsersWithoutId.

public void disableAllUsersWithoutId(long userId) {
    Result findUserQueryResult = dataStore.select(User.class).where(UserEntity.ID.notEqual(userId)).get();
    for (Object object : findUserQueryResult) {
        UserEntity userEntity = (UserEntity) object;
        userEntity.setCurrent(false);
        dataStore.update(userEntity).blockingGet();
    }
}
Also used : UserEntity(com.nextcloud.talk.models.database.UserEntity) Result(io.requery.query.Result)

Aggregations

UserEntity (com.nextcloud.talk.models.database.UserEntity)17 Disposable (io.reactivex.disposables.Disposable)7 NonNull (android.support.annotation.NonNull)6 NcApi (com.nextcloud.talk.api.NcApi)6 Result (io.requery.query.Result)5 ArrayList (java.util.ArrayList)5 TextUtils (android.text.TextUtils)4 LayoutInflater (android.view.LayoutInflater)4 View (android.view.View)4 ViewGroup (android.view.ViewGroup)4 AutoInjector (autodagger.AutoInjector)4 BindView (butterknife.BindView)4 RouterTransaction (com.bluelinelabs.conductor.RouterTransaction)4 R (com.nextcloud.talk.R)4 Intent (android.content.Intent)3 Bundle (android.os.Bundle)3 Nullable (android.support.annotation.Nullable)3 HorizontalChangeHandler (com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler)3 VerticalChangeHandler (com.bluelinelabs.conductor.changehandler.VerticalChangeHandler)3 NextcloudTalkApplication (com.nextcloud.talk.application.NextcloudTalkApplication)3