diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java index 4629e8b19ae5e..ec4e5cf3e767a 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java @@ -15,6 +15,7 @@ import android.widget.RelativeLayout; import androidx.annotation.IntDef; import androidx.annotation.VisibleForTesting; +import com.android.keyguard.clock.DefaultClockController; import com.android.keyguard.dagger.KeyguardStatusViewScope; import com.android.systemui.R; import com.android.systemui.animation.Interpolators; @@ -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..5c5326cfd4e68 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java @@ -168,6 +168,14 @@ public class KeyguardClockSwitchController extends ViewController