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

Commit 502ef2bf authored by Juan Sebastian Martinez's avatar Juan Sebastian Martinez Committed by Android (Google) Code Review
Browse files

Merge "Integrating MagneticNotificationRowManager with NSSL controller." into main

parents 6893f8be 2b2081b9
Loading
Loading
Loading
Loading
+1 −4
Original line number Original line Diff line number Diff line
@@ -1962,13 +1962,10 @@ flag {
}
}


flag {
flag {
   name: "magnetic_notification_horizontal_swipe"
   name: "magnetic_notification_swipes"
   namespace: "systemui"
   namespace: "systemui"
   description: "Add support for magnetic behavior on horizontal notification swipes."
   description: "Add support for magnetic behavior on horizontal notification swipes."
   bug: "390179908"
   bug: "390179908"
   metadata {
        purpose: PURPOSE_BUGFIX
   }
}
}


flag {
flag {
+5 −1
Original line number Original line Diff line number Diff line
@@ -165,6 +165,8 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
    @Mock
    @Mock
    private SensitiveNotificationProtectionController mSensitiveNotificationProtectionController;
    private SensitiveNotificationProtectionController mSensitiveNotificationProtectionController;
    @Mock private ExpandHelper mExpandHelper;
    @Mock private ExpandHelper mExpandHelper;
    @Mock private MagneticNotificationRowManager mMagneticNotificationRowManager;
    @Mock private NotificationSectionsManager mSectionsManager;


    @Captor
    @Captor
    private ArgumentCaptor<Runnable> mSensitiveStateListenerArgumentCaptor;
    private ArgumentCaptor<Runnable> mSensitiveStateListenerArgumentCaptor;
@@ -798,7 +800,9 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
                mActivityStarter,
                mActivityStarter,
                new ResourcesSplitShadeStateController(),
                new ResourcesSplitShadeStateController(),
                mSensitiveNotificationProtectionController,
                mSensitiveNotificationProtectionController,
                mWallpaperInteractor);
                mWallpaperInteractor,
                mMagneticNotificationRowManager,
                mSectionsManager);
    }
    }


    static class LogMatcher implements ArgumentMatcher<LogMaker> {
    static class LogMatcher implements ArgumentMatcher<LogMaker> {
+3 −3
Original line number Original line Diff line number Diff line
@@ -405,7 +405,7 @@ public class NotificationSwipeHelperTest extends SysuiTestCase {
        doNothing().when(mSwipeHelper).superSnapChild(mNotificationRow, 0, 0);
        doNothing().when(mSwipeHelper).superSnapChild(mNotificationRow, 0, 0);
        mSwipeHelper.snapChild(mNotificationRow, 0, 0);
        mSwipeHelper.snapChild(mNotificationRow, 0, 0);


        verify(mCallback, times(1)).onDragCancelled(mNotificationRow);
        verify(mCallback, times(1)).onDragCancelledWithVelocity(mNotificationRow, 0);
        verify(mSwipeHelper, times(1)).superSnapChild(mNotificationRow, 0, 0);
        verify(mSwipeHelper, times(1)).superSnapChild(mNotificationRow, 0, 0);
        verify(mSwipeHelper, times(1)).handleMenuCoveredOrDismissed();
        verify(mSwipeHelper, times(1)).handleMenuCoveredOrDismissed();
    }
    }
@@ -416,7 +416,7 @@ public class NotificationSwipeHelperTest extends SysuiTestCase {
        doNothing().when(mSwipeHelper).superSnapChild(mNotificationRow, 10, 0);
        doNothing().when(mSwipeHelper).superSnapChild(mNotificationRow, 10, 0);
        mSwipeHelper.snapChild(mNotificationRow, 10, 0);
        mSwipeHelper.snapChild(mNotificationRow, 10, 0);


        verify(mCallback, times(1)).onDragCancelled(mNotificationRow);
        verify(mCallback, times(1)).onDragCancelledWithVelocity(mNotificationRow, 0);
        verify(mSwipeHelper, times(1)).superSnapChild(mNotificationRow, 10, 0);
        verify(mSwipeHelper, times(1)).superSnapChild(mNotificationRow, 10, 0);
        verify(mSwipeHelper, times(0)).handleMenuCoveredOrDismissed();
        verify(mSwipeHelper, times(0)).handleMenuCoveredOrDismissed();
    }
    }
@@ -426,7 +426,7 @@ public class NotificationSwipeHelperTest extends SysuiTestCase {
        doNothing().when(mSwipeHelper).superSnapChild(mView, 10, 0);
        doNothing().when(mSwipeHelper).superSnapChild(mView, 10, 0);
        mSwipeHelper.snapChild(mView, 10, 0);
        mSwipeHelper.snapChild(mView, 10, 0);


        verify(mCallback).onDragCancelled(mView);
        verify(mCallback).onDragCancelledWithVelocity(mView, 0);
        verify(mSwipeHelper, never()).superSnapChild(mView, 10, 0);
        verify(mSwipeHelper, never()).superSnapChild(mView, 10, 0);
    }
    }


+18 −3
Original line number Original line Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui;
import static androidx.dynamicanimation.animation.DynamicAnimation.TRANSLATION_X;
import static androidx.dynamicanimation.animation.DynamicAnimation.TRANSLATION_X;
import static androidx.dynamicanimation.animation.FloatPropertyCompat.createFloatPropertyCompat;
import static androidx.dynamicanimation.animation.FloatPropertyCompat.createFloatPropertyCompat;


import static com.android.systemui.Flags.magneticNotificationSwipes;
import static com.android.systemui.classifier.Classifier.NOTIFICATION_DISMISS;
import static com.android.systemui.classifier.Classifier.NOTIFICATION_DISMISS;
import static com.android.systemui.statusbar.notification.NotificationUtils.logKey;
import static com.android.systemui.statusbar.notification.NotificationUtils.logKey;


