Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TextView] inputType=textPassword + singleLine=true misbehaves #43

Closed
ioterateam opened this issue Apr 25, 2018 · 5 comments
Closed

[TextView] inputType=textPassword + singleLine=true misbehaves #43

ioterateam opened this issue Apr 25, 2018 · 5 comments
Assignees
Labels

Comments

@ioterateam
Copy link

Currently i'm using

com.airbnb.android:paris:1.1.0-SNAPSHOT

And i'm getting error value when styling my EditText programmatically, it give me textVisiblePassword instead of textPassword

Here is my code in my fragment

        EditText passEt = new EditText(getContext());
        passEt.setId(new ViewUtil().setViewId());
        Paris.style(passEt).apply(R.style.custom_password_et);
        RelativeLayout.LayoutParams testP = new 
        RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, dimensionToDp(50));
        passEt.setLayoutParams(testP);

Style that i used in styles.xml

    <style name="custom.password_et" parent="@android:style/Widget.EditText">
        <item name="android:layout_marginTop">@dimen/margin_normal</item>
        <item name="android:hint">@string/hint_password</item>
        <item name="android:background">@drawable/et_rounded</item>
        <item name="android:inputType">textPassword</item>
        <item name="android:maxLines">1</item>
        <item name="android:padding">@dimen/margin_small</item>
        <item name="android:paddingStart">@dimen/padding_start</item>
        <item name="android:paddingEnd">@dimen/view_grid_item_close_size</item>
        <item name="android:singleLine">true</item>
        <item name="android:textColor">@color/colorMaterialBlack</item>
        <item name="android:textColorHint">@color/colorMaterialBlackBlur</item>
    </style>

Please fix this bug, thanks

@ngsilverman ngsilverman self-assigned this Apr 25, 2018
@ngsilverman
Copy link
Collaborator

Thanks for creating a new issue for this. I should be able to take a look in the next few days.

@ngsilverman
Copy link
Collaborator

@ioterateam I looked into this and am unable to reproduce the issue.

There's a test here that asserts rather convincingly that setting inputType to textPassword is working. I also played around with a sample and was able to confirm that applying a style containing <item name="android:inputType">textPassword</item> in the same way that you do was successfully changing the input type (the password was not visible).

At this point I'm pretty sure it's not a bug with Paris but rather an issue on your end. I would recommend trying it out with a simpler style that doesn't change any other attributes. How are you currently verifying that the input type is being set to a visible password rather than the standard one? Note that the last character of the password might be visible even if the input type is textPassword. textVisiblePassword makes it completely visible.

@ngsilverman ngsilverman added question and removed bug labels Apr 25, 2018
@ioterateam
Copy link
Author

i found a bug that makes it visible, it's because of attribute <item name="android:singleLine">true</item> in the style. When I exclude it, it's work like normal and show me textPassword, can you re-check it?

@ngsilverman ngsilverman added bug and removed question labels Apr 25, 2018
@ngsilverman ngsilverman changed the title Implement style with attribute android:inputType giving wrong value [TextView] inputType=textPassword + singleLine=true misbehaves Apr 25, 2018
@ngsilverman
Copy link
Collaborator

Thanks for investigating some more, I'm able to repro now. I'll look into this soon.

@ngsilverman
Copy link
Collaborator

@ioterateam I believe I was able to fix the issue. In some ways it's an Android bug, because:

textView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
textView.setSingleLine(true);

Doing this programmatically (in that order) will also break the password input type.

However TextView does some stuff during initialization so that an XML style that sets the same attributes behaves as you would expect. I replicated that logic here and added a few tests.

I published a new snapshot so it should update automatically for you (the previous version might stay cached for a day or so).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants