Fixed
Status Update
Comments
al...@google.com <al...@google.com> #2
Hi Ed, Thank you so much for these suggestions. I've been reviewing them and merging them in. Hopefully it should be live. I've included a thank you note too in the article.
se...@google.com <se...@google.com> #3
Great! Thanks a lot, I'll look for the live updates soon!
te...@gmail.com <te...@gmail.com> #4
took me some time to understand why all my layout start to fail to inflate because of this xD. For now, I fixed it with a ugly try catch
Could it be deferred until attachToWindow?
Could it be deferred until attachToWindow?
ap...@google.com <ap...@google.com> #5
Project: platform/frameworks/support
Branch: androidx-main
commit 78e22170788df05b5676110cb903adafd26f4731
Author: Sean McQuillan <seanmcq@google.com>
Date: Fri Dec 03 15:42:40 2021
Don't call setKeyListener from AppCompat constructors
This leaked a partially constructed this instance to overrides of
setKeyListener.
Instead, explicitly call super. for all calls made during constructor.
No behavior changes for apps that don't override setKeyListener.
Relnote: "AppCompatEditText, AppCompatAutoCompleteTextView, and
AppCompatMultiAutoCompleteTextView will not call overriden
setKeyListener during the constructor. Fixes b/208480173 "
Test: ./gradlew :appc:appc:cAT
Fixes: b/208480173
Change-Id: I5c13aa13569e9a916a4af097153da40cbcf27366
M appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatMultiAutoCompleteTextView.java
M appcompat/appcompat/src/androidTest/java/androidx/appcompat/widget/AppCompatAutoCompleteTextViewEmojiTest.java
M appcompat/appcompat/src/androidTest/java/androidx/appcompat/widget/AppCompatEditTextEmojiTest.java
M appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatEditText.java
M appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatAutoCompleteTextView.java
M appcompat/appcompat/src/androidTest/java/androidx/appcompat/widget/AppCompatMultiAutoCompleteTextViewEmojiTest.java
M appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatEmojiEditTextHelper.java
https://android-review.googlesource.com/1910610
Branch: androidx-main
commit 78e22170788df05b5676110cb903adafd26f4731
Author: Sean McQuillan <seanmcq@google.com>
Date: Fri Dec 03 15:42:40 2021
Don't call setKeyListener from AppCompat constructors
This leaked a partially constructed this instance to overrides of
setKeyListener.
Instead, explicitly call super. for all calls made during constructor.
No behavior changes for apps that don't override setKeyListener.
Relnote: "AppCompatEditText, AppCompatAutoCompleteTextView, and
AppCompatMultiAutoCompleteTextView will not call overriden
setKeyListener during the constructor. Fixes
Test: ./gradlew :appc:appc:cAT
Fixes:
Change-Id: I5c13aa13569e9a916a4af097153da40cbcf27366
M appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatMultiAutoCompleteTextView.java
M appcompat/appcompat/src/androidTest/java/androidx/appcompat/widget/AppCompatAutoCompleteTextViewEmojiTest.java
M appcompat/appcompat/src/androidTest/java/androidx/appcompat/widget/AppCompatEditTextEmojiTest.java
M appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatEditText.java
M appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatAutoCompleteTextView.java
M appcompat/appcompat/src/androidTest/java/androidx/appcompat/widget/AppCompatMultiAutoCompleteTextViewEmojiTest.java
M appcompat/appcompat/src/main/java/androidx/appcompat/widget/AppCompatEmojiEditTextHelper.java
se...@google.com <se...@google.com> #6
Thanks. After exploring, it seemed that the behavior change in onAttachedToWindow was undesireable.
However, with a bit of code duplication it's possible to avoid dispatched calls to setKeyListener from the constructor, so we opted for that approach.
Thank you for the report!
te...@gmail.com <te...@gmail.com> #7
Thanks for your consideration. I was quite sure if any answer came back to get something l like " Don't override addTextChangedListener, problem solved"
Very appreciated you look for it and found a way to not force me keep forever a try-catch to managed this behavior :)
Good continuation,
best regards
Very appreciated you look for it and found a way to not force me keep forever a try-catch to managed this behavior :)
Good continuation,
best regards
Description
Version used: 1.4.0
Devices/Android versions reproduced on: All
Problem is since version 1.4.0, AppCompatEditText constructor call addTextChangedListener during instantiation which is not a final method.
In my lib, I have overrided this method in my sub class to do some job and improve behavior when you add a textWatcher.
But this overrided method can't be called before the construction is fully processed... And since AppCompatEditText call now this method in its constructor, it always failed and crash since the sub construction has not been done yet...
The problem doesn't exist up to version 1.3.1