use of com.waz.zclient.pages.main.profile.views.OnTextChangedListener in project wire-android by wireapp.
the class EmailRegisterFragment method onViewCreated.
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
passwordLengthMessage.setAlpha(0f);
passwordLengthMessage.setText(getResources().getString(R.string.new_reg__password_length, getResources().getInteger(R.integer.password_validator__min_password_length)));
textViewName.setText(getStoreFactory().getAppEntryStore().getName());
textViewEmail.setText(getStoreFactory().getAppEntryStore().getEmail());
textViewPassword.setText(getStoreFactory().getAppEntryStore().getPassword());
textViewPassword.addTextChangedListener(new OnTextChangedListener() {
boolean wasValid = true;
@Override
public void afterTextChanged(Editable s) {
if (isPasswordValid() == wasValid) {
return;
}
if (!isPasswordValid()) {
passwordLengthMessage.animate().alpha(1f).setInterpolator(new Expo.EaseIn()).start();
} else {
passwordLengthMessage.animate().alpha(0f).setInterpolator(new Expo.EaseIn()).start();
}
wasValid = isPasswordValid();
}
});
}
use of com.waz.zclient.pages.main.profile.views.OnTextChangedListener in project wire-android by wireapp.
the class VerifyPhoneNumberPreferenceFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final String number = PhoneNumberUtils.formatNumber(getArguments().getString(ARG_PHONE, ""));
final View view = inflater.inflate(R.layout.fragment_preference_phone_number_verification, container, false);
final TextInputLayout verificationCodeInputLayout = ViewUtils.getView(view, R.id.til__verification_code);
verificationCodeInputLayout.setErrorEnabled(true);
final View backButton = ViewUtils.getView(view, R.id.tv__back_button);
backButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
final View okButton = ViewUtils.getView(view, R.id.tv__ok_button);
okButton.setEnabled(false);
okButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final String code = getVerificationCode();
getStoreFactory().getProfileStore().submitCode(number, code, new ZMessagingApi.PhoneNumberVerificationListener() {
@Override
public void onVerified(KindOfVerification kindOfVerification) {
dismiss();
}
@Override
public void onVerificationFailed(KindOfVerification kindOfVerification, int errorCode, String message, String label) {
if (AppEntryError.PHONE_INVALID_REGISTRATION_CODE.correspondsTo(errorCode, label)) {
verificationCodeInputLayout.setError(getString(AppEntryError.PHONE_INVALID_REGISTRATION_CODE.headerResource));
} else {
verificationCodeInputLayout.setError(getString(AppEntryError.PHONE_REGISTER_GENERIC_ERROR.headerResource));
}
}
});
}
});
final TextView changeNumberButton = ViewUtils.getView(view, R.id.tv__change_number_button);
changeNumberButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (getContainer() == null) {
return;
}
dismiss();
getContainer().changePhoneNumber(number);
}
});
final TextView resendButton = ViewUtils.getView(view, R.id.tv__resend_button);
resendButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
resendButton.animate().alpha(0f).start();
getStoreFactory().getProfileStore().resendPhoneVerificationCode(number, new ZMessagingApi.PhoneConfirmationCodeRequestListener() {
@Override
public void onConfirmationCodeSent(KindOfAccess kindOfAccess) {
resendButton.animate().alpha(1f).start();
}
@Override
public void onPasswordExists(KindOfAccess kindOfAccess) {
}
@Override
public void onConfirmationCodeSendingFailed(KindOfAccess kindOfAccess, int code, String message, String label) {
resendButton.animate().alpha(1f).start();
AppEntryUtil.showErrorDialog(getActivity(), AppEntryError.PHONE_REGISTER_GENERIC_ERROR, null);
}
});
}
});
final TextView verificationDescription = ViewUtils.getView(view, R.id.tv__verification_description);
verificationDescription.setText(getString(R.string.pref__account_action__phone_verification__description, number));
final EditText firstNumberEditText = ViewUtils.getView(view, R.id.et__verification_code__1);
final EditText secondNumberEditText = ViewUtils.getView(view, R.id.et__verification_code__2);
final EditText thirdNumberEditText = ViewUtils.getView(view, R.id.et__verification_code__3);
final EditText fourthNumberEditText = ViewUtils.getView(view, R.id.et__verification_code__4);
final EditText fifthNumberEditText = ViewUtils.getView(view, R.id.et__verification_code__5);
final EditText sixthNumberEditText = ViewUtils.getView(view, R.id.et__verification_code__6);
textBoxes = new LinkedList<>(Arrays.asList(firstNumberEditText, secondNumberEditText, thirdNumberEditText, fourthNumberEditText, fifthNumberEditText, sixthNumberEditText));
for (int i = 0; i < textBoxes.size(); i++) {
final EditText textBox = textBoxes.get(i);
final int finalI = i;
textBox.setTypeface(TypefaceUtils.getTypeface(getString(R.string.wire__typeface__bold)));
textBox.addTextChangedListener(new OnTextChangedListener() {
@Override
public void afterTextChanged(Editable s) {
final String val = textBox.getText().toString().trim();
final char c;
if (TextUtils.isEmpty(val)) {
c = ' ';
} else {
c = val.charAt(0);
}
verificationCode[finalI] = c;
final boolean wasDelete = c == ' ';
if (!jumpToNextEmptyTextBox(wasDelete)) {
okButton.setEnabled(true);
if (finalI == textBoxes.size()) {
okButton.requestFocus();
}
} else {
okButton.setEnabled(false);
}
}
});
}
return view;
}
Aggregations