Skip to content

Commit 4cbd263

Browse files
mdvaccafacebook-github-bot
authored andcommitted
Un-deprecate DisplayMetrics.getWindowDisplayMetrics() method
Summary: The purpose of this diff is to un-deprecate the method DisplayMetrics.getWindowDisplayMetrics(). As React Native is used in devices with multiple screens and displays, we need to provide a non-deprecated way to access display metrics (e.g. screen density) for the window that's used to render react native views. This diff doesn't make any change in behavior, but it un-deprecates the API changelog: [Android][Added] Un-deprecate DisplayMetrics.getWindowDisplayMetrics() method Reviewed By: javache Differential Revision: D37871954 fbshipit-source-id: d8eb97cfae096f2f62ed1389a6de17a892a46b43
1 parent 7db6c08 commit 4cbd263

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

ReactAndroid/src/main/java/com/facebook/react/uimanager/DisplayMetricsHolder.java

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,13 @@
1818

1919
/**
2020
* Holds an instance of the current DisplayMetrics so we don't have to thread it through all the
21-
* classes that need it. Note: windowDisplayMetrics are deprecated in favor of ScreenDisplayMetrics:
22-
* window metrics are supposed to return the drawable area but there's no guarantee that they
23-
* correspond to the actual size of the {@link ReactRootView}. Moreover, they are not consistent
24-
* with what iOS returns. Screen metrics returns the metrics of the entire screen, is consistent
25-
* with iOS and should be used instead.
21+
* classes that need it.
2622
*/
2723
public class DisplayMetricsHolder {
2824

2925
private static @Nullable DisplayMetrics sWindowDisplayMetrics;
3026
private static @Nullable DisplayMetrics sScreenDisplayMetrics;
3127

32-
/**
33-
* @deprecated Use {@link #setScreenDisplayMetrics(DisplayMetrics)} instead. See comment above as
34-
* to why this is not correct to use.
35-
*/
3628
public static void setWindowDisplayMetrics(DisplayMetrics displayMetrics) {
3729
sWindowDisplayMetrics = displayMetrics;
3830
}
@@ -63,11 +55,7 @@ public static void initDisplayMetrics(Context context) {
6355
DisplayMetricsHolder.setScreenDisplayMetrics(screenDisplayMetrics);
6456
}
6557

66-
/**
67-
* @deprecated Use {@link #getScreenDisplayMetrics()} instead. See comment above as to why this is
68-
* not correct to use.
69-
*/
70-
@Deprecated
58+
/** Returns the metrics of the window associated to the Context used to initialize ReactNative */
7159
public static DisplayMetrics getWindowDisplayMetrics() {
7260
return sWindowDisplayMetrics;
7361
}
@@ -76,6 +64,7 @@ public static void setScreenDisplayMetrics(DisplayMetrics screenDisplayMetrics)
7664
sScreenDisplayMetrics = screenDisplayMetrics;
7765
}
7866

67+
/** Screen metrics returns the metrics of the default screen on the device. */
7968
public static DisplayMetrics getScreenDisplayMetrics() {
8069
return sScreenDisplayMetrics;
8170
}

0 commit comments

Comments
 (0)