Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional config flag to allow forcing RTL on LTR locales #28129

Merged
merged 8 commits into from
May 6, 2024

Conversation

aleqsio
Copy link
Contributor

@aleqsio aleqsio commented Apr 10, 2024

Why and how

There's this issue that has been going on for some time πŸ˜…
#26532

It's due to two things:

  • first, the plugin on iOS still sets config keys even if there's no extra config – this is a bug that this PR fixes.
  • second, some apps are targeted for RTL markets and require an additional option to always force RTL, and our locale detection messes with that – I added a new field to the extra manifest field and config plugin options.

New key is:

app.json > expo > extra > forcesRTL

Test Plan

Performed the following tests:

prebuild app expo go
ios if none set:

LTR/RTL depend on calling I18nManager.(force/allow)RTL – built in react-native behavior

if extra.forcesRTL true:

app RTL, I18nManager.isRTL true

if extra.supportsRTL true:

LTR/RTL depend on locale
if none set:

app LTR, I18nManager.isRTL false

if extra.forcesRTL true:

app RTL, I18nManager.isRTL true

if extra.supportsRTL true:

LTR/RTL depend on locale
android if none set:

LTR/RTL depend on calling I18nManager.(force/allow)RTL – built in react-native behavior

if extra.forcesRTL true:

app RTL, I18nManager.isRTL true

if extra.supportsRTL true:

LTR/RTL depend on locale
if none set:

app LTR, I18nManager.isRTL false

if extra.forcesRTL true:

app RTL, I18nManager.isRTL true

if extra.supportsRTL true:

LTR/RTL depend on locale

Checklist

@expo-bot expo-bot added the bot: suggestions ExpoBot has some suggestions label Apr 10, 2024
@expo-bot
Copy link
Collaborator

expo-bot commented Apr 10, 2024

The Pull Request introduced fingerprint changes against the base commit: 9782fb3

Fingerprint diff
[
  {
    "type": "dir",
    "filePath": "../../packages/expo-localization/android",
    "reasons": [
      "expoAutolinkingAndroid"
    ],
    "hash": "d4279285f5a3737985209267bde65337cf36189b"
  }
]

Generated by PR labeler πŸ€–

@aleqsio aleqsio force-pushed the @aleqsio/add-force-rtl-flag branch from 6304141 to 2b2c36e Compare April 30, 2024 12:33
@aleqsio aleqsio marked this pull request as ready for review April 30, 2024 13:31
@aleqsio aleqsio requested a review from EvanBacon as a code owner April 30, 2024 13:31
aleqsio and others added 3 commits April 30, 2024 15:32
Co-authored-by: Expo Bot <34669131+expo-bot@users.noreply.github.com>
@@ -400,7 +400,7 @@ open class ExperienceActivity : BaseExperienceActivity(), StartReactInstanceDele
)
showOrReconfigureManagedAppSplashScreen(optimisticManifest)
setLoadingProgressStatusIfEnabled()
ExperienceRTLManager.setSupportsRTLFromManifest(this, optimisticManifest)
ExperienceRTLManager.setRTLPreferencesFromManifest(this, optimisticManifest)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be necessary to implement something similar in the dev client as it also configures the app based on the manifest. Not very important right now, but it would be nice to have that there too.

it.apply()
}
} else {
if (supportsRTL == "true" || supportsRTL == "false") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (supportsRTL == "true" || supportsRTL == "false") {
if (supportsRTL != null) {

Copy link
Contributor Author

@aleqsio aleqsio May 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really, since we set those keys in the strings.xml config template as unset, we need this exact check.

.getSharedPreferences(SHARED_PREFS_NAME, Context.MODE_PRIVATE)
.edit()
.also {
it.putBoolean(KEY_FOR_PREFS_ALLOWRTL, supportsRTL == "true")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also set KEY_FOR_PREFS_FORCERTL to false? This key may already exist in the shared preferences. We don't want to use the old value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll do that but only if it's explicitly false

            if (forcesRTL == "false") {
              it.putBoolean(KEY_FOR_PREFS_FORCERTL, false)
            }

@expo-bot
Copy link
Collaborator

expo-bot commented May 6, 2024

Hi there! πŸ‘‹ I'm a bot whose goal is to ensure your contributions meet our guidelines.

I've found some issues in your pull request that should be addressed (click on them for more details) πŸ‘‡

⚠️ Suggestion: Missing changelog entries


Your changes should be noted in the changelog. Read Updating Changelogs guide and consider adding an appropriate entry to the following changelogs:


Generated by ExpoBot πŸ€– against 59e5fbf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: fingerprint changed bot: suggestions ExpoBot has some suggestions published Changes from the PR have been published to npm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants