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

Commit 65289e6c authored by Steve Elliott's avatar Steve Elliott Committed by Android (Google) Code Review
Browse files

Merge "Move KeyguardBypassController from RoundnessManager to NSSLCtrlr"

parents ba6dd78b c0f5aea4
Loading
Loading
Loading
Loading
+14 −14
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.statusbar.notification.NotificationSectionsFeatureManager;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.ExpandableView;
import com.android.systemui.statusbar.phone.KeyguardBypassController;

import java.util.HashSet;

@@ -40,27 +39,24 @@ public class NotificationRoundnessManager {
    private final ExpandableView[] mLastInSectionViews;
    private final ExpandableView[] mTmpFirstInSectionViews;
    private final ExpandableView[] mTmpLastInSectionViews;
    private final KeyguardBypassController mBypassController;
    private boolean mExpanded;
    private HashSet<ExpandableView> mAnimatedChildren;
    private Runnable mRoundingChangedCallback;
    private ExpandableNotificationRow mTrackedHeadsUp;
    private float mAppearFraction;
    private boolean mRoundForPulsingViews;

    private ExpandableView mSwipedView = null;
    private ExpandableView mViewBeforeSwipedView = null;
    private ExpandableView mViewAfterSwipedView = null;

    @Inject
    NotificationRoundnessManager(
            KeyguardBypassController keyguardBypassController,
            NotificationSectionsFeatureManager sectionsFeatureManager) {
    NotificationRoundnessManager(NotificationSectionsFeatureManager sectionsFeatureManager) {
        int numberOfSections = sectionsFeatureManager.getNumberOfBuckets();
        mFirstInSectionViews = new ExpandableView[numberOfSections];
        mLastInSectionViews = new ExpandableView[numberOfSections];
        mTmpFirstInSectionViews = new ExpandableView[numberOfSections];
        mTmpLastInSectionViews = new ExpandableView[numberOfSections];
        mBypassController = keyguardBypassController;
    }

    public void updateView(ExpandableView view, boolean animate) {
@@ -85,8 +81,8 @@ public class NotificationRoundnessManager {
            return false;
        }

        final float topRoundness = getRoundness(view, true /* top */);
        final float bottomRoundness = getRoundness(view, false /* top */);
        final float topRoundness = getRoundnessFraction(view, true /* top */);
        final float bottomRoundness = getRoundnessFraction(view, false /* top */);

        final boolean topChanged = view.setTopRoundness(topRoundness, animate);
        final boolean bottomChanged = view.setBottomRoundness(bottomRoundness, animate);
@@ -131,7 +127,7 @@ public class NotificationRoundnessManager {
        ExpandableView oldViewBefore = mViewBeforeSwipedView;
        mViewBeforeSwipedView = viewBefore;
        if (oldViewBefore != null) {
            final float bottomRoundness = getRoundness(oldViewBefore, false /* top */);
            final float bottomRoundness = getRoundnessFraction(oldViewBefore, false /* top */);
            oldViewBefore.setBottomRoundness(bottomRoundness,  animate);
        }
        if (viewBefore != null) {
@@ -141,8 +137,8 @@ public class NotificationRoundnessManager {
        ExpandableView oldSwipedview = mSwipedView;
        mSwipedView = viewSwiped;
        if (oldSwipedview != null) {
            final float bottomRoundness = getRoundness(oldSwipedview, false /* top */);
            final float topRoundness = getRoundness(oldSwipedview, true /* top */);
            final float bottomRoundness = getRoundnessFraction(oldSwipedview, false /* top */);
            final float topRoundness = getRoundnessFraction(oldSwipedview, true /* top */);
            oldSwipedview.setTopRoundness(topRoundness, animate);
            oldSwipedview.setBottomRoundness(bottomRoundness, animate);
        }
@@ -154,7 +150,7 @@ public class NotificationRoundnessManager {
        ExpandableView oldViewAfter = mViewAfterSwipedView;
        mViewAfterSwipedView = viewAfter;
        if (oldViewAfter != null) {
            final float topRoundness = getRoundness(oldViewAfter, true /* top */);
            final float topRoundness = getRoundnessFraction(oldViewAfter, true /* top */);
            oldViewAfter.setTopRoundness(topRoundness, animate);
        }
        if (viewAfter != null) {
@@ -162,7 +158,7 @@ public class NotificationRoundnessManager {
        }
    }

    private float getRoundness(ExpandableView view, boolean top) {
    private float getRoundnessFraction(ExpandableView view, boolean top) {
        if (view == null) {
            return 0f;
        }
@@ -186,7 +182,7 @@ public class NotificationRoundnessManager {
            // rounded.
            return MathUtils.saturate(1.0f - mAppearFraction);
        }
        if (view.showingPulsing() && !mBypassController.getBypassEnabled()) {
        if (view.showingPulsing() && mRoundForPulsingViews) {
            return 1.0f;
        }
        final Resources resources = view.getResources();
@@ -289,4 +285,8 @@ public class NotificationRoundnessManager {
            updateView(previous, true /* animate */);
        }
    }

    public void setShouldRoundPulsingViews(boolean shouldRoundPulsingViews) {
        mRoundForPulsingViews = shouldRoundPulsingViews;
    }
}
+5 −0
Original line number Diff line number Diff line
@@ -698,6 +698,11 @@ public class NotificationStackScrollLayoutController {
        });
        mView.setShadeController(mShadeController);

        mKeyguardBypassController.registerOnBypassStateChangedListener(
                isEnabled -> mNotificationRoundnessManager.setShouldRoundPulsingViews(!isEnabled));
        mNotificationRoundnessManager.setShouldRoundPulsingViews(
                !mKeyguardBypassController.getBypassEnabled());

        if (mFgFeatureController.isForegroundServiceDismissalEnabled()) {
            mView.initializeForegroundServiceSection(
                    (ForegroundServiceDungeonView) mFgServicesSectionController.createView(
+1 −5
Original line number Diff line number Diff line
@@ -37,14 +37,12 @@ import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.ExpandableView;
import com.android.systemui.statusbar.notification.row.NotificationTestHelper;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.util.DeviceConfigProxy;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

import java.util.HashSet;
@@ -59,8 +57,6 @@ public class NotificationRoundnessManagerTest extends SysuiTestCase {
    private Runnable mRoundnessCallback = mock(Runnable.class);
    private ExpandableNotificationRow mFirst;
    private ExpandableNotificationRow mSecond;
    @Mock
    private KeyguardBypassController mBypassController;
    private float mSmallRadiusRatio;

    @Before
@@ -70,7 +66,6 @@ public class NotificationRoundnessManagerTest extends SysuiTestCase {
        mSmallRadiusRatio = resources.getDimension(R.dimen.notification_corner_radius_small)
                / resources.getDimension(R.dimen.notification_corner_radius);
        mRoundnessManager = new NotificationRoundnessManager(
                mBypassController,
                new NotificationSectionsFeatureManager(new DeviceConfigProxy(), mContext));
        allowTestableLooperAsMainThread();
        NotificationTestHelper testHelper = new NotificationTestHelper(
@@ -90,6 +85,7 @@ public class NotificationRoundnessManagerTest extends SysuiTestCase {
                createSection(null, null)
        });
        mRoundnessManager.setExpanded(1.0f, 1.0f);
        mRoundnessManager.setShouldRoundPulsingViews(true);
        reset(mRoundnessCallback);
    }