summaryrefslogtreecommitdiffstats
path: root/src/com/android/contacts/widget
diff options
context:
space:
mode:
authorBrian Attwell <brianattwell@google.com>2014-06-27 15:53:13 -0700
committerBrian Attwell <brianattwell@google.com>2014-06-27 15:59:30 -0700
commite838a44d3cf12bbc6135610f5095a34991d222f5 (patch)
treec5fca2f6a8437553bcad95ee826739492bd60908 /src/com/android/contacts/widget
parent2eb3ed2fe177f6adecabbf8052e36e7849a8c4aa (diff)
downloadpackages_apps_Contacts-e838a44d3cf12bbc6135610f5095a34991d222f5.tar.gz
packages_apps_Contacts-e838a44d3cf12bbc6135610f5095a34991d222f5.tar.bz2
packages_apps_Contacts-e838a44d3cf12bbc6135610f5095a34991d222f5.zip
If extra ScrollView space, don't compress header
When scrolling upwards, don't compress the header unless scrolling is needed to show additional content. Change-Id: I1da3d06b00d9e2efb5834f05fe515593363784e5
Diffstat (limited to 'src/com/android/contacts/widget')
-rw-r--r--src/com/android/contacts/widget/MultiShrinkScroller.java26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/com/android/contacts/widget/MultiShrinkScroller.java b/src/com/android/contacts/widget/MultiShrinkScroller.java
index 156c4bdcd..5c00a0a47 100644
--- a/src/com/android/contacts/widget/MultiShrinkScroller.java
+++ b/src/com/android/contacts/widget/MultiShrinkScroller.java
@@ -80,6 +80,7 @@ public class MultiShrinkScroller extends LinearLayout {
private MultiShrinkScrollerListener mListener;
private TextView mLargeTextView;
private View mPhotoTouchInterceptOverlay;
+ private View mLeftOverSpaceView;
/** Contains desired location/size of the title, once the header is fully compressed */
private TextView mInvisiblePlaceholderTextView;
private int mHeaderTintColor;
@@ -217,6 +218,7 @@ public class MultiShrinkScroller extends LinearLayout {
mTransparentView = findViewById(R.id.transparent_view);
mLargeTextView = (TextView) findViewById(R.id.large_title);
mInvisiblePlaceholderTextView = (TextView) findViewById(R.id.placeholder_textview);
+ mLeftOverSpaceView = findViewById(R.id.card_empty_space);
mListener = listener;
mPhotoView = (QuickContactImageView) findViewById(R.id.photo);
@@ -633,10 +635,10 @@ public class MultiShrinkScroller extends LinearLayout {
if (!mIsTwoPanel) {
return mTransparentStartHeight
// How much the Header view can compress
- + mIntermediateHeaderHeight - mMinimumHeaderHeight
+ + mIntermediateHeaderHeight - getFullyCompressedHeaderHeight()
// How much the ScrollView can scroll. 0, if child is smaller than ScrollView.
+ Math.max(0, mScrollViewChild.getHeight() - getHeight()
- + mMinimumHeaderHeight);
+ + getFullyCompressedHeaderHeight());
} else {
return mTransparentStartHeight
// How much the ScrollView can scroll. 0, if child is smaller than ScrollView.
@@ -662,16 +664,32 @@ public class MultiShrinkScroller extends LinearLayout {
}
final LinearLayout.LayoutParams toolbarLayoutParams
= (LayoutParams) mToolbar.getLayoutParams();
- if (toolbarLayoutParams.height != mMinimumHeaderHeight) {
+ if (toolbarLayoutParams.height > getFullyCompressedHeaderHeight()) {
final int originalValue = toolbarLayoutParams.height;
toolbarLayoutParams.height -= delta;
- toolbarLayoutParams.height = Math.max(toolbarLayoutParams.height, mMinimumHeaderHeight);
+ toolbarLayoutParams.height = Math.max(toolbarLayoutParams.height,
+ getFullyCompressedHeaderHeight());
mToolbar.setLayoutParams(toolbarLayoutParams);
delta -= originalValue - toolbarLayoutParams.height;
}
mScrollView.scrollBy(0, delta);
}
+ /**
+ * Returns the minimum size that we want to compress the header to, given that we don't want to
+ * allow the the ScrollView to scroll unless there is new content off of the edge of ScrollView.
+ */
+ private int getFullyCompressedHeaderHeight() {
+ final LinearLayout.LayoutParams toolbarLayoutParams
+ = (LayoutParams) mToolbar.getLayoutParams();
+ final int usedScrollViewSpace = mScrollViewChild.getHeight()
+ - mLeftOverSpaceView.getHeight();
+ final int leftOverSpace = -getHeight() + usedScrollViewSpace + toolbarLayoutParams.height;
+ return Math.min(
+ Math.max(toolbarLayoutParams.height - leftOverSpace, mMinimumHeaderHeight),
+ mIntermediateHeaderHeight);
+ }
+
private void scrollDown(int delta) {
if (mScrollView.getScrollY() > 0) {
final int originalValue = mScrollView.getScrollY();