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

Fix React Native Appearance/useColorScheme support for SDK 38 #8793

Merged
merged 3 commits into from
Jun 17, 2020

Conversation

brentvatne
Copy link
Member

@brentvatne brentvatne commented Jun 13, 2020

Why

useColorScheme has two problems right now:

How

  • Added the onConfigurationChanged method as required, verified that this fixes useColorScheme from react-native
  • Copy over relevant code from ExpoAppearanceModule to give priority to the current activity local night mode configuration (which is what we use to enforce a specific scheme when userInterfaceStyle is set in app.json). This required bumping appcompat to 1.1.0 in ReactAndroid.

TODO

  • The changes to BaseExperienceActivity will apply to SDK38 just fine, but the ReactAndroid changes will not. These need to be applied to SDK38 too, and I'm not familiar with the process for this on Android.

Test Plan

  • Use the tabs template
  • If TODO hasn't been resolved, set the sdkVersion to UNVERSIONED
  • Set userInterfaceStyle to light in app.json and verify that it's light when you use dark mode, and nothing happens when you toggle between modes while it's open. Same for dark. Verify automatic works as expected.

…Native AppearanceModule

- Fixes userInterfaceStyle app.json setting when used in combination
  with useColorScheme from React native
@brentvatne brentvatne force-pushed the @brent/fix-android-dark-mode branch from e70013b to b2beca7 Compare June 13, 2020 04:03
Copy link
Member

@ide ide left a comment

Choose a reason for hiding this comment

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

Requesting changes to have a separate PR to expo/react-native on a branch prefixed with expo/ so that we don't lose this commit in the future.

Talking to @esamelson if we want this in the release we need this to be in a shippable state soon (Tuesday or Wednesday) since we've already versioned the Android code (will need to re-version) and are otherwise ready to continue the release process.

Comment on lines +182 to +190
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);

if (mReactInstanceManager != null && mReactInstanceManager.isNotNull() && !mIsCrashed) {
mReactInstanceManager.call("onConfigurationChanged", this, newConfig);
}
}

Copy link
Member

Choose a reason for hiding this comment

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

Reviewed this part; looks fine to me.

@brentvatne brentvatne merged commit df43b15 into master Jun 17, 2020
@brentvatne brentvatne deleted the @brent/fix-android-dark-mode branch June 17, 2020 00:45
brentvatne added a commit that referenced this pull request Jun 17, 2020
* [android] Add onConfigurationChanged to BaseExperienceActivity to fix React Native useColorScheme

* [ReactAndroid] Use getLocalNightMode from AppCompatDelegate in React Native AppearanceModule

- Fixes userInterfaceStyle app.json setting when used in combination
  with useColorScheme from React native

* [android] Validate mReactInstanceManager before calling method on it, like elsewhere in activity
brentvatne added a commit to expo/react-native that referenced this pull request Jun 17, 2020
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793
@brentvatne
Copy link
Member Author

brentvatne commented Jun 17, 2020

Added to the react-native fork in expo/react-native@48e27f6 and pushed to this branch https://github.com/expo/react-native/tree/expo/respect-local-night-mode

EvanBacon pushed a commit to expo/react-native that referenced this pull request Jun 27, 2020
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793
EvanBacon pushed a commit to expo/react-native that referenced this pull request Jul 9, 2020
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793
EvanBacon pushed a commit to expo/react-native that referenced this pull request Jul 11, 2020
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793
EvanBacon pushed a commit to expo/react-native that referenced this pull request Jul 11, 2020
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793
EvanBacon pushed a commit to expo/react-native that referenced this pull request Jul 23, 2020
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793
Kudo pushed a commit to expo/react-native that referenced this pull request Jul 19, 2021
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793
douglowder pushed a commit to react-native-tvos/react-native-tvos that referenced this pull request Jan 9, 2022
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793
Kudo pushed a commit to expo/react-native that referenced this pull request Feb 17, 2022
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793

This is a squashed commits with the following changes:

commit 945096e
Author: Kudo Chien <kudo@expo.io>
Date:   Tue Jul 27 16:49:09 2021 +0800

    [android] Upgrade androidx.appcompat to 1.2.0

    Backport from: expo/expo@58fa52e
Kudo pushed a commit to expo/react-native that referenced this pull request Feb 18, 2022
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793

This is a squashed commits with the following changes:

commit 945096e
Author: Kudo Chien <kudo@expo.io>
Date:   Tue Jul 27 16:49:09 2021 +0800

    [android] Upgrade androidx.appcompat to 1.2.0

    Backport from: expo/expo@58fa52e
Kudo pushed a commit to expo/react-native that referenced this pull request Mar 23, 2022
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793

This is a squashed commits with the following changes:

commit 945096e
Author: Kudo Chien <kudo@expo.io>
Date:   Tue Jul 27 16:49:09 2021 +0800

    [android] Upgrade androidx.appcompat to 1.2.0

    Backport from: expo/expo@58fa52e
Kudo pushed a commit to expo/react-native that referenced this pull request Apr 2, 2022
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793

This is a squashed commits with the following changes:

commit 945096e
Author: Kudo Chien <kudo@expo.io>
Date:   Tue Jul 27 16:49:09 2021 +0800

    [android] Upgrade androidx.appcompat to 1.2.0

    Backport from: expo/expo@58fa52e
Kudo pushed a commit to expo/react-native that referenced this pull request Apr 14, 2022
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793

This is a squashed commits with the following changes:

commit 945096e
Author: Kudo Chien <kudo@expo.io>
Date:   Tue Jul 27 16:49:09 2021 +0800

    [android] Upgrade androidx.appcompat to 1.2.0

    Backport from: expo/expo@58fa52e
Kudo pushed a commit to expo/react-native that referenced this pull request May 13, 2022
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793

This is a squashed commits with the following changes:

commit 945096e
Author: Kudo Chien <kudo@expo.io>
Date:   Tue Jul 27 16:49:09 2021 +0800

    [android] Upgrade androidx.appcompat to 1.2.0

    Backport from: expo/expo@58fa52e
douglowder pushed a commit to react-native-tvos/react-native-tvos that referenced this pull request May 23, 2022
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793

This is a squashed commits with the following changes:

commit 945096e54ff9f5d9f5639cea201f101efac472a9
Author: Kudo Chien <kudo@expo.io>
Date:   Tue Jul 27 16:49:09 2021 +0800

    [android] Upgrade androidx.appcompat to 1.2.0

    Backport from: expo/expo@58fa52e
Kudo pushed a commit to expo/react-native that referenced this pull request May 24, 2022
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793

This is a squashed commits with the following changes:

commit 945096e
Author: Kudo Chien <kudo@expo.io>
Date:   Tue Jul 27 16:49:09 2021 +0800

    [android] Upgrade androidx.appcompat to 1.2.0

    Backport from: expo/expo@58fa52e
Kudo pushed a commit to expo/react-native that referenced this pull request Jun 23, 2022
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793

This is a squashed commits with the following changes:

commit 945096e
Author: Kudo Chien <kudo@expo.io>
Date:   Tue Jul 27 16:49:09 2021 +0800

    [android] Upgrade androidx.appcompat to 1.2.0

    Backport from: expo/expo@58fa52e
Kudo pushed a commit to expo/react-native that referenced this pull request Jun 29, 2022
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793

This is a squashed commits with the following changes:

commit 945096e
Author: Kudo Chien <kudo@expo.io>
Date:   Tue Jul 27 16:49:09 2021 +0800

    [android] Upgrade androidx.appcompat to 1.2.0

    Backport from: expo/expo@58fa52e
gabrieldonadel pushed a commit to expo/react-native that referenced this pull request Feb 7, 2024
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793

This is a squashed commits with the following changes:

commit 945096e
Author: Kudo Chien <kudo@expo.io>
Date:   Tue Jul 27 16:49:09 2021 +0800

    [android] Upgrade androidx.appcompat to 1.2.0

    Backport from: expo/expo@58fa52e
gabrieldonadel pushed a commit to expo/react-native that referenced this pull request Mar 7, 2024
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793

This is a squashed commits with the following changes:

commit 945096e
Author: Kudo Chien <kudo@expo.io>
Date:   Tue Jul 27 16:49:09 2021 +0800

    [android] Upgrade androidx.appcompat to 1.2.0

    Backport from: expo/expo@58fa52e
gabrieldonadel pushed a commit to expo/react-native that referenced this pull request Mar 13, 2024
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793

This is a squashed commits with the following changes:

commit 945096e
Author: Kudo Chien <kudo@expo.io>
Date:   Tue Jul 27 16:49:09 2021 +0800

    [android] Upgrade androidx.appcompat to 1.2.0

    Backport from: expo/expo@58fa52e
gabrieldonadel pushed a commit to expo/react-native that referenced this pull request Mar 14, 2024
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793

This is a squashed commits with the following changes:

commit 945096e
Author: Kudo Chien <kudo@expo.io>
Date:   Tue Jul 27 16:49:09 2021 +0800

    [android] Upgrade androidx.appcompat to 1.2.0

    Backport from: expo/expo@58fa52e
alanjhughes pushed a commit to expo/react-native that referenced this pull request Mar 21, 2024
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793

This is a squashed commits with the following changes:

commit 945096e
Author: Kudo Chien <kudo@expo.io>
Date:   Tue Jul 27 16:49:09 2021 +0800

    [android] Upgrade androidx.appcompat to 1.2.0

    Backport from: expo/expo@58fa52e
alanjhughes pushed a commit to expo/react-native that referenced this pull request Mar 27, 2024
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793

