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

[ANDROID] Fix DeviceInfoModule LifecycleEventListener #17227

Closed

Conversation

steveccable
Copy link
Contributor

@steveccable steveccable commented Dec 15, 2017

Motivation

Fixes one of the two parts of issue posted here. Motivation is that we wanted our app to be able to handle user changing font size while the app is running. Yes, we know that changing font size doesn't inherently trigger a re-render, but at the minimum it should cause PixelRatio.getFontScale() to return an updated value.

Test Plan

  1. Render an interface and invoke PixelRatio.getFontScale()
  2. Change the font scale in Settings > Accessibility > Font Size
  3. Return to the React Native app (without reloading Javascript) and invoke PixelRatio.getFontScale() again.
  4. Verify that the result of PixelRatio.getFontScale() has changed to reflect the new font size.

For a video of the problem, see the linked issue under the Motivation heading. In this fixed version, the number actually does update as expected.

Related PRs

None. This should require no documentation change, as it is behavior that the docs seem to indicate should be happening already.
In fact, the documentation at the bottom of this page appears to already indicate that this should be done for anything implementing LifecycleEventListener.

Release Notes

[ANDROID] [BUGFIX] [DeviceInfo] - Fix the DeviceInfoModule to properly respond to LifecycleEvents

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Dec 15, 2017
@steveccable
Copy link
Contributor Author

Also fwiw I have no idea why circleci is failing, especially on the js and objc tests, since this PR makes effectively a 1-line change to Java code used only on Android...

@steveccable
Copy link
Contributor Author

@hramos Any chance you could have a look at this? Alternatively, if you're not the right person to tag, do you know who would be?

@asowayan
Copy link

asowayan commented Jan 5, 2018

@joshyhargreaves Any chance you could have a look at this?

@asowayan
Copy link

asowayan commented Jan 6, 2018

@janicduplessis any chance you can review this PR?

@@ -9,11 +9,6 @@

package com.facebook.react.modules.deviceinfo;

import javax.annotation.Nullable;
Copy link
Contributor

@joshjhargreaves joshjhargreaves Jan 6, 2018

Choose a reason for hiding this comment

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

Unless there's any styling rule requirement, moving of the imports is unnecessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, that was Android Studio moving them around automatically but i can set them back.

Copy link
Contributor

@joshjhargreaves joshjhargreaves left a comment

Choose a reason for hiding this comment

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

I would remove the import ordering changes just for cleanliness, but otherwise this looks good!

You're 100% correct, registering with the reactContext seems absolute necessary. I will also test locally to verify!

@steveccable steveccable force-pushed the android-fontscale-eventlistener branch from fa5766c to 733a313 Compare January 9, 2018 15:37
@steveccable
Copy link
Contributor Author

@joshyhargreaves Cleaned up the imports, now it should be just the one line of actual fix.

@brentvatne
Copy link
Collaborator

lgtm

@grabbou
Copy link
Contributor

grabbou commented Jan 10, 2018

@facebook-github-bot shipit

@facebook-github-bot facebook-github-bot added the Import Started This pull request has been imported. This does not imply the PR has been approved. label Jan 10, 2018
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@grabbou is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

mathiasbynens pushed a commit to mathiasbynens/react-native that referenced this pull request Jan 13, 2018
Summary:
Fixes one of the two parts of [issue posted here](facebook#17209).  Motivation is that we wanted our app to be able to handle user changing font size while the app is running.  Yes, we know that changing font size doesn't inherently trigger a re-render, but at the minimum it should cause `PixelRatio.getFontScale()` to return an updated value.

1. Render an interface and invoke `PixelRatio.getFontScale()`
2. Change the font scale in Settings > Accessibility > Font Size
3. Return to the React Native app (without reloading Javascript) and invoke `PixelRatio.getFontScale()` again.
4. Verify that the result of `PixelRatio.getFontScale()` has changed to reflect the new font size.

For a video of the problem, see the linked issue under the Motivation heading.  In this fixed version, the number actually does update as expected.

None.  This should require no documentation change, as it is behavior that the docs seem to indicate should be happening already.
In fact, [the documentation at the bottom of this page](https://facebook.github.io/react-native/docs/native-modules-android.html) appears to already indicate that this should be done for anything implementing LifecycleEventListener.

[ANDROID] [BUGFIX] [DeviceInfo] - Fix the DeviceInfoModule to properly respond to LifecycleEvents
Closes facebook#17227

Differential Revision: D6692358

Pulled By: hramos

fbshipit-source-id: 3db212fe8103c7aa29a29ead6c772abb7ae4cd85
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Import Started This pull request has been imported. This does not imply the PR has been approved.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants