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

Commit c0ed38f5 authored by Selim Cinek's avatar Selim Cinek Committed by Android Git Automerger
Browse files

am ba6ae57f: Merge "Improved expansion logic of NotificationStackScroller"

* commit 'ba6ae57f':
  Improved expansion logic of NotificationStackScroller
parents be4f609d ba6ae57f
Loading
Loading
Loading
Loading
+19 −5
Original line number Diff line number Diff line
@@ -108,7 +108,7 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {

    private int mGravity;

    private View mScrollView;
    private ScrollAdapter mScrollAdapter;

    private OnScaleGestureListener mScaleGestureListener
            = new ScaleGestureDetector.SimpleOnScaleGestureListener() {
@@ -301,8 +301,8 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
        mGravity = gravity;
    }

    public void setScrollView(View scrollView) {
        mScrollView = scrollView;
    public void setScrollAdapter(ScrollAdapter adapter) {
        mScrollAdapter = adapter;
    }

    private float calculateGlow(float target, float actual) {
@@ -384,7 +384,7 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
                }
                return true;
            }
            if (mScrollView != null && mScrollView.getScrollY() > 0) {
            if (mScrollAdapter != null && !mScrollAdapter.isScrolledToTop()) {
                return false;
            }
            // Now look for other gestures
@@ -407,7 +407,7 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
            }

            case MotionEvent.ACTION_DOWN:
                mWatchingForPull = isInside(mScrollView, x, y);
                mWatchingForPull = isInside(mScrollAdapter.getHostView(), x, y);
                mLastMotionY = y;
                break;

@@ -608,5 +608,19 @@ public class ExpandHelper implements Gefingerpoken, OnClickListener {
        }
        mVibrator.vibrate(duration, AudioManager.STREAM_SYSTEM);
    }

    public interface ScrollAdapter {

        /**
         * @return Whether the view returned by {@link #getHostView()} is scrolled to the top
         * and can therefore be expanded by a single finger drag
         */
        public boolean isScrolledToTop();

        /**
         * @return The view in which the scrolling is performed
         */
        public View getHostView();
    }
}
+25 −6
Original line number Diff line number Diff line
@@ -27,11 +27,11 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.ViewRootImpl;
import android.widget.FrameLayout;
import android.widget.ScrollView;

import com.android.systemui.ExpandHelper;
import com.android.systemui.R;
import com.android.systemui.statusbar.BaseStatusBar;
import com.android.systemui.statusbar.stack.NotificationStackScrollLayout;


public class StatusBarWindowView extends FrameLayout
@@ -42,7 +42,7 @@ public class StatusBarWindowView extends FrameLayout
    private ExpandHelper mExpandHelper;
    private ViewGroup latestItems;
    private NotificationPanelView mNotificationPanel;
    private ScrollView mScrollView;
    private View mNotificationScroller;

    PhoneStatusBar mService;

@@ -56,19 +56,37 @@ public class StatusBarWindowView extends FrameLayout
    protected void onAttachedToWindow () {
        super.onAttachedToWindow();

        ExpandHelper.ScrollAdapter scrollAdapter;
        if (BaseStatusBar.ENABLE_NOTIFICATION_STACK) {
            latestItems = (ViewGroup) findViewById(R.id.notification_stack_scroller);
            NotificationStackScrollLayout stackScrollLayout =
                    (NotificationStackScrollLayout) findViewById(R.id.notification_stack_scroller);

            // ScrollView and notification container are unified in a single view now.
            latestItems = stackScrollLayout;
            scrollAdapter = stackScrollLayout;
            mNotificationScroller = stackScrollLayout;
        } else {
            latestItems = (ViewGroup) findViewById(R.id.latestItems);
            mNotificationScroller = findViewById(R.id.scroll);
            scrollAdapter = new ExpandHelper.ScrollAdapter() {
                @Override
                public boolean isScrolledToTop() {
                    return mNotificationScroller.getScrollY() == 0;
                }

                @Override
                public View getHostView() {
                    return mNotificationScroller;
                }
            };
        }
        mScrollView = (ScrollView) findViewById(R.id.scroll);
        mNotificationPanel = (NotificationPanelView) findViewById(R.id.notification_panel);
        int minHeight = getResources().getDimensionPixelSize(R.dimen.notification_row_min_height);
        int maxHeight = getResources().getDimensionPixelSize(R.dimen.notification_row_max_height);
        mExpandHelper = new ExpandHelper(getContext(), (ExpandHelper.Callback) latestItems,
                minHeight, maxHeight);
        mExpandHelper.setEventSource(this);
        mExpandHelper.setScrollView(mScrollView);
        mExpandHelper.setScrollAdapter(scrollAdapter);

        // We really need to be able to animate while window animations are going on
        // so that activities may be started asynchronously from panel animations
@@ -94,7 +112,8 @@ public class StatusBarWindowView extends FrameLayout
    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        boolean intercept = false;
        if (mNotificationPanel.isFullyExpanded() && mScrollView.getVisibility() == View.VISIBLE) {
        if (mNotificationPanel.isFullyExpanded()
                && mNotificationScroller.getVisibility() == View.VISIBLE) {
            intercept = mExpandHelper.onInterceptTouchEvent(ev);
        }
        if (!intercept) {
+11 −1
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ import com.android.systemui.statusbar.ExpandableNotificationRow;
 * A layout which handles a dynamic amount of notifications and presents them in a scrollable stack.
 */
public class NotificationStackScrollLayout extends ViewGroup
        implements SwipeHelper.Callback, ExpandHelper.Callback {
        implements SwipeHelper.Callback, ExpandHelper.Callback, ExpandHelper.ScrollAdapter {

    private static final String TAG = "NotificationStackScrollLayout";
    private static final boolean DEBUG = false;
@@ -813,4 +813,14 @@ public class NotificationStackScrollLayout extends ViewGroup
            mSwipeHelper.removeLongPressCallback();
        }
    }

    @Override
    public boolean isScrolledToTop() {
        return mOwnScrollY == 0;
    }

    @Override
    public View getHostView() {
        return this;
    }
}
+3 −3

File changed.

Contains only whitespace changes.