Merge "Uncenter aod icons for new lockscreen"

This commit is contained in:
TreeHugger Robot
2020-10-23 20:27:57 +00:00
committed by Android (Google) Code Review
10 changed files with 123 additions and 40 deletions

View File

@@ -67,6 +67,7 @@
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="24dp"
android:visibility="gone">
<com.android.keyguard.GradientTextClock
android:id="@+id/gradient_clock_view"
@@ -88,4 +89,15 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/clock_view" />
<com.android.systemui.statusbar.phone.NotificationIconContainer
android:id="@+id/left_aligned_notification_icon_container"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:layout_width="match_parent"
android:layout_height="@dimen/notification_shelf_height"
android:layout_marginTop="@dimen/widget_vertical_padding"
android:layout_below="@id/keyguard_status_area"
android:visibility="gone"
/>
</com.android.keyguard.KeyguardClockSwitch>

View File

@@ -20,6 +20,7 @@ import android.app.WallpaperManager;
import android.content.res.Resources;
import android.text.format.DateFormat;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
import com.android.internal.colorextraction.ColorExtractor;
@@ -29,6 +30,8 @@ import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.plugins.ClockPlugin;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.phone.NotificationIconAreaController;
import com.android.systemui.statusbar.phone.NotificationIconContainer;
import com.android.systemui.util.ViewController;
import java.util.Locale;
@@ -47,6 +50,9 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
private final SysuiColorExtractor mColorExtractor;
private final ClockManager mClockManager;
private final KeyguardSliceViewController mKeyguardSliceViewController;
private final NotificationIconAreaController mNotificationIconAreaController;
private int mLockScreenMode = KeyguardUpdateMonitor.LOCK_SCREEN_MODE_NORMAL;
private final StatusBarStateController.StateListener mStateListener =
new StatusBarStateController.StateListener() {
@@ -79,13 +85,15 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
@Main Resources resources,
StatusBarStateController statusBarStateController,
SysuiColorExtractor colorExtractor, ClockManager clockManager,
KeyguardSliceViewController keyguardSliceViewController) {
KeyguardSliceViewController keyguardSliceViewController,
NotificationIconAreaController notificationIconAreaController) {
super(keyguardClockSwitch);
mResources = resources;
mStatusBarStateController = statusBarStateController;
mColorExtractor = colorExtractor;
mClockManager = clockManager;
mKeyguardSliceViewController = keyguardSliceViewController;
mNotificationIconAreaController = notificationIconAreaController;
}
/**
@@ -105,6 +113,7 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
mStatusBarStateController.addCallback(mStateListener);
mColorExtractor.addOnColorsChangedListener(mColorsListener);
mView.updateColors(getGradientColors());
updateAodIcons();
}
@Override
@@ -174,7 +183,9 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
* Update lockscreen mode that may change clock display.
*/
void updateLockScreenMode(int mode) {
mView.updateLockScreenMode(mode);
mLockScreenMode = mode;
mView.updateLockScreenMode(mLockScreenMode);
updateAodIcons();
}
void updateTimeZone(TimeZone timeZone) {
@@ -187,6 +198,19 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
mView.setFormat24Hour(Patterns.sClockView24);
}
private void updateAodIcons() {
NotificationIconContainer nic = (NotificationIconContainer)
mView.findViewById(
com.android.systemui.R.id.left_aligned_notification_icon_container);
if (mLockScreenMode == KeyguardUpdateMonitor.LOCK_SCREEN_MODE_LAYOUT_1) {
// alt icon area is set in KeyguardClockSwitchController
mNotificationIconAreaController.setupAodIcons(nic, mLockScreenMode);
} else {
nic.setVisibility(View.GONE);
}
}
private void setClockPlugin(ClockPlugin plugin) {
mView.setClockPlugin(plugin, mStatusBarStateController.getState());
}

View File

