Merge "Fixed a bug when tapping in the empty space of the notification panel" into lmp-mr1-dev

This commit is contained in:
Selim Cinek
2014-10-31 15:03:09 +00:00
committed by Android (Google) Code Review
4 changed files with 74 additions and 3 deletions

View File

@@ -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();
}
}

View File

@@ -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);
}
}

View File

@@ -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;
}

View File

@@ -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.
*/
@@ -2255,6 +2306,13 @@ public class NotificationStackScrollLayout extends ViewGroup
public void onChildLocationsChanged(NotificationStackScrollLayout stackScrollLayout);
}
/**
* 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.
*/