From 4aeee7e94cc5360a66f7affdba490009ea97b192 Mon Sep 17 00:00:00 2001 From: Sherry Zhou Date: Tue, 25 Apr 2023 05:24:45 +0000 Subject: [PATCH] Fix clock translation on lockscreen make clock counter translation by amount of getExpandedPreferredClockY to align to screen Previously reverted due to b/280096103, fix by comparing clockY and calling updateClockTargetRegions less frequently Test: manually Bug: 278413320 Bug: 278456894 Change-Id: I1b133bab62769681d718e273370d319b57e44e98 --- .../android/keyguard/KeyguardClockSwitch.java | 18 ++++++++++++++++-- .../KeyguardClockSwitchController.java | 17 ++++++++++------- .../keyguard/KeyguardStatusViewController.java | 14 +++++++++----- .../shade/NotificationPanelViewController.java | 2 ++ .../phone/KeyguardClockPositionAlgorithm.java | 6 +++++- 5 files changed, 42 insertions(+), 15 deletions(-) diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java index 4629e8b19ae5e..1ca63fb883421 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java @@ -21,6 +21,7 @@ import com.android.systemui.animation.Interpolators; import com.android.systemui.log.LogBuffer; import com.android.systemui.log.LogLevel; import com.android.systemui.plugins.ClockController; +import com.android.systemui.shared.clocks.DefaultClockController; import java.io.PrintWriter; import java.lang.annotation.Retention; @@ -46,6 +47,9 @@ public class KeyguardClockSwitch extends RelativeLayout { public static final int LARGE = 0; public static final int SMALL = 1; + // compensate for translation of parents subject to device screen + // In this case, the translation comes from KeyguardStatusView + public int screenOffsetYPadding = 0; /** Returns a region for the large clock to position itself, based on the given parent. */ public static Rect getLargeClockRegion(ViewGroup parent) { @@ -161,8 +165,18 @@ public class KeyguardClockSwitch extends RelativeLayout { } if (mLargeClockFrame.isLaidOut()) { - mClock.getLargeClock().getEvents().onTargetRegionChanged( - getLargeClockRegion(mLargeClockFrame)); + Rect targetRegion = getLargeClockRegion(mLargeClockFrame); + if (mClock instanceof DefaultClockController) { + mClock.getLargeClock().getEvents().onTargetRegionChanged( + targetRegion); + } else { + mClock.getLargeClock().getEvents().onTargetRegionChanged( + new Rect( + targetRegion.left, + targetRegion.top - screenOffsetYPadding, + targetRegion.right, + targetRegion.bottom - screenOffsetYPadding)); + } } } } diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java index 50dac32d67d78..d8bf570954df6 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java @@ -168,6 +168,16 @@ public class KeyguardClockSwitchController extends ViewController