diff options
author | Eric Arseneau <earseneau@google.com> | 2021-12-19 22:49:43 -0800 |
---|---|---|
committer | Eric Arseneau <earseneau@google.com> | 2021-12-22 12:52:50 -0800 |
commit | 3e8cb98421761bb7dfafe59a22a15fe2e176f272 (patch) | |
tree | 754d2b985bde4574c8789e254b120866cf23002a /packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java | |
parent | 48cbb14e1815430efd7ff5086e7a4c70e75d475f (diff) | |
parent | 6c2cb6876a30dee0b94d946ca529e06cd96b9642 (diff) |
Merge s-mpr-2021-12-05
Change-Id: Ic2889f5eb531008340529eadc36ec8efc62b1984
Diffstat (limited to 'packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java')
-rw-r--r-- | packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java | 51 |
1 files changed, 45 insertions, 6 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java index f4a3fb236ffa..7a01b4e8c971 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java @@ -20,6 +20,7 @@ import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; import android.app.WallpaperManager; +import android.content.res.Resources; import android.text.TextUtils; import android.view.View; import android.widget.FrameLayout; @@ -30,6 +31,7 @@ import com.android.keyguard.clock.ClockManager; import com.android.systemui.R; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.colorextraction.SysuiColorExtractor; +import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.keyguard.KeyguardUnlockAnimationController; import com.android.systemui.plugins.ClockPlugin; import com.android.systemui.plugins.statusbar.StatusBarStateController; @@ -65,18 +67,22 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS private final BroadcastDispatcher mBroadcastDispatcher; private final BatteryController mBatteryController; private final LockscreenSmartspaceController mSmartspaceController; + private final Resources mResources; /** * Clock for both small and large sizes */ private AnimatableClockController mClockViewController; - private FrameLayout mClockFrame; + private FrameLayout mClockFrame; // top aligned clock private AnimatableClockController mLargeClockViewController; - private FrameLayout mLargeClockFrame; + private FrameLayout mLargeClockFrame; // centered clock private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; private final KeyguardBypassController mBypassController; + private int mLargeClockTopMargin = 0; + private int mKeyguardClockTopMargin = 0; + /** * Listener for changes to the color palette. * @@ -113,7 +119,8 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS KeyguardBypassController bypassController, LockscreenSmartspaceController smartspaceController, KeyguardUnlockAnimationController keyguardUnlockAnimationController, - SmartspaceTransitionController smartspaceTransitionController) { + SmartspaceTransitionController smartspaceTransitionController, + @Main Resources resources) { super(keyguardClockSwitch); mStatusBarStateController = statusBarStateController; mColorExtractor = colorExtractor; @@ -125,6 +132,7 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS mKeyguardUpdateMonitor = keyguardUpdateMonitor; mBypassController = bypassController; mSmartspaceController = smartspaceController; + mResources = resources; mKeyguardUnlockAnimationController = keyguardUnlockAnimationController; mSmartspaceTransitionController = smartspaceTransitionController; @@ -154,7 +162,8 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS mBroadcastDispatcher, mBatteryController, mKeyguardUpdateMonitor, - mBypassController); + mBypassController, + mResources); mClockViewController.init(); mLargeClockViewController = @@ -164,7 +173,8 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS mBroadcastDispatcher, mBatteryController, mKeyguardUpdateMonitor, - mBypassController); + mBypassController, + mResources); mLargeClockViewController.init(); } @@ -175,6 +185,8 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS } mColorExtractor.addOnColorsChangedListener(mColorsListener); mView.updateColors(getGradientColors()); + mKeyguardClockTopMargin = + mView.getResources().getDimensionPixelSize(R.dimen.keyguard_clock_top_margin); if (mOnlyClock) { View ksa = mView.findViewById(R.id.keyguard_status_area); @@ -249,6 +261,8 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS */ public void onDensityOrFontScaleChanged() { mView.onDensityOrFontScaleChanged(); + mKeyguardClockTopMargin = + mView.getResources().getDimensionPixelSize(R.dimen.keyguard_clock_top_margin); updateClockLayout(); } @@ -257,9 +271,12 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS if (mSmartspaceController.isEnabled()) { RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT); - lp.topMargin = getContext().getResources().getDimensionPixelSize( + mLargeClockTopMargin = getContext().getResources().getDimensionPixelSize( R.dimen.keyguard_large_clock_top_margin); + lp.topMargin = mLargeClockTopMargin; mLargeClockFrame.setLayoutParams(lp); + } else { + mLargeClockTopMargin = 0; } } @@ -369,6 +386,28 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS } } + /** + * Get y-bottom position of the currently visible clock on the keyguard. + * We can't directly getBottom() because clock changes positions in AOD for burn-in + */ + int getClockBottom(int statusBarHeaderHeight) { + if (mLargeClockFrame.getVisibility() == View.VISIBLE) { + View clock = mLargeClockFrame.findViewById( + com.android.systemui.R.id.animatable_clock_view_large); + int frameHeight = mLargeClockFrame.getHeight(); + int clockHeight = clock.getHeight(); + return frameHeight / 2 + clockHeight / 2; + } else { + return mClockFrame.findViewById( + com.android.systemui.R.id.animatable_clock_view).getHeight() + + statusBarHeaderHeight + mKeyguardClockTopMargin; + } + } + + boolean isClockTopAligned() { + return mLargeClockFrame.getVisibility() != View.VISIBLE; + } + private void updateAodIcons() { NotificationIconContainer nic = (NotificationIconContainer) mView.findViewById( |