This is a squashed commits with the following changes:

commit 945096e
Author: Kudo Chien <kudo@expo.io>
Date:   Tue Jul 27 16:49:09 2021 +0800

    [android] Upgrade androidx.appcompat to 1.2.0

    Backport from: expo/expo@58fa52e
alanjhughes pushed a commit to expo/react-native that referenced this pull request Apr 2, 2024
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793

This is a squashed commits with the following changes:

commit 945096e
Author: Kudo Chien <kudo@expo.io>
Date:   Tue Jul 27 16:49:09 2021 +0800

    [android] Upgrade androidx.appcompat to 1.2.0

    Backport from: expo/expo@58fa52e
alanjhughes pushed a commit to expo/react-native that referenced this pull request Apr 8, 2024
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793

This is a squashed commits with the following changes:

commit 945096e
Author: Kudo Chien <kudo@expo.io>
Date:   Tue Jul 27 16:49:09 2021 +0800

    [android] Upgrade androidx.appcompat to 1.2.0

    Backport from: expo/expo@58fa52e
alanjhughes pushed a commit to expo/react-native that referenced this pull request Apr 11, 2024
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793

This is a squashed commits with the following changes:

commit 945096e
Author: Kudo Chien <kudo@expo.io>
Date:   Tue Jul 27 16:49:09 2021 +0800

    [android] Upgrade androidx.appcompat to 1.2.0

    Backport from: expo/expo@58fa52e
alanjhughes pushed a commit to expo/react-native that referenced this pull request Apr 15, 2024
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793

This is a squashed commits with the following changes:

commit 945096e
Author: Kudo Chien <kudo@expo.io>
Date:   Tue Jul 27 16:49:09 2021 +0800

    [android] Upgrade androidx.appcompat to 1.2.0

    Backport from: expo/expo@58fa52e
alanjhughes pushed a commit to expo/react-native that referenced this pull request Apr 22, 2024
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793

This is a squashed commits with the following changes:

commit 945096e
Author: Kudo Chien <kudo@expo.io>
Date:   Tue Jul 27 16:49:09 2021 +0800

    [android] Upgrade androidx.appcompat to 1.2.0

    Backport from: expo/expo@58fa52e
alanjhughes pushed a commit to expo/react-native that referenced this pull request May 1, 2024
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793

This is a squashed commits with the following changes:

commit 945096e
Author: Kudo Chien <kudo@expo.io>
Date:   Tue Jul 27 16:49:09 2021 +0800

    [android] Upgrade androidx.appcompat to 1.2.0

    Backport from: expo/expo@58fa52e
alanjhughes pushed a commit to expo/react-native that referenced this pull request May 2, 2024
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793

This is a squashed commits with the following changes:

commit 945096e
Author: Kudo Chien <kudo@expo.io>
Date:   Tue Jul 27 16:49:09 2021 +0800

    [android] Upgrade androidx.appcompat to 1.2.0

    Backport from: expo/expo@58fa52e
alanjhughes pushed a commit to expo/react-native that referenced this pull request Jun 4, 2024
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793

This is a squashed commits with the following changes:

commit 945096e
Author: Kudo Chien <kudo@expo.io>
Date:   Tue Jul 27 16:49:09 2021 +0800

    [android] Upgrade androidx.appcompat to 1.2.0

    Backport from: expo/expo@58fa52e
gabrieldonadel pushed a commit to expo/react-native that referenced this pull request Jul 2, 2024
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793

This is a squashed commits with the following changes:

commit 945096e
Author: Kudo Chien <kudo@expo.io>
Date:   Tue Jul 27 16:49:09 2021 +0800

    [android] Upgrade androidx.appcompat to 1.2.0

    Backport from: expo/expo@58fa52e
gabrieldonadel pushed a commit to expo/react-native that referenced this pull request Jul 17, 2024
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793

This is a squashed commits with the following changes:

commit 945096e
Author: Kudo Chien <kudo@expo.io>
Date:   Tue Jul 27 16:49:09 2021 +0800

    [android] Upgrade androidx.appcompat to 1.2.0

    Backport from: expo/expo@58fa52e
gabrieldonadel pushed a commit to expo/react-native that referenced this pull request Jul 17, 2024
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793

This is a squashed commits with the following changes:

commit 945096e
Author: Kudo Chien <kudo@expo.io>
Date:   Tue Jul 27 16:49:09 2021 +0800

    [android] Upgrade androidx.appcompat to 1.2.0

    Backport from: expo/expo@58fa52e
gabrieldonadel pushed a commit to expo/react-native that referenced this pull request Aug 5, 2024
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793

This is a squashed commits with the following changes:

commit 945096e
Author: Kudo Chien <kudo@expo.io>
Date:   Tue Jul 27 16:49:09 2021 +0800

    [android] Upgrade androidx.appcompat to 1.2.0

    Backport from: expo/expo@58fa52e
