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

Commit 48ff9b48 authored by Selim Cinek's avatar Selim Cinek
Browse files

Improved the transition into the statusbar

When expanding, the shelf now transforms into
the statusbar, providing a more seemless transition.

This also modifies the panel peeking:
previously the panel was always peeking right after a tap timeout
which would take the panel away from the users finger.
The panel is now only peeking when the user clicked on the bar instead.

Test: Add some notification and collapse the panel. Observe nicer transition
Bug: 32437839
Change-Id: I772f6684e1cee2004e9b366d203a5c5188af4a93
parent 0242fbb9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@
    <LinearLayout android:id="@+id/status_bar_contents"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingStart="6dp"
        android:paddingStart="@dimen/status_bar_padding_start"
        android:paddingEnd="8dp"
        android:orientation="horizontal"
        >
+3 −0
Original line number Diff line number Diff line
@@ -109,6 +109,9 @@
    <!-- gap on either side of status bar notification icons -->
    <dimen name="status_bar_icon_padding">0dp</dimen>

    <!-- the padding on the start of the statusbar -->
    <dimen name="status_bar_padding_start">6dp</dimen>

    <!-- The padding on the global screenshot background image -->
    <dimen name="global_screenshot_bg_padding">20dp</dimen>

+20 −0
Original line number Diff line number Diff line
@@ -50,6 +50,8 @@ public class NotificationShelf extends ActivatableNotificationView {
    private int[] mTmp = new int[2];
    private boolean mHideBackground;
    private int mIconAppearTopPadding;
    private int mStatusBarHeight;
    private int mStatusBarPaddingStart;

    public NotificationShelf(Context context, AttributeSet attrs) {
        super(context, attrs);
@@ -75,6 +77,9 @@ public class NotificationShelf extends ActivatableNotificationView {
    private void initDimens() {
        mIconAppearTopPadding = getResources().getDimensionPixelSize(
                R.dimen.notification_icon_appear_padding);
        mStatusBarHeight = getResources().getDimensionPixelOffset(R.dimen.status_bar_height);
        mStatusBarPaddingStart = getResources().getDimensionPixelOffset(
                R.dimen.status_bar_padding_start);
    }

    @Override
@@ -124,6 +129,11 @@ public class NotificationShelf extends ActivatableNotificationView {
            mShelfState.yTranslation = Math.min(viewEnd, maxShelfEnd) - mShelfState.height;
            mShelfState.zTranslation = Math.max(mShelfState.zTranslation,
                    ambientState.getBaseZHeight());
            float openedAmount = (mShelfState.yTranslation - getFullyClosedTranslation())
                    / (getIntrinsicHeight() * 2);
            openedAmount = Math.min(1.0f, openedAmount);
            mShelfState.iconContainerTranslation = (1.0f - openedAmount)
                    * (mStatusBarPaddingStart - mNotificationIconContainer.getLeft());
            mShelfState.clipTopAmount = 0;
            mShelfState.alpha = 1.0f;
            mShelfState.belowShelf = false;
@@ -173,6 +183,10 @@ public class NotificationShelf extends ActivatableNotificationView {
        }
    }

    private float getFullyClosedTranslation() {
        return - (getIntrinsicHeight() - mStatusBarHeight) / 2;
    }

    private void updateIconAppearance(NotificationData.Entry entry,
            ExpandableNotificationRow.NotificationViewState rowState,
            ShelfState shelfState) {
@@ -254,15 +268,21 @@ public class NotificationShelf extends ActivatableNotificationView {
        return super.shouldHideBackground() || mHideBackground;
    }

    private void setIconContainerTranslation(float iconContainerTranslation) {
        mNotificationIconContainer.setTranslationX(iconContainerTranslation);
    }

    private class ShelfState extends ExpandableViewState {
        private WeakHashMap<View, ViewState> iconStates = new WeakHashMap<>();
        private boolean hideBackground;
        private float iconContainerTranslation;

        @Override
        public void applyToView(View view) {
            super.applyToView(view);
            mNotificationIconContainer.applyIconStates(iconStates);
            setHideBackground(hideBackground);
            setIconContainerTranslation(iconContainerTranslation);
        }

        public void resetIcons() {
+37 −5
Original line number Diff line number Diff line
@@ -207,6 +207,7 @@ public class NotificationPanelView extends PanelView implements
        }
    };
    private NotificationGroupManager mGroupManager;
    private boolean mOpening;

    public NotificationPanelView(Context context, AttributeSet attrs) {
        super(context, attrs);
@@ -557,9 +558,7 @@ public class NotificationPanelView extends PanelView implements
    protected void flingToHeight(float vel, boolean expand, float target,
            float collapseSpeedUpFactor, boolean expandBecauseOfFalsing) {
        mHeadsUpTouchHelper.notifyFling(!expand);
        setClosingWithAlphaFadeout(!expand
                && mNotificationStackScroller.getFirstChildIntrinsicHeight() <= mMaxFadeoutHeight
                && getFadeoutAlpha() == 1.0f);
        setClosingWithAlphaFadeout(!expand && getFadeoutAlpha() == 1.0f);
        super.flingToHeight(vel, expand, target, collapseSpeedUpFactor, expandBecauseOfFalsing);
    }

@@ -733,6 +732,11 @@ public class NotificationPanelView extends PanelView implements
                / (getTempQsMaxExpansion() - mQsMinExpansionHeight));
    }

    @Override
    protected float getOpeningHeight() {
        return mNotificationStackScroller.getMinExpansionHeight();
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (mBlockTouches || (mQs != null && mQs.isCustomizing())) {
@@ -1426,7 +1430,7 @@ public class NotificationPanelView extends PanelView implements
            if (mKeyguardShowing) {

                // On Keyguard, interpolate the QS expansion linearly to the panel expansion
                t = expandedHeight / getMaxPanelHeight();
                t = expandedHeight / (getMaxPanelHeight());
            } else {

                // In Shade, interpolate linearly such that QS is closed whenever panel height is
@@ -2276,6 +2280,14 @@ public class NotificationPanelView extends PanelView implements
    protected void updateExpandedHeight(float expandedHeight) {
        mNotificationStackScroller.setExpandedHeight(expandedHeight);
        updateKeyguardBottomAreaAlpha();
        setOpening(expandedHeight <= getOpeningHeight());
    }

    private void setOpening(boolean opening) {
        if (opening != mOpening) {
            mOpening = opening;
            mStatusBar.recomputeDisableFlags(false);
        }
    }

    public void setPanelScrimMinFraction(float minFraction) {
@@ -2327,7 +2339,18 @@ public class NotificationPanelView extends PanelView implements
    @Override
    public void setAlpha(float alpha) {
        super.setAlpha(alpha);
        mNotificationStackScroller.setParentFadingOut(alpha != 1.0f);
        updateFullyVisibleState();
    }

    @Override
    public void setVisibility(int visibility) {
        super.setVisibility(visibility);
        updateFullyVisibleState();
    }

    private void updateFullyVisibleState() {
        mNotificationStackScroller.setParentNotFullyVisible(getAlpha() != 1.0f
                || getVisibility() != VISIBLE);
    }

    /**
@@ -2369,6 +2392,15 @@ public class NotificationPanelView extends PanelView implements
        mGroupManager = groupManager;
    }

    public boolean shouldHideNotificationIcons() {
        return !mOpening && !isFullyCollapsed();
    }

    public boolean shouldAnimateIconHiding() {
        // TODO: handle this correctly, not completely working yet
        return mNotificationStackScroller.getTranslationX() != 0;
    }

    private final FragmentListener mFragmentListener = new FragmentListener() {
        @Override
        public void onFragmentViewCreated(String tag, Fragment fragment) {
+1 −1
Original line number Diff line number Diff line
@@ -118,7 +118,7 @@ public abstract class PanelBar extends FrameLayout {
        boolean fullyOpened = false;
        if (SPEW) LOG("panelExpansionChanged: start state=%d", mState);
        PanelView pv = mPanel;
        pv.setVisibility(expanded ? View.VISIBLE : View.INVISIBLE);
        pv.setVisibility(expanded ? VISIBLE : INVISIBLE);
        // adjust any other panels that may be partially visible
        if (expanded) {
            if (mState == STATE_CLOSED) {
Loading