From 82ebfa96e5d47960af1b6cfd483077ce1e933d11 Mon Sep 17 00:00:00 2001 From: Yunfan Chen Date: Wed, 17 Jan 2024 18:57:14 +0900 Subject: Update configuration API docs to reflect behavior change Update the API doc of screenWidthDp and screenHeightDp to reflect the behavior change happening. Bug: 151861875 Bug: 321168774 Test: N/A Change-Id: I3e40b80f66d1c8d465cd1f4cc8bc0bc40d9a35ab --- core/java/android/content/res/Configuration.java | 55 +++++++++++++++--------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/core/java/android/content/res/Configuration.java b/core/java/android/content/res/Configuration.java index d27479299efa..885f4c5e8ec4 100644 --- a/core/java/android/content/res/Configuration.java +++ b/core/java/android/content/res/Configuration.java @@ -802,14 +802,20 @@ public final class Configuration implements Parcelable, ComparableNote: The width measurement excludes window - * insets even when the app is displayed edge to edge using - * {@link android.view.Window#setDecorFitsSystemWindows(boolean) + * * + * Use {@link android.view.WindowMetrics#getBounds()} to always obtain the horizontal + * display area available to an app or embedded activity including the area + * occupied by window insets. A version of the API is also available for use on older platforms + * through {@link androidx.window.layout.WindowMetrics}. + * *

Corresponds to the * * available width resource qualifier. Defaults to @@ -831,14 +837,15 @@ public final class Configuration implements Parcelable, ComparableDiffers from {@link android.view.WindowMetrics} by not including + *

If the app targets {@link android.os.Build.VERSION_CODES#VANILLA_ICE_CREAM} or after, + * it is the same as {@link android.view.WindowMetrics}, but is expressed rounded to the nearest + * dp rather than px. + * + *

Otherwise, differs from {@link android.view.WindowMetrics} by not including * window insets in the width measurement and by expressing the measurement * in dp rather than px. Use {@code screenWidthDp} to obtain the width of * the display area available to an app or embedded activity excluding the - * area occupied by window insets. Use - * {@link android.view.WindowMetrics#getBounds()} to obtain the horizontal - * display area available to an app or embedded activity including the area - * occupied by window insets. + * area occupied by window insets. */ public int screenWidthDp; @@ -849,15 +856,20 @@ public final class Configuration implements Parcelable, ComparableNote: The height measurement excludes window - * insets even when the app is displayed edge to edge using - * {@link android.view.Window#setDecorFitsSystemWindows(boolean) + *

* + * Use {@link android.view.WindowMetrics#getBounds()} to always obtain the vertical + * display area available to an app or embedded activity including the area + * occupied by window insets. A version of the API is also available for use on older platforms + * through {@link androidx.window.layout.WindowMetrics}. + * *

Corresponds to the * * available height resource qualifier. Defaults to @@ -879,14 +891,15 @@ public final class Configuration implements Parcelable, ComparableDiffers from {@link android.view.WindowMetrics} by not including + *

If the app targets {@link android.os.Build.VERSION_CODES#VANILLA_ICE_CREAM} or after, + * it is the same as {@link android.view.WindowMetrics}, but is expressed rounded to the nearest + * dp rather than px. + * + *

Otherwise, differs from {@link android.view.WindowMetrics} by not including * window insets in the height measurement and by expressing the measurement * in dp rather than px. Use {@code screenHeightDp} to obtain the height of * the display area available to an app or embedded activity excluding the - * area occupied by window insets. Use - * {@link android.view.WindowMetrics#getBounds()} to obtain the vertical - * display area available to an app or embedded activity including the area - * occupied by window insets. + * area occupied by window insets. */ public int screenHeightDp; -- cgit v1.2.3-59-g8ed1b