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