diff --git a/litho-widget-material/src/main/java/com/facebook/litho/widget/MaterialTextInputSpec.java b/litho-widget-material/src/main/java/com/facebook/litho/widget/MaterialTextInputSpec.java index 8e12ae73335..2b8968cdc2a 100644 --- a/litho-widget-material/src/main/java/com/facebook/litho/widget/MaterialTextInputSpec.java +++ b/litho-widget-material/src/main/java/com/facebook/litho/widget/MaterialTextInputSpec.java @@ -22,6 +22,7 @@ import android.content.res.ColorStateList; import android.graphics.Typeface; import android.graphics.drawable.Drawable; +import android.os.Build; import android.text.InputFilter; import android.text.TextUtils; import android.text.TextWatcher; @@ -119,6 +120,7 @@ class MaterialTextInputSpec { @PropDefault protected static final int editTextBottomPadding = UNSET; @PropDefault protected static final int importantForAutofill = 0; @PropDefault protected static final boolean disableAutofill = false; + @PropDefault protected static final String tooltipText = ""; @OnCreateInitialState static void onCreateInitialState( @@ -182,6 +184,7 @@ static void onMeasure( @Prop(optional = true) @Nullable String[] autofillHints, @Prop(optional = true) boolean disableAutofill, @Prop(optional = true) @Nullable KeyListener keyListener, + @Prop(optional = true) @Nullable String tooltipText, @State AtomicReference savedText) { EditText editText = TextInputSpec.createAndMeasureEditText( @@ -237,7 +240,8 @@ static void onMeasure( editTextStartPadding, editTextTopPadding, editTextEndPadding, - editTextBottomPadding); + editTextBottomPadding, + tooltipText); textInputLayout.addView(editText); textInputLayout.measure( @@ -285,6 +289,7 @@ static boolean shouldUpdate( @Prop(optional = true, resType = ResType.DIMEN_OFFSET) Diff editTextEndPadding, @Prop(optional = true, resType = ResType.DIMEN_OFFSET) Diff editTextBottomPadding, @Prop(optional = true) Diff keyListener, + @Prop(optional = true) Diff tooltipText, @State Diff measureSeqNumber, @State Diff> mountedEditTextRef, @State Diff> savedText) { @@ -331,7 +336,8 @@ static boolean shouldUpdate( || !ObjectsCompat.equals(editTextTopPadding.getPrevious(), editTextTopPadding.getNext()) || !ObjectsCompat.equals(editTextEndPadding.getPrevious(), editTextEndPadding.getNext()) || !ObjectsCompat.equals( - editTextBottomPadding.getPrevious(), editTextBottomPadding.getNext())) { + editTextBottomPadding.getPrevious(), editTextBottomPadding.getNext()) + || !ObjectsCompat.equals(tooltipText.getPrevious(), tooltipText.getNext())) { return true; } @@ -390,6 +396,7 @@ static void onMount( @Prop(optional = true) int importantForAutofill, @Prop(optional = true) @Nullable String[] autofillHints, @Prop(optional = true) boolean disableAutofill, + @Prop(optional = true) @Nullable String tooltipText, @State AtomicReference savedText, @State AtomicReference mountedEditTextRef) { EditTextWithEventHandlers editText = (EditTextWithEventHandlers) textInputLayout.getEditText(); @@ -447,7 +454,8 @@ static void onMount( editTextStartPadding, editTextTopPadding, editTextEndPadding, - editTextBottomPadding); + editTextBottomPadding, + tooltipText); // NULLSAFE_FIXME[Nullable Dereference] editText.setTextState(savedText); // NULLSAFE_FIXME[Nullable Dereference] @@ -466,7 +474,8 @@ static void setParams( int editTextStartPadding, int editTextTopPadding, int editTextEndPadding, - int editTextBottomPadding) { + int editTextBottomPadding, + @Nullable String tooltipText) { textInputLayout.setHint(hint); textInputLayout.setCounterEnabled(counterEnabled); textInputLayout.setCounterMaxLength(counterMaxLength); @@ -475,6 +484,9 @@ static void setParams( // vertical center issue textInputLayout.setBoxBackgroundMode(boxBackgroundMode); textInputLayout.setBoxStrokeWidth(boxStrokeWidth); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + editText.setTooltipText(tooltipText); + } if (editTextStartPadding != UNSET || editTextTopPadding != UNSET || editTextEndPadding != UNSET