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

Commit 5e3742e9 authored by Anthony Chen's avatar Anthony Chen
Browse files

Allow the "clear all" button to be toggled.

Android Auto UX does not want a "clear all" button. Conditionally create
the "clear all" button depending on this config value.

Test: booted up on phone and Android Auto headunit
Bug: 33210494
Change-Id: Idc3d702efec5d51d6da28f5af3673248997270cc
parent 43791354
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -338,4 +338,7 @@
    <!-- Whether to show activity indicators in the status bar -->
    <bool name="config_showActivity">false</bool>

    <!-- Whether or not the button to clear all notifications will be shown. -->
    <bool name="config_enableNotificationsClearAll">true</bool>

</resources>
+37 −14
Original line number Diff line number Diff line
@@ -716,6 +716,7 @@ public class StatusBar extends SystemUI implements DemoMode,
    private ConfigurationListener mConfigurationListener;
    private InflationExceptionHandler mInflationExceptionHandler = this::handleInflationException;
    private boolean mReinflateNotificationsOnUserSwitched;
    private boolean mClearAllEnabled;

    private void recycleAllVisibilityObjects(ArraySet<NotificationVisibility> array) {
        final int N = array.size();
@@ -761,8 +762,10 @@ public class StatusBar extends SystemUI implements DemoMode,
        mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
        mDisplay = mWindowManager.getDefaultDisplay();
        updateDisplaySize();
        mScrimSrcModeEnabled = mContext.getResources().getBoolean(
                R.bool.config_status_bar_scrim_behind_use_src);

        Resources res = mContext.getResources();
        mScrimSrcModeEnabled = res.getBoolean(R.bool.config_status_bar_scrim_behind_use_src);
        mClearAllEnabled = res.getBoolean(R.bool.config_enableNotificationsClearAll);

        DateTimeView.setReceiverHandler(Dependency.get(Dependency.TIME_TICK_HANDLER));
        putComponent(StatusBar.class, this);
@@ -810,7 +813,7 @@ public class StatusBar extends SystemUI implements DemoMode,

        mRecents = getComponent(Recents.class);

        final Configuration currentConfig = mContext.getResources().getConfiguration();
        final Configuration currentConfig = res.getConfiguration();
        mLocale = currentConfig.locale;
        mLayoutDirection = TextUtils.getLayoutDirectionFromLocale(mLocale);

@@ -823,7 +826,7 @@ public class StatusBar extends SystemUI implements DemoMode,
        mCommandQueue.addCallbacks(this);

        int[] switches = new int[9];
        ArrayList<IBinder> binders = new ArrayList<IBinder>();
        ArrayList<IBinder> binders = new ArrayList<>();
        ArrayList<String> iconSlots = new ArrayList<>();
        ArrayList<StatusBarIcon> icons = new ArrayList<>();
        Rect fullscreenStackBounds = new Rect();
@@ -904,8 +907,8 @@ public class StatusBar extends SystemUI implements DemoMode,
            Slog.e(TAG, "Failed to register VR mode state listener: " + e);
        }

        mNonBlockablePkgs = new HashSet<String>();
        Collections.addAll(mNonBlockablePkgs, mContext.getResources().getStringArray(
        mNonBlockablePkgs = new HashSet<>();
        Collections.addAll(mNonBlockablePkgs, res.getStringArray(
                com.android.internal.R.array.config_nonBlockableNotificationPackages));
        // end old BaseStatusBar.start().

@@ -1358,6 +1361,10 @@ public class StatusBar extends SystemUI implements DemoMode,
    }

    private void inflateDismissView() {
        if (!mClearAllEnabled) {
            return;
        }

        mDismissView = (DismissView) LayoutInflater.from(mContext).inflate(
                R.layout.status_bar_notification_dismiss_all, mStackScroller, false);
        mDismissView.setOnButtonClickListener(new View.OnClickListener() {
@@ -2023,9 +2030,11 @@ public class StatusBar extends SystemUI implements DemoMode,
    }

    private void updateClearAll() {
        boolean showDismissView =
                mState != StatusBarState.KEYGUARD &&
               hasActiveClearableNotifications();
        if (!mClearAllEnabled) {
            return;
        }
        boolean showDismissView = mState != StatusBarState.KEYGUARD
                && hasActiveClearableNotifications();
        mStackScroller.updateDismissView(showDismissView);
    }

@@ -6615,9 +6624,23 @@ public class StatusBar extends SystemUI implements DemoMode,
        }
        mNotificationPanel.setNoVisibleNotifications(visibleNotifications == 0);

        mStackScroller.changeViewPosition(mDismissView, mStackScroller.getChildCount() - 1);
        mStackScroller.changeViewPosition(mEmptyShadeView, mStackScroller.getChildCount() - 2);
        mStackScroller.changeViewPosition(mNotificationShelf, mStackScroller.getChildCount() - 3);
        // The following views will be moved to the end of mStackScroller. This counter represents
        // the offset from the last child. Initialized to 1 for the very last position. It is post-
        // incremented in the following "changeViewPosition" calls so that its value is correct for
        // subsequent calls.
        int offsetFromEnd = 1;
        if (mDismissView != null) {
            mStackScroller.changeViewPosition(mDismissView,
                    mStackScroller.getChildCount() - offsetFromEnd++);
        }

        mStackScroller.changeViewPosition(mEmptyShadeView,
                mStackScroller.getChildCount() - offsetFromEnd++);

        // No post-increment for this call because it is the last one. Make sure to add one if
        // another "changeViewPosition" call is ever added.
        mStackScroller.changeViewPosition(mNotificationShelf,
                mStackScroller.getChildCount() - offsetFromEnd);
    }

    public boolean shouldShowOnKeyguard(StatusBarNotification sbn) {
+14 −5
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import android.graphics.Rect;
import android.os.Bundle;
import android.os.Handler;
import android.service.notification.StatusBarNotification;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.util.FloatProperty;
import android.util.Log;
@@ -3574,7 +3575,9 @@ public class NotificationStackScrollLayout extends ViewGroup
    }

    public void goToFullShade(long delay) {
        if (mDismissView != null) {
            mDismissView.setInvisible();
        }
        mEmptyShadeView.setInvisible();
        mGoToFullShadeNeedsAnimation = true;
        mGoToFullShadeDelay = delay;
@@ -3701,7 +3704,7 @@ public class NotificationStackScrollLayout extends ViewGroup
        return -1;
    }

    public void setDismissView(DismissView dismissView) {
    public void setDismissView(@NonNull DismissView dismissView) {
        int index = -1;
        if (mDismissView != null) {
            index = indexOfChild(mDismissView);
@@ -3757,6 +3760,10 @@ public class NotificationStackScrollLayout extends ViewGroup
    }

    public void updateDismissView(boolean visible) {
        if (mDismissView == null) {
            return;
        }

        int oldVisibility = mDismissView.willBeGone() ? GONE : mDismissView.getVisibility();
        int newVisibility = visible ? VISIBLE : GONE;
        if (oldVisibility != newVisibility) {
@@ -3814,15 +3821,17 @@ public class NotificationStackScrollLayout extends ViewGroup
    }

    public boolean isDismissViewNotGone() {
        return mDismissView.getVisibility() != View.GONE && !mDismissView.willBeGone();
        return mDismissView != null
                && mDismissView.getVisibility() != View.GONE
                && !mDismissView.willBeGone();
    }

    public boolean isDismissViewVisible() {
        return mDismissView.isVisible();
        return mDismissView != null && mDismissView.isVisible();
    }

    public int getDismissViewHeight() {
        return mDismissView.getHeight() + mPaddingBetweenElements;
        return mDismissView == null ? 0 : mDismissView.getHeight() + mPaddingBetweenElements;
    }

    public int getEmptyShadeViewHeight() {