From 17bdae386bcf757d61c59d59281b30527fc95b6c Mon Sep 17 00:00:00 2001 From: Christian Oder Date: Mon, 6 Jan 2020 14:48:35 +0100 Subject: [crdroid][11.0] KeyguardClockPositionAlgorithm: Allow forcing default clockY positioning set clocks preferred Y coordinates to -1 to use default Y handling on custom clocks Change-Id: I4ce8106987e7aa1a5bb3da1865aa86ce99343e09 --- .../phone/KeyguardClockPositionAlgorithm.java | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java index a3f14ba28dcb..24148c9700d2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java @@ -38,6 +38,11 @@ public class KeyguardClockPositionAlgorithm { */ private static float CLOCK_HEIGHT_WEIGHT = 0.7f; + /** + * Allow using the default clock Y calculations + */ + public static int CLOCK_USE_DEFAULT_Y = -1; + /** * Margin between the bottom of the clock and the notification shade. */ @@ -180,12 +185,17 @@ public class KeyguardClockPositionAlgorithm { return mHeight / 2 - mKeyguardStatusHeight - mClockNotificationsMargin; } - private int getPreferredClockY() { - return mClockPreferredY; + private int getPreferredAlternativeClockY(int alternative) { + if (mClockPreferredY != CLOCK_USE_DEFAULT_Y) { + return mClockPreferredY; + } else { + return alternative; + } } private int getExpandedPreferredClockY() { - return (mHasCustomClock && (!mHasVisibleNotifs || mBypassEnabled)) ? getPreferredClockY() + return (mHasCustomClock && (!mHasVisibleNotifs || mBypassEnabled)) + ? getPreferredAlternativeClockY(getExpandedClockPosition()) : getExpandedClockPosition(); } @@ -215,8 +225,8 @@ public class KeyguardClockPositionAlgorithm { private int getClockY(float panelExpansion) { // Dark: Align the bottom edge of the clock at about half of the screen: - float clockYDark = (mHasCustomClock ? getPreferredClockY() : getMaxClockY()) - + burnInPreventionOffsetY(); + float clockYDark = (mHasCustomClock ? getPreferredAlternativeClockY(getMaxClockY()) + : getMaxClockY()) + burnInPreventionOffsetY(); clockYDark = MathUtils.max(0, clockYDark); float clockYRegular = getExpandedPreferredClockY(); -- cgit v1.2.3