From a34ae4718a8efc9e1a1f9b91b88c9dba10f62a7f Mon Sep 17 00:00:00 2001 From: Michal Brzezinski Date: Fri, 11 Jun 2021 12:44:26 +0100 Subject: [PATCH] Always showing big clock on the lockscreen in split shade Big clock should be always visible on the left side of the lockscreen in split shade mode, regardless of the number of notifications. Bug: 190702873 Test: KeyguardClockSwitchTest and NotificationPanelViewTest Change-Id: I7c4bb9684533f278f2014cf6fdf1b1b3f2e04515 --- .../android/keyguard/KeyguardClockSwitch.java | 40 ++++++++++++------- .../KeyguardClockSwitchController.java | 10 +++-- .../KeyguardStatusViewController.java | 8 ++-- .../NotificationPanelViewController.java | 8 +++- .../keyguard/KeyguardClockSwitchTest.java | 35 ++++++++++++++++ .../phone/NotificationPanelViewTest.java | 35 ++++++++++++++++ 6 files changed, 114 insertions(+), 22 deletions(-) diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java index ef052c4b81ac3..0bd9ca4b52ae7 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java @@ -14,6 +14,9 @@ import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.RelativeLayout; +import androidx.annotation.IntDef; +import androidx.annotation.VisibleForTesting; + import com.android.internal.colorextraction.ColorExtractor; import com.android.keyguard.dagger.KeyguardStatusViewScope; import com.android.systemui.R; @@ -22,6 +25,8 @@ import com.android.systemui.plugins.ClockPlugin; import java.io.FileDescriptor; import java.io.PrintWriter; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; import java.util.Arrays; import java.util.TimeZone; @@ -37,6 +42,13 @@ public class KeyguardClockSwitch extends RelativeLayout { private static final long CLOCK_IN_MILLIS = 200; private static final long SMARTSPACE_MOVE_MILLIS = 350; + @IntDef({LARGE, SMALL}) + @Retention(RetentionPolicy.SOURCE) + public @interface ClockSize { } + + public static final int LARGE = 0; + public static final int SMALL = 1; + /** * Optional/alternative clock injected via plugin. */ @@ -64,13 +76,13 @@ public class KeyguardClockSwitch extends RelativeLayout { private float mDarkAmount; /** - * Boolean value indicating if notifications are visible on lock screen. Use null to signify - * it is uninitialized. + * Indicates which clock is currently displayed - should be one of {@link ClockSize}. + * Use null to signify it is uninitialized. */ - private Boolean mHasVisibleNotifications = null; + @ClockSize private Integer mDisplayedClockSize = null; - private AnimatorSet mClockInAnim = null; - private AnimatorSet mClockOutAnim = null; + @VisibleForTesting AnimatorSet mClockInAnim = null; + @VisibleForTesting AnimatorSet mClockOutAnim = null; private ObjectAnimator mSmartspaceAnim = null; /** @@ -260,19 +272,17 @@ public class KeyguardClockSwitch extends RelativeLayout { } /** - * Based upon whether notifications are showing or not, display/hide the large clock and - * the smaller version. + * Display the desired clock and hide the other one + * + * @return true if desired clock appeared and false if it was already visible */ - boolean willSwitchToLargeClock(boolean hasVisibleNotifications) { - if (mHasVisibleNotifications != null - && hasVisibleNotifications == mHasVisibleNotifications) { + boolean switchToClock(@ClockSize int clockSize) { + if (mDisplayedClockSize != null && clockSize == mDisplayedClockSize) { return false; } - boolean useLargeClock = !hasVisibleNotifications; - animateClockChange(useLargeClock); - - mHasVisibleNotifications = hasVisibleNotifications; - return useLargeClock; + animateClockChange(clockSize == LARGE); + mDisplayedClockSize = clockSize; + return true; } public Paint getPaint() { diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java index ef6212d4f3547..a928270ba3c0c 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java @@ -19,6 +19,8 @@ package com.android.keyguard; import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; +import static com.android.keyguard.KeyguardClockSwitch.LARGE; + import android.app.WallpaperManager; import android.content.res.Resources; import android.text.TextUtils; @@ -234,10 +236,12 @@ public class KeyguardClockSwitchController extends ViewController