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

Commit 2b2081b9 authored by Juan Sebastian Martinez's avatar Juan Sebastian Martinez
Browse files

Integrating MagneticNotificationRowManager with NSSL controller.

This is the second part of the series of changes for magnetic
notifications. It integrates the MagneticNotificationRowManager with the
NSSL controller and NotificationSwipeHelper.

Flag: com.android.systemui.magnetic_notification_swipes
Test: manual. Verified magnetic behavior when swiping notifications.
Bug: 390179908
Change-Id: I39e5a8e88f26d7168c5bd5dd5291e7085a275d1e
parent d76dd602
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -1955,13 +1955,10 @@ flag {
}

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

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

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

    static class LogMatcher implements ArgumentMatcher<LogMaker> {
+3 −3
Original line number Diff line number Diff line
@@ -405,7 +405,7 @@ public class NotificationSwipeHelperTest extends SysuiTestCase {
        doNothing().when(mSwipeHelper).superSnapChild(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)).handleMenuCoveredOrDismissed();
    }
@@ -416,7 +416,7 @@ public class NotificationSwipeHelperTest extends SysuiTestCase {
        doNothing().when(mSwipeHelper).superSnapChild(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(0)).handleMenuCoveredOrDismissed();
    }
@@ -426,7 +426,7 @@ public class NotificationSwipeHelperTest extends SysuiTestCase {
        doNothing().when(mSwipeHelper).superSnapChild(mView, 10, 0);
        mSwipeHelper.snapChild(mView, 10, 0);

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

+18 −3
Original line number 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.FloatPropertyCompat.createFloatPropertyCompat;

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

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

    protected final Handler mHandler;

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

    private final FlingAnimationUtils mFlingAnimationUtils;
    private float mPagingTouchSlop;
@@ -153,6 +153,12 @@ public class SwipeHelper implements Gefingerpoken, Dumpable {
                R.bool.config_fadeDependingOnAmountSwiped);
        mFalsingManager = falsingManager;
        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(),
                getMaxEscapeAnimDuration() / 1000f);
    }
@@ -718,7 +724,7 @@ public class SwipeHelper implements Gefingerpoken, Dumpable {
                        dismissChild(mTouchedView, velocity,
                                !swipedFastEnough() /* useAccelerateInterpolator */);
                    } else {
                        mCallback.onDragCancelled(mTouchedView);
                        mCallback.onDragCancelledWithVelocity(mTouchedView, velocity);
                        snapChild(mTouchedView, 0 /* leftTarget */, velocity);
                    }
                    mTouchedView = null;
@@ -924,6 +930,15 @@ public class SwipeHelper implements Gefingerpoken, Dumpable {

        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.
         *
+18 −0
Original line number 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.modes.ZenModesBackend;
import com.android.systemui.CoreStartable;
import com.android.systemui.Flags;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Application;
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.OnUserInteractionCallback;
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.NotificationSectionsManager;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController;
@@ -322,4 +325,19 @@ public interface NotificationsModule {
            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