Slightly changed fields validation in create account form
This commit is contained in:
parent
f965c84184
commit
e3da406e0d
2 changed files with 66 additions and 15 deletions
|
@ -75,6 +75,23 @@
|
||||||
android:textColor="@android:color/black"
|
android:textColor="@android:color/black"
|
||||||
android:background="@drawable/setup_field_background" />
|
android:background="@drawable/setup_field_background" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:contentDescription="@string/content_description_setup_ok"
|
||||||
|
android:id="@+id/setup_password_ok"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingRight="5dp"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:src="@drawable/wizard_notok"/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:textCursorDrawable="@null"
|
android:textCursorDrawable="@null"
|
||||||
android:id="@+id/setup_password_confirm"
|
android:id="@+id/setup_password_confirm"
|
||||||
|
@ -91,7 +108,7 @@
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:contentDescription="@string/content_description_setup_ok"
|
android:contentDescription="@string/content_description_setup_ok"
|
||||||
android:id="@+id/setup_password_ok"
|
android:id="@+id/setup_confirm_password_ok"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingRight="5dp"
|
android:paddingRight="5dp"
|
||||||
|
|
|
@ -50,6 +50,7 @@ public class WizardFragment extends Fragment {
|
||||||
private boolean usernameOk = false;
|
private boolean usernameOk = false;
|
||||||
private boolean passwordOk = false;
|
private boolean passwordOk = false;
|
||||||
private boolean emailOk = false;
|
private boolean emailOk = false;
|
||||||
|
private boolean confirmPasswordOk = false;
|
||||||
private ImageView createAccount;
|
private ImageView createAccount;
|
||||||
private TextView errorMessage;
|
private TextView errorMessage;
|
||||||
|
|
||||||
|
@ -66,7 +67,10 @@ public class WizardFragment extends Fragment {
|
||||||
passwordConfirm = (EditText) view.findViewById(R.id.setup_password_confirm);
|
passwordConfirm = (EditText) view.findViewById(R.id.setup_password_confirm);
|
||||||
|
|
||||||
ImageView passwordOkIV = (ImageView) view.findViewById(R.id.setup_password_ok);
|
ImageView passwordOkIV = (ImageView) view.findViewById(R.id.setup_password_ok);
|
||||||
addXMLRPCPasswordHandler(password, passwordConfirm, passwordOkIV);
|
addXMLRPCPasswordHandler(password, passwordOkIV);
|
||||||
|
|
||||||
|
ImageView passwordConfirmOkIV = (ImageView) view.findViewById(R.id.setup_confirm_password_ok);
|
||||||
|
addXMLRPCConfirmPasswordHandler(password, passwordConfirm, passwordConfirmOkIV);
|
||||||
|
|
||||||
email = (EditText) view.findViewById(R.id.setup_email);
|
email = (EditText) view.findViewById(R.id.setup_email);
|
||||||
ImageView emailOkIV = (ImageView) view.findViewById(R.id.setup_email_ok);
|
ImageView emailOkIV = (ImageView) view.findViewById(R.id.setup_email_ok);
|
||||||
|
@ -95,7 +99,7 @@ public class WizardFragment extends Fragment {
|
||||||
errorMessage.setText(R.string.wizard_server_unavailable);
|
errorMessage.setText(R.string.wizard_server_unavailable);
|
||||||
usernameOk = false;
|
usernameOk = false;
|
||||||
icon.setImageResource(R.drawable.wizard_notok);
|
icon.setImageResource(R.drawable.wizard_notok);
|
||||||
createAccount.setEnabled(usernameOk && passwordOk && emailOk);
|
createAccount.setEnabled(usernameOk && passwordOk && confirmPasswordOk && emailOk);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -108,7 +112,7 @@ public class WizardFragment extends Fragment {
|
||||||
errorMessage.setText(R.string.wizard_username_unavailable);
|
errorMessage.setText(R.string.wizard_username_unavailable);
|
||||||
usernameOk = false;
|
usernameOk = false;
|
||||||
icon.setImageResource(R.drawable.wizard_notok);
|
icon.setImageResource(R.drawable.wizard_notok);
|
||||||
createAccount.setEnabled(usernameOk && passwordOk && emailOk);
|
createAccount.setEnabled(usernameOk && passwordOk && confirmPasswordOk && emailOk);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -117,7 +121,7 @@ public class WizardFragment extends Fragment {
|
||||||
errorMessage.setText("");
|
errorMessage.setText("");
|
||||||
icon.setImageResource(R.drawable.wizard_ok);
|
icon.setImageResource(R.drawable.wizard_ok);
|
||||||
usernameOk = true;
|
usernameOk = true;
|
||||||
createAccount.setEnabled(usernameOk && passwordOk && emailOk);
|
createAccount.setEnabled(usernameOk && passwordOk && confirmPasswordOk && emailOk);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -253,12 +257,12 @@ public class WizardFragment extends Fragment {
|
||||||
errorMessage.setText(R.string.wizard_email_incorrect);
|
errorMessage.setText(R.string.wizard_email_incorrect);
|
||||||
icon.setImageResource(R.drawable.wizard_notok);
|
icon.setImageResource(R.drawable.wizard_notok);
|
||||||
}
|
}
|
||||||
createAccount.setEnabled(usernameOk && passwordOk && emailOk);
|
createAccount.setEnabled(usernameOk && passwordOk && confirmPasswordOk && emailOk);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addXMLRPCPasswordHandler(final EditText field1, final EditText field2, final ImageView icon) {
|
private void addXMLRPCPasswordHandler(final EditText field1, final ImageView icon) {
|
||||||
TextWatcher passwordListener = new TextWatcher() {
|
TextWatcher passwordListener = new TextWatcher() {
|
||||||
public void afterTextChanged(Editable arg0) {
|
public void afterTextChanged(Editable arg0) {
|
||||||
|
|
||||||
|
@ -271,21 +275,51 @@ public class WizardFragment extends Fragment {
|
||||||
public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3)
|
public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3)
|
||||||
{
|
{
|
||||||
passwordOk = false;
|
passwordOk = false;
|
||||||
if (isPasswordCorrect(field1.getText().toString()) && field1.getText().toString().equals(field2.getText().toString())) {
|
if (isPasswordCorrect(field1.getText().toString())) {
|
||||||
passwordOk = true;
|
passwordOk = true;
|
||||||
icon.setImageResource(R.drawable.wizard_ok);
|
icon.setImageResource(R.drawable.wizard_ok);
|
||||||
errorMessage.setText("");
|
errorMessage.setText("");
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
if (isPasswordCorrect(field1.getText().toString())) {
|
|
||||||
errorMessage.setText(R.string.wizard_passwords_unmatched);
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
errorMessage.setText(R.string.wizard_password_incorrect);
|
errorMessage.setText(R.string.wizard_password_incorrect);
|
||||||
}
|
|
||||||
icon.setImageResource(R.drawable.wizard_notok);
|
icon.setImageResource(R.drawable.wizard_notok);
|
||||||
}
|
}
|
||||||
createAccount.setEnabled(usernameOk && passwordOk && emailOk);
|
createAccount.setEnabled(usernameOk && passwordOk && confirmPasswordOk && emailOk);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
field1.addTextChangedListener(passwordListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addXMLRPCConfirmPasswordHandler(final EditText field1, final EditText field2, final ImageView icon) {
|
||||||
|
TextWatcher passwordListener = new TextWatcher() {
|
||||||
|
public void afterTextChanged(Editable arg0) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3)
|
||||||
|
{
|
||||||
|
confirmPasswordOk = false;
|
||||||
|
if (field1.getText().toString().equals(field2.getText().toString())) {
|
||||||
|
confirmPasswordOk = true;
|
||||||
|
icon.setImageResource(R.drawable.wizard_ok);
|
||||||
|
|
||||||
|
if (!isPasswordCorrect(field1.getText().toString())) {
|
||||||
|
errorMessage.setText(R.string.wizard_password_incorrect);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
errorMessage.setText("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
errorMessage.setText(R.string.wizard_passwords_unmatched);
|
||||||
|
icon.setImageResource(R.drawable.wizard_notok);
|
||||||
|
}
|
||||||
|
createAccount.setEnabled(usernameOk && passwordOk && confirmPasswordOk && emailOk);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue