summaryrefslogtreecommitdiffstats
path: root/src/com
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
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')
-rw-r--r--src/com/android/contacts/quickcontact/ExpandingEntryCardView.java9
-rw-r--r--src/com/android/contacts/quickcontact/QuickContactActivity.java13
-rw-r--r--src/com/android/contacts/widget/MultiShrinkScroller.java48
3 files changed, 61 insertions, 9 deletions
diff --git a/src/com/android/contacts/quickcontact/ExpandingEntryCardView.java b/src/com/android/contacts/quickcontact/ExpandingEntryCardView.java
index 209284f20..390fc2843 100644
--- a/src/com/android/contacts/quickcontact/ExpandingEntryCardView.java
+++ b/src/com/android/contacts/quickcontact/ExpandingEntryCardView.java
@@ -112,6 +112,10 @@ public class ExpandingEntryCardView extends LinearLayout {
}
}
+ public interface ExpandingEntryCardViewListener {
+ void onCollapse(int heightDelta);
+ }
+
private View mExpandCollapseButton;
private TextView mExpandCollapseTextView;
private TextView mTitleTextView;
@@ -120,6 +124,7 @@ public class ExpandingEntryCardView extends LinearLayout {
private OnClickListener mOnClickListener;
private boolean mIsExpanded = false;
private int mCollapsedEntriesCount;
+ private ExpandingEntryCardViewListener mListener;
private List<Entry> mEntries;
private List<View> mEntryViews;
private LinearLayout mEntriesViewGroup;
@@ -169,12 +174,13 @@ public class ExpandingEntryCardView extends LinearLayout {
* @param entries The Entry list to display.
*/
public void initialize(List<Entry> entries, int numInitialVisibleEntries,
- boolean isExpanded) {
+ boolean isExpanded, ExpandingEntryCardViewListener listener) {
LayoutInflater layoutInflater = LayoutInflater.from(getContext());
mIsExpanded = isExpanded;
mEntries = entries;
mEntryViews = new ArrayList<View>(entries.size());
mCollapsedEntriesCount = Math.min(numInitialVisibleEntries, entries.size());
+ mListener = listener;
if (mIsExpanded) {
updateExpandCollapseButton(getCollapseButtonText());
@@ -415,6 +421,7 @@ public class ExpandingEntryCardView extends LinearLayout {
private void collapse() {
int startingHeight = mEntriesViewGroup.getHeight();
int finishHeight = measureCollapsedViewGroupHeight();
+ mListener.onCollapse(startingHeight - finishHeight);
mIsExpanded = false;
updateExpandCollapseButton(getExpandButtonText());
diff --git a/src/com/android/contacts/quickcontact/QuickContactActivity.java b/src/com/android/contacts/quickcontact/QuickContactActivity.java
index c2f6538eb..1550aa40b 100644
--- a/src/com/android/contacts/quickcontact/QuickContactActivity.java
+++ b/src/com/android/contacts/quickcontact/QuickContactActivity.java
@@ -90,6 +90,7 @@ import com.android.contacts.interactions.ContactDeletionInteraction;
import com.android.contacts.interactions.ContactInteraction;
import com.android.contacts.interactions.SmsInteractionsLoader;
import com.android.contacts.quickcontact.ExpandingEntryCardView.Entry;
+import com.android.contacts.quickcontact.ExpandingEntryCardView.ExpandingEntryCardViewListener;
import com.android.contacts.util.ImageViewDrawableSetter;
import com.android.contacts.util.SchedulingUtils;
import com.android.contacts.widget.MultiShrinkScroller;
@@ -234,6 +235,14 @@ public class QuickContactActivity extends ContactsActivity {
}
};
+ final ExpandingEntryCardViewListener mExpandingEntryCardViewListener
+ = new ExpandingEntryCardViewListener() {
+ @Override
+ public void onCollapse(int heightDelta) {
+ mScroller.prepareForShrinkingScrollChild(heightDelta);
+ }
+ };
+
/**
* Headless fragment used to handle account selection callbacks invoked from
* {@link DirectoryContactUtil}.
@@ -586,7 +595,7 @@ public class QuickContactActivity extends ContactsActivity {
if (entries.size() > 0) {
mCommunicationCard.initialize(entries,
/* numInitialVisibleEntries = */ MIN_NUM_COMMUNICATION_ENTRIES_SHOWN,
- /* isExpanded = */ false);
+ /* isExpanded = */ false, mExpandingEntryCardViewListener);
}
final boolean hasData = !entries.isEmpty();
@@ -1087,7 +1096,7 @@ public class QuickContactActivity extends ContactsActivity {
if (allInteractions.size() > 0) {
mRecentCard.initialize(contactInteractionsToEntries(allInteractions),
/* numInitialVisibleEntries = */ MIN_NUM_COLLAPSED_RECENT_ENTRIES_SHOWN,
- /* isExpanded = */ false);
+ /* isExpanded = */ false, mExpandingEntryCardViewListener);
mRecentCard.setVisibility(View.VISIBLE);
}
}
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();
+ }
+ }
}