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

Commit 40d59546 authored by Bryce Lee's avatar Bryce Lee Committed by Android (Google) Code Review
Browse files

Merge "Set communal view alpha."

parents 65219623 56fd5687
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -160,6 +160,21 @@ public class CommunalHostViewController extends ViewController<CommunalHostView>
                statusBarState, keyguardFadingAway, goingToFullShade, oldStatusBarState);
    }

    /**
     * Set keyguard status view alpha.
     */
    public void setAlpha(float alpha) {
        if (!mKeyguardVisibilityHelper.isVisibilityAnimating()) {
            mView.setAlpha(alpha);

            // Some communal view implementations, such as SurfaceViews, do not behave correctly
            // inheriting the alpha of their parent. Directly set child alpha here to work around
            // this.
            for (int i = mView.getChildCount() - 1; i >= 0; --i) {
                mView.getChildAt(i).setAlpha(alpha);
            }
        }
    }
    @Override
    public void init() {
        super.init();
+1 −0
Original line number Diff line number Diff line
@@ -209,6 +209,7 @@ public class CommunalSurfaceViewController extends ViewController<SurfaceView> {
                    if (surfacePackage != null) {
                        mView.setChildSurfacePackage(surfacePackage);
                        mView.setZOrderOnTop(true);
                        mView.setUseAlpha();
                        mView.postInvalidate();
                        mCommunalStateController.setCommunalViewShowing(true);
                    } else {
+7 −0
Original line number Diff line number Diff line
@@ -1574,6 +1574,12 @@ public class NotificationPanelViewController extends PanelViewController {
        return true;
    }

    private void updateCommunal() {
        if (mCommunalViewController != null) {
            mCommunalViewController.setAlpha(mKeyguardOnlyContentAlpha);
        }
    }

    private void updateClock() {
        float alpha = mClockPositionResult.clockAlpha * mKeyguardOnlyContentAlpha;
        mKeyguardStatusViewController.setAlpha(alpha);
@@ -2675,6 +2681,7 @@ public class NotificationPanelViewController extends PanelViewController {
            updateKeyguardBottomAreaAlpha();
        }
        updateClock();
        updateCommunal();
    }

    private void trackMovement(MotionEvent event) {
+15 −0
Original line number Diff line number Diff line
@@ -77,6 +77,9 @@ public class CommunalHostViewControllerTest extends SysuiTestCase {
    @Mock
    private CommunalSource mCommunalSource;

    @Mock
    private View mChildView;

    @Before
    public void setup() {
        MockitoAnnotations.initMocks(this);
@@ -211,4 +214,16 @@ public class CommunalHostViewControllerTest extends SysuiTestCase {
        // Verify state controller is notified communal view is hidden.
        verify(mCommunalStateController).setCommunalViewShowing(false);
    }

    @Test
    public void testAlphaPropagation() {
        final float alpha = 0.8f;

        // Ensure alpha setting is propagated to children.
        when(mCommunalView.getChildCount()).thenReturn(1);
        when(mCommunalView.getChildAt(0)).thenReturn(mChildView);
        mController.setAlpha(alpha);
        verify(mChildView).setAlpha(alpha);
        verify(mCommunalView).setAlpha(alpha);
    }
}
+9 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import static com.google.common.truth.Truth.assertThat;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyFloat;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.atLeast;
@@ -901,6 +902,14 @@ public class NotificationPanelViewTest extends SysuiTestCase {
                anyBoolean(), anyBoolean(), anyInt());
    }

    @Test
    public void testCommunalAlphaUpdate() {
        // Verify keyguard content alpha changes are propagate. Note the actual value set is not
        // checked since an interpolation is applied to the incoming value.
        mNotificationPanelViewController.setKeyguardOnlyContentAlpha(0.8f);
        verify(mCommunalHostViewController).setAlpha(anyFloat());
    }

    private void triggerPositionClockAndNotifications() {
        mNotificationPanelViewController.closeQs();
    }