Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 46712ee2 authored by LuK1337's avatar LuK1337 Committed by Łukasz Patron
Browse files

SystemUI: Make center clock layout safe insets aware

This effectively fixes wrongly centered clock layout on
devices with side notch / hole punch.

Change-Id: I7cb8cbbe628397c50d37e23ba1853368e61a1fc9
parent 0de4290f
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import android.view.DisplayCutout;
import android.view.Gravity;
import android.view.IWindowManager;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowInsets;
@@ -405,6 +406,13 @@ public class PhoneStatusBarView extends PanelBar implements Callbacks {
                        mDisplayCutout, cornerCutoutMargins, mRoundedCornerPadding);

        setPadding(padding.first, getPaddingTop(), padding.second, getPaddingBottom());

        // Apply negative paddings to center clock layout so that we'll actually be on the center.
        final int winRotation = getDisplay().getRotation();
        LayoutParams centerClockParams =
                (LayoutParams) findViewById(R.id.center_clock_layout).getLayoutParams();
        centerClockParams.leftMargin = winRotation == Surface.ROTATION_0 ? -padding.first : 0;
        centerClockParams.rightMargin = winRotation == Surface.ROTATION_0 ? -padding.second : 0;
    }

    public void setHeadsUpVisible(boolean headsUpVisible) {