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

Commit 628a0ae6 authored by Selim Cinek's avatar Selim Cinek Committed by Android (Google) Code Review
Browse files

Merge "Collapsing the heads up when showing the bouncer" into qt-r1-dev

parents 5c0932cf a678b0ee
Loading
Loading
Loading
Loading
+21 −2
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import com.android.systemui.statusbar.phone.DozeParameters
import com.android.systemui.statusbar.phone.HeadsUpManagerPhone
import com.android.systemui.statusbar.phone.KeyguardBypassController
import com.android.systemui.statusbar.phone.NotificationIconAreaController
import com.android.systemui.statusbar.phone.PanelExpansionListener
import com.android.systemui.statusbar.policy.OnHeadsUpChangedListener

import javax.inject.Inject
@@ -40,7 +41,8 @@ class NotificationWakeUpCoordinator @Inject constructor(
        private val mHeadsUpManagerPhone: HeadsUpManagerPhone,
        private val statusBarStateController: StatusBarStateController,
        private val bypassController: KeyguardBypassController)
    : OnHeadsUpChangedListener, StatusBarStateController.StateListener {
    : OnHeadsUpChangedListener, StatusBarStateController.StateListener,
        PanelExpansionListener {

    private val mNotificationVisibility
            = object : FloatProperty<NotificationWakeUpCoordinator>("notificationVisibility") {
@@ -98,7 +100,9 @@ class NotificationWakeUpCoordinator @Inject constructor(
            }
        }

    private var collapsedEnoughToHide: Boolean = false
    lateinit var iconAreaController : NotificationIconAreaController

    var pulsing: Boolean = false
        set(value) {
            field = value
@@ -120,7 +124,6 @@ class NotificationWakeUpCoordinator @Inject constructor(
                }
            }
        }

    /**
     * True if we can show pulsing heads up notifications
     */
@@ -132,6 +135,10 @@ class NotificationWakeUpCoordinator @Inject constructor(
                // We also allow pulsing on the lock screen!
                canShow = canShow || (wakingUp || willWakeUp || fullyAwake)
                        && statusBarStateController.state == StatusBarState.KEYGUARD
                // We want to hide the notifications when collapsed too much
                if (collapsedEnoughToHide) {
                    canShow = false
                }
            }
            return canShow
        }
