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

Commit a5eb4588 authored by Ibrahim Yilmaz's avatar Ibrahim Yilmaz Committed by Android (Google) Code Review
Browse files

Merge "Revert "Delete ShadeFullExpansionListener"" into main

parents 6c4553d3 089c7b6c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2629,6 +2629,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
        if (isPanelExpanded() != isExpanded) {
            setExpandedOrAwaitingInputTransfer(isExpanded);
            updateSystemUiStateFlags();
            mShadeExpansionStateManager.onShadeExpansionFullyChanged(isExpanded);
            if (!isExpanded) {
                mQsController.closeQsCustomizer();
            }
+22 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import javax.inject.Inject
class ShadeExpansionStateManager @Inject constructor() : ShadeStateEvents {

    private val expansionListeners = CopyOnWriteArrayList<ShadeExpansionListener>()
    private val fullExpansionListeners = CopyOnWriteArrayList<ShadeFullExpansionListener>()
    private val qsExpansionListeners = CopyOnWriteArrayList<ShadeQsExpansionListener>()
    private val qsExpansionFractionListeners =
        CopyOnWriteArrayList<ShadeQsExpansionFractionListener>()
@@ -66,6 +67,15 @@ class ShadeExpansionStateManager @Inject constructor() : ShadeStateEvents {
        expansionListeners.remove(listener)
    }

    fun addFullExpansionListener(listener: ShadeFullExpansionListener) {
        fullExpansionListeners.add(listener)
        listener.onShadeExpansionFullyChanged(qsExpanded)
    }

    fun removeFullExpansionListener(listener: ShadeFullExpansionListener) {
        fullExpansionListeners.remove(listener)
    }

    fun addQsExpansionListener(listener: ShadeQsExpansionListener) {
        qsExpansionListeners.add(listener)
        listener.onQsExpansionChanged(qsExpanded)
@@ -89,6 +99,11 @@ class ShadeExpansionStateManager @Inject constructor() : ShadeStateEvents {
        stateListeners.add(listener)
    }

    /** Removes a state listener. */
    fun removeStateListener(listener: ShadeStateListener) {
        stateListeners.remove(listener)
    }

    override fun addShadeStateEventsListener(listener: ShadeStateEventsListener) {
        shadeStateEventsListeners.addIfAbsent(listener)
    }
@@ -181,6 +196,13 @@ class ShadeExpansionStateManager @Inject constructor() : ShadeStateEvents {
        }
    }

    fun onShadeExpansionFullyChanged(isExpanded: Boolean) {
        this.expanded = isExpanded

        debugLog("expanded=$isExpanded")
        fullExpansionListeners.forEach { it.onShadeExpansionFullyChanged(isExpanded) }
    }

    /** Updates the panel state if necessary. */
    fun updateState(@PanelState state: Int) {
        debugLog(
+23 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.shade

/** A listener interface to be notified of expansion events for the notification shade. */
fun interface ShadeFullExpansionListener {
    /** Invoked whenever the shade expansion changes, when it is fully collapsed or expanded */
    fun onShadeExpansionFullyChanged(isExpanded: Boolean)
}
+6 −7
Original line number Diff line number Diff line
@@ -148,13 +148,12 @@ constructor(
     *
     * TODO(b/300258424) remove all but the first sentence of this comment
     */
    val isAnyExpanded: StateFlow<Boolean> =
    val isAnyExpanded: Flow<Boolean> =
        if (sceneContainerFlags.isEnabled()) {
            anyExpansion.map { it > 0f }.distinctUntilChanged()
        } else {
            repository.legacyExpandedOrAwaitingInputTransfer
        }
            .stateIn(scope, SharingStarted.Eagerly, false)

    /**
     * Whether the user is expanding or collapsing the shade with user input. This will be true even
@@ -185,7 +184,7 @@ constructor(
     * but a transition they initiated is still animating.
     */
    val isUserInteracting: Flow<Boolean> =
        combine(isUserInteractingWithShade, isUserInteractingWithQs) { shade, qs -> shade || qs }
        combine(isUserInteractingWithShade, isUserInteractingWithShade) { shade, qs -> shade || qs }
            .distinctUntilChanged()

    /** Are touches allowed on the notification panel? */
+4 −28
Original line number Diff line number Diff line
@@ -48,12 +48,11 @@ import androidx.annotation.Nullable;

import com.android.internal.statusbar.IStatusBarService;
import com.android.internal.statusbar.NotificationVisibility;
import com.android.systemui.CoreStartable;
import com.android.systemui.Dumpable;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.power.domain.interactor.PowerInteractor;
import com.android.systemui.res.R;
import com.android.systemui.shade.domain.interactor.ShadeInteractor;
import com.android.systemui.statusbar.dagger.CentralSurfacesDependenciesModule;
import com.android.systemui.statusbar.notification.NotifPipelineFlags;
import com.android.systemui.statusbar.notification.RemoteInputControllerLogger;
@@ -66,7 +65,6 @@ import com.android.systemui.statusbar.policy.RemoteInputUriController;
import com.android.systemui.statusbar.policy.RemoteInputView;
import com.android.systemui.util.DumpUtilsKt;
import com.android.systemui.util.ListenerSet;
import com.android.systemui.util.kotlin.JavaAdapter;

import java.io.PrintWriter;
import java.util.ArrayList;
@@ -80,7 +78,7 @@ import java.util.function.Consumer;
 * interaction, keeping track of notifications to remove when NotificationPresenter is collapsed,
 * and handling clicks on remote views.
 */
public class NotificationRemoteInputManager implements CoreStartable {
public class NotificationRemoteInputManager implements Dumpable {
    public static final boolean ENABLE_REMOTE_INPUT =
            SystemProperties.getBoolean("debug.enable_remote_input", true);
    public static boolean FORCE_REMOTE_INPUT_HISTORY =
@@ -96,8 +94,6 @@ public class NotificationRemoteInputManager implements CoreStartable {
    private final NotificationVisibilityProvider mVisibilityProvider;
    private final PowerInteractor mPowerInteractor;
    private final ActionClickLogger mLogger;
    private final JavaAdapter mJavaAdapter;
    private final ShadeInteractor mShadeInteractor;
    protected final Context mContext;
    protected final NotifPipelineFlags mNotifPipelineFlags;
    private final UserManager mUserManager;
@@ -265,8 +261,7 @@ public class NotificationRemoteInputManager implements CoreStartable {
            RemoteInputControllerLogger remoteInputControllerLogger,
            NotificationClickNotifier clickNotifier,
            ActionClickLogger logger,
            JavaAdapter javaAdapter,
            ShadeInteractor shadeInteractor) {
            DumpManager dumpManager) {
        mContext = context;
        mNotifPipelineFlags = notifPipelineFlags;
        mLockscreenUserManager = lockscreenUserManager;
@@ -274,8 +269,6 @@ public class NotificationRemoteInputManager implements CoreStartable {
        mVisibilityProvider = visibilityProvider;
        mPowerInteractor = powerInteractor;
        mLogger = logger;
        mJavaAdapter = javaAdapter;
        mShadeInteractor = shadeInteractor;
        mBarService = IStatusBarService.Stub.asInterface(
                ServiceManager.getService(Context.STATUS_BAR_SERVICE));
        mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
@@ -284,25 +277,8 @@ public class NotificationRemoteInputManager implements CoreStartable {
        mRemoteInputUriController = remoteInputUriController;
        mRemoteInputControllerLogger = remoteInputControllerLogger;
        mClickNotifier = clickNotifier;
    }

    @Override
    public void start() {
        mJavaAdapter.alwaysCollectFlow(mShadeInteractor.isAnyExpanded(),
                this::onShadeOrQsExpanded);
    }

    private void onShadeOrQsExpanded(boolean expanded) {
        if (expanded && mStatusBarStateController.getState() != StatusBarState.KEYGUARD) {
            try {
                mBarService.clearNotificationEffects();
            } catch (RemoteException e) {
                // Won't fail unless the world has ended.
            }
        }
        if (!expanded) {
            onPanelCollapsed();
        }
        dumpManager.registerDumpable(this);
    }

    /** Add a listener for various remote input events.  Works with NEW pipeline only. */
Loading