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

Commit b31a5f43 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add history onboarding" into rvc-dev

parents 061f46b9 da7c2458
Loading
Loading
Loading
Loading
+19 −3
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ public class FooterView extends StackScrollerDecorView {
    private final int mClearAllTopPadding;
    private FooterViewButton mDismissButton;
    private FooterViewButton mManageButton;
    private boolean mShowHistory;

    public FooterView(Context context, AttributeSet attrs) {
        super(context, attrs);
@@ -72,15 +73,30 @@ public class FooterView extends StackScrollerDecorView {
                || touchY > mContent.getY() + mContent.getHeight();
    }

    public void showHistory(boolean showHistory) {
        mShowHistory = showHistory;
        if (mShowHistory) {
            mManageButton.setText(R.string.manage_notifications_history_text);
            mManageButton.setContentDescription(
                    mContext.getString(R.string.manage_notifications_history_text));
        } else {
            mManageButton.setText(R.string.manage_notifications_text);
            mManageButton.setContentDescription(
                    mContext.getString(R.string.manage_notifications_text));
        }
    }

    public boolean isHistoryShown() {
        return mShowHistory;
    }

    @Override
    protected void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        mDismissButton.setText(R.string.clear_all_notifications_text);
        mDismissButton.setContentDescription(
                mContext.getString(R.string.accessibility_clear_all));
        mManageButton.setText(R.string.manage_notifications_history_text);
        mManageButton.setContentDescription(
                mContext.getString(R.string.manage_notifications_history_text));
        showHistory(mShowHistory);
    }

    public boolean isButtonVisible() {
+18 −10
Original line number Diff line number Diff line
@@ -628,8 +628,11 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
                mHighPriorityBeforeSpeedBump = "1".equals(newValue);
            } else if (key.equals(Settings.Secure.NOTIFICATION_DISMISS_RTL)) {
                updateDismissRtlSetting("1".equals(newValue));
            } else if (key.equals(Settings.Secure.NOTIFICATION_HISTORY_ENABLED)) {
                updateFooter();
            }
        }, HIGH_PRIORITY, Settings.Secure.NOTIFICATION_DISMISS_RTL);
        }, HIGH_PRIORITY, Settings.Secure.NOTIFICATION_DISMISS_RTL,
                Settings.Secure.NOTIFICATION_HISTORY_ENABLED);

        mFeatureFlags = featureFlags;
        mNotifPipeline = notifPipeline;
@@ -742,12 +745,17 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
    @VisibleForTesting
    @ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
    public void updateFooter() {
        if (mFooterView == null) {
            return;
        }
        boolean showDismissView = mClearAllEnabled && hasActiveClearableNotifications(ROWS_ALL);
        boolean showFooterView = (showDismissView || hasActiveNotifications())
                && mStatusBarState != StatusBarState.KEYGUARD
                && !mRemoteInputManager.getController().isRemoteInputActive();
        boolean showHistory = Settings.Secure.getInt(mContext.getContentResolver(),
                Settings.Secure.NOTIFICATION_HISTORY_ENABLED, 0) == 1;

        updateFooterView(showFooterView, showDismissView);
        updateFooterView(showFooterView, showDismissView, showHistory);
    }

    /**
@@ -4979,13 +4987,14 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
    }

    @ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
    public void updateFooterView(boolean visible, boolean showDismissView) {
    public void updateFooterView(boolean visible, boolean showDismissView, boolean showHistory) {
        if (mFooterView == null) {
            return;
        }
        boolean animate = mIsExpanded && mAnimationsEnabled;
        mFooterView.setVisible(visible, animate);
        mFooterView.setSecondaryVisible(showDismissView, animate);
        mFooterView.showHistory(showHistory);
    }

    @ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
@@ -5565,12 +5574,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
        mIconAreaController = controller;
    }

    @ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
    public void manageNotifications(View v) {
        Intent intent = new Intent(Settings.ACTION_NOTIFICATION_HISTORY);
        mStatusBar.startActivity(intent, true, true, Intent.FLAG_ACTIVITY_SINGLE_TOP);
    }

    @ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
    @VisibleForTesting
    void clearNotifications(
@@ -5705,7 +5708,12 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
            mMetricsLogger.action(MetricsEvent.ACTION_DISMISS_ALL_NOTES);
            clearNotifications(ROWS_ALL, true /* closeShade */);
        });
        footerView.setManageButtonClickListener(this::manageNotifications);
        footerView.setManageButtonClickListener(v -> {
            Intent intent = footerView.isHistoryShown() ? new Intent(
                    Settings.ACTION_NOTIFICATION_HISTORY) : new Intent(
                    Settings.ACTION_NOTIFICATION_SETTINGS);
            mStatusBar.startActivity(intent, true, true, Intent.FLAG_ACTIVITY_SINGLE_TOP);
        });
        setFooterView(footerView);
    }

