diff options
author | Selim Cinek <cinek@google.com> | 2014-10-31 15:03:09 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-10-31 15:03:10 +0000 |
commit | 43d991ef8a23f7d43f3b4f539eaa613436c8acdb (patch) | |
tree | 25b95abb2e3430d6d1e5dd3c3c5017982dbc3940 /packages/SystemUI/src/com/android/systemui/statusbar | |
parent | 104078c8ba7504376f77ab7ea7f183d2250d323d (diff) | |
parent | 3a9c10a2861404f1be9f06a3a54ae18803c81d1d (diff) | |
download | frameworks_base-43d991ef8a23f7d43f3b4f539eaa613436c8acdb.zip frameworks_base-43d991ef8a23f7d43f3b4f539eaa613436c8acdb.tar.gz frameworks_base-43d991ef8a23f7d43f3b4f539eaa613436c8acdb.tar.bz2 |
Merge "Fixed a bug when tapping in the empty space of the notification panel" into lmp-mr1-dev
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/statusbar')
4 files changed, 74 insertions, 3 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/DismissView.java b/packages/SystemUI/src/com/android/systemui/statusbar/DismissView.java index 897dbf2..479c2fb 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/DismissView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/DismissView.java @@ -36,4 +36,11 @@ public class DismissView extends StackScrollerDecorView { public void setOnButtonClickListener(OnClickListener listener) { mContent.setOnClickListener(listener); } + + public boolean isOnEmptySpace(float touchX, float touchY) { + return touchX < mContent.getX() + || touchX > mContent.getX() + mContent.getWidth() + || touchY < mContent.getY() + || touchY > mContent.getY() + mContent.getHeight(); + } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java index 0bde7ef..aacfa6e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java @@ -52,7 +52,7 @@ import com.android.systemui.statusbar.stack.StackStateAnimator; public class NotificationPanelView extends PanelView implements ExpandableView.OnHeightChangedListener, ObservableScrollView.Listener, View.OnClickListener, NotificationStackScrollLayout.OnOverscrollTopChangedListener, - KeyguardAffordanceHelper.Callback { + KeyguardAffordanceHelper.Callback, NotificationStackScrollLayout.OnEmptySpaceClickListener { // Cap and total height of Roboto font. Needs to be adjusted when font for the big clock is // changed. @@ -197,6 +197,7 @@ public class NotificationPanelView extends PanelView implements findViewById(R.id.notification_stack_scroller); mNotificationStackScroller.setOnHeightChangedListener(this); mNotificationStackScroller.setOverscrollTopChangedListener(this); + mNotificationStackScroller.setOnEmptySpaceClickListener(this); mNotificationStackScroller.setScrollView(mScrollView); mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(getContext(), android.R.interpolator.fast_out_slow_in); @@ -1867,4 +1868,9 @@ public class NotificationPanelView extends PanelView implements public void onScreenTurnedOn() { mKeyguardStatusView.refreshTime(); } + + @Override + public void onEmptySpaceClicked(float x, float y) { + onEmptySpaceClick(x); + } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java index 0cf2d05..e416d93 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java @@ -903,7 +903,7 @@ public abstract class PanelView extends FrameLayout { * * @return whether the panel will be expanded after the action performed by this method */ - private boolean onEmptySpaceClick(float x) { + protected boolean onEmptySpaceClick(float x) { if (mHintAnimationRunning) { return true; } 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 dd178cd..a1168f4 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java @@ -40,6 +40,7 @@ import com.android.systemui.statusbar.EmptyShadeView; import com.android.systemui.statusbar.ExpandableNotificationRow; import com.android.systemui.statusbar.ExpandableView; import com.android.systemui.statusbar.SpeedBumpView; +import com.android.systemui.statusbar.StackScrollerDecorView; import com.android.systemui.statusbar.StatusBarState; import com.android.systemui.statusbar.phone.PhoneStatusBar; import com.android.systemui.statusbar.policy.ScrollAdapter; @@ -84,6 +85,9 @@ public class NotificationStackScrollLayout extends ViewGroup private int mLastMotionY; private int mDownX; private int mActivePointerId; + private boolean mTouchIsClick; + private float mInitialTouchX; + private float mInitialTouchY; private int mSidePaddings; private Paint mDebugPaint; @@ -133,6 +137,7 @@ public class NotificationStackScrollLayout extends ViewGroup private OnChildLocationsChangedListener mListener; private OnOverscrollTopChangedListener mOverscrollTopChangedListener; private ExpandableView.OnHeightChangedListener mOnHeightChangedListener; + private OnEmptySpaceClickListener mOnEmptySpaceClickListener; private boolean mNeedsAnimation; private boolean mTopPaddingNeedsAnimation; private boolean mDimmedNeedsAnimation; @@ -584,7 +589,9 @@ public class NotificationStackScrollLayout extends ViewGroup final int count = getChildCount(); for (int childIdx = 0; childIdx < count; childIdx++) { ExpandableView slidingChild = (ExpandableView) getChildAt(childIdx); - if (slidingChild.getVisibility() == GONE) { + if (slidingChild.getVisibility() == GONE + || slidingChild instanceof StackScrollerDecorView + || slidingChild == mSpeedBumpView) { continue; } float childTop = slidingChild.getTranslationY(); @@ -690,6 +697,7 @@ public class NotificationStackScrollLayout extends ViewGroup transformTouchEvent(ev, this, mScrollView); return mScrollView.onTouchEvent(ev); } + handleEmptySpaceClick(ev); boolean expandWantsIt = false; if (!mSwipingInProgress && !mOnlyScrollingInThisMotion && isScrollingEnabled()) { if (isCancelOrUp) { @@ -1433,6 +1441,7 @@ public class NotificationStackScrollLayout extends ViewGroup transformTouchEvent(ev, mScrollView, this); } initDownStates(ev); + handleEmptySpaceClick(ev); boolean expandWantsIt = false; if (!mSwipingInProgress && !mOnlyScrollingInThisMotion && isScrollingEnabled()) { expandWantsIt = mExpandHelper.onInterceptTouchEvent(ev); @@ -1451,11 +1460,31 @@ public class NotificationStackScrollLayout extends ViewGroup return swipeWantsIt || scrollWantsIt || expandWantsIt || super.onInterceptTouchEvent(ev); } + private void handleEmptySpaceClick(MotionEvent ev) { + switch (ev.getActionMasked()) { + case MotionEvent.ACTION_MOVE: + if (mTouchIsClick && (Math.abs(ev.getY() - mInitialTouchY) > mTouchSlop + || Math.abs(ev.getX() - mInitialTouchX) > mTouchSlop )) { + mTouchIsClick = false; + } + break; + case MotionEvent.ACTION_UP: + if (mPhoneStatusBar.getBarState() != StatusBarState.KEYGUARD && mTouchIsClick && + isBelowLastNotification(mInitialTouchX, mInitialTouchY)) { + mOnEmptySpaceClickListener.onEmptySpaceClicked(mInitialTouchX, mInitialTouchY); + } + break; + } + } + private void initDownStates(MotionEvent ev) { if (ev.getAction() == MotionEvent.ACTION_DOWN) { mExpandedInThisMotion = false; mOnlyScrollingInThisMotion = !mScroller.isFinished(); mDisallowScrollingInThisMotion = false; + mTouchIsClick = true; + mInitialTouchX = ev.getX(); + mInitialTouchY = ev.getY(); } } @@ -1998,6 +2027,10 @@ public class NotificationStackScrollLayout extends ViewGroup this.mOnHeightChangedListener = mOnHeightChangedListener; } + public void setOnEmptySpaceClickListener(OnEmptySpaceClickListener listener) { + mOnEmptySpaceClickListener = listener; + } + public void onChildAnimationFinished() { requestChildrenUpdate(); } @@ -2248,6 +2281,24 @@ public class NotificationStackScrollLayout extends ViewGroup } } + private boolean isBelowLastNotification(float touchX, float touchY) { + ExpandableView lastChildNotGone = (ExpandableView) getLastChildNotGone(); + if (lastChildNotGone == null) { + return touchY > mIntrinsicPadding; + } + if (lastChildNotGone != mDismissView && lastChildNotGone != mEmptyShadeView) { + return touchY > lastChildNotGone.getY() + lastChildNotGone.getActualHeight(); + } else if (lastChildNotGone == mEmptyShadeView) { + return touchY > mEmptyShadeView.getY(); + } else { + float dismissY = mDismissView.getY(); + boolean belowDismissView = touchY > dismissY + mDismissView.getActualHeight(); + return belowDismissView || (touchY > dismissY + && mDismissView.isOnEmptySpace(touchX - mDismissView.getX(), + touchY - dismissY)); + } + } + /** * A listener that is notified when some child locations might have changed. */ @@ -2256,6 +2307,13 @@ public class NotificationStackScrollLayout extends ViewGroup } /** + * A listener that is notified when the empty space below the notifications is clicked on + */ + public interface OnEmptySpaceClickListener { + public void onEmptySpaceClicked(float x, float y); + } + + /** * A listener that gets notified when the overscroll at the top has changed. */ public interface OnOverscrollTopChangedListener { |