From 044aadbaf6830b21aab821804dc5a7989010022e Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Fri, 17 May 2024 06:20:29 -0700 Subject: [PATCH] Fix bad merge of I18nUtil (#44600) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/44600 I didn't pay close enough attention during merge between V1 and V2 of D57248205, and what I ultimately checked in is not correct. Fix the logic here. Changelog: [Internal] Reviewed By: yungsters Differential Revision: D57488372 fbshipit-source-id: c9db597a6ae4ca5ae81e6ccd9913a14be268dd57 --- packages/react-native/ReactAndroid/api/ReactAndroid.api | 1 - .../com/facebook/react/modules/i18nmanager/I18nUtil.kt | 9 ++------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index 5c5cc396486..0e01ff68d47 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -3351,7 +3351,6 @@ public final class com/facebook/react/modules/i18nmanager/I18nUtil { public final fun doLeftAndRightSwapInRTL (Landroid/content/Context;)Z public final fun forceRTL (Landroid/content/Context;Z)V public static final fun getInstance ()Lcom/facebook/react/modules/i18nmanager/I18nUtil; - public final fun hasRtlSupport (Landroid/content/Context;)Z public final fun isRTL (Landroid/content/Context;)Z public final fun swapLeftAndRightInRTL (Landroid/content/Context;Z)V } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/I18nUtil.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/I18nUtil.kt index 1968ec99bd5..57347b30481 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/I18nUtil.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/I18nUtil.kt @@ -20,9 +20,8 @@ public class I18nUtil private constructor() { * * allows RTL layout when using RTL locale */ public fun isRTL(context: Context): Boolean = - if (isRTLForced(context)) { - true - } else isRTLAllowed(context) && isDevicePreferredLanguageRTL + applicationHasRtlSupport(context) && + (isRTLForced(context) || (isRTLAllowed(context) && isDevicePreferredLanguageRTL)) /** * Android relies on the presence of `android:supportsRtl="true"` being set in order to resolve @@ -33,10 +32,6 @@ public class I18nUtil private constructor() { return (context.getApplicationInfo().flags and ApplicationInfo.FLAG_SUPPORTS_RTL) != 0 } - public fun hasRtlSupport(context: Context): Boolean { - return applicationHasRtlSupport(context) || isRTLAllowed(context) - } - /** * Should be used very early during app start up Before the bridge is initialized *