agoda-com / Kakao

This repo is no longer supported. Please visit a https://github.com/KakaoCup/Kakao
Apache License 2.0
1.11k stars 102 forks source link

KTextInputLayout depends from TextInputEditText #164

Closed v-rodionov closed 4 years ago

v-rodionov commented 4 years ago

Hi, we got a problem :)

In our layout files we have something like

    <com.google.android.material.textfield.TextInputLayout>
        <androidx.appcompat.widget.AppCompatEditText />
    </com.google.android.material.textfield.TextInputLayout>

In test

object TestScreen : Screen<TestScreen>() {
    val textInputLayout = KTextInputLayout { withId(R.id.textInputLayout) }
}

TestScreen {
    textInputLayout{ 
        edit { typeText("some text") }
    } 
}

Expected Results:

Test passed

Actual Results:

androidx.test.espresso.NoMatchingViewException: No views in hierarchy found matching: (is descendant of a: (with id: com.test.test:id/textInputLayout) and an instance of com.google.android.material.textfield.TextInputEditText)


It's because KTextInputLayout has check

isInstanceOf(TextInputEditText::class.java)

Do you have any reasons to check TextInputEditText ? I think it's possible to replace TextInputEditText to AppCompatEditText or EditText TextInputEditText extends AppCompatEditText

Unlimity commented 4 years ago

Hi! Thank you for reaching out. As per the Google's documentation, the intended use of TextInputLayout is with TextInputEditText or it's descendants, since it gives you access to proper behavior and accessibility services. Although it is possible to just reference the EditText, I'm not sure this is the best approach. But anyway, you can submit a PR and resolve the issue. But please make sure in that case that you add support of ViewMatchers.isAssignableFrom() to Kakao and use it in this case so that any type of EditText would be matched.

Vacxe commented 4 years ago

@v-rodionov I think at first you can try to change your codebase with TextInputEditText and if the behaviour will be the same I think it can solve this issue.

v-rodionov commented 4 years ago

@Vacxe We replaced TextInputEditTexttoAppCompatEditTextbecause our users have crash on meizu devices(https://issuetracker.google.com/issues/112105087). The crash was fixed in new library version, but in alpha only(https://github.com/material-components/material-components-android/pull/358).