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

Commit 8ebb9d33 authored by Jay Aliomer's avatar Jay Aliomer Committed by Automerger Merge Worker
Browse files

Enabled x button for clearable silent Notif[s] am: 5e6673f9

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16150089

Change-Id: I3da83d270dd114a848181b0c88af921b99f92326
parents 80633cee 5e6673f9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ public abstract class ListEntry {
    private final ListAttachState mPreviousAttachState = ListAttachState.create();
    private final ListAttachState mAttachState = ListAttachState.create();

    ListEntry(String key, long creationTime) {
    protected ListEntry(String key, long creationTime) {
        mKey = key;
        mCreationTime = creationTime;
    }
+23 −3
Original line number Diff line number Diff line
@@ -78,6 +78,8 @@ public class ShadeListBuilder implements Dumpable {
    private final SystemClock mSystemClock;
    private final ShadeListBuilderLogger mLogger;
    private final NotificationInteractionTracker mInteractionTracker;
    // used exclusivly by ShadeListBuilder#notifySectionEntriesUpdated
    private final ArrayList<ListEntry> mTempSectionMembers = new ArrayList<>();

    private List<ListEntry> mNotifList = new ArrayList<>();
    private List<ListEntry> mNewNotifList = new ArrayList<>();
@@ -356,7 +358,7 @@ public class ShadeListBuilder implements Dumpable {
        // section by our list of custom comparators
        dispatchOnBeforeSort(mReadOnlyNotifList);
        mPipelineState.incrementTo(STATE_SORTING);
        sortList();
        sortListAndNotifySections();

        // Step 7: Lock in our group structure and log anything that's changed since the last run
        mPipelineState.incrementTo(STATE_FINALIZING);
@@ -382,6 +384,22 @@ public class ShadeListBuilder implements Dumpable {
        mIterationCount++;
    }

    private void notifySectionEntriesUpdated() {
        NotifSection currentSection = null;
        mTempSectionMembers.clear();
        for (int i = 0; i < mNotifList.size(); i++) {
            ListEntry currentEntry = mNotifList.get(i);
            if (currentSection != currentEntry.getSection()) {
                if (currentSection != null) {
                    currentSection.getSectioner().onEntriesUpdated(mTempSectionMembers);
                    mTempSectionMembers.clear();
                }
                currentSection = currentEntry.getSection();
            }
            mTempSectionMembers.add(currentEntry);
        }
    }

    /**
     * Points mNotifList to the list stored in mNewNotifList.
     * Reuses the (emptied) mNotifList as mNewNotifList.
@@ -713,7 +731,7 @@ public class ShadeListBuilder implements Dumpable {
        }
    }

    private void sortList() {
    private void sortListAndNotifySections() {
        // Assign sections to top-level elements and sort their children
        for (ListEntry entry : mNotifList) {
            NotifSection section = applySections(entry);
@@ -728,6 +746,9 @@ public class ShadeListBuilder implements Dumpable {

        // Finally, sort all top-level elements
        mNotifList.sort(mTopLevelComparator);

        // notify sections since the list is sorted now
        notifySectionEntriesUpdated();
    }

    private void freeEmptyGroups() {
@@ -937,7 +958,6 @@ public class ShadeListBuilder implements Dumpable {
        }

        entry.getAttachState().setSection(finalSection);

        return finalSection;
    }

+22 −3
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.statusbar.notification.collection.coordinator;

import android.annotation.NonNull;
import android.annotation.Nullable;

import com.android.systemui.dagger.SysUISingleton;
@@ -27,9 +28,12 @@ import com.android.systemui.statusbar.notification.collection.listbuilder.plugga
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifSectioner;
import com.android.systemui.statusbar.notification.collection.provider.HighPriorityProvider;
import com.android.systemui.statusbar.notification.collection.render.NodeController;
import com.android.systemui.statusbar.notification.collection.render.SectionHeaderController;
import com.android.systemui.statusbar.notification.dagger.AlertingHeader;
import com.android.systemui.statusbar.notification.dagger.SilentHeader;

import java.util.List;

import javax.inject.Inject;

/**
@@ -44,7 +48,8 @@ public class RankingCoordinator implements Coordinator {
    public static final boolean SHOW_ALL_SECTIONS = false;
    private final StatusBarStateController mStatusBarStateController;
    private final HighPriorityProvider mHighPriorityProvider;
    private final NodeController mSilentHeaderController;
    private final NodeController mSilentNodeController;
    private final SectionHeaderController mSilentHeaderController;
    private final NodeController mAlertingHeaderController;

    @Inject
@@ -52,10 +57,12 @@ public class RankingCoordinator implements Coordinator {
            StatusBarStateController statusBarStateController,
            HighPriorityProvider highPriorityProvider,
            @AlertingHeader NodeController alertingHeaderController,
            @SilentHeader NodeController silentHeaderController) {
            @SilentHeader SectionHeaderController silentHeaderController,
            @SilentHeader NodeController silentNodeController) {
        mStatusBarStateController = statusBarStateController;
        mHighPriorityProvider = highPriorityProvider;
        mAlertingHeaderController = alertingHeaderController;
        mSilentNodeController = silentNodeController;
        mSilentHeaderController = silentHeaderController;
    }

@@ -101,7 +108,19 @@ public class RankingCoordinator implements Coordinator {
        @Nullable
        @Override
        public NodeController getHeaderNodeController() {
            return mSilentHeaderController;
            return mSilentNodeController;
        }

        @Nullable
        @Override
        public void onEntriesUpdated(@NonNull List<ListEntry> entries) {
            for (int i = 0; i < entries.size(); i++) {
                if (entries.get(i).getRepresentativeEntry().getSbn().isClearable()) {
                    mSilentHeaderController.setClearSectionEnabled(true);
                    return;
                }
            }
            mSilentHeaderController.setClearSectionEnabled(false);
        }
    };

+8 −0
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ import com.android.systemui.statusbar.notification.collection.ShadeListBuilder;
import com.android.systemui.statusbar.notification.collection.render.NodeController;
import com.android.systemui.statusbar.notification.collection.render.NodeSpec;

import java.util.List;

/**
 * Pluggable for participating in notif sectioning. See {@link ShadeListBuilder#setSections}.
 */
@@ -46,4 +48,10 @@ public abstract class NotifSectioner extends Pluggable<NotifSectioner> {
    public @Nullable NodeController getHeaderNodeController() {
        return null;
    }

    /**
     * Notify of children of this section being updated
     * @param entries of this section that are borrowed (must clone to store)
     */
    public void onEntriesUpdated(List<ListEntry> entries) {}
}
+10 −2
Original line number Diff line number Diff line
@@ -33,7 +33,8 @@ import javax.inject.Inject
interface SectionHeaderController {
    fun reinflateView(parent: ViewGroup)
    val headerView: SectionHeaderView?
    fun setOnClearAllClickListener(listener: View.OnClickListener)
    fun setClearSectionEnabled(enabled: Boolean)
    fun setOnClearSectionClickListener(listener: View.OnClickListener)
}

@SectionHeaderScope
@@ -46,6 +47,7 @@ internal class SectionHeaderNodeControllerImpl @Inject constructor(
) : NodeController, SectionHeaderController {

    private var _view: SectionHeaderView? = null
    private var clearAllButtonEnabled = false
    private var clearAllClickListener: View.OnClickListener? = null
    private val onHeaderClickListener = View.OnClickListener {
        activityStarter.startActivity(
@@ -76,12 +78,18 @@ internal class SectionHeaderNodeControllerImpl @Inject constructor(
            parent.addView(inflated, oldPos)
        }
        _view = inflated
        _view?.setClearSectionButtonEnabled(clearAllButtonEnabled)
    }

    override val headerView: SectionHeaderView?
        get() = _view

    override fun setOnClearAllClickListener(listener: View.OnClickListener) {
    override fun setClearSectionEnabled(enabled: Boolean) {
        clearAllButtonEnabled = enabled
        _view?.setClearSectionButtonEnabled(enabled)
    }

    override fun setOnClearSectionClickListener(listener: View.OnClickListener) {
        clearAllClickListener = listener
        _view?.setOnClearAllClickListener(listener)
    }
Loading