diff options
author | Jorim Jaggi <jjaggi@google.com> | 2015-04-23 18:53:17 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-04-23 18:53:18 +0000 |
commit | a47f4d7c4d0cdd85558d422adc4e2aedcd3aeeb1 (patch) | |
tree | 4b18ae8a1893c2dd9f6ed23b29c0b00e5777f8f4 /packages/SystemUI/src/com/android/systemui | |
parent | 63fc1514755601772e0fab029f4aa8003f54ddec (diff) | |
parent | 6d4a27fb7fbe6c9d26ca583780fc3fcc34e0c6bd (diff) | |
download | frameworks_base-a47f4d7c4d0cdd85558d422adc4e2aedcd3aeeb1.zip frameworks_base-a47f4d7c4d0cdd85558d422adc4e2aedcd3aeeb1.tar.gz frameworks_base-a47f4d7c4d0cdd85558d422adc4e2aedcd3aeeb1.tar.bz2 |
Merge "Position panel dynamically when expanding"
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui')
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java | 57 |
1 files changed, 54 insertions, 3 deletions
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 03e5746..7d61099 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java @@ -187,6 +187,9 @@ public class NotificationPanelView extends PanelView implements private boolean mExpansionIsFromHeadsUp; private int mBottomBarHeight; private boolean mExpandingFromHeadsUp; + private int mPositionMinSideMargin; + private int mLastOrientation = -1; + private Runnable mHeadsUpExistenceChangedRunnable = new Runnable() { @Override public void run() { @@ -236,6 +239,7 @@ public class NotificationPanelView extends PanelView implements mAfforanceHelper = new KeyguardAffordanceHelper(this, getContext()); mSecureCameraLaunchManager = new SecureCameraLaunchManager(getContext(), mKeyguardBottomArea); + mLastOrientation = getResources().getConfiguration().orientation; // recompute internal state when qspanel height changes mQsContainer.addOnLayoutChangeListener(new OnLayoutChangeListener() { @@ -268,6 +272,8 @@ public class NotificationPanelView extends PanelView implements getResources().getDimensionPixelSize(R.dimen.notification_scrim_wait_distance); mQsFalsingThreshold = getResources().getDimensionPixelSize( R.dimen.qs_falsing_threshold); + mPositionMinSideMargin = getResources().getDimensionPixelSize( + R.dimen.notification_panel_min_side_margin); } public void updateResources() { @@ -692,6 +698,9 @@ public class NotificationPanelView extends PanelView implements if (!mHeadsUpTouchHelper.isTrackingHeadsUp() && handleQSTouch(event)) { return true; } + if (event.getActionMasked() == MotionEvent.ACTION_DOWN && isFullyCollapsed()) { + updateVerticalPanelPosition(event.getX()); + } super.onTouchEvent(event); return true; } @@ -740,7 +749,7 @@ public class NotificationPanelView extends PanelView implements } private boolean isInQsArea(float x, float y) { - return (x >= mScrollView.getLeft() && x <= mScrollView.getRight()) && + return (x >= mScrollView.getX() && x <= mScrollView.getX() + mScrollView.getWidth()) && (y <= mNotificationStackScroller.getBottomMostNotificationBottom() || y <= mQsContainer.getY() + mQsContainer.getHeight()); } @@ -939,7 +948,7 @@ public class NotificationPanelView extends PanelView implements mKeyguardStatusBar.setAlpha(1f); mKeyguardStatusBar.setVisibility(keyguardShowing ? View.VISIBLE : View.INVISIBLE); } - + resetVerticalPanelPosition(); updateQsState(); } @@ -1376,7 +1385,7 @@ public class NotificationPanelView extends PanelView implements return false; } View header = mKeyguardShowing ? mKeyguardStatusBar : mHeader; - boolean onHeader = x >= header.getLeft() && x <= header.getRight() + boolean onHeader = x >= header.getX() && x <= header.getX() + header.getWidth() && y >= header.getTop() && y <= header.getBottom(); if (mQsExpanded) { return onHeader || (mScrollView.isScrolledToBottom() && yDiff < 0) && isInQsArea(x, y); @@ -1771,6 +1780,10 @@ public class NotificationPanelView extends PanelView implements protected void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); mAfforanceHelper.onConfigurationChanged(); + if (newConfig.orientation != mLastOrientation) { + resetVerticalPanelPosition(); + } + mLastOrientation = newConfig.orientation; } @Override @@ -2185,4 +2198,42 @@ public class NotificationPanelView extends PanelView implements mExpandingFromHeadsUp = true; } } + + @Override + protected void onClosingFinished() { + super.onClosingFinished(); + resetVerticalPanelPosition(); + } + + /** + * Updates the vertical position of the panel so it is positioned closer to the touch + * responsible for opening the panel. + * + * @param x the x-coordinate the touch event + */ + private void updateVerticalPanelPosition(float x) { + if (mNotificationStackScroller.getWidth() * 1.75f > getWidth()) { + resetVerticalPanelPosition(); + return; + } + float leftMost = mPositionMinSideMargin + mNotificationStackScroller.getWidth() / 2; + float rightMost = getWidth() - mPositionMinSideMargin + - mNotificationStackScroller.getWidth() / 2; + if (Math.abs(x - getWidth() / 2) < mNotificationStackScroller.getWidth() / 4) { + x = getWidth() / 2; + } + x = Math.min(rightMost, Math.max(leftMost, x)); + setVerticalPanelTranslation(x - + (mNotificationStackScroller.getLeft() + mNotificationStackScroller.getWidth()/2)); + } + + private void resetVerticalPanelPosition() { + setVerticalPanelTranslation(0f); + } + + private void setVerticalPanelTranslation(float translation) { + mNotificationStackScroller.setTranslationX(translation); + mScrollView.setTranslationX(translation); + mHeader.setTranslationX(translation); + } } |