@@ -76,8 +77,7 @@ public class SwipeHelper implements Gefingerpoken, Dumpable {


    protected final Handler mHandler;
    protected final Handler mHandler;


    private final SpringConfig mSnapBackSpringConfig =
    private final SpringConfig mSnapBackSpringConfig;
            new SpringConfig(SpringForce.STIFFNESS_LOW, SpringForce.DAMPING_RATIO_LOW_BOUNCY);


    private final FlingAnimationUtils mFlingAnimationUtils;
    private final FlingAnimationUtils mFlingAnimationUtils;
    private float mPagingTouchSlop;
    private float mPagingTouchSlop;
@@ -153,6 +153,12 @@ public class SwipeHelper implements Gefingerpoken, Dumpable {
                R.bool.config_fadeDependingOnAmountSwiped);
                R.bool.config_fadeDependingOnAmountSwiped);
        mFalsingManager = falsingManager;
        mFalsingManager = falsingManager;
        mFeatureFlags = featureFlags;
        mFeatureFlags = featureFlags;
        if (magneticNotificationSwipes()) {
            mSnapBackSpringConfig = new SpringConfig(550f /*stiffness*/, 0.52f /*dampingRatio*/);
        } else {
            mSnapBackSpringConfig = new SpringConfig(
                    SpringForce.STIFFNESS_LOW, SpringForce.DAMPING_RATIO_LOW_BOUNCY);
        }
        mFlingAnimationUtils = new FlingAnimationUtils(resources.getDisplayMetrics(),
        mFlingAnimationUtils = new FlingAnimationUtils(resources.getDisplayMetrics(),
                getMaxEscapeAnimDuration() / 1000f);
                getMaxEscapeAnimDuration() / 1000f);
    }
    }
@@ -718,7 +724,7 @@ public class SwipeHelper implements Gefingerpoken, Dumpable {
                        dismissChild(mTouchedView, velocity,
                        dismissChild(mTouchedView, velocity,
                                !swipedFastEnough() /* useAccelerateInterpolator */);
                                !swipedFastEnough() /* useAccelerateInterpolator */);
                    } else {
                    } else {
                        mCallback.onDragCancelled(mTouchedView);
                        mCallback.onDragCancelledWithVelocity(mTouchedView, velocity);
                        snapChild(mTouchedView, 0 /* leftTarget */, velocity);
                        snapChild(mTouchedView, 0 /* leftTarget */, velocity);
                    }
                    }
                    mTouchedView = null;
                    mTouchedView = null;
@@ -924,6 +930,15 @@ public class SwipeHelper implements Gefingerpoken, Dumpable {


        void onDragCancelled(View v);
        void onDragCancelled(View v);


        /**
         * A drag operation has been cancelled on a view with a final velocity.
         * @param v View that was dragged.
         * @param finalVelocity Final velocity of the drag.
         */
        default void onDragCancelledWithVelocity(View v, float finalVelocity) {
            onDragCancelled(v);
        }

        /**
        /**
         * Called when the child is long pressed and available to start drag and drop.
         * Called when the child is long pressed and available to start drag and drop.
         *
         *
+18 −0
Original line number Original line Diff line number Diff line
@@ -27,6 +27,7 @@ import com.android.settingslib.notification.data.repository.ZenModeRepositoryImp
import com.android.settingslib.notification.domain.interactor.NotificationsSoundPolicyInteractor;
import com.android.settingslib.notification.domain.interactor.NotificationsSoundPolicyInteractor;
import com.android.settingslib.notification.modes.ZenModesBackend;
import com.android.settingslib.notification.modes.ZenModesBackend;
import com.android.systemui.CoreStartable;
import com.android.systemui.CoreStartable;
import com.android.systemui.Flags;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Application;
import com.android.systemui.dagger.qualifiers.Application;
import com.android.systemui.dagger.qualifiers.Background;
import com.android.systemui.dagger.qualifiers.Background;
@@ -84,6 +85,8 @@ import com.android.systemui.statusbar.notification.row.NotificationEntryProcesso
import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
import com.android.systemui.statusbar.notification.row.OnUserInteractionCallback;
import com.android.systemui.statusbar.notification.row.OnUserInteractionCallback;
import com.android.systemui.statusbar.notification.row.ui.viewmodel.ActivatableNotificationViewModelModule;
import com.android.systemui.statusbar.notification.row.ui.viewmodel.ActivatableNotificationViewModelModule;
import com.android.systemui.statusbar.notification.stack.MagneticNotificationRowManager;
import com.android.systemui.statusbar.notification.stack.MagneticNotificationRowManagerImpl;
import com.android.systemui.statusbar.notification.stack.NotificationListContainer;
import com.android.systemui.statusbar.notification.stack.NotificationListContainer;
import com.android.systemui.statusbar.notification.stack.NotificationSectionsManager;
import com.android.systemui.statusbar.notification.stack.NotificationSectionsManager;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController;
@@ -322,4 +325,19 @@ public interface NotificationsModule {
            return (entry, recoveredBuilder) -> null;
            return (entry, recoveredBuilder) -> null;
        }
        }
    }
    }

    /**
     * Provide an implementation of {@link MagneticNotificationRowManager} based on its flag.
     */
    @Provides
    @SysUISingleton
    static MagneticNotificationRowManager provideMagneticNotificationRowManager(
            Provider<MagneticNotificationRowManagerImpl> implProvider
    ) {
        if (Flags.magneticNotificationSwipes()) {
            return implProvider.get();
        } else {
            return MagneticNotificationRowManager.getEmpty();
        }
    }
}
}
Loading