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

Commit 99ba4bac authored by Gus Prevas's avatar Gus Prevas
Browse files

Fixes icons in shelf scrolled due to exposed menu.

This change modifies NotificationStackScrollLayout to reset the exposed
menu state in the following cases:

- transitioning to AOD
- scrolling via a touch on the exposed notification
- shade height changing, causing footer to clip the exposed notification

This prevents the notification's icon from having its scrollX set (which
is how we keep it lined up with the translated notification) when it's
in the shelf.

Test: manual
Change-Id: Ie2d179c9275ec457ee46c6a40859310610a6d9d8
Fixes: 112304611
parent 5d61fb37
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -426,6 +426,10 @@ public class AmbientState {
        return mDarkAmount == 1;
    }

    public boolean isDarkAtAll() {
        return mDarkAmount != 0;
    }

    public void setDarkTopPadding(int darkTopPadding) {
        mDarkTopPadding = darkTopPadding;
    }
+9 −4
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.animation.TimeAnimator;
import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.annotation.Nullable;
import android.app.WallpaperManager;
import android.content.Context;
@@ -40,7 +39,6 @@ import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.Handler;
import android.os.ServiceManager;
import android.provider.Settings;
import android.service.notification.StatusBarNotification;
@@ -82,7 +80,6 @@ import com.android.systemui.ExpandHelper;
import com.android.systemui.Interpolators;
import com.android.systemui.R;
import com.android.systemui.SwipeHelper;
import com.android.systemui.SwipeHelper.Callback;
import com.android.systemui.classifier.FalsingManager;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin;
@@ -3734,12 +3731,14 @@ public class NotificationStackScrollLayout extends ViewGroup
        return y < getHeight() - getEmptyBottomMargin();
    }

    @VisibleForTesting
    @ShadeViewRefactor(RefactorComponent.INPUT)
    private void setIsBeingDragged(boolean isDragged) {
    void setIsBeingDragged(boolean isDragged) {
        mIsBeingDragged = isDragged;
        if (isDragged) {
            requestDisallowInterceptTouchEvent(true);
            cancelLongPress();
            resetExposedMenuView(true /* animate */, true /* force */);
        }
    }

@@ -3869,6 +3868,7 @@ public class NotificationStackScrollLayout extends ViewGroup
    public void onPanelTrackingStarted() {
        mPanelTracking = true;
        mAmbientState.setPanelTracking(true);
        resetExposedMenuView(true /* animate */, true /* force */);
    }

    @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER)
@@ -4271,8 +4271,10 @@ public class NotificationStackScrollLayout extends ViewGroup
        mLinearDarkAmount = linearDarkAmount;
        mInterpolatedDarkAmount = interpolatedDarkAmount;
        boolean wasFullyDark = mAmbientState.isFullyDark();
        boolean wasDarkAtAll = mAmbientState.isDarkAtAll();
        mAmbientState.setDarkAmount(interpolatedDarkAmount);
        boolean nowFullyDark = mAmbientState.isFullyDark();
        boolean nowDarkAtAll = mAmbientState.isDarkAtAll();
        if (nowFullyDark != wasFullyDark) {
            updateContentHeight();
            DozeParameters dozeParameters = DozeParameters.getInstance(mContext);
@@ -4283,6 +4285,9 @@ public class NotificationStackScrollLayout extends ViewGroup
                mIconAreaController.setFullyDark(nowFullyDark);
            }
        }
        if (!wasDarkAtAll && nowDarkAtAll) {
            resetExposedMenuView(true /* animate */, true /* animate */);
        }
        updateAlgorithmHeightAndPadding();
        updateBackgroundDimming();
        updatePanelTranslation();
+33 −0
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@ package com.android.systemui.statusbar.notification.stack;

import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertNull;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
@@ -36,6 +38,7 @@ import android.service.dreams.IDreamManager;
import android.support.test.annotation.UiThreadTest;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
import android.view.View;

import com.android.systemui.ExpandHelper;
import com.android.systemui.R;
@@ -314,6 +317,36 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
        verify(mStackScroller).setEmptyShadeView(any());
    }

    @Test
    @UiThreadTest
    public void testSetIsBeingDraggedResetsExposedMenu() {
        NotificationSwipeHelper swipeActionHelper =
                (NotificationSwipeHelper) mStackScroller.getSwipeActionHelper();
        swipeActionHelper.setExposedMenuView(new View(mContext));
        mStackScroller.setIsBeingDragged(true);
        assertNull(swipeActionHelper.getExposedMenuView());
    }

    @Test
    @UiThreadTest
    public void testPanelTrackingStartResetsExposedMenu() {
        NotificationSwipeHelper swipeActionHelper =
                (NotificationSwipeHelper) mStackScroller.getSwipeActionHelper();
        swipeActionHelper.setExposedMenuView(new View(mContext));
        mStackScroller.onPanelTrackingStarted();
        assertNull(swipeActionHelper.getExposedMenuView());
    }

    @Test
    @UiThreadTest
    public void testDarkModeResetsExposedMenu() {
        NotificationSwipeHelper swipeActionHelper =
                (NotificationSwipeHelper) mStackScroller.getSwipeActionHelper();
        swipeActionHelper.setExposedMenuView(new View(mContext));
        mStackScroller.setDarkAmount(0.1f, 0.1f);
        assertNull(swipeActionHelper.getExposedMenuView());
    }

    private void setBarStateForTest(int state) {
        ArgumentCaptor<StatusBarStateController.StateListener> captor =
                ArgumentCaptor.forClass(StatusBarStateController.StateListener.class);