From 474b704e5d9c7ba3a678e13164716aa797648e21 Mon Sep 17 00:00:00 2001 From: Prabir Pradhan Date: Mon, 10 Jan 2022 11:52:44 -0800 Subject: [PATCH] PointerLocationView: Make header avoid rounded corners Fixes: 201281153 Test: manual: check that the pointer location header is shown below the rounded corner cutouts Change-Id: I6f140e018d37927283b63c4e7082bd9cfac0f0a6 --- .../internal/widget/PointerLocationView.java | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/core/java/com/android/internal/widget/PointerLocationView.java b/core/java/com/android/internal/widget/PointerLocationView.java index 627381c620c1e..09ff4e0aa0764 100644 --- a/core/java/com/android/internal/widget/PointerLocationView.java +++ b/core/java/com/android/internal/widget/PointerLocationView.java @@ -37,6 +37,7 @@ import android.view.InputDevice; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.MotionEvent.PointerCoords; +import android.view.RoundedCorner; import android.view.VelocityTracker; import android.view.View; import android.view.ViewConfiguration; @@ -229,13 +230,29 @@ public class PointerLocationView extends View implements InputDeviceListener, @Override public WindowInsets onApplyWindowInsets(WindowInsets insets) { - if (insets.getDisplayCutout() != null) { - mHeaderPaddingTop = insets.getDisplayCutout().getSafeInsetTop(); - mWaterfallInsets = insets.getDisplayCutout().getWaterfallInsets(); - } else { - mHeaderPaddingTop = 0; - mWaterfallInsets = Insets.NONE; + int headerPaddingTop = 0; + Insets waterfallInsets = Insets.NONE; + + final RoundedCorner topLeftRounded = + insets.getRoundedCorner(RoundedCorner.POSITION_TOP_LEFT); + if (topLeftRounded != null) { + headerPaddingTop = topLeftRounded.getRadius(); } + + final RoundedCorner topRightRounded = + insets.getRoundedCorner(RoundedCorner.POSITION_TOP_RIGHT); + if (topRightRounded != null) { + headerPaddingTop = Math.max(headerPaddingTop, topRightRounded.getRadius()); + } + + if (insets.getDisplayCutout() != null) { + headerPaddingTop = + Math.max(headerPaddingTop, insets.getDisplayCutout().getSafeInsetTop()); + waterfallInsets = insets.getDisplayCutout().getWaterfallInsets(); + } + + mHeaderPaddingTop = headerPaddingTop; + mWaterfallInsets = waterfallInsets; return super.onApplyWindowInsets(insets); }