diff options
author | Selim Cinek <cinek@google.com> | 2015-05-21 16:14:45 -0700 |
---|---|---|
committer | Selim Cinek <cinek@google.com> | 2015-05-21 23:38:30 +0000 |
commit | 79d79c455beecf7a70460575ab21d9bf49767e2c (patch) | |
tree | 4cae0022f455f67321c118170a436c5d95a584ba /packages/SystemUI/src/com/android | |
parent | ffa6eb8791b65d3959682ee187124c1a06d28884 (diff) | |
download | frameworks_base-79d79c455beecf7a70460575ab21d9bf49767e2c.zip frameworks_base-79d79c455beecf7a70460575ab21d9bf49767e2c.tar.gz frameworks_base-79d79c455beecf7a70460575ab21d9bf49767e2c.tar.bz2 |
The heads up now have a margin on top and don't stick to the edge
Bug: 21337754
Change-Id: I199bc0732df62eadc2458db12a7c1059da988020
Diffstat (limited to 'packages/SystemUI/src/com/android')
5 files changed, 33 insertions, 5 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpTouchHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpTouchHelper.java index e6da81e..f57575d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpTouchHelper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpTouchHelper.java @@ -21,6 +21,7 @@ import android.view.MotionEvent; import android.view.ViewConfiguration; import com.android.systemui.Gefingerpoken; +import com.android.systemui.R; import com.android.systemui.statusbar.ExpandableNotificationRow; import com.android.systemui.statusbar.ExpandableView; import com.android.systemui.statusbar.policy.HeadsUpManager; @@ -42,6 +43,7 @@ public class HeadsUpTouchHelper implements Gefingerpoken { private boolean mCollapseSnoozes; private NotificationPanelView mPanel; private ExpandableNotificationRow mPickedChild; + private final int mNotificationsTopPadding; public HeadsUpTouchHelper(HeadsUpManager headsUpManager, NotificationStackScrollLayout stackScroller, @@ -52,6 +54,8 @@ public class HeadsUpTouchHelper implements Gefingerpoken { Context context = stackScroller.getContext(); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = configuration.getScaledTouchSlop(); + mNotificationsTopPadding = context.getResources() + .getDimensionPixelSize(R.dimen.notifications_top_padding); } public boolean isTrackingHeadsUp() { @@ -76,6 +80,10 @@ public class HeadsUpTouchHelper implements Gefingerpoken { mInitialTouchX = x; setTrackingHeadsUp(false); ExpandableView child = mStackScroller.getChildAtRawPosition(x, y); + if (child == null && y < mNotificationsTopPadding) { + // We should also allow drags from the margin above the heads up + child = mStackScroller.getChildAtRawPosition(x, y + mNotificationsTopPadding); + } mTouchingHeadsUpView = false; if (child instanceof ExpandableNotificationRow) { mPickedChild = (ExpandableNotificationRow) child; @@ -102,7 +110,8 @@ public class HeadsUpTouchHelper implements Gefingerpoken { mInitialTouchX = x; mInitialTouchY = y; int expandedHeight = mPickedChild.getActualHeight(); - mPanel.startExpandMotion(x, y, true /* startTracking */, expandedHeight); + mPanel.startExpandMotion(x, y, true /* startTracking */, expandedHeight + + mNotificationsTopPadding); mHeadsUpManager.unpinAll(); return true; } 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 c10be7c..5d48190 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java @@ -190,6 +190,7 @@ public class NotificationPanelView extends PanelView implements private int mOldLayoutDirection; private HeadsUpTouchHelper mHeadsUpTouchHelper; private boolean mIsExpansionFromHeadsUp; + private boolean mListenForHeadsUp; private int mNavigationBarBottomHeight; private boolean mExpandingFromHeadsUp; private boolean mCollapsedOnDown; @@ -649,6 +650,7 @@ public class NotificationPanelView extends PanelView implements mQsTouchAboveFalsingThreshold = mQsFullyExpanded; mDozingOnDown = isDozing(); mCollapsedOnDown = isFullyCollapsed(); + mListenForHeadsUp = mCollapsedOnDown && mHeadsUpManager.hasPinnedHeadsUp(); } } @@ -709,6 +711,12 @@ public class NotificationPanelView extends PanelView implements return false; } initDownStates(event); + if (mListenForHeadsUp && !mHeadsUpTouchHelper.isTrackingHeadsUp() + && mHeadsUpTouchHelper.onInterceptTouchEvent(event)) { + mIsExpansionFromHeadsUp = true; + MetricsLogger.count(mContext, COUNTER_PANEL_OPEN, 1); + MetricsLogger.count(mContext, COUNTER_PANEL_OPEN_PEEK, 1); + } if ((!mIsExpanding || mHintAnimationRunning) && !mQsExpanded && mStatusBar.getBarState() != StatusBarState.SHADE) { 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 b98d0038..6d35ff0 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java @@ -58,6 +58,7 @@ public abstract class PanelView extends FrameLayout { private float mHintDistance; private int mEdgeTapAreaWidth; private float mInitialOffsetOnTouch; + private boolean mCollapsedAndHeadsUpOnDown; private float mExpandedFraction = 0; protected float mExpandedHeight = 0; private boolean mPanelClosedOnDown; @@ -258,6 +259,8 @@ public abstract class PanelView extends FrameLayout { mMotionAborted = false; mPeekTouching = mPanelClosedOnDown; mTouchAboveFalsingThreshold = false; + mCollapsedAndHeadsUpOnDown = isFullyCollapsed() + && mHeadsUpManager.hasPinnedHeadsUp(); if (mVelocityTracker == null) { initVelocityTracker(); } @@ -270,7 +273,7 @@ public abstract class PanelView extends FrameLayout { || mPeekPending || mPeekAnimator != null; onTrackingStarted(); } - if (isFullyCollapsed()) { + if (isFullyCollapsed() && !mHeadsUpManager.hasPinnedHeadsUp()) { schedulePeek(); } break; @@ -302,7 +305,7 @@ public abstract class PanelView extends FrameLayout { && (Math.abs(h) > Math.abs(x - mInitialTouchX) || mIgnoreXTouchSlop)) { mTouchSlopExceeded = true; - if (mGestureWaitForTouchSlop && !mTracking) { + if (mGestureWaitForTouchSlop && !mTracking && !mCollapsedAndHeadsUpOnDown) { if (!mJustPeeked && mInitialOffsetOnTouch != 0f) { startExpandMotion(x, y, false /* startTracking */, mExpandedHeight); h = 0; @@ -477,6 +480,7 @@ public abstract class PanelView extends FrameLayout { mJustPeeked = false; mMotionAborted = false; mPanelClosedOnDown = isFullyCollapsed(); + mCollapsedAndHeadsUpOnDown = false; mHasLayoutedSinceDown = false; mUpdateFlingOnLayout = false; mTouchAboveFalsingThreshold = false; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java index 14060df..6e30803 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java @@ -81,6 +81,7 @@ public class HeadsUpManager implements ViewTreeObserver.OnComputeInternalInsetsL private final View mStatusBarWindowView; private final int mStatusBarHeight; + private final int mNotificationsTopPadding; private PhoneStatusBar mBar; private int mSnoozeLengthMs; private ContentObserver mSettingsObserver; @@ -128,6 +129,8 @@ public class HeadsUpManager implements ViewTreeObserver.OnComputeInternalInsetsL mStatusBarWindowView = statusBarWindowView; mStatusBarHeight = resources.getDimensionPixelSize( com.android.internal.R.dimen.status_bar_height); + mNotificationsTopPadding = context.getResources() + .getDimensionPixelSize(R.dimen.notifications_top_padding); } private void updateTouchableRegionListener() { @@ -379,7 +382,7 @@ public class HeadsUpManager implements ViewTreeObserver.OnComputeInternalInsetsL } info.setTouchableInsets(ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION); - info.touchableRegion.set(minX, minY, maxX, maxY); + info.touchableRegion.set(minX, minY, maxX, maxY + mNotificationsTopPadding); } else if (mHeadsUpGoingAway || mWaitingOnCollapseWhenGoingAway) { info.setTouchableInsets(ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION); info.touchableRegion.set(0, 0, mStatusBarWindowView.getWidth(), mStatusBarHeight); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java index 081a9c5..5c604b6 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java @@ -64,6 +64,7 @@ public class StackScrollAlgorithm { private int mTopStackTotalSize; private int mPaddingBetweenElementsDimmed; private int mPaddingBetweenElementsNormal; + private int mNotificationsTopPadding; private int mBottomStackSlowDownLength; private int mTopStackSlowDownLength; private int mCollapseSecondCardPadding; @@ -104,6 +105,8 @@ public class StackScrollAlgorithm { .getDimensionPixelSize(R.dimen.notification_padding_dimmed); mPaddingBetweenElementsNormal = context.getResources() .getDimensionPixelSize(R.dimen.notification_padding); + mNotificationsTopPadding = context.getResources() + .getDimensionPixelSize(R.dimen.notifications_top_padding); mCollapsedSize = context.getResources() .getDimensionPixelSize(R.dimen.notification_min_height); mMaxNotificationHeight = context.getResources() @@ -518,7 +521,8 @@ public class StackScrollAlgorithm { bottomPosition); } if (row.isPinned()) { - childState.yTranslation = Math.max(childState.yTranslation, 0); + childState.yTranslation = Math.max(childState.yTranslation, + mNotificationsTopPadding); childState.height = row.getHeadsUpHeight(); if (!isTopEntry) { // Ensure that a headsUp doesn't vertically extend further than the heads-up at |