Fixed
Status Update
Comments
al...@google.com <al...@google.com>
ro...@google.com <ro...@google.com> #2
Or when changing to textView.textMetricsParamsCompat still crash.
private fun setAsyncText(textView: AppCompatTextView, text: String?) {
if (!text.isNullOrEmpty()) {
val textFuture = PrecomputedTextCompat.getTextFuture(text!!, textView.textMetricsParamsCompat, null)
textView.setTextFuture(textFuture) //Crash
}
}
private fun setAsyncText(textView: AppCompatTextView, text: String?) {
if (!text.isNullOrEmpty()) {
val textFuture = PrecomputedTextCompat.getTextFuture(text!!, textView.textMetricsParamsCompat, null)
textView.setTextFuture(textFuture) //Crash
}
}
va...@google.com <va...@google.com> #3
add this line :
textView.setLayoutDirection(ViewCompat.getLayoutDirection(textView));
before :
setTextFuture(....)
textView.setLayoutDirection(ViewCompat.getLayoutDirection(textView));
before :
setTextFuture(....)
ca...@google.com <ca...@google.com> #4
Thanks, #3. It worked.
But I think it is better when set before this line
val textFuture = PrecomputedTextCompat.getTextFuture(text!!, textView.textMetricsParamsCompat, null)
Set android:layoutDirection="locale" or android:layoutDirection="inherit" for AppCompatTextView in the XML layout didn't this problem.
The new method btw re-set layoutDirector. Weird! This should handle in the AppcompatTextView.
private fun setAsyncText(textView: AppCompatTextView, text: String?) {
if (!text.isNullOrEmpty()) {
textView.layoutDirection = textView.layoutDirection
val textFuture = PrecomputedTextCompat.getTextFuture(text!!, textView.textMetricsParamsCompat, null)
textView.setTextFuture(textFuture) //Crash
}
}
But I think it is better when set before this line
val textFuture = PrecomputedTextCompat.getTextFuture(text!!, textView.textMetricsParamsCompat, null)
Set android:layoutDirection="locale" or android:layoutDirection="inherit" for AppCompatTextView in the XML layout didn't this problem.
The new method btw re-set layoutDirector. Weird! This should handle in the AppcompatTextView.
private fun setAsyncText(textView: AppCompatTextView, text: String?) {
if (!text.isNullOrEmpty()) {
textView.layoutDirection = textView.layoutDirection
val textFuture = PrecomputedTextCompat.getTextFuture(text!!, textView.textMetricsParamsCompat, null)
textView.setTextFuture(textFuture) //Crash
}
}
ap...@google.com <ap...@google.com> #5
Sorry. I forgot the info.
minSdk 21
targetSdk 28
Thanks #3 again.
minSdk 21
targetSdk 28
Thanks #3 again.
Description
This is effectively a follow-up to b/180881870
The fix to that bug (https://android-review.googlesource.com/1783607 ) stored the from one of the constructors to
window
parameterImpl30
.However, this was not the primary constructor, which means that only instances of b/180881870 on API 30.
WindowInsetsControllerCompat
constructed with aWindow
will be able to workaroundIn particular, the code-path that uses
WindowInsetsControllerCompat.toWindowInsetsControllerCompat(insetsController: InsetsController)
bypasses the window constructor, meaning that the bug will still occur on API 30 with any method of retrieving theWindowInsetsControllerCompat
with that code-path.Those methods include:
ViewCompat.getWindowInsetsController(view: View)
WindowCompat.getInsetsController(window: Window, view: View)
WindowInsetsControllerCompat.toWindowInsetsControllerCompat(insetsController: InsetsController)
The current workaround is to avoid all of the above methods, and instead directly use the proper constructor:
WindowInsetsControllerCompat(window: Window, view: View)
.As a proposed fix, the constructor of b/180881870 . This would necessarily bubble up to the other methods, ensuring that the bug will be fixed across all versions.
WindowInsetsControllerCompat
that doesn't take aWindow
should be deprecated for API 30, since theWindow
is required to workaround