diff options
author | Brian Attwell <brianattwell@google.com> | 2014-07-30 15:37:42 -0700 |
---|---|---|
committer | Brian Attwell <brianattwell@google.com> | 2014-07-31 00:21:01 +0000 |
commit | fc00d0b3bf888751d53e946ad7e170e871c95788 (patch) | |
tree | c4e3b358aa493d75a18d0f0731ca3cb98add861e /src/com/android/contacts/widget | |
parent | ac9b31665c157e6aa7bce487a5467e8abd8224d5 (diff) | |
download | packages_apps_Contacts-fc00d0b3bf888751d53e946ad7e170e871c95788.tar.gz packages_apps_Contacts-fc00d0b3bf888751d53e946ad7e170e871c95788.tar.bz2 packages_apps_Contacts-fc00d0b3bf888751d53e946ad7e170e871c95788.zip |
Only the first QC snap should be aggressive
Only when first interacting with QC should the QC aggressively
snap to the top or the bottom of the screen.
Bug: 16683381
Change-Id: Ie250a5b4b77cacc4e4f3f77007ab7c92c5b4dd02
Diffstat (limited to 'src/com/android/contacts/widget')
-rw-r--r-- | src/com/android/contacts/widget/MultiShrinkScroller.java | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/com/android/contacts/widget/MultiShrinkScroller.java b/src/com/android/contacts/widget/MultiShrinkScroller.java index 8f1146a71..370c3ae28 100644 --- a/src/com/android/contacts/widget/MultiShrinkScroller.java +++ b/src/com/android/contacts/widget/MultiShrinkScroller.java @@ -111,6 +111,10 @@ public class MultiShrinkScroller extends LinearLayout { private int mCollapsedTitleStartMargin; private int mMinimumPortraitHeaderHeight; private int mMaximumPortraitHeaderHeight; + /** + * True once the header has touched the top of the screen at least once. + */ + private boolean mHasEverTouchedTheTop; private final Scroller mScroller; private final EdgeEffect mEdgeGlowBottom; @@ -490,6 +494,11 @@ public class MultiShrinkScroller extends LinearLayout { * If needed, snap the subviews to the top of the Window. */ private boolean snapToTop(int flingDelta) { + if (mHasEverTouchedTheTop) { + // Only when first interacting with QuickContacts should QuickContacts snap to the top + // of the screen. After this, QuickContacts can be placed most anywhere on the screen. + return false; + } final int requiredScroll = -getScroll_ignoreOversizedHeaderForSnapping() + mTransparentStartHeight; if (-getScroll_ignoreOversizedHeaderForSnapping() - flingDelta < 0 @@ -508,7 +517,18 @@ public class MultiShrinkScroller extends LinearLayout { * If needed, scroll all the subviews off the bottom of the Window. */ private void snapToBottom(int flingDelta) { - if (-getScroll_ignoreOversizedHeaderForSnapping() - flingDelta > 0) { + if (mHasEverTouchedTheTop) { + // If QuickContacts has touched the top of the screen previously, then we + // will less aggressively snap to the bottom of the screen. + final float predictedScrollPastTop = -getScroll() + mIntermediateHeaderHeight + - flingDelta; + final float heightMinusHeader = getHeight() - mIntermediateHeaderHeight; + if (predictedScrollPastTop > heightMinusHeader) { + scrollOffBottom(); + } + return; + } + if (-getScroll() - flingDelta > 0) { scrollOffBottom(); } } @@ -560,6 +580,7 @@ public class MultiShrinkScroller extends LinearLayout { updatePhotoTintAndDropShadow(); updateHeaderTextSize(); final boolean isFullscreen = getScrollNeededToBeFullScreen() <= 0; + mHasEverTouchedTheTop |= isFullscreen; if (mListener != null) { if (wasFullscreen && !isFullscreen) { mListener.onExitFullscreen(); |