Merge "Fixed a bug when tapping in the empty space of the notification panel" into lmp-mr1-dev
This commit is contained in:
@@ -36,4 +36,11 @@ public class DismissView extends StackScrollerDecorView {
|
|||||||
public void setOnButtonClickListener(OnClickListener listener) {
|
public void setOnButtonClickListener(OnClickListener listener) {
|
||||||
mContent.setOnClickListener(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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ import com.android.systemui.statusbar.stack.StackStateAnimator;
|
|||||||
public class NotificationPanelView extends PanelView implements
|
public class NotificationPanelView extends PanelView implements
|
||||||
ExpandableView.OnHeightChangedListener, ObservableScrollView.Listener,
|
ExpandableView.OnHeightChangedListener, ObservableScrollView.Listener,
|
||||||
View.OnClickListener, NotificationStackScrollLayout.OnOverscrollTopChangedListener,
|
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
|
// Cap and total height of Roboto font. Needs to be adjusted when font for the big clock is
|
||||||
// changed.
|
// changed.
|
||||||
@@ -197,6 +197,7 @@ public class NotificationPanelView extends PanelView implements
|
|||||||
findViewById(R.id.notification_stack_scroller);
|
findViewById(R.id.notification_stack_scroller);
|
||||||
mNotificationStackScroller.setOnHeightChangedListener(this);
|
mNotificationStackScroller.setOnHeightChangedListener(this);
|
||||||
mNotificationStackScroller.setOverscrollTopChangedListener(this);
|
mNotificationStackScroller.setOverscrollTopChangedListener(this);
|
||||||
|
mNotificationStackScroller.setOnEmptySpaceClickListener(this);
|
||||||
mNotificationStackScroller.setScrollView(mScrollView);
|
mNotificationStackScroller.setScrollView(mScrollView);
|
||||||
mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(getContext(),
|
mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(getContext(),
|
||||||
android.R.interpolator.fast_out_slow_in);
|
android.R.interpolator.fast_out_slow_in);
|
||||||
@@ -1867,4 +1868,9 @@ public class NotificationPanelView extends PanelView implements
|
|||||||
public void onScreenTurnedOn() {
|
public void onScreenTurnedOn() {
|
||||||
mKeyguardStatusView.refreshTime();
|
mKeyguardStatusView.refreshTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEmptySpaceClicked(float x, float y) {
|
||||||
|
onEmptySpaceClick(x);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -903,7 +903,7 @@ public abstract class PanelView extends FrameLayout {
|
|||||||
*
|
*
|
||||||
* @return whether the panel will be expanded after the action performed by this method
|
* @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) {
|
if (mHintAnimationRunning) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import com.android.systemui.statusbar.EmptyShadeView;
|
|||||||
import com.android.systemui.statusbar.ExpandableNotificationRow;
|
import com.android.systemui.statusbar.ExpandableNotificationRow;
|
||||||
import com.android.systemui.statusbar.ExpandableView;
|
import com.android.systemui.statusbar.ExpandableView;
|
||||||
import com.android.systemui.statusbar.SpeedBumpView;
|
import com.android.systemui.statusbar.SpeedBumpView;
|
||||||
|
import com.android.systemui.statusbar.StackScrollerDecorView;
|
||||||
import com.android.systemui.statusbar.StatusBarState;
|
import com.android.systemui.statusbar.StatusBarState;
|
||||||
import com.android.systemui.statusbar.phone.PhoneStatusBar;
|
import com.android.systemui.statusbar.phone.PhoneStatusBar;
|
||||||
import com.android.systemui.statusbar.policy.ScrollAdapter;
|
import com.android.systemui.statusbar.policy.ScrollAdapter;
|
||||||
@@ -84,6 +85,9 @@ public class NotificationStackScrollLayout extends ViewGroup
|
|||||||
private int mLastMotionY;
|
private int mLastMotionY;
|
||||||
private int mDownX;
|
private int mDownX;
|
||||||
private int mActivePointerId;
|
private int mActivePointerId;
|
||||||
|
private boolean mTouchIsClick;
|
||||||
|
private float mInitialTouchX;
|
||||||
|
private float mInitialTouchY;
|
||||||
|
|
||||||
private int mSidePaddings;
|
private int mSidePaddings;
|
||||||
private Paint mDebugPaint;
|
private Paint mDebugPaint;
|
||||||
@@ -133,6 +137,7 @@ public class NotificationStackScrollLayout extends ViewGroup
|
|||||||
private OnChildLocationsChangedListener mListener;
|
private OnChildLocationsChangedListener mListener;
|
||||||
private OnOverscrollTopChangedListener mOverscrollTopChangedListener;
|
private OnOverscrollTopChangedListener mOverscrollTopChangedListener;
|
||||||
private ExpandableView.OnHeightChangedListener mOnHeightChangedListener;
|
private ExpandableView.OnHeightChangedListener mOnHeightChangedListener;
|
||||||
|
private OnEmptySpaceClickListener mOnEmptySpaceClickListener;
|
||||||
private boolean mNeedsAnimation;
|
private boolean mNeedsAnimation;
|
||||||
private boolean mTopPaddingNeedsAnimation;
|
private boolean mTopPaddingNeedsAnimation;
|
||||||
private boolean mDimmedNeedsAnimation;
|
private boolean mDimmedNeedsAnimation;
|
||||||
@@ -584,7 +589,9 @@ public class NotificationStackScrollLayout extends ViewGroup
|
|||||||
final int count = getChildCount();
|
final int count = getChildCount();
|
||||||
for (int childIdx = 0; childIdx < count; childIdx++) {
|
for (int childIdx = 0; childIdx < count; childIdx++) {
|
||||||
ExpandableView slidingChild = (ExpandableView) getChildAt(childIdx);
|
ExpandableView slidingChild = (ExpandableView) getChildAt(childIdx);
|
||||||
if (slidingChild.getVisibility() == GONE) {
|
if (slidingChild.getVisibility() == GONE
|
||||||
|
|| slidingChild instanceof StackScrollerDecorView
|
||||||
|
|| slidingChild == mSpeedBumpView) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
float childTop = slidingChild.getTranslationY();
|
float childTop = slidingChild.getTranslationY();
|
||||||
@@ -690,6 +697,7 @@ public class NotificationStackScrollLayout extends ViewGroup
|
|||||||
transformTouchEvent(ev, this, mScrollView);
|
transformTouchEvent(ev, this, mScrollView);
|
||||||
return mScrollView.onTouchEvent(ev);
|
return mScrollView.onTouchEvent(ev);
|
||||||
}
|
}
|
||||||
|
handleEmptySpaceClick(ev);
|
||||||
boolean expandWantsIt = false;
|
boolean expandWantsIt = false;
|
||||||
if (!mSwipingInProgress && !mOnlyScrollingInThisMotion && isScrollingEnabled()) {
|
if (!mSwipingInProgress && !mOnlyScrollingInThisMotion && isScrollingEnabled()) {
|
||||||
if (isCancelOrUp) {
|
if (isCancelOrUp) {
|
||||||
@@ -1433,6 +1441,7 @@ public class NotificationStackScrollLayout extends ViewGroup
|
|||||||
transformTouchEvent(ev, mScrollView, this);
|
transformTouchEvent(ev, mScrollView, this);
|
||||||
}
|
}
|
||||||
initDownStates(ev);
|
initDownStates(ev);
|
||||||
|
handleEmptySpaceClick(ev);
|
||||||
boolean expandWantsIt = false;
|
boolean expandWantsIt = false;
|
||||||
if (!mSwipingInProgress && !mOnlyScrollingInThisMotion && isScrollingEnabled()) {
|
if (!mSwipingInProgress && !mOnlyScrollingInThisMotion && isScrollingEnabled()) {
|
||||||
expandWantsIt = mExpandHelper.onInterceptTouchEvent(ev);
|
expandWantsIt = mExpandHelper.onInterceptTouchEvent(ev);
|
||||||
@@ -1451,11 +1460,31 @@ public class NotificationStackScrollLayout extends ViewGroup
|
|||||||
return swipeWantsIt || scrollWantsIt || expandWantsIt || super.onInterceptTouchEvent(ev);
|
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) {
|
private void initDownStates(MotionEvent ev) {
|
||||||
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
|
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
|
||||||
mExpandedInThisMotion = false;
|
mExpandedInThisMotion = false;
|
||||||
mOnlyScrollingInThisMotion = !mScroller.isFinished();
|
mOnlyScrollingInThisMotion = !mScroller.isFinished();
|
||||||
mDisallowScrollingInThisMotion = false;
|
mDisallowScrollingInThisMotion = false;
|
||||||
|
mTouchIsClick = true;
|
||||||
|
mInitialTouchX = ev.getX();
|
||||||
|
mInitialTouchY = ev.getY();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1998,6 +2027,10 @@ public class NotificationStackScrollLayout extends ViewGroup
|
|||||||
this.mOnHeightChangedListener = mOnHeightChangedListener;
|
this.mOnHeightChangedListener = mOnHeightChangedListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setOnEmptySpaceClickListener(OnEmptySpaceClickListener listener) {
|
||||||
|
mOnEmptySpaceClickListener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
public void onChildAnimationFinished() {
|
public void onChildAnimationFinished() {
|
||||||
requestChildrenUpdate();
|
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.
|
* 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);
|
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.
|
* A listener that gets notified when the overscroll at the top has changed.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user