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

Commit 5de6e94e authored by Chris Wren's avatar Chris Wren
Browse files

Allow pinch gestures to spill over into the shade header.

Bug: 6430396
Change-Id: I62c242f11f47c5e6fff25c31716465b3e777d4ab
parent a0e0d580
Loading
Loading
Loading
Loading
+22 −3
Original line number Original line Diff line number Diff line
@@ -31,7 +31,7 @@ import com.android.internal.widget.SizeAdaptiveLayout;


public class ExpandHelper implements Gefingerpoken, OnClickListener {
public class ExpandHelper implements Gefingerpoken, OnClickListener {
    public interface Callback {
    public interface Callback {
        View getChildAtPosition(MotionEvent ev);
        View getChildAtRawPosition(float x, float y);
        View getChildAtPosition(float x, float y);
        View getChildAtPosition(float x, float y);
        boolean canChildBeExpanded(View v);
        boolean canChildBeExpanded(View v);
        boolean setUserExpandedChild(View v, boolean userxpanded);
        boolean setUserExpandedChild(View v, boolean userxpanded);
@@ -62,6 +62,7 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
    private Context mContext;
    private Context mContext;


    private boolean mStretching;
    private boolean mStretching;
    private View mEventSource;
    private View mCurrView;
    private View mCurrView;
    private View mCurrViewTopGlow;
    private View mCurrViewTopGlow;
    private View mCurrViewBottomGlow;
    private View mCurrViewBottomGlow;
@@ -141,7 +142,19 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
            @Override
            @Override
            public boolean onScaleBegin(ScaleGestureDetector detector) {
            public boolean onScaleBegin(ScaleGestureDetector detector) {
                if (DEBUG) Log.v(TAG, "onscalebegin()");
                if (DEBUG) Log.v(TAG, "onscalebegin()");
                View v = mCallback.getChildAtPosition(detector.getFocusX(), detector.getFocusY());
                float x = detector.getFocusX();
                float y = detector.getFocusY();

                View v = null;
                if (mEventSource != null) {
                    int[] location = new int[2];
                    mEventSource.getLocationOnScreen(location);
                    x += (float) location[0];
                    y += (float) location[1];
                    v = mCallback.getChildAtRawPosition(x, y);
                } else {
                    v = mCallback.getChildAtPosition(x, y);
                }


                // your fingers have to be somewhat close to the bounds of the view in question
                // your fingers have to be somewhat close to the bounds of the view in question
                mInitialTouchFocusY = detector.getFocusY();
                mInitialTouchFocusY = detector.getFocusY();
@@ -189,6 +202,11 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
            }
            }
        });
        });
    }
    }

    public void setEventSource(View eventSource) {
        mEventSource = eventSource;
    }

    public void setGlow(float glow) {
    public void setGlow(float glow) {
        if (!mGlowAnimationSet.isRunning() || glow == 0f) {
        if (!mGlowAnimationSet.isRunning() || glow == 0f) {
            if (mGlowAnimationSet.isRunning()) {
            if (mGlowAnimationSet.isRunning()) {
@@ -211,7 +229,6 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
            }
            }
        }
        }
    }
    }

    public boolean onInterceptTouchEvent(MotionEvent ev) {
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        if (DEBUG) Log.d(TAG, "interceptTouch: act=" + (ev.getAction()) +
        if (DEBUG) Log.d(TAG, "interceptTouch: act=" + (ev.getAction()) +
                         " stretching=" + mStretching);
                         " stretching=" + mStretching);
@@ -223,11 +240,13 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
        final int action = ev.getAction();
        final int action = ev.getAction();
        if (DEBUG) Log.d(TAG, "touch: act=" + (action) + " stretching=" + mStretching);
        if (DEBUG) Log.d(TAG, "touch: act=" + (action) + " stretching=" + mStretching);
        if (mStretching) {
        if (mStretching) {
            if (DEBUG) Log.d(TAG, "detector ontouch");
            mDetector.onTouchEvent(ev);
            mDetector.onTouchEvent(ev);
        }
        }
        switch (action) {
        switch (action) {
            case MotionEvent.ACTION_UP:
            case MotionEvent.ACTION_UP:
            case MotionEvent.ACTION_CANCEL:
            case MotionEvent.ACTION_CANCEL:
                if (DEBUG) Log.d(TAG, "cancel");
                mStretching = false;
                mStretching = false;
                clearView();
                clearView();
                break;
                break;
+1 −1
Original line number Original line Diff line number Diff line
@@ -289,7 +289,7 @@ public class PhoneStatusBar extends BaseStatusBar {
                        animateCollapse();
                        animateCollapse();
                    }
                    }
                }
                }
                return true;
                return mStatusBarWindow.onTouchEvent(event);
            }});
            }});


        mStatusBarView = (PhoneStatusBarView) mStatusBarWindow.findViewById(R.id.status_bar);
        mStatusBarView = (PhoneStatusBarView) mStatusBarWindow.findViewById(R.id.status_bar);
