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

Commit c2b49576 authored by Mady Mellor's avatar Mady Mellor Committed by Android (Google) Code Review
Browse files

Merge "Fix inline controls from being swipeable" into nyc-dev

parents e36fb2b7 34958fa2
Loading
Loading
Loading
Loading
+9 −1
Original line number Original line Diff line number Diff line
@@ -144,7 +144,9 @@ public class SwipeHelper implements Gefingerpoken {
    protected Animator getViewTranslationAnimator(View v, float target,
    protected Animator getViewTranslationAnimator(View v, float target,
            AnimatorUpdateListener listener) {
            AnimatorUpdateListener listener) {
        ObjectAnimator anim = createTranslationAnimation(v, target);
        ObjectAnimator anim = createTranslationAnimation(v, target);
        if (listener != null) {
            anim.addUpdateListener(listener);
            anim.addUpdateListener(listener);
        }
        return anim;
        return anim;
    }
    }


@@ -370,6 +372,9 @@ public class SwipeHelper implements Gefingerpoken {
        };
        };


        Animator anim = getViewTranslationAnimator(animView, newPos, updateListener);
        Animator anim = getViewTranslationAnimator(animView, newPos, updateListener);
        if (anim == null) {
            return;
        }
        if (useAccelerateInterpolator) {
        if (useAccelerateInterpolator) {
            anim.setInterpolator(Interpolators.FAST_OUT_LINEAR_IN);
            anim.setInterpolator(Interpolators.FAST_OUT_LINEAR_IN);
        } else {
        } else {
@@ -411,6 +416,9 @@ public class SwipeHelper implements Gefingerpoken {
        };
        };


        Animator anim = getViewTranslationAnimator(animView, targetLeft, updateListener);
        Animator anim = getViewTranslationAnimator(animView, targetLeft, updateListener);
        if (anim == null) {
            return;
        }
        int duration = SNAP_ANIM_LEN;
        int duration = SNAP_ANIM_LEN;
        anim.setDuration(duration);
        anim.setDuration(duration);
        anim.addListener(new AnimatorListenerAdapter() {
        anim.addListener(new AnimatorListenerAdapter() {
+53 −7
Original line number Original line Diff line number Diff line
@@ -684,7 +684,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        mTranslateableViews.remove(mGutsStub);
        mTranslateableViews.remove(mGutsStub);
    }
    }


    public void setTranslationForOutline(float translationX) {
    private void setTranslationForOutline(float translationX) {
        setOutlineRect(false, translationX, getTop(), getRight() + translationX, getBottom());
        setOutlineRect(false, translationX, getTop(), getRight() + translationX, getBottom());
    }
    }


@@ -704,6 +704,46 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        if (mTranslateAnim != null) {
        if (mTranslateAnim != null) {
            mTranslateAnim.cancel();
            mTranslateAnim.cancel();
        }
        }
        mTranslateAnim = (AnimatorSet) getTranslateViewAnimator(leftTarget,
                null /* updateListener */);
        if (mTranslateAnim != null) {
            mTranslateAnim.start();
        }
    }

    @Override
    public void setTranslation(float translationX) {
        if (areGutsExposed()) {
            // Don't translate if guts are showing.
            return;
        }
        // Translate the group of views
        for (int i = 0; i < mTranslateableViews.size(); i++) {
            if (mTranslateableViews.get(i) != null) {
                mTranslateableViews.get(i).setTranslationX(translationX);
            }
        }
        setTranslationForOutline(translationX);
        if (mSettingsIconRow != null) {
            mSettingsIconRow.updateSettingsIcons(translationX, getMeasuredWidth());
        }
    }

    @Override
    public float getTranslation() {
        if (mTranslateableViews != null && mTranslateableViews.size() > 0) {
            // All of the views in the list should have same translation, just use first one.
            return mTranslateableViews.get(0).getTranslationX();
        }
        return 0;
    }

    public Animator getTranslateViewAnimator(final float leftTarget,
            AnimatorUpdateListener listener) {
        if (areGutsExposed()) {
            // No translation if guts are exposed.
            return null;
        }
        AnimatorSet set = new AnimatorSet();
        AnimatorSet set = new AnimatorSet();
        if (mTranslateableViews != null) {
        if (mTranslateableViews != null) {
            for (int i = 0; i < mTranslateableViews.size(); i++) {
            for (int i = 0; i < mTranslateableViews.size(); i++) {
@@ -715,8 +755,15 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
                        @Override
                        @Override
                        public void onAnimationUpdate(ValueAnimator animation) {
                        public void onAnimationUpdate(ValueAnimator animation) {
                            setTranslationForOutline((float) animation.getAnimatedValue());
                            setTranslationForOutline((float) animation.getAnimatedValue());
                            if (mSettingsIconRow != null) {
                                mSettingsIconRow.updateSettingsIcons(
                                        (float) animation.getAnimatedValue(), getMeasuredWidth());
                            }
                        }
                        }
                    });
                    });
                    if (listener != null) {
                        translateAnim.addUpdateListener(listener);
                    }
                }
                }
                translateAnim.addListener(new AnimatorListenerAdapter() {
                translateAnim.addListener(new AnimatorListenerAdapter() {
                    @Override
                    @Override
@@ -730,8 +777,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
                set.play(translateAnim);
                set.play(translateAnim);
            }
            }
        }
        }
        mTranslateAnim = set;
        return set;
        set.start();
    }
    }


    public float getSpaceForGear() {
    public float getSpaceForGear() {
@@ -748,10 +794,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        return mSettingsIconRow;
        return mSettingsIconRow;
    }
    }


    public ArrayList<View> getContentViews() {
        return mTranslateableViews;
    }

    public void inflateGuts() {
    public void inflateGuts() {
        if (mGuts == null) {
        if (mGuts == null) {
            mGutsStub.inflate();
            mGutsStub.inflate();
@@ -1169,6 +1211,10 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        return mMaxExpandHeight;
        return mMaxExpandHeight;
    }
    }


    public boolean areGutsExposed() {
        return (mGuts != null && mGuts.areGutsExposed());
    }

    @Override
    @Override
    public boolean isContentExpandable() {
    public boolean isContentExpandable() {
        NotificationContentView showingLayout = getShowingLayout();
        NotificationContentView showingLayout = getShowingLayout();
+14 −0
Original line number Original line Diff line number Diff line
@@ -283,6 +283,20 @@ public abstract class ExpandableView extends FrameLayout {
    public void setBelowSpeedBump(boolean below) {
    public void setBelowSpeedBump(boolean below) {
    }
    }


    /**
     * Sets the translation of the view.
     */
    public void setTranslation(float translation) {
        setTranslationX(translation);
    }

    /**
     * Gets the translation of the view.
     */
    public float getTranslation() {
        return getTranslationX();
    }

    public void onHeightReset() {
    public void onHeightReset() {
        if (mOnHeightChangedListener != null) {
        if (mOnHeightChangedListener != null) {
            mOnHeightChangedListener.onReset(this);
            mOnHeightChangedListener.onReset(this);
+24 −75
Original line number Original line Diff line number Diff line
@@ -714,6 +714,7 @@ public class NotificationStackScrollLayout extends ViewGroup


        if (targetLeft == 0 && mCurrIconRow != null) {
        if (targetLeft == 0 && mCurrIconRow != null) {
            mCurrIconRow.resetState();
            mCurrIconRow.resetState();
            mCurrIconRow = null;
            if (mGearExposedView != null && mGearExposedView == mTranslatingParentView) {
            if (mGearExposedView != null && mGearExposedView == mTranslatingParentView) {
                mGearExposedView = null;
                mGearExposedView = null;
            }
            }
@@ -3367,7 +3368,6 @@ public class NotificationStackScrollLayout extends ViewGroup


        private static final long GEAR_SHOW_DELAY = 60;
        private static final long GEAR_SHOW_DELAY = 60;


        private ArrayList<View> mTranslatingViews = new ArrayList<>();
        private CheckForDrag mCheckForDrag;
        private CheckForDrag mCheckForDrag;
        private Handler mHandler;
        private Handler mHandler;
        private int mMoveState = MOVE_STATE_UNDEFINED;
        private int mMoveState = MOVE_STATE_UNDEFINED;
@@ -3384,6 +3384,7 @@ public class NotificationStackScrollLayout extends ViewGroup


            // Reset check for drag gesture
            // Reset check for drag gesture
            mCheckForDrag = null;
            mCheckForDrag = null;
            mCurrIconRow = null;


            // Slide back any notifications that might be showing a gear
            // Slide back any notifications that might be showing a gear
            resetExposedGearView();
            resetExposedGearView();
@@ -3392,9 +3393,6 @@ public class NotificationStackScrollLayout extends ViewGroup
                // Set the listener for the current row's gear
                // Set the listener for the current row's gear
                mCurrIconRow = ((ExpandableNotificationRow) currView).getSettingsRow();
                mCurrIconRow = ((ExpandableNotificationRow) currView).getSettingsRow();
                mCurrIconRow.setGearListener(NotificationStackScrollLayout.this);
                mCurrIconRow.setGearListener(NotificationStackScrollLayout.this);

                // And the translating children
                mTranslatingViews = ((ExpandableNotificationRow) currView).getContentViews();
            }
            }
            mMoveState = MOVE_STATE_UNDEFINED;
            mMoveState = MOVE_STATE_UNDEFINED;
        }
        }
@@ -3408,15 +3406,12 @@ public class NotificationStackScrollLayout extends ViewGroup
            }
            }
            mMoveState = newMoveState;
            mMoveState = newMoveState;


            if (view instanceof ExpandableNotificationRow) {
            final boolean gutsExposed = (view instanceof ExpandableNotificationRow)
                ((ExpandableNotificationRow) view).setTranslationForOutline(translation);
                    && ((ExpandableNotificationRow) view).areGutsExposed();
                if (!isPinnedHeadsUp(view)) {

                    // Only show the gear if we're not a heads up view.
            if (!isPinnedHeadsUp(view) && !gutsExposed) {
                // Only show the gear if we're not a heads up view and guts aren't exposed.
                checkForDrag();
                checkForDrag();
                    if (mCurrIconRow != null) {
                        mCurrIconRow.updateSettingsIcons(translation, getSize(view));
                    }
                }
            }
            }
        }
        }


@@ -3439,12 +3434,12 @@ public class NotificationStackScrollLayout extends ViewGroup
                    (!fromLeft && absTrans >= snapBackThreshold * 0.4f
                    (!fromLeft && absTrans >= snapBackThreshold * 0.4f
                            && absTrans <= notiThreshold);
                            && absTrans <= notiThreshold);


            if (pastGear && !isPinnedHeadsUp(animView)) {
            if (pastGear && !isPinnedHeadsUp(animView)
                    && (animView instanceof ExpandableNotificationRow)) {
                // bouncity
                // bouncity
                final float target = fromLeft ? snapBackThreshold : -snapBackThreshold;
                final float target = fromLeft ? snapBackThreshold : -snapBackThreshold;
                mGearExposedView = mTranslatingParentView;
                mGearExposedView = mTranslatingParentView;
                if (mGearDisplayedListener != null
                if (mGearDisplayedListener != null) {
                        && (animView instanceof ExpandableNotificationRow)) {
                    mGearDisplayedListener.onGearDisplayed((ExpandableNotificationRow) animView);
                    mGearDisplayedListener.onGearDisplayed((ExpandableNotificationRow) animView);
                }
                }
                super.snapChild(animView, target, velocity);
                super.snapChild(animView, target, velocity);
@@ -3453,39 +3448,17 @@ public class NotificationStackScrollLayout extends ViewGroup
            }
            }
        }
        }


        @Override
        public void onTranslationUpdate(View animView, float value, boolean canBeDismissed) {
            if (mDismissAllInProgress) {
                // When dismissing all, we translate the entire view instead.
                super.onTranslationUpdate(animView, value, canBeDismissed);
                return;
            }
            if (animView instanceof ExpandableNotificationRow) {
                ((ExpandableNotificationRow) animView).setTranslationForOutline(value);
            }
            if (mCurrIconRow != null) {
                mCurrIconRow.updateSettingsIcons(value, getSize(animView));
            }
        }

        @Override
        @Override
        public Animator getViewTranslationAnimator(View v, float target,
        public Animator getViewTranslationAnimator(View v, float target,
                AnimatorUpdateListener listener) {
                AnimatorUpdateListener listener) {
            if (mDismissAllInProgress) {
            if (mDismissAllInProgress) {
                // When dismissing all, we translate the entire view instead.
                // When dismissing all, we translate the entire view instead.
                return super.getViewTranslationAnimator(v, target, listener);
                return super.getViewTranslationAnimator(v, target, listener);
            } else if (v instanceof ExpandableNotificationRow) {
                return ((ExpandableNotificationRow) v).getTranslateViewAnimator(target, listener);
            } else {
                return super.getViewTranslationAnimator(v, target, listener);
            }
            }
            ArrayList<Animator> animators = new ArrayList<Animator>();
            for (int i = 0; i < mTranslatingViews.size(); i++) {
                ObjectAnimator anim = createTranslationAnimation(mTranslatingViews.get(i), target);
                animators.add(anim);
                if (i == 0 && listener != null) {
                    anim.addUpdateListener(listener);
                }
            }
            AnimatorSet set = new AnimatorSet();
            set.playTogether(animators);
            return set;
        }
        }


        @Override
        @Override
@@ -3493,13 +3466,8 @@ public class NotificationStackScrollLayout extends ViewGroup
            if (mDismissAllInProgress) {
            if (mDismissAllInProgress) {
                // When dismissing all, we translate the entire view instead.
                // When dismissing all, we translate the entire view instead.
                super.setTranslation(v, translate);
                super.setTranslation(v, translate);
                return;
            } else {
            }
                ((ExpandableView) v).setTranslation(translate);
            // Translate the group of views
            for (int i = 0; i < mTranslatingViews.size(); i++) {
                if (mTranslatingViews.get(i) != null) {
                    super.setTranslation(mTranslatingViews.get(i), translate);
                }
            }
            }
        }
        }


@@ -3508,15 +3476,11 @@ public class NotificationStackScrollLayout extends ViewGroup
            if (mDismissAllInProgress) {
            if (mDismissAllInProgress) {
                // When dismissing all, we translate the entire view instead.
                // When dismissing all, we translate the entire view instead.
                return super.getTranslation(v);
                return super.getTranslation(v);
            } else {
                return ((ExpandableView) v).getTranslation();
            }
            }
            // All of the views in the list should have same translation, just use first one.
            if (mTranslatingViews.size() > 0) {
                return super.getTranslation(mTranslatingViews.get(0));
            }
            return 0;
        }
        }



        /**
        /**
         * Returns the horizontal space in pixels required to display the gear behind a
         * Returns the horizontal space in pixels required to display the gear behind a
         * notification.
         * notification.
@@ -3571,26 +3535,11 @@ public class NotificationStackScrollLayout extends ViewGroup
            final View prevGearExposedView = mGearExposedView;
            final View prevGearExposedView = mGearExposedView;
            mGearExposedView = null;
            mGearExposedView = null;


            AnimatorListenerAdapter listener = new AnimatorListenerAdapter() {
            Animator anim = getViewTranslationAnimator(prevGearExposedView,
                public void onAnimationEnd(Animator animator) {
                    0 /* leftTarget */, null /* updateListener */);
                    if (prevGearExposedView instanceof ExpandableNotificationRow) {
            if (anim != null) {
                        ((ExpandableNotificationRow) prevGearExposedView).getSettingsRow()
                anim.start();
                                .resetState();
                    }
            }
            }
            };
            AnimatorUpdateListener updateListener = new AnimatorUpdateListener() {
                @Override
                public void onAnimationUpdate(ValueAnimator animation) {
                    if (prevGearExposedView instanceof ExpandableNotificationRow) {
                        ((ExpandableNotificationRow) prevGearExposedView)
                                .setTranslationForOutline((float) animation.getAnimatedValue());
                    }
                }
            };
            Animator set = getViewTranslationAnimator(prevGearExposedView, 0, updateListener);
            set.addListener(listener);
            set.start();
        }
        }
    }
    }