Skip to content

Commit cf9514e

Browse files
NickGerlemanfacebook-github-bot
authored andcommitted
Fix ReactTextAnchorViewManager Nullability (facebook#50879)
Summary: Pull Request resolved: facebook#50879 The view for a view manager should not be nullable. Let's fix that. These are also all bound specifically to `ReactTextView` instead of the generic constraint, so I just changed the constraint. Really this should just be totally merged with `ReactTextViewManager`. Changelog: [Internal] Reviewed By: cortinico, rshest Differential Revision: D73453631 fbshipit-source-id: 74bcadeef0e83a719dfe2b989784501575b58168
1 parent 1156c08 commit cf9514e

File tree

3 files changed

+14
-40
lines changed

3 files changed

+14
-40
lines changed

packages/react-native/ReactAndroid/api/ReactAndroid.api

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6352,27 +6352,6 @@ public final class com/facebook/react/views/text/ReactFontManager$Companion {
63526352
public final fun getInstance ()Lcom/facebook/react/views/text/ReactFontManager;
63536353
}
63546354

6355-
public abstract class com/facebook/react/views/text/ReactTextAnchorViewManager : com/facebook/react/uimanager/BaseViewManager {
6356-
public fun <init> ()V
6357-
public final fun setAccessible (Lcom/facebook/react/views/text/ReactTextView;Z)V
6358-
public final fun setAdjustFontSizeToFit (Lcom/facebook/react/views/text/ReactTextView;Z)V
6359-
public final fun setAndroidHyphenationFrequency (Lcom/facebook/react/views/text/ReactTextView;Ljava/lang/String;)V
6360-
public final fun setBorderColor (Lcom/facebook/react/views/text/ReactTextView;ILjava/lang/Integer;)V
6361-
public final fun setBorderRadius (Lcom/facebook/react/views/text/ReactTextView;IF)V
6362-
public final fun setBorderStyle (Lcom/facebook/react/views/text/ReactTextView;Ljava/lang/String;)V
6363-
public final fun setBorderWidth (Lcom/facebook/react/views/text/ReactTextView;IF)V
6364-
public final fun setDataDetectorType (Lcom/facebook/react/views/text/ReactTextView;Ljava/lang/String;)V
6365-
public final fun setDisabled (Lcom/facebook/react/views/text/ReactTextView;Z)V
6366-
public final fun setEllipsizeMode (Lcom/facebook/react/views/text/ReactTextView;Ljava/lang/String;)V
6367-
public final fun setFontSize (Lcom/facebook/react/views/text/ReactTextView;F)V
6368-
public final fun setIncludeFontPadding (Lcom/facebook/react/views/text/ReactTextView;Z)V
6369-
public final fun setLetterSpacing (Lcom/facebook/react/views/text/ReactTextView;F)V
6370-
public final fun setNumberOfLines (Lcom/facebook/react/views/text/ReactTextView;I)V
6371-
public final fun setSelectable (Lcom/facebook/react/views/text/ReactTextView;Z)V
6372-
public final fun setSelectionColor (Lcom/facebook/react/views/text/ReactTextView;Ljava/lang/Integer;)V
6373-
public final fun setTextAlignVertical (Lcom/facebook/react/views/text/ReactTextView;Ljava/lang/String;)V
6374-
}
6375-
63766355
public class com/facebook/react/views/text/ReactTextShadowNode : com/facebook/react/views/text/ReactBaseTextShadowNode {
63776356
public fun <init> ()V
63786357
public fun <init> (Lcom/facebook/react/views/text/ReactTextViewManagerCallback;)V
@@ -6448,7 +6427,7 @@ public class com/facebook/react/views/text/ReactTextView : androidx/appcompat/wi
64486427
protected fun verifyDrawable (Landroid/graphics/drawable/Drawable;)Z
64496428
}
64506429

6451-
public class com/facebook/react/views/text/ReactTextViewManager : com/facebook/react/views/text/ReactTextAnchorViewManager, com/facebook/react/uimanager/IViewManagerWithChildren {
6430+
public class com/facebook/react/views/text/ReactTextViewManager : com/facebook/react/uimanager/IViewManagerWithChildren {
64526431
protected field mReactTextViewManagerCallback Lcom/facebook/react/views/text/ReactTextViewManagerCallback;
64536432
public fun <init> ()V
64546433
public fun <init> (Lcom/facebook/react/views/text/ReactTextViewManagerCallback;)V

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextAnchorViewManager.kt

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,9 @@ import android.text.Layout
1111
import android.text.TextUtils
1212
import android.text.util.Linkify
1313
import android.view.Gravity
14-
import android.view.View
1514
import com.facebook.common.logging.FLog
1615
import com.facebook.react.common.ReactConstants
17-
import com.facebook.react.uimanager.BackgroundStyleApplicator.setBorderColor
18-
import com.facebook.react.uimanager.BackgroundStyleApplicator.setBorderRadius
19-
import com.facebook.react.uimanager.BackgroundStyleApplicator.setBorderStyle
20-
import com.facebook.react.uimanager.BackgroundStyleApplicator.setBorderWidth
16+
import com.facebook.react.uimanager.BackgroundStyleApplicator
2117
import com.facebook.react.uimanager.BaseViewManager
2218
import com.facebook.react.uimanager.LengthPercentage
2319
import com.facebook.react.uimanager.LengthPercentageType
@@ -31,15 +27,15 @@ import com.facebook.react.uimanager.style.LogicalEdge
3127
import com.facebook.react.views.text.DefaultStyleValuesUtil.getDefaultTextColorHighlight
3228

3329
/**
34-
* Abstract class for anchor `<Text>`-ish spannable views, such as [TextView] or [EditText].
30+
* Previously a superclass of multiple text view managers. Now only used by [ReactTextViewManager].
3531
*
3632
* This is a "shadowing" view manager, which means that the [NativeViewHierarchyManager] will NOT
3733
* manage children of native [TextView] instances instantiated by this manager. Instead we
3834
* use @{link ReactBaseTextShadowNode} hierarchy to calculate a [Spannable] text represented the
3935
* whole text subtree.
4036
*/
41-
public abstract class ReactTextAnchorViewManager<T : View?, C : ReactBaseTextShadowNode?> :
42-
BaseViewManager<T, C>() {
37+
internal abstract class ReactTextAnchorViewManager<C : ReactBaseTextShadowNode?> :
38+
BaseViewManager<ReactTextView, C>() {
4339

4440
@ReactProp(name = "accessible")
4541
public fun setAccessible(view: ReactTextView, accessible: Boolean) {
@@ -130,20 +126,20 @@ public abstract class ReactTextAnchorViewManager<T : View?, C : ReactBaseTextSha
130126
ViewProps.BORDER_BOTTOM_RIGHT_RADIUS,
131127
ViewProps.BORDER_BOTTOM_LEFT_RADIUS],
132128
defaultFloat = Float.NaN)
133-
public fun setBorderRadius(view: ReactTextView?, index: Int, borderRadius: Float) {
129+
public fun setBorderRadius(view: ReactTextView, index: Int, borderRadius: Float) {
134130
val radius =
135131
if (java.lang.Float.isNaN(borderRadius)) {
136132
null
137133
} else {
138134
LengthPercentage(borderRadius, LengthPercentageType.POINT)
139135
}
140-
setBorderRadius(checkNotNull(view), BorderRadiusProp.entries[index], radius)
136+
BackgroundStyleApplicator.setBorderRadius(view, BorderRadiusProp.values()[index], radius)
141137
}
142138

143139
@ReactProp(name = "borderStyle")
144-
public fun setBorderStyle(view: ReactTextView?, borderStyle: String?) {
140+
public fun setBorderStyle(view: ReactTextView, borderStyle: String?) {
145141
val parsedBorderStyle = if (borderStyle == null) null else fromString(borderStyle)
146-
setBorderStyle(checkNotNull(view), parsedBorderStyle)
142+
BackgroundStyleApplicator.setBorderStyle(view, parsedBorderStyle)
147143
}
148144

149145
@ReactPropGroup(
@@ -157,8 +153,8 @@ public abstract class ReactTextAnchorViewManager<T : View?, C : ReactBaseTextSha
157153
ViewProps.BORDER_START_WIDTH,
158154
ViewProps.BORDER_END_WIDTH],
159155
defaultFloat = Float.NaN)
160-
public fun setBorderWidth(view: ReactTextView?, index: Int, width: Float) {
161-
setBorderWidth(checkNotNull(view), LogicalEdge.entries[index], width)
156+
public fun setBorderWidth(view: ReactTextView, index: Int, width: Float) {
157+
BackgroundStyleApplicator.setBorderWidth(view, LogicalEdge.values()[index], width)
162158
}
163159

164160
@ReactPropGroup(
@@ -170,8 +166,8 @@ public abstract class ReactTextAnchorViewManager<T : View?, C : ReactBaseTextSha
170166
"borderTopColor",
171167
"borderBottomColor"],
172168
customType = "Color")
173-
public fun setBorderColor(view: ReactTextView?, index: Int, color: Int?) {
174-
setBorderColor(checkNotNull(view), LogicalEdge.ALL, color)
169+
public fun setBorderColor(view: ReactTextView, index: Int, color: Int?) {
170+
BackgroundStyleApplicator.setBorderColor(view, LogicalEdge.ALL, color)
175171
}
176172

177173
@ReactProp(name = ViewProps.INCLUDE_FONT_PADDING, defaultBoolean = true)

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextViewManager.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@
3838
*/
3939
@Nullsafe(Nullsafe.Mode.LOCAL)
4040
@ReactModule(name = ReactTextViewManager.REACT_CLASS)
41-
public class ReactTextViewManager
42-
extends ReactTextAnchorViewManager<ReactTextView, ReactTextShadowNode>
41+
public class ReactTextViewManager extends ReactTextAnchorViewManager<ReactTextShadowNode>
4342
implements IViewManagerWithChildren {
4443

4544
private static final String TAG = "ReactTextViewManager";

0 commit comments

Comments
 (0)