diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml b/packages/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml index f22c729744d34..3714db324fb47 100644 --- a/packages/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml +++ b/packages/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml @@ -67,6 +67,7 @@ android:layout_height="wrap_content" android:layout_alignParentEnd="true" android:layout_alignParentTop="true" + android:layout_marginBottom="24dp" android:visibility="gone"> + + diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java index ed0317c11f71d..628193dc305db 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java @@ -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 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) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconContainer.java index bf858520c3380..9561851ab28be 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconContainer.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconContainer.java @@ -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 { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java index 47b16c8eaaa5c..b185f48b02458 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java @@ -441,7 +441,6 @@ public class NotificationPanelViewController extends PanelViewController { private KeyguardIndicationController mKeyguardIndicationController; private Consumer 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); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java index c7932bb44cf44..9bd98f2e8c245 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -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() { diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java index 094230db9d8c2..4559113bcf544 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java @@ -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); diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardStatusViewControllerTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardStatusViewControllerTest.java index 752a744826a16..4cfbe69f175f0 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardStatusViewControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardStatusViewControllerTest.java @@ -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 diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationIconAreaControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationIconAreaControllerTest.java index ede5fceb4ebdc..a1d419cfb6c7e 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationIconAreaControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationIconAreaControllerTest.java @@ -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);