+42 −0
Original line number Original line Diff line number Diff line
@@ -18,17 +18,39 @@ package com.android.systemui.statusbar.phone;


import android.content.Context;
import android.content.Context;
import android.util.AttributeSet;
import android.util.AttributeSet;
import android.util.Log;
import android.view.KeyEvent;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.widget.FrameLayout;
import android.widget.FrameLayout;
import android.widget.TextSwitcher;
import android.widget.TextSwitcher;


import com.android.systemui.ExpandHelper;
import com.android.systemui.R;
import com.android.systemui.statusbar.policy.NotificationRowLayout;



public class StatusBarWindowView extends FrameLayout
public class StatusBarWindowView extends FrameLayout
{
{
    private static final String TAG = "StatusBarWindowView";

    private ExpandHelper mExpandHelper;
    private NotificationRowLayout latestItems;

    PhoneStatusBar mService;
    PhoneStatusBar mService;


    public StatusBarWindowView(Context context, AttributeSet attrs) {
    public StatusBarWindowView(Context context, AttributeSet attrs) {
        super(context, attrs);
        super(context, attrs);
        setMotionEventSplittingEnabled(false);
    }

    @Override
    protected void onAttachedToWindow () {
        super.onAttachedToWindow();
        latestItems = (NotificationRowLayout) findViewById(R.id.latestItems);
        int minHeight = getResources().getDimensionPixelSize(R.dimen.notification_row_min_height);
        int maxHeight = getResources().getDimensionPixelSize(R.dimen.notification_row_max_height);
        mExpandHelper = new ExpandHelper(mContext, latestItems, minHeight, maxHeight);
        mExpandHelper.setEventSource(this);
    }
    }


    @Override
    @Override
@@ -43,5 +65,25 @@ public class StatusBarWindowView extends FrameLayout
        }
        }
        return super.dispatchKeyEvent(event);
        return super.dispatchKeyEvent(event);
    }
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        MotionEvent cancellation = MotionEvent.obtain(ev);
        cancellation.setAction(MotionEvent.ACTION_CANCEL);

        boolean intercept = mExpandHelper.onInterceptTouchEvent(ev) ||
                super.onInterceptTouchEvent(ev);
        if (intercept) {
            latestItems.onInterceptTouchEvent(cancellation);
        }
        return intercept;
    }

    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        boolean handled = mExpandHelper.onTouchEvent(ev) ||
                super.onTouchEvent(ev);
        return handled;
    }
}
}
+12 −36
Original line number Original line Diff line number Diff line
@@ -36,7 +36,6 @@ import android.view.inputmethod.InputMethodManager;
import android.widget.LinearLayout;
import android.widget.LinearLayout;


import com.android.systemui.ExpandHelper;
import com.android.systemui.ExpandHelper;
import com.android.systemui.Gefingerpoken;
import com.android.systemui.R;
import com.android.systemui.R;
import com.android.systemui.SwipeHelper;
import com.android.systemui.SwipeHelper;
import com.android.systemui.statusbar.NotificationData;
import com.android.systemui.statusbar.NotificationData;
@@ -62,9 +61,6 @@ public class NotificationRowLayout
    HashMap<View, ValueAnimator> mDisappearingViews = new HashMap<View, ValueAnimator>();
    HashMap<View, ValueAnimator> mDisappearingViews = new HashMap<View, ValueAnimator>();


    private SwipeHelper mSwipeHelper;
    private SwipeHelper mSwipeHelper;
    private ExpandHelper mExpandHelper;

    private Gefingerpoken mCurrentHelper;


    // Flag set during notification removal animation to avoid causing too much work until
    // Flag set during notification removal animation to avoid causing too much work until
    // animation is done
    // animation is done
