Merge "Always showing big clock on the lockscreen in split shade" into sc-v2-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
231abe1398
@@ -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() {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
@@ -1241,7 +1243,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 =
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ package com.android.systemui.statusbar.phone;
|
||||
|
||||
import static android.content.res.Configuration.ORIENTATION_PORTRAIT;
|
||||
|
||||
import static com.android.keyguard.KeyguardClockSwitch.LARGE;
|
||||
import static com.android.keyguard.KeyguardClockSwitch.SMALL;
|
||||
import static com.android.systemui.statusbar.StatusBarState.KEYGUARD;
|
||||
import static com.android.systemui.statusbar.StatusBarState.SHADE;
|
||||
import static com.android.systemui.statusbar.StatusBarState.SHADE_LOCKED;
|
||||
@@ -32,6 +34,7 @@ import static org.mockito.Mockito.atLeast;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@@ -686,6 +689,38 @@ public class NotificationPanelViewTest extends SysuiTestCase {
|
||||
.setNotificationScrimTop(NOTIFICATION_SCRIM_TOP_PADDING_IN_SPLIT_SHADE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSwitchesToCorrectClockInSinglePaneShade() {
|
||||
mStatusBarStateController.setState(KEYGUARD);
|
||||
|
||||
when(mNotificationStackScrollLayoutController.getVisibleNotificationCount()).thenReturn(0);
|
||||
triggerPositionClockAndNotifications();
|
||||
verify(mKeyguardStatusViewController).displayClock(LARGE);
|
||||
|
||||
when(mNotificationStackScrollLayoutController.getVisibleNotificationCount()).thenReturn(1);
|
||||
mNotificationPanelViewController.closeQs();
|
||||
verify(mKeyguardStatusViewController).displayClock(SMALL);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSwitchesToCorrectClockInSplitShade() {
|
||||
mStatusBarStateController.setState(KEYGUARD);
|
||||
enableSplitShade();
|
||||
|
||||
when(mNotificationStackScrollLayoutController.getVisibleNotificationCount()).thenReturn(0);
|
||||
triggerPositionClockAndNotifications();
|
||||
verify(mKeyguardStatusViewController).displayClock(LARGE);
|
||||
|
||||
when(mNotificationStackScrollLayoutController.getVisibleNotificationCount()).thenReturn(1);
|
||||
triggerPositionClockAndNotifications();
|
||||
verify(mKeyguardStatusViewController, times(2)).displayClock(LARGE);
|
||||
verify(mKeyguardStatusViewController, never()).displayClock(SMALL);
|
||||
}
|
||||
|
||||
private void triggerPositionClockAndNotifications() {
|
||||
mNotificationPanelViewController.closeQs();
|
||||
}
|
||||
|
||||
private FalsingManager.FalsingTapListener getFalsingTapListener() {
|
||||
for (View.OnAttachStateChangeListener listener : mOnAttachStateChangeListeners) {
|
||||
listener.onViewAttachedToWindow(mView);
|
||||
|
||||
Reference in New Issue
Block a user