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

Commit 1aff4138 authored by Jeff DeCew's avatar Jeff DeCew
Browse files

Merge "Do not show the notification footer until the user is set up." into...

Merge "Do not show the notification footer until the user is set up." into sc-qpr1-dev am: 114f3ee9 am: 96af4baf

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15854211

Change-Id: I160060dfeda7c5c44d2199e5836ed9f15ad52147
parents 9873b6bd 96af4baf
Loading
Loading
Loading
Loading
+12 −0
Original line number Original line Diff line number Diff line
@@ -254,6 +254,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
    private boolean mExpandedInThisMotion;
    private boolean mExpandedInThisMotion;
    private boolean mShouldShowShelfOnly;
    private boolean mShouldShowShelfOnly;
    protected boolean mScrollingEnabled;
    protected boolean mScrollingEnabled;
    private boolean mIsCurrentUserSetup;
    protected FooterView mFooterView;
    protected FooterView mFooterView;
    protected EmptyShadeView mEmptyShadeView;
    protected EmptyShadeView mEmptyShadeView;
    private boolean mDismissAllInProgress;
    private boolean mDismissAllInProgress;
@@ -693,6 +694,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        boolean showDismissView = mClearAllEnabled &&
        boolean showDismissView = mClearAllEnabled &&
                mController.hasActiveClearableNotifications(ROWS_ALL);
                mController.hasActiveClearableNotifications(ROWS_ALL);
        boolean showFooterView = (showDismissView || getVisibleNotificationCount() > 0)
        boolean showFooterView = (showDismissView || getVisibleNotificationCount() > 0)
                && mIsCurrentUserSetup  // see: b/193149550
                && mStatusBarState != StatusBarState.KEYGUARD
                && mStatusBarState != StatusBarState.KEYGUARD
                && !mUnlockedScreenOffAnimationController.isScreenOffAnimationPlaying()
                && !mUnlockedScreenOffAnimationController.isScreenOffAnimationPlaying()
                && !mIsRemoteInputActive;
                && !mIsRemoteInputActive;
@@ -5620,6 +5622,16 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        mAnimateNextTopPaddingChange = true;
        mAnimateNextTopPaddingChange = true;
    }
    }


    /**
     * Sets whether the current user is set up, which is required to show the footer (b/193149550)
     */
    public void setCurrentUserSetup(boolean isCurrentUserSetup) {
        if (mIsCurrentUserSetup != isCurrentUserSetup) {
            mIsCurrentUserSetup = isCurrentUserSetup;
            updateFooter();
        }
    }

    /**
    /**
     * A listener that is notified when the empty space below the notifications is clicked on
     * A listener that is notified when the empty space below the notifications is clicked on
     */
     */
