From 8c81ffa60a211e4ae7db50cd04de0e4a4c29df04 Mon Sep 17 00:00:00 2001 From: shubhamguptadream11 Date: Tue, 27 Aug 2024 05:00:36 -0700 Subject: [PATCH] fix(android): make getUri and isResource available for override (#46152) Summary: Fixes following issues: - https://github.com/facebook/react-native/issues/46150 - https://github.com/facebook/react-native/issues/46155 ## Changelog: [ANDROID] [FIXED] - Make getUri and isResource open Pull Request resolved: https://github.com/facebook/react-native/pull/46152 Reviewed By: NickGerleman, rshest, blakef Differential Revision: D61845164 Pulled By: cortinico fbshipit-source-id: 88ccdad92423b5add9b2fad4c98f296b6cbfb27d --- .../react-native/ReactAndroid/api/ReactAndroid.api | 4 ++-- .../facebook/react/views/imagehelper/ImageSource.kt | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index 5d6870bc1e2..410ebdc0055 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -6720,9 +6720,9 @@ public class com/facebook/react/views/imagehelper/ImageSource { public final fun getSize ()D public final fun getSource ()Ljava/lang/String; public static final fun getTransparentBitmapImageSource (Landroid/content/Context;)Lcom/facebook/react/views/imagehelper/ImageSource; - public final fun getUri ()Landroid/net/Uri; + public fun getUri ()Landroid/net/Uri; public fun hashCode ()I - public final fun isResource ()Z + public fun isResource ()Z } public final class com/facebook/react/views/imagehelper/ImageSource$Companion { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/imagehelper/ImageSource.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/imagehelper/ImageSource.kt index 583b4a0eaaf..947044cf43e 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/imagehelper/ImageSource.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/imagehelper/ImageSource.kt @@ -23,12 +23,14 @@ constructor( ) { /** Get the URI for this image - can be either a parsed network URI or a resource URI. */ - public val uri: Uri = computeUri(context) + public open val uri: Uri = computeUri(context) /** Get the area of this image. */ public val size: Double = width * height /** Get whether this image source represents an Android resource or a network URI. */ - public var isResource: Boolean = false - private set + public open val isResource: Boolean + get() = _isResource + + private var _isResource: Boolean = false override fun equals(other: Any?): Boolean { if (this === other) { @@ -58,7 +60,7 @@ constructor( } private fun computeLocalUri(context: Context): Uri { - isResource = true + _isResource = true return ResourceDrawableIdHelper.instance.getResourceDrawableUri(context, source) }