@@ -247,6 +254,18 @@ class NotificationWakeUpCoordinator @Inject constructor(
        this.state = newState
    }

    override fun onPanelExpansionChanged(expansion: Float, tracking: Boolean) {
        val collapsedEnough = expansion <= 0.9f
        if (collapsedEnough != this.collapsedEnoughToHide) {
            val couldShowPulsingHuns = canShowPulsingHuns;
            this.collapsedEnoughToHide = collapsedEnough
            if (couldShowPulsingHuns && !canShowPulsingHuns) {
                updateNotificationVisibility(animate = true, increaseSpeed = true)
                mHeadsUpManagerPhone.releaseAllImmediately()
            }
        }
    }

    private fun updateDozeAmountIfBypass(): Boolean {
        if (bypassController.bypassEnabled) {
            var amount = 1.0f;
+20 −8
Original line number Diff line number Diff line
@@ -323,14 +323,24 @@ public class LockIcon extends KeyguardAffordanceView implements OnUserInfoChange
        }
        updateDarkTint();

        updateIconVisibility();
        updateClickability();

        return true;
    }

    /**
     * Update the icon visibility
     * @return true if the visibility changed
     */
    private boolean updateIconVisibility() {
        boolean onAodNotPulsingOrDocked = mDozing && (!mPulsing || mDocked);
        boolean invisible = onAodNotPulsingOrDocked || mWakeAndUnlockRunning
                || mShowingLaunchAffordance;
        if (mBypassController.getBypassEnabled() && !mBouncerShowingScrimmed) {
            if (mHeadsUpManager.isHeadsUpGoingAway()
                    || mHeadsUpManager.hasPinnedHeadsUp()
                    || (mStatusBarStateController.getState() == StatusBarState.KEYGUARD
                    && !mWakeUpCoordinator.getNotificationsFullyHidden())) {
            if ((mHeadsUpManager.isHeadsUpGoingAway() || mHeadsUpManager.hasPinnedHeadsUp())
                    && mStatusBarStateController.getState() == StatusBarState.KEYGUARD
                    && !mWakeUpCoordinator.getNotificationsFullyHidden()) {
                invisible = true;
            }
        }
@@ -349,11 +359,10 @@ public class LockIcon extends KeyguardAffordanceView implements OnUserInfoChange
                        .setDuration(233)
                        .start();
            }
        }
        updateClickability();

            return true;
        }
        return false;
    }

    private boolean canBlockUpdates() {
        return mKeyguardShowing || mKeyguardMonitor.isKeyguardFadingAway();
@@ -440,9 +449,12 @@ public class LockIcon extends KeyguardAffordanceView implements OnUserInfoChange
    @Override
    public void onFullyHiddenChanged(boolean isFullyHidden) {
        if (mBypassController.getBypassEnabled()) {
            boolean changed = updateIconVisibility();
            if (changed) {
                update();
            }
        }
    }

    public void setBouncerShowingScrimmed(boolean bouncerShowing) {
        mBouncerShowingScrimmed = bouncerShowing;
+2 −22
Original line number Diff line number Diff line
@@ -1723,8 +1723,8 @@ public class NotificationPanelView extends PanelView implements
            mStatusBar.executeRunnableDismissingKeyguard(null, null /* cancelAction */,
                    false /* dismissShade */, true /* afterKeyguardGone */, false /* deferred */);
        }
        if (mExpansionListener != null) {
            mExpansionListener.onQsExpansionChanged(mQsMaxExpansionHeight != 0
        for (int i = 0; i < mExpansionListeners.size(); i++) {
            mExpansionListeners.get(i).onQsExpansionChanged(mQsMaxExpansionHeight != 0
                    ? mQsExpansionHeight / mQsMaxExpansionHeight : 0);
        }
        if (DEBUG) {
@@ -3380,24 +3380,4 @@ public class NotificationPanelView extends PanelView implements
        mOnReinflationListener = onReinflationListener;
    }

    /**
     * Panel and QS expansion callbacks.
     */
    public interface PanelExpansionListener {
        /**
         * Invoked whenever the notification panel expansion changes, at every animation frame.
         * This is the main expansion that happens when the user is swiping up to dismiss the
         * lock screen.
         *
         * @param expansion 0 when collapsed, 1 when expanded.
         * @param tracking {@code true} when the user is actively dragging the panel.
         */
        void onPanelExpansionChanged(float expansion, boolean tracking);

        /**
         * Invoked whenever the QS expansion changes, at every animation frame.
         * @param expansion 0 when collapsed, 1 when expanded.
         */
        void onQsExpansionChanged(float expansion);
    }
}
+38 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 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.statusbar.phone;

/**
 * Panel and QS expansion callbacks.
 */
public interface PanelExpansionListener {
    /**
     * Invoked whenever the notification panel expansion changes, at every animation frame.
     * This is the main expansion that happens when the user is swiping up to dismiss the
     * lock screen.
     *
     * @param expansion 0 when collapsed, 1 when expanded.
     * @param tracking {@code true} when the user is actively dragging the panel.
     */
    void onPanelExpansionChanged(float expansion, boolean tracking);

    /**
     * Invoked whenever the QS expansion changes, at every animation frame.
     * @param expansion 0 when collapsed, 1 when expanded.
     */
    default void onQsExpansionChanged(float expansion) {};
}
+6 −6
Original line number Diff line number Diff line
@@ -50,11 +50,11 @@ import com.android.systemui.statusbar.FlingAnimationUtils;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.SysuiStatusBarStateController;
import com.android.systemui.statusbar.VibratorHelper;
import com.android.systemui.statusbar.phone.NotificationPanelView.PanelExpansionListener;
import com.android.systemui.statusbar.policy.KeyguardMonitor;

import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;

public abstract class PanelView extends FrameLayout {
    public static final boolean DEBUG = PanelBar.DEBUG;
@@ -69,7 +69,7 @@ public abstract class PanelView extends FrameLayout {
    private boolean mVibrateOnOpening;
    protected boolean mLaunchingNotification;
    private int mFixedDuration = NO_FIXED_DURATION;
    protected PanelExpansionListener mExpansionListener;
    protected ArrayList<PanelExpansionListener> mExpansionListeners = new ArrayList<>();

    private final void logf(String fmt, Object... args) {
        Log.v(TAG, (mViewName != null ? (mViewName + ": ") : "") + String.format(fmt, args));
@@ -1174,13 +1174,13 @@ public abstract class PanelView extends FrameLayout {
                    || mPeekAnimator != null || mInstantExpanding
                    || isPanelVisibleBecauseOfHeadsUp() || mTracking || mHeightAnimator != null);
        }
        if (mExpansionListener != null) {
            mExpansionListener.onPanelExpansionChanged(mExpandedFraction, mTracking);
        for (int i = 0; i < mExpansionListeners.size(); i++) {
            mExpansionListeners.get(i).onPanelExpansionChanged(mExpandedFraction, mTracking);
        }
    }

    public void setExpansionListener(PanelExpansionListener panelExpansionListener) {
        mExpansionListener = panelExpansionListener;
    public void addExpansionListener(PanelExpansionListener panelExpansionListener) {
        mExpansionListeners.add(panelExpansionListener);
    }

    protected abstract boolean isPanelVisibleBecauseOfHeadsUp();
Loading