Skip to content

Commit

Permalink
Fix DeviceInfoModule LifecycleEventListener
Browse files Browse the repository at this point in the history
Summary:
Fixes one of the two parts of [issue posted here](#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 #17227

Differential Revision: D6692358

Pulled By: hramos

fbshipit-source-id: 3db212fe8103c7aa29a29ead6c772abb7ae4cd85
  • Loading branch information
steveccable authored and facebook-github-bot committed Jan 10, 2018
1 parent b41d41f commit 22735f6
Showing 1 changed file with 1 addition and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class DeviceInfoModule extends BaseJavaModule implements
public DeviceInfoModule(ReactApplicationContext reactContext) {
this((Context) reactContext);
mReactApplicationContext = reactContext;
mReactApplicationContext.addLifecycleEventListener(this);
}

public DeviceInfoModule(Context context) {
Expand Down

0 comments on commit 22735f6

Please sign in to comment.