1313import android .view .WindowMetrics ;
1414import androidx .annotation .NonNull ;
1515
16- final class UtilsDevice {
16+ class UtilsDevice {
1717 private UtilsDevice () {
1818 }
1919
@@ -52,20 +52,20 @@ private static void applyWindowMetrics(@NonNull Context context,
5252 types |= WindowInsets .Type .statusBars ();
5353 }
5454
55- // boolean drawUnderCutout;
56- // WindowManager.LayoutParams params = ((Activity) context).getWindow().getAttributes();
57- // drawUnderCutout = params.layoutInDisplayCutoutMode
58- // == WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
55+ boolean drawUnderCutout ;
56+ WindowManager .LayoutParams params = ((Activity ) context ).getWindow ().getAttributes ();
57+ drawUnderCutout = params .layoutInDisplayCutoutMode
58+ == WindowManager .LayoutParams .LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES ;
5959
6060 // Only subtract display cutout insets when not allowed to draw under the cutout
61- // if (!drawUnderCutout && windowInsets.isVisible(WindowInsets.Type.displayCutout())) {
62- // types |= WindowInsets.Type.displayCutout();
63- //} Cutout is always respected as safe area for now even in fullscreen mode
64- }
65-
66- // Only subtract display cutout insets when not allowed to draw under the cutout
67- if ( windowInsets . isVisible ( WindowInsets .Type .displayCutout ())) {
68- types |= WindowInsets . Type . displayCutout ();
61+ if (!drawUnderCutout && windowInsets .isVisible (WindowInsets .Type .displayCutout ())) {
62+ types |= WindowInsets .Type .displayCutout ();
63+ }
64+ // Cutout is always respected as safe area for now even in fullscreen mode
65+ // Only subtract display cutout insets when not allowed to draw under the cutout
66+ if ( windowInsets . isVisible ( WindowInsets . Type . displayCutout ())) {
67+ types |= WindowInsets .Type .displayCutout ();
68+ }
6969 }
7070
7171 final Insets insets = windowInsets .getInsets (types );
@@ -88,11 +88,7 @@ private static void applyWindowMetrics(@NonNull Context context,
8888 private static void applyLegacyMetrics (@ NonNull WindowManager wm ,
8989 @ NonNull DisplayMetrics outMetrics ) {
9090 final Display display = wm .getDefaultDisplay ();
91- if (Build .VERSION .SDK_INT < Build .VERSION_CODES .Q ) {
92- display .getMetrics (outMetrics );
93- } else {
94- display .getRealMetrics (outMetrics );
95- }
91+ display .getRealMetrics (outMetrics );
9692 //getMetrics gives us size minus navigation bar
9793 }
9894}
0 commit comments