Search in sources :

Example 1 with CredentialsUpdateListener

use of com.waz.api.CredentialsUpdateListener in project wire-android by wireapp.

the class ChangeUsernamePreferenceDialogFragment method onStart.

@Override
public void onStart() {
    super.onStart();
    usernameEditText.addTextChangedListener(usernameTextWatcher);
    backButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!cancelEnabled && getStoreFactory() != null) {
                CredentialsUpdateListener emptyCredentialsListener = new CredentialsUpdateListener() {

                    @Override
                    public void onUpdated() {
                    }

                    @Override
                    public void onUpdateFailed(int code, String message, String label) {
                    }
                };
                getStoreFactory().getZMessagingApiStore().getApi().getSelf().setUsername(suggestedUsername, emptyCredentialsListener);
            }
            dismiss();
        }
    });
    okButton.setOnClickListener(okButtonClickListener);
    usernameEditText.requestFocus();
}
Also used : CredentialsUpdateListener(com.waz.api.CredentialsUpdateListener) LoadingIndicatorView(com.waz.zclient.views.LoadingIndicatorView) View(android.view.View)

Example 2 with CredentialsUpdateListener

use of com.waz.api.CredentialsUpdateListener in project wire-android by wireapp.

the class AppEntryStore method addEmailAndPasswordToPhone.

@Override
public void addEmailAndPasswordToPhone(final String email, final String password, final ErrorCallback emailErrorCallback, final ErrorCallback passwordErrorCallback) {
    setAndStoreEmail(email);
    this.password = password;
    final CredentialsUpdateListener emailUpdateListener = new CredentialsUpdateListener() {

        @Override
        public void onUpdated() {
            appEntryStateCallback.tagAppEntryEvent(EmailVerification.submitted(EmailVerification.Context.POST_LOGIN));
            appEntryStateCallback.tagAppEntryEvent(EditSelfUser.emailAddedSignIn());
            setState(AppEntryState.PHONE_VERIFY_EMAIL);
        }

        @Override
        public void onUpdateFailed(int errorCode, String message, String label) {
            if (AppEntryError.EMAIL_EXISTS.correspondsTo(errorCode, label)) {
                emailErrorCallback.onError(AppEntryError.EMAIL_EXISTS);
            } else if (AppEntryError.EMAIL_INVALID.correspondsTo(errorCode, label)) {
                emailErrorCallback.onError(AppEntryError.EMAIL_INVALID);
            } else {
                emailErrorCallback.onError(AppEntryError.EMAIL_GENERIC_ERROR);
            }
        }
    };
    self.setPassword(password, new CredentialsUpdateListener() {

        @Override
        public void onUpdated() {
            appEntryStateCallback.tagAppEntryEvent(EditSelfUser.passwordAddedSignIn());
            self.setEmail(email, emailUpdateListener);
        }

        @Override
        public void onUpdateFailed(int errorCode, String message, String label) {
            // were being added on this one.
            if (errorCode == AppEntryError.FORBIDDEN.errorCode) {
                self.setEmail(email, emailUpdateListener);
            } else {
                passwordErrorCallback.onError(AppEntryError.PHONE_ADD_PASSWORD);
            }
        }
    });
}
Also used : CredentialsUpdateListener(com.waz.api.CredentialsUpdateListener)

Example 3 with CredentialsUpdateListener

use of com.waz.api.CredentialsUpdateListener in project wire-android by wireapp.

the class AppEntryStore method addPhoneToEmail.

@Override
public void addPhoneToEmail(String countryCode, String phone, final ErrorCallback errorCallback) {
    setAndStoreCountryCode(countryCode);
    setAndStorePhone(phone);
    self.setPhone(countryCode + phone, new CredentialsUpdateListener() {

        @Override
        public void onUpdated() {
            appEntryStateCallback.tagAppEntryEvent(EditSelfUser.phoneAddedSignIn());
            setState(AppEntryState.EMAIL_SET_CODE);
        }

        @Override
        public void onUpdateFailed(int errorCode, String message, String label) {
            if (AppEntryError.PHONE_EXISTS.correspondsTo(errorCode, label)) {
                errorCallback.onError(AppEntryError.PHONE_EXISTS);
            } else {
                errorCallback.onError(AppEntryError.PHONE_REGISTER_GENERIC_ERROR);
            }
        }
    });
}
Also used : CredentialsUpdateListener(com.waz.api.CredentialsUpdateListener)

