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

Commit cecb405f authored by András Kurucz's avatar András Kurucz
Browse files

Reset selected Notification importance after closing the guts

The selected importance state was never resetted which resulted in some inconsistent behaviour after binding a NotificationInfo view again. It is fixed by resetting it upon closing the guts.

Remove unused fields from the PartialConversationInfo.
Add a new test for NotificationGuts to check if the close callback is
called.

Test: atest NotificationInfoTest
Test: atest NotificationConversationInfoTest
Test: atest PartialConversationInfoTest
Test: atest NotificationGutsTest
Test: manual

Fixes: 241915559

Change-Id: Ibfcf88107e6b8548d7d98138925be1671c64a176
parent 382cf794
Loading
Loading
Loading
Loading
+4 −4
Original line number Original line Diff line number Diff line
@@ -165,7 +165,7 @@ public class FeedbackInfo extends LinearLayout implements NotificationGuts.GutsC
    }
    }


    private void positiveFeedback(View v) {
    private void positiveFeedback(View v) {
        mGutsContainer.closeControls(v, false);
        mGutsContainer.closeControls(v, /* save= */ false);
        handleFeedback(true);
        handleFeedback(true);
    }
    }


@@ -176,7 +176,7 @@ public class FeedbackInfo extends LinearLayout implements NotificationGuts.GutsC
            menuItem = mMenuRowPlugin.getLongpressMenuItem(mContext);
            menuItem = mMenuRowPlugin.getLongpressMenuItem(mContext);
        }
        }


        mGutsContainer.closeControls(v, false);
        mGutsContainer.closeControls(v, /* save= */ false);
        mNotificationGutsManager.openGuts(mExpandableNotificationRow, 0, 0, menuItem);
        mNotificationGutsManager.openGuts(mExpandableNotificationRow, 0, 0, menuItem);
        handleFeedback(false);
        handleFeedback(false);
    }
    }
@@ -203,7 +203,7 @@ public class FeedbackInfo extends LinearLayout implements NotificationGuts.GutsC
    }
    }


    private void closeControls(View v) {
    private void closeControls(View v) {
        mGutsContainer.closeControls(v, false);
        mGutsContainer.closeControls(v, /* save= */ false);
    }
    }


    @Override
    @Override
@@ -232,7 +232,7 @@ public class FeedbackInfo extends LinearLayout implements NotificationGuts.GutsC
    }
    }


    @Override
    @Override
    public boolean shouldBeSaved() {
    public boolean shouldBeSavedOnClose() {
        return false;
        return false;
    }
    }


+9 −8
Original line number Original line Diff line number Diff line
@@ -157,7 +157,7 @@ public class NotificationConversationInfo extends LinearLayout implements
            mShadeController.animateCollapsePanels();
            mShadeController.animateCollapsePanels();
            mPeopleSpaceWidgetManager.requestPinAppWidget(mShortcutInfo, new Bundle());
            mPeopleSpaceWidgetManager.requestPinAppWidget(mShortcutInfo, new Bundle());
        }
        }
        mGutsContainer.closeControls(v, true);
        mGutsContainer.closeControls(v, /* save= */ true);
    };
    };


    public NotificationConversationInfo(Context context, AttributeSet attrs) {
    public NotificationConversationInfo(Context context, AttributeSet attrs) {
@@ -186,7 +186,6 @@ public class NotificationConversationInfo extends LinearLayout implements
    }
    }


    public void bindNotification(
    public void bindNotification(
            @Action int selectedAction,
            ShortcutManager shortcutManager,
            ShortcutManager shortcutManager,
            PackageManager pm,
            PackageManager pm,
            PeopleSpaceWidgetManager peopleSpaceWidgetManager,
            PeopleSpaceWidgetManager peopleSpaceWidgetManager,
@@ -205,8 +204,6 @@ public class NotificationConversationInfo extends LinearLayout implements
            OnConversationSettingsClickListener onConversationSettingsClickListener,
            OnConversationSettingsClickListener onConversationSettingsClickListener,
            Optional<BubblesManager> bubblesManagerOptional,
            Optional<BubblesManager> bubblesManagerOptional,
            ShadeController shadeController) {
            ShadeController shadeController) {
        mPressedApply = false;
        mSelectedAction = selectedAction;
        mINotificationManager = iNotificationManager;
        mINotificationManager = iNotificationManager;
        mPeopleSpaceWidgetManager = peopleSpaceWidgetManager;
        mPeopleSpaceWidgetManager = peopleSpaceWidgetManager;
        mOnUserInteractionCallback = onUserInteractionCallback;
        mOnUserInteractionCallback = onUserInteractionCallback;
@@ -417,9 +414,7 @@ public class NotificationConversationInfo extends LinearLayout implements
    }
    }


    @Override
    @Override
    public void onFinishedClosing() {
    public void onFinishedClosing() { }
        mSelectedAction = -1;
    }


    @Override
    @Override
    public boolean needsFalsingProtection() {
    public boolean needsFalsingProtection() {
@@ -564,7 +559,7 @@ public class NotificationConversationInfo extends LinearLayout implements
    }
    }


    @Override
    @Override
    public boolean shouldBeSaved() {
    public boolean shouldBeSavedOnClose() {
        return mPressedApply;
        return mPressedApply;
    }
    }