@@ -27,6 +27,8 @@ import com.android.systemui.statusbar.notification.AnimatableProperty;
import com.android.systemui.statusbar.notification.PropertyAnimator;
import com.android.systemui.statusbar.notification.stack.AnimationProperties;
import com.android.systemui.statusbar.notification.stack.StackStateAnimator;
import com.android.systemui.statusbar.phone.NotificationIconAreaController;
import com.android.systemui.statusbar.phone.NotificationIconContainer;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.util.ViewController;
@@ -50,8 +52,10 @@ public class KeyguardStatusViewController extends ViewController<KeyguardStatusV
private final KeyguardStateController mKeyguardStateController;
private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
private final ConfigurationController mConfigurationController;
private final NotificationIconAreaController mNotificationIconAreaController;
private boolean mKeyguardStatusViewAnimating;
private int mLockScreenMode = KeyguardUpdateMonitor.LOCK_SCREEN_MODE_NORMAL;
@Inject
public KeyguardStatusViewController(
@@ -60,13 +64,15 @@ public class KeyguardStatusViewController extends ViewController<KeyguardStatusV
KeyguardClockSwitchController keyguardClockSwitchController,
KeyguardStateController keyguardStateController,
KeyguardUpdateMonitor keyguardUpdateMonitor,
ConfigurationController configurationController) {
ConfigurationController configurationController,
NotificationIconAreaController notificationIconAreaController) {
super(keyguardStatusView);
mKeyguardSliceViewController = keyguardSliceViewController;
mKeyguardClockSwitchController = keyguardClockSwitchController;
mKeyguardStateController = keyguardStateController;
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
mConfigurationController = configurationController;
mNotificationIconAreaController = notificationIconAreaController;
}
@Override
@@ -78,6 +84,7 @@ public class KeyguardStatusViewController extends ViewController<KeyguardStatusV
protected void onViewAttached() {
mKeyguardUpdateMonitor.registerCallback(mInfoCallback);
mConfigurationController.addCallback(mConfigurationListener);
updateAodIcons();
}
@Override
@@ -248,6 +255,17 @@ public class KeyguardStatusViewController extends ViewController<KeyguardStatusV
mKeyguardClockSwitchController.refresh();
}
private void updateAodIcons() {
NotificationIconContainer nic = (NotificationIconContainer)
mView.findViewById(com.android.systemui.R.id.clock_notification_icon_container);
if (mLockScreenMode == KeyguardUpdateMonitor.LOCK_SCREEN_MODE_NORMAL) {
// alternate icon area is set in KeyguardClockSwitchController
mNotificationIconAreaController.setupAodIcons(nic, mLockScreenMode);
} else {
nic.setVisibility(View.GONE);
}
}
private final ConfigurationController.ConfigurationListener mConfigurationListener =
new ConfigurationController.ConfigurationListener() {
@Override
@@ -265,8 +283,10 @@ public class KeyguardStatusViewController extends ViewController<KeyguardStatusV
private KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() {
@Override
public void onLockScreenModeChanged(int mode) {
mLockScreenMode = mode;
mKeyguardClockSwitchController.updateLockScreenMode(mode);
mKeyguardSliceViewController.updateLockScreenMode(mode);
updateAodIcons();
}
@Override

View File

@@ -91,9 +91,7 @@ public class NotificationIconAreaController implements
private boolean mAnimationsEnabled;
private int mAodIconTint;
private boolean mFullyHidden;
private boolean mAodIconsVisible;
private boolean mIsPulsing;
private boolean mShowLowPriority = true;
@VisibleForTesting
@@ -158,22 +156,23 @@ public class NotificationIconAreaController implements
}
/**
* Called by the StatusBar. The StatusBar passes the NotificationIconContainer which holds
* the aod icons.
* Called by the Keyguard*ViewController whose view contains the aod icons.
*/
void setupAodIcons(@NonNull NotificationIconContainer aodIcons) {
public void setupAodIcons(@NonNull NotificationIconContainer aodIcons,
int lockScreenMode) {
boolean changed = mAodIcons != null;
if (changed) {
mAodIcons.setAnimationsEnabled(false);
mAodIcons.removeAllViews();
}
mAodIcons = aodIcons;
mAodIcons.setOnLockScreen(true);
mAodIcons.setOnLockScreen(true, lockScreenMode);
updateAodIconsVisibility(false /* animate */);
updateAnimations();
if (changed) {
updateAodNotificationIcons();
}
updateIconLayoutParams(mContext);
}
public void setupShelf(NotificationShelfController notificationShelfController) {
@@ -182,23 +181,31 @@ public class NotificationIconAreaController implements
}
public void onDensityOrFontScaleChanged(Context context) {
updateIconLayoutParams(context);
}
private void updateIconLayoutParams(Context context) {
reloadDimens(context);
final FrameLayout.LayoutParams params = generateIconLayoutParams();
for (int i = 0; i < mNotificationIcons.getChildCount(); i++) {
View child = mNotificationIcons.getChildAt(i);
child.setLayoutParams(params);
}
for (int i = 0; i < mShelfIcons.getChildCount(); i++) {
View child = mShelfIcons.getChildAt(i);
child.setLayoutParams(params);
}
for (int i = 0; i < mCenteredIcon.getChildCount(); i++) {
View child = mCenteredIcon.getChildAt(i);
child.setLayoutParams(params);
}
for (int i = 0; i < mAodIcons.getChildCount(); i++) {
View child = mAodIcons.getChildAt(i);
child.setLayoutParams(params);
if (mShelfIcons != null) {
for (int i = 0; i < mShelfIcons.getChildCount(); i++) {
View child = mShelfIcons.getChildAt(i);
child.setLayoutParams(params);
}
}
if (mAodIcons != null) {
for (int i = 0; i < mAodIcons.getChildCount(); i++) {
View child = mAodIcons.getChildAt(i);
child.setLayoutParams(params);
}
}
}
@@ -358,6 +365,9 @@ public class NotificationIconAreaController implements
}
public void updateAodNotificationIcons() {
if (mAodIcons == null) {
return;
}
updateIconsForLayout(entry -> entry.getIcons().getAodIcon(), mAodIcons,
false /* showAmbient */,
true /* showLowPriority */,
@@ -546,6 +556,9 @@ public class NotificationIconAreaController implements
@Override
public void onDozingChanged(boolean isDozing) {
if (mAodIcons == null) {
return;
}
boolean animate = mDozeParameters.getAlwaysOn()
&& !mDozeParameters.getDisplayNeedsBlanking();
mAodIcons.setDozing(isDozing, animate, 0);
@@ -564,7 +577,9 @@ public class NotificationIconAreaController implements
private void updateAnimations() {
boolean inShade = mStatusBarStateController.getState() == StatusBarState.SHADE;
mAodIcons.setAnimationsEnabled(mAnimationsEnabled && !inShade);
if (mAodIcons != null) {
mAodIcons.setAnimationsEnabled(mAnimationsEnabled && !inShade);
}
mCenteredIcon.setAnimationsEnabled(mAnimationsEnabled && inShade);
mNotificationIcons.setAnimationsEnabled(mAnimationsEnabled && inShade);
}
@@ -575,6 +590,9 @@ public class NotificationIconAreaController implements
}
public void appearAodIcons() {
if (mAodIcons == null) {
return;
}
if (mDozeParameters.shouldControlScreenOff()) {
mAodIcons.setTranslationY(-mAodIconAppearTranslation);
mAodIcons.setAlpha(0);
@@ -637,6 +655,9 @@ public class NotificationIconAreaController implements
}
private void updateAodIconsVisibility(boolean animate) {
if (mAodIcons == null) {
return;
}
boolean visible = mBypassController.getBypassEnabled()
|| mWakeUpCoordinator.getNotificationsFullyHidden();
if (mStatusBarStateController.getState() != StatusBarState.KEYGUARD) {

View File

@@ -34,6 +34,7 @@ import android.view.animation.Interpolator;
import androidx.collection.ArrayMap;
import com.android.internal.statusbar.StatusBarIcon;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.systemui.Interpolators;
import com.android.systemui.R;
import com.android.systemui.statusbar.AlphaOptimizedFrameLayout;
@@ -148,6 +149,7 @@ public class NotificationIconContainer extends AlphaOptimizedFrameLayout {
private float mActualPaddingStart = NO_VALUE;
private boolean mDozing;
private boolean mOnLockScreen;
private int mLockScreenMode = KeyguardUpdateMonitor.LOCK_SCREEN_MODE_NORMAL;
private boolean mChangingViewPositions;
private int mAddAnimationStartIndex = -1;
private int mCannedAnimationStartIndex = -1;
@@ -453,7 +455,8 @@ public class NotificationIconContainer extends AlphaOptimizedFrameLayout {
mFirstVisibleIconState = mIconStates.get(getChildAt(0));
}
boolean center = mOnLockScreen;
boolean center = mOnLockScreen
&& mLockScreenMode == KeyguardUpdateMonitor.LOCK_SCREEN_MODE_NORMAL;
if (center && translationX < getLayoutEnd()) {
float initialTranslation =
mFirstVisibleIconState == null ? 0 : mFirstVisibleIconState.xTranslation;
@@ -686,8 +689,13 @@ public class NotificationIconContainer extends AlphaOptimizedFrameLayout {
}
}
public void setOnLockScreen(boolean onLockScreen) {
/**
* Set whether the device is on the lockscreen and which lockscreen mode the device is
* configured to. Depending on these values, the layout of the AOD icons change.
*/
public void setOnLockScreen(boolean onLockScreen, int lockScreenMode) {
mOnLockScreen = onLockScreen;
mLockScreenMode = lockScreenMode;
}
public class IconState extends ViewState {

View File

@@ -441,7 +441,6 @@ public class NotificationPanelViewController extends PanelViewController {
private KeyguardIndicationController mKeyguardIndicationController;
private Consumer<Boolean> mAffordanceLaunchListener;
private int mShelfHeight;
private Runnable mOnReinflationListener;
private int mDarkIconSize;
private int mHeadsUpInset;
private boolean mHeadsUpPinnedMode;
@@ -767,9 +766,6 @@ public class NotificationPanelViewController extends PanelViewController {
false,
mBarState);
setKeyguardBottomAreaVisibility(mBarState, false);
if (mOnReinflationListener != null) {
mOnReinflationListener.run();
}
}
private void initBottomArea() {
@@ -3102,10 +3098,6 @@ public class NotificationPanelViewController extends PanelViewController {
mKeyguardIndicationController.showTransientIndication(id);
}
public void setOnReinflationListener(Runnable onReinflationListener) {
mOnReinflationListener = onReinflationListener;
}
public void setAlpha(float alpha) {
mView.setAlpha(alpha);
}

View File

@@ -1035,10 +1035,8 @@ public class StatusBar extends SystemUI implements DemoMode,
mStackScrollerController.getNotificationListContainer();
mNotificationLogger.setUpWithContainer(notifListContainer);
updateAodIconArea();
inflateShelf();
mNotificationIconAreaController.setupShelf(mNotificationShelfController);
mNotificationPanelViewController.setOnReinflationListener(this::updateAodIconArea);
mNotificationPanelViewController.addExpansionListener(mWakeUpCoordinator);
// Allow plugins to reference DarkIconDispatcher and StatusBarStateController
@@ -1270,12 +1268,6 @@ public class StatusBar extends SystemUI implements DemoMode,
ThreadedRenderer.overrideProperty("ambientRatio", String.valueOf(1.5f));
}
private void updateAodIconArea() {
mNotificationIconAreaController.setupAodIcons(
getNotificationShadeWindowView()
.findViewById(R.id.clock_notification_icon_container));
}
@NonNull
@Override
public Lifecycle getLifecycle() {

View File

@@ -16,7 +16,6 @@
package com.android.keyguard;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.never;
@@ -38,6 +37,8 @@ import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.plugins.ClockPlugin;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.phone.NotificationIconAreaController;
import com.android.systemui.statusbar.phone.NotificationIconContainer;
import org.junit.Before;
import org.junit.Test;
@@ -60,6 +61,8 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase {
@Mock
private KeyguardClockSwitch mView;
@Mock
private NotificationIconContainer mNotificationIcons;
@Mock
private ClockPlugin mClockPlugin;
@Mock
ColorExtractor.GradientColors mGradientColors;
@@ -67,6 +70,8 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase {
KeyguardSliceViewController mKeyguardSliceViewController;
@Mock
Resources mResources;
@Mock
NotificationIconAreaController mNotificationIconAreaController;
private KeyguardClockSwitchController mController;
@@ -74,6 +79,8 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase {
public void setup() {
MockitoAnnotations.initMocks(this);
when(mView.findViewById(com.android.systemui.R.id.left_aligned_notification_icon_container))
.thenReturn(mNotificationIcons);
when(mView.isAttachedToWindow()).thenReturn(true);
when(mResources.getString(anyInt())).thenReturn("h:mm");
mController = new KeyguardClockSwitchController(
@@ -82,7 +89,8 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase {
mStatusBarStateController,
mColorExtractor,
mClockManager,
mKeyguardSliceViewController);
mKeyguardSliceViewController,
mNotificationIconAreaController);
when(mStatusBarStateController.getState()).thenReturn(StatusBarState.SHADE);
when(mColorExtractor.getColors(anyInt())).thenReturn(mGradientColors);

View File

@@ -22,6 +22,7 @@ import android.test.suitebuilder.annotation.SmallTest;
import android.testing.AndroidTestingRunner;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.statusbar.phone.NotificationIconAreaController;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.KeyguardStateController;
@@ -47,6 +48,8 @@ public class KeyguardStatusViewControllerTest extends SysuiTestCase {
private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
@Mock
ConfigurationController mConfigurationController;
@Mock
NotificationIconAreaController mNotificationIconAreaController;
private KeyguardStatusViewController mController;
@@ -60,7 +63,8 @@ public class KeyguardStatusViewControllerTest extends SysuiTestCase {
mKeyguardClockSwitchController,
mKeyguardStateController,
mKeyguardUpdateMonitor,
mConfigurationController);
mConfigurationController,
mNotificationIconAreaController);
}
@Test

View File

@@ -25,6 +25,7 @@ import android.testing.TestableLooper;
import androidx.test.filters.SmallTest;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.bubbles.Bubbles;
import com.android.systemui.demomode.DemoModeController;
@@ -76,7 +77,6 @@ public class NotificationIconAreaControllerTest extends SysuiTestCase {
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
mController = new NotificationIconAreaController(
mContext,
mStatusBarStateController,
@@ -89,7 +89,6 @@ public class NotificationIconAreaControllerTest extends SysuiTestCase {
mDemoModeController,
mDarkIconDispatcher,
mStatusBarWindowController);
mController.setupAodIcons(mAodIcons);
}
@Test
@@ -108,6 +107,9 @@ public class NotificationIconAreaControllerTest extends SysuiTestCase {
@Test
public void testAppearResetsTranslation() {
mController.setupAodIcons(
mAodIcons,
KeyguardUpdateMonitor.LOCK_SCREEN_MODE_NORMAL);
when(mDozeParameters.shouldControlScreenOff()).thenReturn(false);
mController.appearAodIcons();
verify(mAodIcons).setTranslationY(0);