Example 4 with CredentialsUpdateListener

use of com.waz.api.CredentialsUpdateListener in project wire-android by wireapp.

the class AddEmailAndPasswordPreferenceDialogFragment method handleInput.

private void handleInput() {
    final String email = emailInputLayout.getEditText().getText().toString().trim();
    if (!emailValidator.validate(email)) {
        emailInputLayout.setError(getString(R.string.pref__account_action__dialog__add_email_password__error__invalid_email));
        return;
    }
    final String password = passwordInputLayout.getEditText().getText().toString().trim();
    if (!passwordValidator.validate(password)) {
        passwordInputLayout.setError(getString(R.string.pref__account_action__dialog__add_email_password__error__invalid_password));
        return;
    }
    getStoreFactory().getProfileStore().addEmailAndPassword(email, password, new CredentialsUpdateListener() {

        @Override
        public void onUpdated() {
            if (getContainer() == null) {
                return;
            }
            getContainer().onVerifyEmail(email);
        }

        @Override
        public void onUpdateFailed(int errorCode, String message, String label) {
            if (passwordInputLayout == null || emailInputLayout == null) {
                return;
            }
            if (AppEntryError.PHONE_ADD_PASSWORD.correspondsTo(errorCode, label)) {
                passwordInputLayout.setError(getString(AppEntryError.PHONE_ADD_PASSWORD.headerResource));
            } else if (AppEntryError.EMAIL_EXISTS.correspondsTo(errorCode, label)) {
                passwordInputLayout.setError(getString(AppEntryError.EMAIL_EXISTS.headerResource));
            } else if (AppEntryError.EMAIL_INVALID.correspondsTo(errorCode, label)) {
                passwordInputLayout.setError(getString(AppEntryError.EMAIL_INVALID.headerResource));
            } else {
                passwordInputLayout.setError(getString(AppEntryError.EMAIL_GENERIC_ERROR.headerResource));
            }
        }
    });
}
Also used : CredentialsUpdateListener(com.waz.api.CredentialsUpdateListener) SuppressLint(android.annotation.SuppressLint)

Example 5 with CredentialsUpdateListener

use of com.waz.api.CredentialsUpdateListener in project wire-android by wireapp.

the class ChangeEmailPreferenceDialogFragment method handleInput.

private void handleInput() {
    final String email = inputLayout.getEditText().getText().toString().trim();
    if (!emailValidator.validate(email)) {
        inputLayout.setError(getString(R.string.pref__account_action__dialog__change_email__error__invalid_email));
        return;
    }
    if (email.equalsIgnoreCase(getStoreFactory().getProfileStore().getMyEmail())) {
        dismiss();
        return;
    }
    inputLayout.setError(null);
    getStoreFactory().getProfileStore().setMyEmail(email, new CredentialsUpdateListener() {

        @Override
        public void onUpdated() {
            if (getContainer() == null) {
                return;
            }
            getContainer().onVerifyEmail(email);
        }

        @Override
        public void onUpdateFailed(int errorCode, String message, String label) {
            if (inputLayout == null) {
                dismiss();
                return;
            }
            if (AppEntryError.EMAIL_EXISTS.correspondsTo(errorCode, label)) {
                inputLayout.setError(getString(AppEntryError.EMAIL_EXISTS.headerResource));
            } else if (AppEntryError.EMAIL_INVALID.correspondsTo(errorCode, label)) {
                inputLayout.setError(getString(AppEntryError.EMAIL_INVALID.headerResource));
            } else {
                inputLayout.setError(getString(AppEntryError.EMAIL_GENERIC_ERROR.headerResource));
            }
        }
    });
}
Also used : CredentialsUpdateListener(com.waz.api.CredentialsUpdateListener) SuppressLint(android.annotation.SuppressLint)

Aggregations

CredentialsUpdateListener (com.waz.api.CredentialsUpdateListener)6 SuppressLint (android.annotation.SuppressLint)2 View (android.view.View)1 BaseScalaActivity (com.waz.zclient.BaseScalaActivity)1 KeptGeneratedUsernameEvent (com.waz.zclient.core.controllers.tracking.events.onboarding.KeptGeneratedUsernameEvent)1 LoadingIndicatorView (com.waz.zclient.views.LoadingIndicatorView)1