+30 −0
Original line number Original line Diff line number Diff line
@@ -119,6 +119,8 @@ import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.phone.dagger.StatusBarComponent;
import com.android.systemui.statusbar.phone.dagger.StatusBarComponent;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener;
import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
import com.android.systemui.statusbar.policy.DeviceProvisionedController.DeviceProvisionedListener;
import com.android.systemui.statusbar.policy.OnHeadsUpChangedListener;
import com.android.systemui.statusbar.policy.OnHeadsUpChangedListener;
import com.android.systemui.statusbar.policy.ZenModeController;
import com.android.systemui.statusbar.policy.ZenModeController;
import com.android.systemui.tuner.TunerService;
import com.android.systemui.tuner.TunerService;
@@ -146,6 +148,7 @@ public class NotificationStackScrollLayoutController {
    private final HeadsUpManagerPhone mHeadsUpManager;
    private final HeadsUpManagerPhone mHeadsUpManager;
    private final NotificationRoundnessManager mNotificationRoundnessManager;
    private final NotificationRoundnessManager mNotificationRoundnessManager;
    private final TunerService mTunerService;
    private final TunerService mTunerService;
    private final DeviceProvisionedController mDeviceProvisionedController;
    private final DynamicPrivacyController mDynamicPrivacyController;
    private final DynamicPrivacyController mDynamicPrivacyController;
    private final ConfigurationController mConfigurationController;
    private final ConfigurationController mConfigurationController;
    private final ZenModeController mZenModeController;
    private final ZenModeController mZenModeController;
@@ -226,6 +229,28 @@ public class NotificationStackScrollLayoutController {
                }
                }
            };
            };


    private final DeviceProvisionedListener mDeviceProvisionedListener =
            new DeviceProvisionedListener() {
                @Override
                public void onDeviceProvisionedChanged() {
                    updateCurrentUserIsSetup();
                }

                @Override
                public void onUserSwitched() {
                    updateCurrentUserIsSetup();
                }

                @Override
                public void onUserSetupChanged() {
                    updateCurrentUserIsSetup();
                }

                private void updateCurrentUserIsSetup() {
                    mView.setCurrentUserSetup(mDeviceProvisionedController.isCurrentUserSetup());
                }
            };

    private final DynamicPrivacyController.Listener mDynamicPrivacyControllerListener = () -> {
    private final DynamicPrivacyController.Listener mDynamicPrivacyControllerListener = () -> {
        if (mView.isExpanded()) {
        if (mView.isExpanded()) {
            // The bottom might change because we're using the final actual height of the view
            // The bottom might change because we're using the final actual height of the view
@@ -600,6 +625,7 @@ public class NotificationStackScrollLayoutController {
            HeadsUpManagerPhone headsUpManager,
            HeadsUpManagerPhone headsUpManager,
            NotificationRoundnessManager notificationRoundnessManager,
            NotificationRoundnessManager notificationRoundnessManager,
            TunerService tunerService,
            TunerService tunerService,
            DeviceProvisionedController deviceProvisionedController,
            DynamicPrivacyController dynamicPrivacyController,
            DynamicPrivacyController dynamicPrivacyController,
            ConfigurationController configurationController,
            ConfigurationController configurationController,
            SysuiStatusBarStateController statusBarStateController,
            SysuiStatusBarStateController statusBarStateController,
@@ -636,6 +662,7 @@ public class NotificationStackScrollLayoutController {
        mHeadsUpManager = headsUpManager;
        mHeadsUpManager = headsUpManager;
        mNotificationRoundnessManager = notificationRoundnessManager;
        mNotificationRoundnessManager = notificationRoundnessManager;
        mTunerService = tunerService;
        mTunerService = tunerService;
        mDeviceProvisionedController = deviceProvisionedController;
        mDynamicPrivacyController = dynamicPrivacyController;
        mDynamicPrivacyController = dynamicPrivacyController;
        mConfigurationController = configurationController;
        mConfigurationController = configurationController;
        mStatusBarStateController = statusBarStateController;
        mStatusBarStateController = statusBarStateController;
@@ -787,6 +814,9 @@ public class NotificationStackScrollLayoutController {
            return Unit.INSTANCE;
            return Unit.INSTANCE;
        });
        });


        // callback is invoked synchronously, updating mView immediately
        mDeviceProvisionedController.addCallback(mDeviceProvisionedListener);

        if (mView.isAttachedToWindow()) {
        if (mView.isAttachedToWindow()) {
            mOnAttachStateChangeListener.onViewAttachedToWindow(mView);
            mOnAttachStateChangeListener.onViewAttachedToWindow(mView);
        }
        }
+3 −0
Original line number Original line Diff line number Diff line
@@ -75,6 +75,7 @@ import com.android.systemui.statusbar.phone.ScrimController;
import com.android.systemui.statusbar.phone.ShadeController;
import com.android.systemui.statusbar.phone.ShadeController;
import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
import com.android.systemui.statusbar.policy.ZenModeController;
import com.android.systemui.statusbar.policy.ZenModeController;
import com.android.systemui.tuner.TunerService;
import com.android.systemui.tuner.TunerService;


@@ -99,6 +100,7 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
    @Mock private HeadsUpManagerPhone mHeadsUpManager;
    @Mock private HeadsUpManagerPhone mHeadsUpManager;
    @Mock private NotificationRoundnessManager mNotificationRoundnessManager;
    @Mock private NotificationRoundnessManager mNotificationRoundnessManager;
    @Mock private TunerService mTunerService;
    @Mock private TunerService mTunerService;
    @Mock private DeviceProvisionedController mDeviceProvisionedController;
    @Mock private DynamicPrivacyController mDynamicPrivacyController;
    @Mock private DynamicPrivacyController mDynamicPrivacyController;
    @Mock private ConfigurationController mConfigurationController;
    @Mock private ConfigurationController mConfigurationController;
    @Mock private NotificationStackScrollLayout mNotificationStackScrollLayout;
    @Mock private NotificationStackScrollLayout mNotificationStackScrollLayout;
@@ -152,6 +154,7 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
                mHeadsUpManager,
                mHeadsUpManager,
                mNotificationRoundnessManager,
                mNotificationRoundnessManager,
                mTunerService,
                mTunerService,
                mDeviceProvisionedController,
                mDynamicPrivacyController,
                mDynamicPrivacyController,
                mConfigurationController,
                mConfigurationController,
                mSysuiStatusBarStateController,
                mSysuiStatusBarStateController,
+23 −0
Original line number Original line Diff line number Diff line
@@ -280,6 +280,8 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
    @Test
    @Test
    public void testUpdateFooter_noNotifications() {
    public void testUpdateFooter_noNotifications() {
        setBarStateForTest(StatusBarState.SHADE);
        setBarStateForTest(StatusBarState.SHADE);
        mStackScroller.setCurrentUserSetup(true);

        FooterView view = mock(FooterView.class);
        FooterView view = mock(FooterView.class);
        mStackScroller.setFooterView(view);
        mStackScroller.setFooterView(view);
        mStackScroller.updateFooter();
        mStackScroller.updateFooter();
@@ -289,6 +291,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
    @Test
    @Test
    public void testUpdateFooter_remoteInput() {
    public void testUpdateFooter_remoteInput() {
        setBarStateForTest(StatusBarState.SHADE);
        setBarStateForTest(StatusBarState.SHADE);
        mStackScroller.setCurrentUserSetup(true);


        ExpandableNotificationRow row = mock(ExpandableNotificationRow.class);
        ExpandableNotificationRow row = mock(ExpandableNotificationRow.class);
        when(row.canViewBeDismissed()).thenReturn(true);
        when(row.canViewBeDismissed()).thenReturn(true);
@@ -308,6 +311,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
    @Test
    @Test
    public void testUpdateFooter_oneClearableNotification() {
    public void testUpdateFooter_oneClearableNotification() {
        setBarStateForTest(StatusBarState.SHADE);
        setBarStateForTest(StatusBarState.SHADE);
        mStackScroller.setCurrentUserSetup(true);


        when(mEmptyShadeView.getVisibility()).thenReturn(GONE);
        when(mEmptyShadeView.getVisibility()).thenReturn(GONE);
        when(mStackScrollLayoutController.hasActiveClearableNotifications(ROWS_ALL))
        when(mStackScrollLayoutController.hasActiveClearableNotifications(ROWS_ALL))
@@ -320,9 +324,26 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
        verify(mStackScroller).updateFooterView(true, true, true);
        verify(mStackScroller).updateFooterView(true, true, true);
    }
    }


    @Test
    public void testUpdateFooter_oneClearableNotification_beforeUserSetup() {
        setBarStateForTest(StatusBarState.SHADE);
        mStackScroller.setCurrentUserSetup(false);

        when(mEmptyShadeView.getVisibility()).thenReturn(GONE);
        when(mStackScrollLayoutController.hasActiveClearableNotifications(ROWS_ALL))
                .thenReturn(true);
        when(mStackScrollLayoutController.hasActiveNotifications()).thenReturn(true);

        FooterView view = mock(FooterView.class);
        mStackScroller.setFooterView(view);
        mStackScroller.updateFooter();
        verify(mStackScroller).updateFooterView(false, true, true);
    }

    @Test
    @Test
    public void testUpdateFooter_oneNonClearableNotification() {
    public void testUpdateFooter_oneNonClearableNotification() {
        setBarStateForTest(StatusBarState.SHADE);
        setBarStateForTest(StatusBarState.SHADE);
        mStackScroller.setCurrentUserSetup(true);


        ExpandableNotificationRow row = mock(ExpandableNotificationRow.class);
        ExpandableNotificationRow row = mock(ExpandableNotificationRow.class);
        when(row.canViewBeDismissed()).thenReturn(false);
        when(row.canViewBeDismissed()).thenReturn(false);
@@ -341,6 +362,8 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {


    @Test
    @Test
    public void testUpdateFooter_atEnd() {
    public void testUpdateFooter_atEnd() {
        mStackScroller.setCurrentUserSetup(true);

        // add footer
        // add footer
        mStackScroller.inflateFooterView();
        mStackScroller.inflateFooterView();