gabrieldonadel pushed a commit to expo/react-native that referenced this pull request Aug 16, 2024
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793

This is a squashed commits with the following changes:

commit 945096e
Author: Kudo Chien <kudo@expo.io>
Date:   Tue Jul 27 16:49:09 2021 +0800

    [android] Upgrade androidx.appcompat to 1.2.0

    Backport from: expo/expo@58fa52e
gabrieldonadel pushed a commit to expo/react-native that referenced this pull request Aug 22, 2024
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793

This is a squashed commits with the following changes:

commit 945096e
Author: Kudo Chien <kudo@expo.io>
Date:   Tue Jul 27 16:49:09 2021 +0800

    [android] Upgrade androidx.appcompat to 1.2.0

    Backport from: expo/expo@58fa52e
gabrieldonadel pushed a commit to expo/react-native that referenced this pull request Oct 8, 2024
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793

This is a squashed commits with the following changes:

commit 945096e
Author: Kudo Chien <kudo@expo.io>
Date:   Tue Jul 27 16:49:09 2021 +0800

    [android] Upgrade androidx.appcompat to 1.2.0

    Backport from: expo/expo@58fa52e
gabrieldonadel pushed a commit to expo/react-native that referenced this pull request Oct 10, 2024
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793

This is a squashed commits with the following changes:

commit 945096e
Author: Kudo Chien <kudo@expo.io>
Date:   Tue Jul 27 16:49:09 2021 +0800

    [android] Upgrade androidx.appcompat to 1.2.0

    Backport from: expo/expo@58fa52e
gabrieldonadel pushed a commit to expo/react-native that referenced this pull request Oct 16, 2024
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793

This is a squashed commits with the following changes:

commit 945096e
Author: Kudo Chien <kudo@expo.io>
Date:   Tue Jul 27 16:49:09 2021 +0800

    [android] Upgrade androidx.appcompat to 1.2.0

    Backport from: expo/expo@58fa52e
gabrieldonadel pushed a commit to expo/react-native that referenced this pull request Oct 17, 2024
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793

This is a squashed commits with the following changes:

commit 945096e
Author: Kudo Chien <kudo@expo.io>
Date:   Tue Jul 27 16:49:09 2021 +0800

    [android] Upgrade androidx.appcompat to 1.2.0

    Backport from: expo/expo@58fa52e
gabrieldonadel pushed a commit to expo/react-native that referenced this pull request Oct 23, 2024
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793

This is a squashed commits with the following changes:

commit 945096e
Author: Kudo Chien <kudo@expo.io>
Date:   Tue Jul 27 16:49:09 2021 +0800

    [android] Upgrade androidx.appcompat to 1.2.0

    Backport from: expo/expo@58fa52e
gabrieldonadel pushed a commit to expo/react-native that referenced this pull request Oct 29, 2024
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793

This is a squashed commits with the following changes:

commit 945096e
Author: Kudo Chien <kudo@expo.io>
Date:   Tue Jul 27 16:49:09 2021 +0800

    [android] Upgrade androidx.appcompat to 1.2.0

    Backport from: expo/expo@58fa52e
gabrieldonadel pushed a commit to expo/react-native that referenced this pull request Nov 14, 2024
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793

This is a squashed commits with the following changes:

commit 945096e
Author: Kudo Chien <kudo@expo.io>
Date:   Tue Jul 27 16:49:09 2021 +0800

    [android] Upgrade androidx.appcompat to 1.2.0

    Backport from: expo/expo@58fa52e
gabrieldonadel pushed a commit to expo/react-native that referenced this pull request Nov 22, 2024
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793

This is a squashed commits with the following changes:

commit 945096e
Author: Kudo Chien <kudo@expo.io>
Date:   Tue Jul 27 16:49:09 2021 +0800

    [android] Upgrade androidx.appcompat to 1.2.0

    Backport from: expo/expo@58fa52e
gabrieldonadel pushed a commit to expo/react-native that referenced this pull request Dec 9, 2024
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793

This is a squashed commits with the following changes:

commit 945096e
Author: Kudo Chien <kudo@expo.io>
Date:   Tue Jul 27 16:49:09 2021 +0800

    [android] Upgrade androidx.appcompat to 1.2.0

    Backport from: expo/expo@58fa52e
gabrieldonadel pushed a commit to expo/react-native that referenced this pull request Jan 9, 2025
… play nicely with Expo client color scheme locking mechanism. expo/expo#8793

This is a squashed commits with the following changes:

commit 945096e
Author: Kudo Chien <kudo@expo.io>
Date:   Tue Jul 27 16:49:09 2021 +0800

    [android] Upgrade androidx.appcompat to 1.2.0

    Backport from: expo/expo@58fa52e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants