Search in sources :

Example 11 with TextInputLayout

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());
}
Also used : Button(android.widget.Button) TextInputLayout(android.support.design.widget.TextInputLayout) Test(org.junit.Test)

Example 12 with TextInputLayout

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));
    });
}
Also used : EditText(android.widget.EditText) TextInputLayout(android.support.design.widget.TextInputLayout) TextView(android.widget.TextView) View(android.view.View)

Example 13 with TextInputLayout

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();
        }
    };
}
Also used : ViewAction(android.support.test.espresso.ViewAction) UiController(android.support.test.espresso.UiController) TextInputLayout(android.support.design.widget.TextInputLayout) View(android.view.View)

Example 14 with TextInputLayout

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();
        }
    };
}
Also used : ViewAction(android.support.test.espresso.ViewAction) UiController(android.support.test.espresso.UiController) TextInputLayout(android.support.design.widget.TextInputLayout) View(android.view.View)

Example 15 with TextInputLayout

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();
        }
    };
}
Also used : ViewAction(android.support.test.espresso.ViewAction) UiController(android.support.test.espresso.UiController) TextInputLayout(android.support.design.widget.TextInputLayout) View(android.view.View)

Aggregations

TextInputLayout (android.support.design.widget.TextInputLayout)19 View (android.view.View)12 UiController (android.support.test.espresso.UiController)7 ViewAction (android.support.test.espresso.ViewAction)7 EditText (android.widget.EditText)5 Button (android.widget.Button)4 TextView (android.widget.TextView)4 Nullable (android.support.annotation.Nullable)3 Editable (android.text.Editable)3 TextWatcher (android.text.TextWatcher)2 EmailFieldValidator (com.firebase.ui.auth.ui.email.fieldvalidators.EmailFieldValidator)2 Test (org.junit.Test)2 SuppressLint (android.annotation.SuppressLint)1 FragmentTransaction (android.support.v4.app.FragmentTransaction)1 AppCompatEditText (android.support.v7.widget.AppCompatEditText)1 AdapterView (android.widget.AdapterView)1 CheckBox (android.widget.CheckBox)1 CompoundButton (android.widget.CompoundButton)1 Spinner (android.widget.Spinner)1 WelcomeBackPasswordPrompt (com.firebase.ui.auth.ui.accountlink.WelcomeBackPasswordPrompt)1