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.FrameLayout;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
|
|
||||||
|
import androidx.annotation.IntDef;
|
||||||
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
|
||||||
import com.android.internal.colorextraction.ColorExtractor;
|
import com.android.internal.colorextraction.ColorExtractor;
|
||||||
import com.android.keyguard.dagger.KeyguardStatusViewScope;
|
import com.android.keyguard.dagger.KeyguardStatusViewScope;
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
@@ -22,6 +25,8 @@ import com.android.systemui.plugins.ClockPlugin;
|
|||||||
|
|
||||||
import java.io.FileDescriptor;
|
import java.io.FileDescriptor;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.TimeZone;
|
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 CLOCK_IN_MILLIS = 200;
|
||||||
private static final long SMARTSPACE_MOVE_MILLIS = 350;
|
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.
|
* Optional/alternative clock injected via plugin.
|
||||||
*/
|
*/
|
||||||
@@ -64,13 +76,13 @@ public class KeyguardClockSwitch extends RelativeLayout {
|
|||||||
private float mDarkAmount;
|
private float mDarkAmount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Boolean value indicating if notifications are visible on lock screen. Use null to signify
|
* Indicates which clock is currently displayed - should be one of {@link ClockSize}.
|
||||||
* it is uninitialized.
|
* Use null to signify it is uninitialized.
|
||||||
*/
|
*/
|
||||||
private Boolean mHasVisibleNotifications = null;
|
@ClockSize private Integer mDisplayedClockSize = null;
|
||||||
|
|
||||||
private AnimatorSet mClockInAnim = null;
|
@VisibleForTesting AnimatorSet mClockInAnim = null;
|
||||||
private AnimatorSet mClockOutAnim = null;
|
@VisibleForTesting AnimatorSet mClockOutAnim = null;
|
||||||
private ObjectAnimator mSmartspaceAnim = 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
|
* Display the desired clock and hide the other one
|
||||||
* the smaller version.
|
*
|
||||||
|
* @return true if desired clock appeared and false if it was already visible
|
||||||
*/
|
*/
|
||||||
boolean willSwitchToLargeClock(boolean hasVisibleNotifications) {
|
boolean switchToClock(@ClockSize int clockSize) {
|
||||||
if (mHasVisibleNotifications != null
|
if (mDisplayedClockSize != null && clockSize == mDisplayedClockSize) {
|
||||||
&& hasVisibleNotifications == mHasVisibleNotifications) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
boolean useLargeClock = !hasVisibleNotifications;
|
animateClockChange(clockSize == LARGE);
|
||||||
animateClockChange(useLargeClock);
|
mDisplayedClockSize = clockSize;
|
||||||
|
return true;
|
||||||
mHasVisibleNotifications = hasVisibleNotifications;
|
|
||||||
return useLargeClock;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Paint getPaint() {
|
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.MATCH_PARENT;
|
||||||
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
|
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||||
|
|
||||||
|
import static com.android.keyguard.KeyguardClockSwitch.LARGE;
|
||||||
|
|
||||||
import android.app.WallpaperManager;
|
import android.app.WallpaperManager;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.text.TextUtils;
|
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) {
|
public void displayClock(@KeyguardClockSwitch.ClockSize int clockSize) {
|
||||||
if (mView.willSwitchToLargeClock(hasVisibleNotifications)) {
|
boolean appeared = mView.switchToClock(clockSize);
|
||||||
|
if (appeared && clockSize == LARGE) {
|
||||||
mLargeClockViewController.animateAppear();
|
mLargeClockViewController.animateAppear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package com.android.keyguard;
|
|||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
|
|
||||||
|
import com.android.keyguard.KeyguardClockSwitch.ClockSize;
|
||||||
import com.android.systemui.keyguard.KeyguardUnlockAnimationController;
|
import com.android.systemui.keyguard.KeyguardUnlockAnimationController;
|
||||||
import com.android.systemui.shared.system.smartspace.SmartspaceTransitionController;
|
import com.android.systemui.shared.system.smartspace.SmartspaceTransitionController;
|
||||||
import com.android.systemui.statusbar.notification.AnimatableProperty;
|
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) {
|
public void displayClock(@ClockSize int clockSize) {
|
||||||
mKeyguardClockSwitchController.setHasVisibleNotifications(hasVisibleNotifications);
|
mKeyguardClockSwitchController.displayClock(clockSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ import static androidx.constraintlayout.widget.ConstraintSet.PARENT_ID;
|
|||||||
import static androidx.constraintlayout.widget.ConstraintSet.START;
|
import static androidx.constraintlayout.widget.ConstraintSet.START;
|
||||||
|
|
||||||
import static com.android.internal.jank.InteractionJankMonitor.CUJ_NOTIFICATION_SHADE_QS_EXPAND_COLLAPSE;
|
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.QS_COLLAPSE;
|
||||||
import static com.android.systemui.classifier.Classifier.QUICK_SETTINGS;
|
import static com.android.systemui.classifier.Classifier.QUICK_SETTINGS;
|
||||||
import static com.android.systemui.statusbar.StatusBarState.KEYGUARD;
|
import static com.android.systemui.statusbar.StatusBarState.KEYGUARD;
|
||||||
@@ -1241,7 +1243,11 @@ public class NotificationPanelViewController extends PanelViewController {
|
|||||||
boolean bypassEnabled = mKeyguardBypassController.getBypassEnabled();
|
boolean bypassEnabled = mKeyguardBypassController.getBypassEnabled();
|
||||||
final boolean hasVisibleNotifications = mNotificationStackScrollLayoutController
|
final boolean hasVisibleNotifications = mNotificationStackScrollLayoutController
|
||||||
.getVisibleNotificationCount() != 0 || mMediaDataManager.hasActiveMedia();
|
.getVisibleNotificationCount() != 0 || mMediaDataManager.hasActiveMedia();
|
||||||
mKeyguardStatusViewController.setHasVisibleNotifications(hasVisibleNotifications);
|
if (hasVisibleNotifications && !mShouldUseSplitNotificationShade) {
|
||||||
|
mKeyguardStatusViewController.displayClock(SMALL);
|
||||||
|
} else {
|
||||||
|
mKeyguardStatusViewController.displayClock(LARGE);
|
||||||
|
}
|
||||||
int userIconHeight = mKeyguardQsUserSwitchController != null
|
int userIconHeight = mKeyguardQsUserSwitchController != null
|
||||||
? mKeyguardQsUserSwitchController.getUserIconHeight() : 0;
|
? mKeyguardQsUserSwitchController.getUserIconHeight() : 0;
|
||||||
float expandedFraction =
|
float expandedFraction =
|
||||||
|
|||||||
@@ -19,6 +19,9 @@ package com.android.keyguard;
|
|||||||
import static android.view.View.GONE;
|
import static android.view.View.GONE;
|
||||||
import static android.view.View.VISIBLE;
|
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 com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
@@ -247,4 +250,36 @@ public class KeyguardClockSwitchTest extends SysuiTestCase {
|
|||||||
|
|
||||||
verify(plugin).setStyle(style);
|
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 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.KEYGUARD;
|
||||||
import static com.android.systemui.statusbar.StatusBarState.SHADE;
|
import static com.android.systemui.statusbar.StatusBarState.SHADE;
|
||||||
import static com.android.systemui.statusbar.StatusBarState.SHADE_LOCKED;
|
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.doAnswer;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
@@ -686,6 +689,38 @@ public class NotificationPanelViewTest extends SysuiTestCase {
|
|||||||
.setNotificationScrimTop(NOTIFICATION_SCRIM_TOP_PADDING_IN_SPLIT_SHADE);
|
.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() {
|
private FalsingManager.FalsingTapListener getFalsingTapListener() {
|
||||||
for (View.OnAttachStateChangeListener listener : mOnAttachStateChangeListeners) {
|
for (View.OnAttachStateChangeListener listener : mOnAttachStateChangeListeners) {
|
||||||
listener.onViewAttachedToWindow(mView);
|
listener.onViewAttachedToWindow(mView);
|
||||||
|
|||||||
Reference in New Issue
Block a user