@@ -578,6 +573,12 @@ public class NotificationConversationInfo extends LinearLayout implements
        if (save && mSelectedAction > -1) {
        if (save && mSelectedAction > -1) {
            updateChannel();
            updateChannel();
        }
        }

        // Clear the selected importance when closing, so when when we open again,
        // we starts from a clean state.
        mSelectedAction = -1;
        mPressedApply = false;

        return false;
        return false;
    }
    }


+3 −3
Original line number Original line Diff line number Diff line
@@ -76,7 +76,7 @@ public class NotificationGuts extends FrameLayout {


                    switch (action) {
                    switch (action) {
                        case AccessibilityNodeInfo.ACTION_LONG_CLICK:
                        case AccessibilityNodeInfo.ACTION_LONG_CLICK:
                            closeControls(host, false);
                            closeControls(host, /* save= */ false);
                            return true;
                            return true;
                    }
                    }


@@ -123,7 +123,7 @@ public class NotificationGuts extends FrameLayout {
        /**
        /**
         * Return whether something changed and needs to be saved, possibly requiring a bouncer.
         * Return whether something changed and needs to be saved, possibly requiring a bouncer.
         */
         */
        boolean shouldBeSaved();
        boolean shouldBeSavedOnClose();


        /**
        /**
         * Called when the guts view has finished its close animation.
         * Called when the guts view has finished its close animation.
@@ -259,7 +259,7 @@ public class NotificationGuts extends FrameLayout {
        if (mGutsContent != null) {
        if (mGutsContent != null) {
            if ((mGutsContent.isLeavebehind() && leavebehinds)
            if ((mGutsContent.isLeavebehind() && leavebehinds)
                    || (!mGutsContent.isLeavebehind() && controls)) {
                    || (!mGutsContent.isLeavebehind() && controls)) {
                closeControls(x, y, mGutsContent.shouldBeSaved(), force);
                closeControls(x, y, mGutsContent.shouldBeSavedOnClose(), force);
            }
            }
        }
        }
    }
    }
+0 −1
Original line number Original line Diff line number Diff line
@@ -477,7 +477,6 @@ public class NotificationGutsManager implements Dumpable, NotificationLifetimeEx
                        R.dimen.notification_guts_conversation_icon_size));
                        R.dimen.notification_guts_conversation_icon_size));


        notificationInfoView.bindNotification(
        notificationInfoView.bindNotification(
                notificationInfoView.getSelectedAction(),
                mShortcutManager,
                mShortcutManager,
                pmUser,
                pmUser,
                mPeopleSpaceWidgetManager,
                mPeopleSpaceWidgetManager,
+8 −6
Original line number Original line Diff line number Diff line
@@ -158,7 +158,7 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
    // used by standard ui
    // used by standard ui
    private OnClickListener mOnDismissSettings = v -> {
    private OnClickListener mOnDismissSettings = v -> {
        mPressedApply = true;
        mPressedApply = true;
        mGutsContainer.closeControls(v, true);
        mGutsContainer.closeControls(v, /* save= */ true);
    };
    };


    public NotificationInfo(Context context, AttributeSet attrs) {
    public NotificationInfo(Context context, AttributeSet attrs) {
@@ -541,10 +541,6 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G


    @Override
    @Override
    public void onFinishedClosing() {
    public void onFinishedClosing() {
        if (mChosenImportance != null) {
            mStartingChannelImportance = mChosenImportance;
        }

        bindInlineControls();
        bindInlineControls();


        logUiEvent(NotificationControlsEvent.NOTIFICATION_CONTROLS_CLOSE);
        logUiEvent(NotificationControlsEvent.NOTIFICATION_CONTROLS_CLOSE);
@@ -604,7 +600,7 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
    }
    }


    @Override
    @Override
    public boolean shouldBeSaved() {
    public boolean shouldBeSavedOnClose() {
        return mPressedApply;
        return mPressedApply;
    }
    }


@@ -627,6 +623,12 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
        if (save) {
        if (save) {
            saveImportance();
            saveImportance();
        }
        }

        // Clear the selected importance when closing, so when when we open again,
        // we starts from a clean state.
        mChosenImportance = null;
        mPressedApply = false;

        return false;
        return false;
    }
    }


Loading