diff options
author | Selim Cinek <cinek@google.com> | 2014-03-28 12:19:01 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-03-28 12:19:01 +0000 |
commit | ba6ae57f64e09fd9240640b6a0dd538e5f349bf1 (patch) | |
tree | 77df300f7d887b284b4a70da896b790f76606fe0 | |
parent | 45e1bcdac3741bda1104e78de6ed6937f6c3b152 (diff) | |
parent | fab078b01fbad026f006744016272327f7ab116b (diff) | |
download | frameworks_base-ba6ae57f64e09fd9240640b6a0dd538e5f349bf1.zip frameworks_base-ba6ae57f64e09fd9240640b6a0dd538e5f349bf1.tar.gz frameworks_base-ba6ae57f64e09fd9240640b6a0dd538e5f349bf1.tar.bz2 |
Merge "Improved expansion logic of NotificationStackScroller"
4 files changed, 58 insertions, 15 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/ExpandHelper.java b/packages/SystemUI/src/com/android/systemui/ExpandHelper.java index 48a6522..b85d5b9 100644 --- a/packages/SystemUI/src/com/android/systemui/ExpandHelper.java +++ b/packages/SystemUI/src/com/android/systemui/ExpandHelper.java @@ -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(); + } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index adfa118..e7f96dc 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -1483,7 +1483,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode { } mExpandedVisible = true; - if(!ENABLE_NOTIFICATION_STACK) { + if (!ENABLE_NOTIFICATION_STACK) { ((NotificationRowLayout) mPile).setLayoutTransitionsEnabled(true); } if (mNavigationBarView != null) @@ -1777,7 +1777,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode { } mExpandedVisible = false; - if(!ENABLE_NOTIFICATION_STACK) { + if (!ENABLE_NOTIFICATION_STACK) { ((NotificationRowLayout) mPile).setLayoutTransitionsEnabled(false); } if (mNavigationBarView != null) @@ -2477,7 +2477,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode { int totalDelay = 0; - if(!ENABLE_NOTIFICATION_STACK) { + if (!ENABLE_NOTIFICATION_STACK) { // Set the shade-animating state to avoid doing other work during // all of these animations. In particular, avoid layout and // redrawing when collapsing the shade. diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java index 925e0d8..eeae081 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java @@ -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) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java index edac3a7..ff8ea405 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java @@ -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; + } } |