@@ -81,8 +77,6 @@ public class NotificationRowLayout
        
        
        setOrientation(LinearLayout.VERTICAL);
        setOrientation(LinearLayout.VERTICAL);


        setMotionEventSplittingEnabled(false);

        if (DEBUG) {
        if (DEBUG) {
            setOnHierarchyChangeListener(new ViewGroup.OnHierarchyChangeListener() {
            setOnHierarchyChangeListener(new ViewGroup.OnHierarchyChangeListener() {
                @Override
                @Override
@@ -101,9 +95,6 @@ public class NotificationRowLayout
        float densityScale = getResources().getDisplayMetrics().density;
        float densityScale = getResources().getDisplayMetrics().density;
        float pagingTouchSlop = ViewConfiguration.get(mContext).getScaledPagingTouchSlop();
        float pagingTouchSlop = ViewConfiguration.get(mContext).getScaledPagingTouchSlop();
        mSwipeHelper = new SwipeHelper(SwipeHelper.X, this, densityScale, pagingTouchSlop);
        mSwipeHelper = new SwipeHelper(SwipeHelper.X, this, densityScale, pagingTouchSlop);
        int minHeight = getResources().getDimensionPixelSize(R.dimen.notification_row_min_height);
        int maxHeight = getResources().getDimensionPixelSize(R.dimen.notification_row_max_height);
        mExpandHelper = new ExpandHelper(mContext, this, minHeight, maxHeight);
    }
    }


    public void setLongPressListener(View.OnLongClickListener listener) {
    public void setLongPressListener(View.OnLongClickListener listener) {
@@ -135,39 +126,17 @@ public class NotificationRowLayout
        if (DEBUG) Log.v(TAG, "onInterceptTouchEvent()");
        if (DEBUG) Log.v(TAG, "onInterceptTouchEvent()");
        if (DEBUG) logLayoutTransition();
        if (DEBUG) logLayoutTransition();


        MotionEvent cancellation = MotionEvent.obtain(ev);
        return mSwipeHelper.onInterceptTouchEvent(ev) ||
        cancellation.setAction(MotionEvent.ACTION_CANCEL);
                super.onInterceptTouchEvent(ev);

        if (mSwipeHelper.onInterceptTouchEvent(ev)) {
            if (DEBUG) Log.v(TAG, "will swipe");
            mCurrentHelper = mSwipeHelper;
            mExpandHelper.onInterceptTouchEvent(cancellation);
            return true;
        } else if (mExpandHelper.onInterceptTouchEvent(ev)) {
            if (DEBUG) Log.v(TAG, "will stretch");
            mCurrentHelper = mExpandHelper;
            mSwipeHelper.onInterceptTouchEvent(cancellation);
            return true;
        } else {
            mCurrentHelper = null;
            if (super.onInterceptTouchEvent(ev)) {
                if (DEBUG) Log.v(TAG, "intercepting ourselves");
                mSwipeHelper.onInterceptTouchEvent(cancellation);
                mExpandHelper.onInterceptTouchEvent(cancellation);
                return true;
            }
        }
        return false;
    }
    }


    @Override
    @Override
    public boolean onTouchEvent(MotionEvent ev) {
    public boolean onTouchEvent(MotionEvent ev) {
        if (DEBUG) Log.v(TAG, "onTouchEvent()");
        if (DEBUG) Log.v(TAG, "onTouchEvent()");
        if (DEBUG) logLayoutTransition();
        if (DEBUG) logLayoutTransition();
        if (mCurrentHelper != null) {

            return mCurrentHelper.onTouchEvent(ev);
        return mSwipeHelper.onTouchEvent(ev) ||
        }
                super.onTouchEvent(ev);
        return super.onTouchEvent(ev);
    }
    }


    public boolean canChildBeDismissed(View v) {
    public boolean canChildBeDismissed(View v) {
@@ -202,6 +171,13 @@ public class NotificationRowLayout
    public View getChildAtPosition(MotionEvent ev) {
    public View getChildAtPosition(MotionEvent ev) {
        return getChildAtPosition(ev.getX(), ev.getY());
        return getChildAtPosition(ev.getX(), ev.getY());
    }
    }

    public View getChildAtRawPosition(float touchX, float touchY) {
        int[] location = new int[2];
        getLocationOnScreen(location);
        return getChildAtPosition((float) (touchX - location[0]), (float) (touchY - location[1]));
    }

    public View getChildAtPosition(float touchX, float touchY) {
    public View getChildAtPosition(float touchX, float touchY) {
        // find the view under the pointer, accounting for GONE views
        // find the view under the pointer, accounting for GONE views
        final int count = getChildCount();
        final int count = getChildCount();