Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a34ae471 authored by Michal Brzezinski's avatar Michal Brzezinski
Browse files

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
parent aab4632a
Loading
Loading
Loading
Loading
+25 −15
Original line number Diff line number Diff line
@@ -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() {
+7 −3
Original line number Diff line number Diff line
@@ -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<KeyguardClockS
    }

    /**
     * Set whether or not the lock screen is showing notifications.
     * Set which clock should be displayed on the keyguard. The other one will be automatically
     * hidden.
     */
    public void setHasVisibleNotifications(boolean hasVisibleNotifications) {
        if (mView.willSwitchToLargeClock(hasVisibleNotifications)) {
    public void displayClock(@KeyguardClockSwitch.ClockSize int clockSize) {
        boolean appeared = mView.switchToClock(clockSize);
        if (appeared && clockSize == LARGE) {
            mLargeClockViewController.animateAppear();
        }
    }
+5 −3
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.keyguard;
import android.graphics.Rect;
import android.util.Slog;

import com.android.keyguard.KeyguardClockSwitch.ClockSize;
import com.android.systemui.keyguard.KeyguardUnlockAnimationController;
import com.android.systemui.shared.system.smartspace.SmartspaceTransitionController;
import com.android.systemui.statusbar.notification.AnimatableProperty;
@@ -126,10 +127,11 @@ public class KeyguardStatusViewController extends ViewController<KeyguardStatusV
    }

    /**
     * Set whether or not the lock screen is showing notifications.
     * Set which clock should be displayed on the keyguard. The other one will be automatically
     * hidden.
     */
    public void setHasVisibleNotifications(boolean hasVisibleNotifications) {
        mKeyguardClockSwitchController.setHasVisibleNotifications(hasVisibleNotifications);
    public void displayClock(@ClockSize int clockSize) {
        mKeyguardClockSwitchController.displayClock(clockSize);
    }

    /**
+7 −1
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ import static androidx.constraintlayout.widget.ConstraintSet.PARENT_ID;
import static androidx.constraintlayout.widget.ConstraintSet.START;

import static com.android.internal.jank.InteractionJankMonitor.CUJ_NOTIFICATION_SHADE_QS_EXPAND_COLLAPSE;
import static com.android.keyguard.KeyguardClockSwitch.LARGE;
import static com.android.keyguard.KeyguardClockSwitch.SMALL;
import static com.android.systemui.classifier.Classifier.QS_COLLAPSE;
import static com.android.systemui.classifier.Classifier.QUICK_SETTINGS;
import static com.android.systemui.statusbar.StatusBarState.KEYGUARD;
@@ -1239,7 +1241,11 @@ public class NotificationPanelViewController extends PanelViewController {
        boolean bypassEnabled = mKeyguardBypassController.getBypassEnabled();
        final boolean hasVisibleNotifications = mNotificationStackScrollLayoutController
                .getVisibleNotificationCount() != 0 || mMediaDataManager.hasActiveMedia();
        mKeyguardStatusViewController.setHasVisibleNotifications(hasVisibleNotifications);
        if (hasVisibleNotifications && !mShouldUseSplitNotificationShade) {
            mKeyguardStatusViewController.displayClock(SMALL);
        } else {
            mKeyguardStatusViewController.displayClock(LARGE);
        }
        int userIconHeight = mKeyguardQsUserSwitchController != null
                ? mKeyguardQsUserSwitchController.getUserIconHeight() : 0;
        float expandedFraction =
+35 −0
Original line number Diff line number Diff line
@@ -19,6 +19,9 @@ package com.android.keyguard;
import static android.view.View.GONE;
import static android.view.View.VISIBLE;

import static com.android.keyguard.KeyguardClockSwitch.LARGE;
import static com.android.keyguard.KeyguardClockSwitch.SMALL;

import static com.google.common.truth.Truth.assertThat;

import static org.mockito.Mockito.mock;
@@ -247,4 +250,36 @@ public class KeyguardClockSwitchTest extends SysuiTestCase {

        verify(plugin).setStyle(style);
    }

    @Test
    public void switchingToBigClock_makesSmallClockDisappear() {
        mKeyguardClockSwitch.switchToClock(LARGE);

        mKeyguardClockSwitch.mClockInAnim.end();
        mKeyguardClockSwitch.mClockOutAnim.end();

        assertThat(mLargeClockFrame.getAlpha()).isEqualTo(1);
        assertThat(mLargeClockFrame.getVisibility()).isEqualTo(VISIBLE);
        assertThat(mClockFrame.getAlpha()).isEqualTo(0);
    }

    @Test
    public void switchingToSmallClock_makesBigClockDisappear() {
        mKeyguardClockSwitch.switchToClock(SMALL);

        mKeyguardClockSwitch.mClockInAnim.end();
        mKeyguardClockSwitch.mClockOutAnim.end();

        assertThat(mClockFrame.getAlpha()).isEqualTo(1);
        assertThat(mClockFrame.getVisibility()).isEqualTo(VISIBLE);
        // only big clock is removed at switch
        assertThat(mLargeClockFrame.getParent()).isNull();
        assertThat(mLargeClockFrame.getAlpha()).isEqualTo(0);
    }

    @Test
    public void switchingToBigClock_returnsTrueOnlyWhenItWasNotVisibleBefore() {
        assertThat(mKeyguardClockSwitch.switchToClock(LARGE)).isTrue();
        assertThat(mKeyguardClockSwitch.switchToClock(LARGE)).isFalse();
    }
}
Loading