+17 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import static org.mockito.Mockito.mock;

import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;
@@ -66,6 +67,22 @@ public class FooterViewTest extends SysuiTestCase {
        assertTrue(mView.findViewById(R.id.manage_text).hasOnClickListeners());
    }

    @Test
    public void setHistoryShown() {
        mView.showHistory(true);
        assertTrue(mView.isHistoryShown());
        assertTrue(((TextView) mView.findViewById(R.id.manage_text))
                .getText().toString().contains("History"));
    }

    @Test
    public void setHistoryNotShown() {
        mView.showHistory(false);
        assertFalse(mView.isHistoryShown());
        assertTrue(((TextView) mView.findViewById(R.id.manage_text))
                .getText().toString().contains("Manage"));
    }

    @Test
    public void testPerformVisibilityAnimation() {
        mView.setVisible(false /* visible */, false /* animate */);
+16 −6
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@

package com.android.systemui.statusbar.notification.stack;

import static android.provider.Settings.Secure.NOTIFICATION_HISTORY_ENABLED;
import static android.provider.Settings.Secure.NOTIFICATION_NEW_INTERRUPTION_MODEL;

import static junit.framework.Assert.assertEquals;
@@ -151,6 +152,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
                NOTIFICATION_NEW_INTERRUPTION_MODEL, 0);
        Settings.Secure.putInt(mContext.getContentResolver(),
                NOTIFICATION_NEW_INTERRUPTION_MODEL, 1);
        Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_HISTORY_ENABLED, 1);

        // Inject dependencies before initializing the layout
        mDependency.injectMockDependency(VisualStabilityManager.class);
@@ -311,7 +313,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
        mStackScroller.setFooterView(view);
        when(view.willBeGone()).thenReturn(true);

        mStackScroller.updateFooterView(true, false);
        mStackScroller.updateFooterView(true, false, true);

        verify(view).setVisible(eq(true), anyBoolean());
        verify(view).setSecondaryVisible(eq(false), anyBoolean());
@@ -323,7 +325,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
        mStackScroller.setFooterView(view);
        when(view.willBeGone()).thenReturn(true);

        mStackScroller.updateFooterView(true, true);
        mStackScroller.updateFooterView(true, true, true);

        verify(view).setVisible(eq(true), anyBoolean());
        verify(view).setSecondaryVisible(eq(true), anyBoolean());
@@ -344,8 +346,10 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
        setBarStateForTest(StatusBarState.SHADE);
        assertEquals(0, mEntryManager.getActiveNotificationsCount());

        FooterView view = mock(FooterView.class);
        mStackScroller.setFooterView(view);
        mStackScroller.updateFooter();
        verify(mStackScroller, atLeastOnce()).updateFooterView(false, false);
        verify(mStackScroller, atLeastOnce()).updateFooterView(false, false, true);
    }

    @Test
@@ -361,8 +365,10 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
        when(mStackScroller.getChildAt(anyInt())).thenReturn(row);
        when(mRemoteInputController.isRemoteInputActive()).thenReturn(true);

        FooterView view = mock(FooterView.class);
        mStackScroller.setFooterView(view);
        mStackScroller.updateFooter();
        verify(mStackScroller).updateFooterView(false, true);
        verify(mStackScroller).updateFooterView(false, true, true);
    }

    @Test
@@ -378,8 +384,10 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
        when(mStackScroller.getChildCount()).thenReturn(1);
        when(mStackScroller.getChildAt(anyInt())).thenReturn(row);

        FooterView view = mock(FooterView.class);
        mStackScroller.setFooterView(view);
        mStackScroller.updateFooter();
        verify(mStackScroller).updateFooterView(true, true);
        verify(mStackScroller).updateFooterView(true, true, true);
    }

    @Test
@@ -390,8 +398,10 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
        entries.add(new NotificationEntryBuilder().build());
        addEntriesToEntryManager(entries);

        FooterView view = mock(FooterView.class);
        mStackScroller.setFooterView(view);
        mStackScroller.updateFooter();
        verify(mStackScroller).updateFooterView(true, false);
        verify(mStackScroller).updateFooterView(true, false, true);
    }

    @Test