use of android.support.design.widget.TextInputLayout in project FirebaseUI-Android by firebase.
the class RegisterEmailActivityTest method testSignUpButton_validatesFields.
@Test
public void testSignUpButton_validatesFields() {
RegisterEmailActivity registerEmailActivity = createActivity();
// Trigger RegisterEmailFragment (bypass check email)
registerEmailActivity.onNewUser(new User.Builder(TestConstants.EMAIL).build());
Button button = (Button) registerEmailActivity.findViewById(R.id.button_create);
button.performClick();
TextInputLayout nameLayout = (TextInputLayout) registerEmailActivity.findViewById(R.id.name_layout);
TextInputLayout passwordLayout = (TextInputLayout) registerEmailActivity.findViewById(R.id.password_layout);
assertEquals(registerEmailActivity.getString(R.string.required_field), nameLayout.getError().toString());
assertEquals(String.format(registerEmailActivity.getResources().getQuantityString(R.plurals.error_weak_password, R.integer.min_password_length), registerEmailActivity.getResources().getInteger(R.integer.min_password_length)), passwordLayout.getError().toString());
}
use of android.support.design.widget.TextInputLayout in project materialistic by hidroh.
the class FeedbackActivity method onCreate.
@SuppressWarnings("ConstantConditions")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_feedback);
AppUtils.setTextWithLinks((TextView) findViewById(R.id.feedback_note), AppUtils.fromHtml(getString(R.string.feedback_note)));
final TextInputLayout titleLayout = (TextInputLayout) findViewById(R.id.textinput_title);
final TextInputLayout bodyLayout = (TextInputLayout) findViewById(R.id.textinput_body);
final EditText title = (EditText) findViewById(R.id.edittext_title);
final EditText body = (EditText) findViewById(R.id.edittext_body);
final View sendButton = findViewById(R.id.feedback_button);
findViewById(R.id.button_rate).setOnClickListener(v -> {
AppUtils.openPlayStore(FeedbackActivity.this);
finish();
});
sendButton.setOnClickListener(v -> {
titleLayout.setErrorEnabled(false);
bodyLayout.setErrorEnabled(false);
if (title.length() == 0) {
titleLayout.setError(getString(R.string.title_required));
}
if (body.length() == 0) {
bodyLayout.setError(getString(R.string.comment_required));
}
if (title.length() == 0 || body.length() == 0) {
return;
}
sendButton.setEnabled(false);
mFeedbackClient.send(title.getText().toString(), body.getText().toString(), new FeedbackCallback(this));
});
}
use of android.support.design.widget.TextInputLayout in project material-components-android by material-components.
the class TextInputLayoutActions method setErrorTextAppearance.
public static ViewAction setErrorTextAppearance(final int resId) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isAssignableFrom(TextInputLayout.class);
}
@Override
public String getDescription() {
return "Sets the error text appearance";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
TextInputLayout layout = (TextInputLayout) view;
layout.setErrorTextAppearance(resId);
uiController.loopMainThreadUntilIdle();
}
};
}
use of android.support.design.widget.TextInputLayout in project material-components-android by material-components.
the class TextInputLayoutActions method setErrorEnabled.
public static ViewAction setErrorEnabled(final boolean enabled) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isAssignableFrom(TextInputLayout.class);
}
@Override
public String getDescription() {
return "Enables/disables the error";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
TextInputLayout layout = (TextInputLayout) view;
layout.setErrorEnabled(enabled);
uiController.loopMainThreadUntilIdle();
}
};
}
use of android.support.design.widget.TextInputLayout in project material-components-android by material-components.
the class TextInputLayoutActions method setCounterEnabled.
public static ViewAction setCounterEnabled(final boolean enabled) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isAssignableFrom(TextInputLayout.class);
}
@Override
public String getDescription() {
return "Sets the counter enabled";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
TextInputLayout layout = (TextInputLayout) view;
layout.setCounterEnabled(enabled);
uiController.loopMainThreadUntilIdle();
}
};
}
Aggregations