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

Commit 9a9c9c12 authored by Steve Kondik's avatar Steve Kondik Committed by Gerrit Code Review
Browse files

Merge "Slide notifications during swipe-to-clear" into gingerbread

parents fe440be7 c4986ff2
Loading
Loading
Loading
Loading
+32 −14
Original line number Diff line number Diff line
@@ -16,18 +16,18 @@

package com.android.systemui.statusbar;

import com.android.systemui.R;

import android.content.Context;
import android.graphics.Point;
import android.os.Handler;
import android.util.AttributeSet;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.ViewConfiguration;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.LinearLayout;

import com.android.systemui.R;

public class LatestItemContainer extends LinearLayout {
    private final GestureDetector mGestureDetector;

@@ -35,6 +35,8 @@ public class LatestItemContainer extends LinearLayout {

    private final Handler mHandler = new Handler();

    private final Point mStartPoint = new Point();

    public LatestItemContainer(final Context context, AttributeSet attrs) {
        super(context, attrs);

@@ -63,16 +65,32 @@ public class LatestItemContainer extends LinearLayout {

    @Override
    public boolean onInterceptTouchEvent(MotionEvent event) {
        if (mSwipeCallback != null) {
            boolean handled = mGestureDetector.onTouchEvent(event);
            switch (event.getAction() & MotionEvent.ACTION_MASK) {
                case MotionEvent.ACTION_OUTSIDE:
                case MotionEvent.ACTION_CANCEL:
                    reset();
                    break;
                case MotionEvent.ACTION_UP:
                if (handled) {
                    return true;
                } else {
                    return super.onInterceptTouchEvent(event);
                    if (!handled) {
                        reset();
                    }
                    return handled;
                case MotionEvent.ACTION_MOVE:
                    int diffX = ((int) event.getX()) - mStartPoint.x;
                    scrollTo(-diffX, 0);
                    break;
                case MotionEvent.ACTION_DOWN:
                    mStartPoint.x = (int) event.getX();
                    break;
            }
        return false;
        }
        return super.onInterceptTouchEvent(event);
    }

    private void reset() {
        scrollTo(0, 0);
    }

    public void setOnSwipeCallback(Runnable callback) {