From a7f47f9d3d2953aa0dcc30b972b08103454781f3 Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Tue, 5 Nov 2024 03:24:06 -0800 Subject: [PATCH] Stable API - Make classes inside `com.facebook.react.views.progressbar` internal (#47376) Summary: This makes several classes inside `com.facebook.react.views.progressbar` internal: - ReactProgressBarViewManager - ProgressBarShadowNode - ProgressBarContainerView Those classes should have not been exposed in the first place and users should not depend on them directly. Marked as Breaking but verified that there are no meaningful usages in OSS. Changelog: [Android] [Breaking] - Stable API - Make classes inside `com.facebook.react.views.progressbar` internal Differential Revision: D65423290 --- .../ReactAndroid/api/ReactAndroid.api | 59 ------------------- .../ReactAndroid/gradle.properties | 2 + .../progressbar/ProgressBarContainerView.kt | 2 +- .../progressbar/ProgressBarShadowNode.kt | 4 +- .../ReactProgressBarViewManager.kt | 50 ++++++++-------- 5 files changed, 30 insertions(+), 87 deletions(-) diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index 3153ac9deb6df0..122e03b50633fa 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -6835,65 +6835,6 @@ public abstract interface class com/facebook/react/views/modal/ReactModalHostVie public abstract fun onRequestClose (Landroid/content/DialogInterface;)V } -public final class com/facebook/react/views/progressbar/ProgressBarContainerView : android/widget/FrameLayout { - public static final field MAX_PROGRESS I - public fun (Landroid/content/Context;)V -} - -public final class com/facebook/react/views/progressbar/ProgressBarShadowNode : com/facebook/react/uimanager/LayoutShadowNode, com/facebook/yoga/YogaMeasureFunction { - public fun ()V - public final fun getStyle ()Ljava/lang/String; - public fun measure (Lcom/facebook/yoga/YogaNode;FLcom/facebook/yoga/YogaMeasureMode;FLcom/facebook/yoga/YogaMeasureMode;)J - public final fun setStyle (Ljava/lang/String;)V -} - -public class com/facebook/react/views/progressbar/ProgressBarShadowNode$$PropsSetter : com/facebook/react/uimanager/ViewManagerPropertyUpdater$ShadowNodeSetter { - public fun ()V - public fun getProperties (Ljava/util/Map;)V - public synthetic fun setProperty (Lcom/facebook/react/uimanager/ReactShadowNode;Ljava/lang/String;Ljava/lang/Object;)V - public fun setProperty (Lcom/facebook/react/views/progressbar/ProgressBarShadowNode;Ljava/lang/String;Ljava/lang/Object;)V -} - -public final class com/facebook/react/views/progressbar/ReactProgressBarViewManager : com/facebook/react/uimanager/BaseViewManager, com/facebook/react/viewmanagers/AndroidProgressBarManagerInterface { - public static final field Companion Lcom/facebook/react/views/progressbar/ReactProgressBarViewManager$Companion; - public static final field REACT_CLASS Ljava/lang/String; - public fun ()V - public synthetic fun createShadowNodeInstance ()Lcom/facebook/react/uimanager/ReactShadowNode; - public fun createShadowNodeInstance ()Lcom/facebook/react/views/progressbar/ProgressBarShadowNode; - public synthetic fun createViewInstance (Lcom/facebook/react/uimanager/ThemedReactContext;)Landroid/view/View; - public fun getName ()Ljava/lang/String; - public fun getShadowNodeClass ()Ljava/lang/Class; - public fun measure (Landroid/content/Context;Lcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/bridge/ReadableMap;FLcom/facebook/yoga/YogaMeasureMode;FLcom/facebook/yoga/YogaMeasureMode;[F)J - public synthetic fun onAfterUpdateTransaction (Landroid/view/View;)V - public synthetic fun setAnimating (Landroid/view/View;Z)V - public fun setAnimating (Lcom/facebook/react/views/progressbar/ProgressBarContainerView;Z)V - public synthetic fun setColor (Landroid/view/View;Ljava/lang/Integer;)V - public fun setColor (Lcom/facebook/react/views/progressbar/ProgressBarContainerView;Ljava/lang/Integer;)V - public synthetic fun setIndeterminate (Landroid/view/View;Z)V - public fun setIndeterminate (Lcom/facebook/react/views/progressbar/ProgressBarContainerView;Z)V - public synthetic fun setProgress (Landroid/view/View;D)V - public fun setProgress (Lcom/facebook/react/views/progressbar/ProgressBarContainerView;D)V - public synthetic fun setStyleAttr (Landroid/view/View;Ljava/lang/String;)V - public fun setStyleAttr (Lcom/facebook/react/views/progressbar/ProgressBarContainerView;Ljava/lang/String;)V - public synthetic fun setTestID (Landroid/view/View;Ljava/lang/String;)V - public fun setTestID (Lcom/facebook/react/views/progressbar/ProgressBarContainerView;Ljava/lang/String;)V - public synthetic fun setTypeAttr (Landroid/view/View;Ljava/lang/String;)V - public fun setTypeAttr (Lcom/facebook/react/views/progressbar/ProgressBarContainerView;Ljava/lang/String;)V - public synthetic fun updateExtraData (Landroid/view/View;Ljava/lang/Object;)V - public fun updateExtraData (Lcom/facebook/react/views/progressbar/ProgressBarContainerView;Ljava/lang/Object;)V -} - -public class com/facebook/react/views/progressbar/ReactProgressBarViewManager$$PropsSetter : com/facebook/react/uimanager/ViewManagerPropertyUpdater$ViewManagerSetter { - public fun ()V - public fun getProperties (Ljava/util/Map;)V - public synthetic fun setProperty (Lcom/facebook/react/uimanager/ViewManager;Landroid/view/View;Ljava/lang/String;Ljava/lang/Object;)V - public fun setProperty (Lcom/facebook/react/views/progressbar/ReactProgressBarViewManager;Lcom/facebook/react/views/progressbar/ProgressBarContainerView;Ljava/lang/String;Ljava/lang/Object;)V -} - -public final class com/facebook/react/views/progressbar/ReactProgressBarViewManager$Companion { - public final fun createProgressBar (Landroid/content/Context;I)Landroid/widget/ProgressBar; -} - public abstract interface class com/facebook/react/views/scroll/FpsListener { public abstract fun disable (Ljava/lang/String;)V public abstract fun enable (Ljava/lang/String;)V diff --git a/packages/react-native/ReactAndroid/gradle.properties b/packages/react-native/ReactAndroid/gradle.properties index 6748b2bfd5cde4..7db47027e6799d 100644 --- a/packages/react-native/ReactAndroid/gradle.properties +++ b/packages/react-native/ReactAndroid/gradle.properties @@ -13,6 +13,8 @@ react.internal.disableJavaVersionAlignment=true # - BuildConfig classes because they are generated and not part of the public API # - PropsSetter classes because they are generated by the Annotation processor which is not used in OSS binaryCompatibilityValidator.ignoredClasses=com.facebook.react.BuildConfig,\ + com.facebook.react.views.progressbar.ReactProgressBarViewManager$$PropsSetter,\ + com.facebook.react.views.progressbar.ProgressBarShadowNode$$PropsSetter,\ com.facebook.react.views.safeareaview.ReactSafeAreaViewManager$$PropsSetter,\ com.facebook.react.views.unimplementedview.ReactUnimplementedViewManager$$PropsSetter,\ com.facebook.react.views.safeareaview.ReactSafeAreaViewShadowNode$$PropsSetter diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/progressbar/ProgressBarContainerView.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/progressbar/ProgressBarContainerView.kt index c5531cc69fd900..c24b2540fd5760 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/progressbar/ProgressBarContainerView.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/progressbar/ProgressBarContainerView.kt @@ -18,7 +18,7 @@ import com.facebook.react.bridge.JSApplicationIllegalArgumentException * Controls an enclosing [ProgressBar]. Exists so that the [ProgressBar] can be recreated if the * style would change. */ -public class ProgressBarContainerView(context: Context) : FrameLayout(context) { +internal class ProgressBarContainerView(context: Context) : FrameLayout(context) { internal var color: Int? = null internal var indeterminate = true diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/progressbar/ProgressBarShadowNode.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/progressbar/ProgressBarShadowNode.kt index 791ab36a3404da..8f35b5cbc4fb4c 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/progressbar/ProgressBarShadowNode.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/progressbar/ProgressBarShadowNode.kt @@ -21,7 +21,7 @@ import com.facebook.yoga.YogaNode * Node responsible for holding the style of the ProgressBar, see under [ ] for possible styles. * ReactProgressBarViewManager manages how this style is applied to the ProgressBar. */ -public class ProgressBarShadowNode : LayoutShadowNode(), YogaMeasureFunction { +internal class ProgressBarShadowNode : LayoutShadowNode(), YogaMeasureFunction { private val height: SparseIntArray = SparseIntArray() private val width: SparseIntArray = SparseIntArray() private val measured: MutableSet = HashSet() @@ -31,7 +31,7 @@ public class ProgressBarShadowNode : LayoutShadowNode(), YogaMeasureFunction { } @set:ReactProp(name = ReactProgressBarViewManager.PROP_STYLE) - public var style: String? = ReactProgressBarViewManager.DEFAULT_STYLE + var style: String? = ReactProgressBarViewManager.DEFAULT_STYLE set(value) { field = value ?: ReactProgressBarViewManager.DEFAULT_STYLE } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/progressbar/ReactProgressBarViewManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/progressbar/ReactProgressBarViewManager.kt index 69ad62ac8eb264..b254df069e64b0 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/progressbar/ReactProgressBarViewManager.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/progressbar/ReactProgressBarViewManager.kt @@ -34,7 +34,7 @@ import java.util.WeakHashMap * a new one with the style given. */ @ReactModule(name = ReactProgressBarViewManager.REACT_CLASS) -public class ReactProgressBarViewManager : +internal class ReactProgressBarViewManager : BaseViewManager(), AndroidProgressBarManagerInterface { private val measuredStyles = WeakHashMap>() @@ -42,60 +42,60 @@ public class ReactProgressBarViewManager : private val delegate: ViewManagerDelegate = AndroidProgressBarManagerDelegate(this) - public override fun getName(): String = REACT_CLASS + override fun getName(): String = REACT_CLASS - protected override fun createViewInstance(context: ThemedReactContext): ProgressBarContainerView { + override fun createViewInstance(context: ThemedReactContext): ProgressBarContainerView { return ProgressBarContainerView(context) } @ReactProp(name = PROP_STYLE) - public override fun setStyleAttr(view: ProgressBarContainerView, styleName: String?) { + override fun setStyleAttr(view: ProgressBarContainerView, styleName: String?) { view.setStyle(styleName) } @ReactProp(name = ViewProps.COLOR, customType = "Color") - public override fun setColor(view: ProgressBarContainerView, color: Int?) { + override fun setColor(view: ProgressBarContainerView, color: Int?) { view.color = color } @ReactProp(name = PROP_INDETERMINATE) - public override fun setIndeterminate(view: ProgressBarContainerView, indeterminate: Boolean) { + override fun setIndeterminate(view: ProgressBarContainerView, indeterminate: Boolean) { view.indeterminate = indeterminate } @ReactProp(name = PROP_PROGRESS) - public override fun setProgress(view: ProgressBarContainerView, progress: Double) { + override fun setProgress(view: ProgressBarContainerView, progress: Double) { view.progress = progress } @ReactProp(name = PROP_ANIMATING) - public override fun setAnimating(view: ProgressBarContainerView, animating: Boolean) { + override fun setAnimating(view: ProgressBarContainerView, animating: Boolean) { view.animating = animating } - public override fun setTestID(view: ProgressBarContainerView, value: String?) { + override fun setTestID(view: ProgressBarContainerView, value: String?) { super.setTestId(view, value) } @ReactProp(name = PROP_ATTR) - public override fun setTypeAttr(view: ProgressBarContainerView, value: String?): Unit = Unit + override fun setTypeAttr(view: ProgressBarContainerView, value: String?): Unit = Unit - public override fun createShadowNodeInstance(): ProgressBarShadowNode = ProgressBarShadowNode() + override fun createShadowNodeInstance(): ProgressBarShadowNode = ProgressBarShadowNode() - public override fun getShadowNodeClass(): Class = + override fun getShadowNodeClass(): Class = ProgressBarShadowNode::class.java - public override fun updateExtraData(root: ProgressBarContainerView, extraData: Any) { + override fun updateExtraData(root: ProgressBarContainerView, extraData: Any) { // do nothing } - protected override fun onAfterUpdateTransaction(view: ProgressBarContainerView) { + override fun onAfterUpdateTransaction(view: ProgressBarContainerView) { view.apply() } - protected override fun getDelegate(): ViewManagerDelegate = delegate + override fun getDelegate(): ViewManagerDelegate = delegate - public override fun measure( + override fun measure( context: Context, localData: ReadableMap, props: ReadableMap, @@ -119,15 +119,15 @@ public class ReactProgressBarViewManager : toDIPFromPixel(value.first.toFloat()), toDIPFromPixel(value.second.toFloat())) } - public companion object { - public const val REACT_CLASS: String = "AndroidProgressBar" + companion object { + const val REACT_CLASS: String = "AndroidProgressBar" - internal const val PROP_STYLE: String = "styleAttr" - internal const val PROP_ATTR: String = "typeAttr" - internal const val PROP_INDETERMINATE: String = "indeterminate" - internal const val PROP_PROGRESS: String = "progress" - internal const val PROP_ANIMATING: String = "animating" - internal const val DEFAULT_STYLE: String = "Normal" + const val PROP_STYLE: String = "styleAttr" + const val PROP_ATTR: String = "typeAttr" + const val PROP_INDETERMINATE: String = "indeterminate" + const val PROP_PROGRESS: String = "progress" + const val PROP_ANIMATING: String = "animating" + const val DEFAULT_STYLE: String = "Normal" private val progressBarCtorLock = Any() @@ -136,7 +136,7 @@ public class ReactProgressBarViewManager : * ProgressBar constructor that may cause crashes when two ProgressBars are constructed at the * same time on two different threads. This static ctor wrapper protects against that. */ - public fun createProgressBar(context: Context?, style: Int): ProgressBar { + fun createProgressBar(context: Context?, style: Int): ProgressBar { synchronized(progressBarCtorLock) { return ProgressBar(context, null, style) }