diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index 118fb0dc62b660..542dcea8769bca 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -128,6 +128,7 @@ public class com/facebook/react/ReactActivityDelegate { public fun getReactInstanceManager ()Lcom/facebook/react/ReactInstanceManager; protected fun getReactNativeHost ()Lcom/facebook/react/ReactNativeHost; protected fun isFabricEnabled ()Z + protected fun isWideColorGamutEnabled ()Z protected fun loadApp (Ljava/lang/String;)V public fun onActivityResult (IILandroid/content/Intent;)V public fun onBackPressed ()Z diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java index fcc796e4e981e2..d70d1c5187813b 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java @@ -10,7 +10,9 @@ import android.app.Activity; import android.content.Context; import android.content.Intent; +import android.content.pm.ActivityInfo; import android.content.res.Configuration; +import android.os.Build; import android.os.Bundle; import android.view.KeyEvent; import androidx.annotation.Nullable; @@ -102,6 +104,9 @@ public String getMainComponentName() { public void onCreate(Bundle savedInstanceState) { String mainComponentName = getMainComponentName(); final Bundle launchOptions = composeLaunchOptions(); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && isWideColorGamutEnabled()) { + mActivity.getWindow().setColorMode(ActivityInfo.COLOR_MODE_WIDE_COLOR_GAMUT); + } if (ReactFeatureFlags.enableBridgelessArchitecture) { mReactDelegate = new ReactDelegate(getPlainActivity(), getReactHost(), mainComponentName, launchOptions); @@ -217,4 +222,13 @@ protected Activity getPlainActivity() { protected boolean isFabricEnabled() { return ReactFeatureFlags.enableFabricRenderer; } + + /** + * Override this method if you wish to selectively toggle wide color gamut for a specific surface. + * + * @return true if wide gamut is enabled for this Activity, false otherwise. + */ + protected boolean isWideColorGamutEnabled() { + return false; + } }