summaryrefslogtreecommitdiffstats
path: root/src/com/android/contacts/widget
diff options
context:
space:
mode:
authorBrian Attwell <brianattwell@google.com>2014-06-27 18:26:32 -0700
committerBrian Attwell <brianattwell@google.com>2014-06-30 11:20:45 -0700
commite8ce6ee1c5ab9f4f3dd11526337c70a8867647d9 (patch)
treefd9deadef9eb7a3779c01bf98f9a1558f5a12cca /src/com/android/contacts/widget
parent0c6b438f48cf6e5a391e37a2006264a43438d5d8 (diff)
downloadpackages_apps_Contacts-e8ce6ee1c5ab9f4f3dd11526337c70a8867647d9.tar.gz
packages_apps_Contacts-e8ce6ee1c5ab9f4f3dd11526337c70a8867647d9.tar.bz2
packages_apps_Contacts-e8ce6ee1c5ab9f4f3dd11526337c70a8867647d9.zip
Expand header when card collapses
If the card collapses enough to open up unused space inside MultiShrinkScroller, then expand the contact header. Change-Id: I88f3009ad90b2defcb7825cc797fd6105178efa4
Diffstat (limited to 'src/com/android/contacts/widget')
-rw-r--r--src/com/android/contacts/widget/MultiShrinkScroller.java48
1 files changed, 42 insertions, 6 deletions
diff --git a/src/com/android/contacts/widget/MultiShrinkScroller.java b/src/com/android/contacts/widget/MultiShrinkScroller.java
index 5c00a0a47..68195da78 100644
--- a/src/com/android/contacts/widget/MultiShrinkScroller.java
+++ b/src/com/android/contacts/widget/MultiShrinkScroller.java
@@ -501,6 +501,26 @@ public class MultiShrinkScroller extends LinearLayout {
}
/**
+ * Change the height of the header/toolbar. Do *not* use this outside animations. This was
+ * designed for use by {@link #prepareForShrinkingScrollChild}.
+ */
+ @NeededForReflection
+ public void setToolbarHeight(int delta) {
+ final LinearLayout.LayoutParams toolbarLayoutParams
+ = (LayoutParams) mToolbar.getLayoutParams();
+ toolbarLayoutParams.height = delta;
+ mToolbar.setLayoutParams(toolbarLayoutParams);
+
+ updatePhotoTintAndDropShadow();
+ updateHeaderTextSize();
+ }
+
+ @NeededForReflection
+ public int getToolbarHeight() {
+ return mToolbar.getLayoutParams().height;
+ }
+
+ /**
* Set the height of the toolbar and update its tint accordingly.
*/
@NeededForReflection
@@ -680,14 +700,17 @@ public class MultiShrinkScroller extends LinearLayout {
* 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();
+ return Math.min(Math.max(mToolbar.getLayoutParams().height - getOverflowingChildViewSize(),
+ mMinimumHeaderHeight), mIntermediateHeaderHeight);
+ }
+
+ /**
+ * Returns the amount of mScrollViewChild that doesn't fit inside its parent.
+ */
+ private int getOverflowingChildViewSize() {
final int usedScrollViewSpace = mScrollViewChild.getHeight()
- mLeftOverSpaceView.getHeight();
- final int leftOverSpace = -getHeight() + usedScrollViewSpace + toolbarLayoutParams.height;
- return Math.min(
- Math.max(toolbarLayoutParams.height - leftOverSpace, mMinimumHeaderHeight),
- mIntermediateHeaderHeight);
+ return -getHeight() + usedScrollViewSpace + mToolbar.getLayoutParams().height;
}
private void scrollDown(int delta) {
@@ -986,4 +1009,17 @@ public class MultiShrinkScroller extends LinearLayout {
return (long)(1000 / getRefreshRate());
}
}
+
+ /**
+ * Expand the header if the mScrollViewChild is about to shrink by enough to create new empty
+ * space at the bottom of this ViewGroup.
+ */
+ public void prepareForShrinkingScrollChild(int heightDelta) {
+ final int newEmptyScrollViewSpace = -getOverflowingChildViewSize() + heightDelta;
+ if (newEmptyScrollViewSpace > 0 && !mIsTwoPanel) {
+ final int newDesiredToolbarHeight = Math.min(mToolbar.getLayoutParams().height
+ + newEmptyScrollViewSpace, mIntermediateHeaderHeight);
+ ObjectAnimator.ofInt(this, "toolbarHeight", newDesiredToolbarHeight).start();
+ }
+ }
}