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

Commit 0db9a678 authored by Jorim Jaggi's avatar Jorim Jaggi Committed by Android Git Automerger
Browse files

am a0437d35: Merge "Hide header when notifications collide with it on...

am a0437d35: Merge "Hide header when notifications collide with it on Keyguard." into lmp-preview-dev

* commit 'a0437d355a853adb5023ab0885952620d0cf4f07':
  Hide header when notifications collide with it on Keyguard.
parents 1044046a 03bce432
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -319,6 +319,9 @@
    <!-- Volume panel z depth -->
    <dimen name="volume_panel_z">3dp</dimen>

    <!-- Distance between notifications and header when they are considered to be colliding. -->
    <dimen name="header_notifications_collide_distance">24dp</dimen>

    <!-- Move distance for the hint animations on the lockscreen (unlock, phone, camera)-->
    <dimen name="hint_move_distance">75dp</dimen>
</resources>
+48 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.Configuration;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
@@ -91,8 +92,12 @@ public class NotificationPanelView extends PanelView implements
    private ValueAnimator mQsExpansionAnimator;
    private FlingAnimationUtils mFlingAnimationUtils;
    private int mStatusBarMinHeight;
    private boolean mHeaderHidden;
    private int mNotificationsHeaderCollideDistance;

    private Interpolator mFastOutSlowInInterpolator;
    private Interpolator mFastOutLinearInterpolator;
    private Interpolator mLinearOutSlowInInterpolator;
    private ObjectAnimator mClockAnimator;
    private int mClockAnimationTarget = -1;
    private int mTopPaddingAdjustment;
@@ -143,6 +148,10 @@ public class NotificationPanelView extends PanelView implements
        mNotificationStackScroller.setOverscrollTopChangedListener(this);
        mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(getContext(),
                android.R.interpolator.fast_out_slow_in);
        mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(getContext(),
                android.R.interpolator.linear_out_slow_in);
        mFastOutLinearInterpolator = AnimationUtils.loadInterpolator(getContext(),
                android.R.interpolator.fast_out_linear_in);
        mKeyguardBottomArea = (KeyguardBottomAreaView) findViewById(R.id.keyguard_bottom_area);
        mSwipeTranslationViews.add(mNotificationStackScroller);
        mSwipeTranslationViews.add(mKeyguardStatusView);
@@ -159,6 +168,8 @@ public class NotificationPanelView extends PanelView implements
        mStatusBarMinHeight = getResources().getDimensionPixelSize(
                com.android.internal.R.dimen.status_bar_height);
        mQsPeekHeight = getResources().getDimensionPixelSize(R.dimen.qs_peek_height);
        mNotificationsHeaderCollideDistance =
                getResources().getDimensionPixelSize(R.dimen.header_notifications_collide_distance);
        mClockPositionAlgorithm.loadDimens(getResources());
    }

@@ -708,6 +719,43 @@ public class NotificationPanelView extends PanelView implements
            positionClockAndNotifications();
        }
        mNotificationStackScroller.setStackHeight(expandedHeight);
        updateKeyguardHeaderVisibility();
    }

    /**
     * Hides the header when notifications are colliding with it.
     */
    private void updateKeyguardHeaderVisibility() {
        if (mStatusBar.getBarState() == StatusBarState.KEYGUARD
                || mStatusBar.getBarState() == StatusBarState.SHADE_LOCKED) {
            boolean hidden = mNotificationStackScroller.getNotificationsTopY()
                    <= mHeader.getBottom() + mNotificationsHeaderCollideDistance;
            if (hidden && !mHeaderHidden) {
                mHeader.animate()
                        .alpha(0f)
                        .withLayer()
                        .translationY(-mHeader.getHeight()/2)
                        .setInterpolator(mFastOutLinearInterpolator)
                        .setDuration(200);
            } else if (!hidden && mHeaderHidden) {
                mHeader.animate()
                        .alpha(1f)
                        .withLayer()
                        .translationY(0)
                        .setInterpolator(mLinearOutSlowInInterpolator)
                        .setDuration(200);
            }
            mHeaderHidden = hidden;
        } else {
            mHeader.animate().cancel();
            mHeader.setAlpha(1f);
            mHeader.setTranslationY(0f);
            if (mHeader.getLayerType() != LAYER_TYPE_NONE) {
                mHeader.setLayerType(LAYER_TYPE_NONE, null);
            }
            mHeaderHidden = false;
        }

    }

    @Override
+7 −0
Original line number Diff line number Diff line
@@ -1608,6 +1608,13 @@ public class NotificationStackScrollLayout extends ViewGroup
        updateSpeedBump(true);
    }

    /**
     * @return the y position of the first notification
     */
    public float getNotificationsTopY() {
        return mTopPadding + getTranslationY();
    }

    /**
     * A listener that is notified when some child locations might have changed.
     */