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

Commit 2dcdc087 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "New LS clock is positioned a min distance from top"

parents 770e6072 f303da38
Loading
Loading
Loading
Loading
+13 −5
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@ import com.android.systemui.R;
 * Utility class to calculate the clock position and top padding of notifications on Keyguard.
 */
public class KeyguardClockPositionAlgorithm {

    /**
     * How much the clock height influences the shade position.
     * 0 means nothing, 1 means move the shade up by the height of the clock
@@ -80,6 +79,11 @@ public class KeyguardClockPositionAlgorithm {
     */
    private int mMinTopMargin;

    /**
     * Minimum top inset (in pixels) to avoid overlap with any display cutouts.
     */
    private int mCutoutTopInset = 0;

    /**
     * Maximum bottom padding to avoid overlap with {@link KeyguardBottomAreaView} or
     * the ambient indication.
@@ -172,7 +176,7 @@ public class KeyguardClockPositionAlgorithm {
            float panelExpansion, int parentHeight, int keyguardStatusHeight, int clockPreferredY,
            boolean hasCustomClock, boolean hasVisibleNotifs, float dark, float emptyDragAmount,
            boolean bypassEnabled, int unlockedStackScrollerPadding, boolean showLockIcon,
            float qsExpansion) {
            float qsExpansion, int cutoutTopInset) {
        mMinTopMargin = statusBarMinHeight + (showLockIcon
                ? mContainerTopPaddingWithLockIcon : mContainerTopPaddingWithoutLockIcon);
        mMaxShadeBottom = maxShadeBottom;
@@ -188,6 +192,7 @@ public class KeyguardClockPositionAlgorithm {
        mBypassEnabled = bypassEnabled;
        mUnlockedStackScrollerPadding = unlockedStackScrollerPadding;
        mQsExpansion = qsExpansion;
        mCutoutTopInset = cutoutTopInset;
    }

    public void run(Result result) {
@@ -270,10 +275,13 @@ public class KeyguardClockPositionAlgorithm {

        float darkAmount = mBypassEnabled && !mHasCustomClock ? 1.0f : mDarkAmount;

        // TODO(b/12836565) - prototyping only adjustment
        if (mLockScreenMode != KeyguardUpdateMonitor.LOCK_SCREEN_MODE_NORMAL) {
            // This will keep the clock at the top
            clockYDark = (int) (clockY + burnInPreventionOffsetY());
            // This will keep the clock at the top but out of the cutout area
            float shift = 0;
            if (clockY - mBurnInPreventionOffsetYLargeClock < mCutoutTopInset) {
                shift = mCutoutTopInset - (clockY - mBurnInPreventionOffsetYLargeClock);
            }
            clockYDark = clockY + burnInPreventionOffsetY() + shift;
        }
        return (int) (MathUtils.lerp(clockY, clockYDark, darkAmount) + mEmptyDragAmount);
    }
+7 −1
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ import android.os.PowerManager;
import android.os.SystemClock;
import android.util.Log;
import android.util.MathUtils;
import android.view.DisplayCutout;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.VelocityTracker;
@@ -344,6 +345,7 @@ public class NotificationPanelViewController extends PanelViewController {
    private float mEmptyDragAmount;
    private float mDownX;
    private float mDownY;
    private int mDisplayCutoutTopInset = 0; // in pixels

    private final KeyguardClockPositionAlgorithm
            mClockPositionAlgorithm =
@@ -909,7 +911,8 @@ public class NotificationPanelViewController extends PanelViewController {
                    hasVisibleNotifications, mInterpolatedDarkAmount, mEmptyDragAmount,
                    bypassEnabled, getUnlockedStackScrollerPadding(),
                    mUpdateMonitor.shouldShowLockIcon(),
                    getQsExpansionFraction());
                    getQsExpansionFraction(),
                    mDisplayCutoutTopInset);
            mClockPositionAlgorithm.run(mClockPositionResult);
            mKeyguardStatusViewController.updatePosition(
                    mClockPositionResult.clockX, mClockPositionResult.clockY,
@@ -3835,6 +3838,9 @@ public class NotificationPanelViewController extends PanelViewController {

    private class OnApplyWindowInsetsListener implements View.OnApplyWindowInsetsListener {
        public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
            final DisplayCutout displayCutout = v.getRootWindowInsets().getDisplayCutout();
            mDisplayCutoutTopInset = displayCutout != null ? displayCutout.getSafeInsetTop() : 0;

            mNavigationBarBottomHeight = insets.getStableInsetBottom();
            updateMaxHeadsUpTranslation();
            return insets;
+3 −1
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
    private boolean mHasCustomClock;
    private boolean mHasVisibleNotifs;
    private float mQsExpansion;
    private int mCutoutTopInset = 0; // in pixels

    @Before
    public void setUp() {
@@ -394,7 +395,8 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
        mClockPositionAlgorithm.setup(EMPTY_MARGIN, SCREEN_HEIGHT, mNotificationStackHeight,
                mPanelExpansion, SCREEN_HEIGHT, mKeyguardStatusHeight, mPreferredClockY,
                mHasCustomClock, mHasVisibleNotifs, mDark, ZERO_DRAG, false /* bypassEnabled */,
                0 /* unlockedStackScrollerPadding */, false /* udfpsEnrolled */, mQsExpansion);
                0 /* unlockedStackScrollerPadding */, false /* udfpsEnrolled */,
                mQsExpansion, mCutoutTopInset);
        mClockPositionAlgorithm.run(mClockPosition);
    }
}