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

Commit a390648f authored by András Kurucz's avatar András Kurucz Committed by Android (Google) Code Review
Browse files

Merge "Convert HeadsUpEntry#isSensitive to a flow" into main

parents 54a1c633 3f8b4f96
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -118,7 +118,7 @@ public class HeadsUpStatusBarView extends AlphaOptimizedLinearLayout {

        if (mShowingEntry != null) {
            CharSequence text = entry.headsUpStatusBarText;
            if (entry.isSensitive()) {
            if (entry.isSensitive().getValue()) {
                text = entry.headsUpStatusBarTextPublic;
            }
            mTextView.setText(text);
+1 −1
Original line number Diff line number Diff line
@@ -396,7 +396,7 @@ constructor(
            }
            if (view is ExpandableNotificationRow) {
                // Only drag down on sensitive views, otherwise the ExpandHelper will take this
                return view.entry.isSensitive
                return view.entry.isSensitive.value
            }
        }
        return false
+13 −8
Original line number Diff line number Diff line
@@ -76,6 +76,10 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import kotlinx.coroutines.flow.MutableStateFlow;
import kotlinx.coroutines.flow.StateFlow;
import kotlinx.coroutines.flow.StateFlowKt;

/**
 * Represents a notification that the system UI knows about
 *
@@ -162,8 +166,8 @@ public final class NotificationEntry extends ListEntry {
     */
    private boolean hasSentReply;

    private boolean mSensitive = true;
    private ListenerSet<OnSensitivityChangedListener> mOnSensitivityChangedListeners =
    private final MutableStateFlow<Boolean> mSensitive = StateFlowKt.MutableStateFlow(true);
    private final ListenerSet<OnSensitivityChangedListener> mOnSensitivityChangedListeners =
            new ListenerSet<>();

    private boolean mPulseSupressed;
@@ -934,6 +938,11 @@ public final class NotificationEntry extends ListEntry {
        return Objects.equals(n.category, category);
    }

    /** @see #setSensitive(boolean, boolean)  */
    public StateFlow<Boolean> isSensitive() {
        return mSensitive;
    }

    /**
     * Set this notification to be sensitive.
     *
@@ -942,8 +951,8 @@ public final class NotificationEntry extends ListEntry {
     */
    public void setSensitive(boolean sensitive, boolean deviceSensitive) {
        getRow().setSensitive(sensitive, deviceSensitive);
        if (sensitive != mSensitive) {
            mSensitive = sensitive;
        if (sensitive != mSensitive.getValue()) {
            mSensitive.setValue(sensitive);
            for (NotificationEntry.OnSensitivityChangedListener listener :
                    mOnSensitivityChangedListeners) {
                listener.onSensitivityChanged(this);
@@ -951,10 +960,6 @@ public final class NotificationEntry extends ListEntry {
        }
    }

    public boolean isSensitive() {
        return mSensitive;
    }

    /** Add a listener to be notified when the entry's sensitivity changes. */
    public void addOnSensitivityChangedListener(OnSensitivityChangedListener listener) {
        mOnSensitivityChangedListeners.addIfAbsent(listener);
+5 −5
Original line number Diff line number Diff line
@@ -39,13 +39,13 @@ import com.android.systemui.statusbar.notification.InflationException
import com.android.systemui.statusbar.notification.collection.NotificationEntry
import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection
import com.android.systemui.statusbar.notification.collection.notifcollection.NotifCollectionListener
import java.util.concurrent.ConcurrentHashMap
import javax.inject.Inject
import kotlin.coroutines.CoroutineContext
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.util.concurrent.ConcurrentHashMap
import javax.inject.Inject
import kotlin.coroutines.CoroutineContext

/**
 * Inflates and updates icons associated with notifications
@@ -206,7 +206,7 @@ constructor(
    private fun getIconDescriptors(entry: NotificationEntry): Pair<StatusBarIcon, StatusBarIcon> {
        val iconDescriptor = getIconDescriptor(entry, redact = false)
        val sensitiveDescriptor =
            if (entry.isSensitive) {
            if (entry.isSensitive.value) {
                getIconDescriptor(entry, redact = true)
            } else {
                iconDescriptor
@@ -376,7 +376,7 @@ constructor(
        val isSmallIcon = iconDescriptor.icon.equals(entry.sbn.notification.smallIcon)
        return isImportantConversation(entry) &&
            !isSmallIcon &&
            (!usedInSensitiveContext || !entry.isSensitive)
            (!usedInSensitiveContext || !entry.isSensitive.value)
    }

    private fun isImportantConversation(entry: NotificationEntry): Boolean {
+1 −1
Original line number Diff line number Diff line
@@ -247,7 +247,7 @@ class StatusBarNotificationPresenter implements NotificationPresenter, CommandQu
        if (nowExpanded) {
            if (mStatusBarStateController.getState() == StatusBarState.KEYGUARD) {
                mShadeTransitionController.goToLockedShade(clickedEntry.getRow());
            } else if (clickedEntry.isSensitive()
            } else if (clickedEntry.isSensitive().getValue()
                    && mDynamicPrivacyController.isInLockedDownShade()) {
                mStatusBarStateController.setLeaveOpenOnKeyguardHide(true);
                mActivityStarter.dismissKeyguardThenExecute(() -> false /* dismissAction */