Keep landscape quickcontact title on screen
When QuickContacts opens partially offset from the top of
the screen, the title should be visible. To do this, I
offset the title padding by the amount that QuickContacts is
offset from the top of the screen, up to a maximum amount
equal to the starting QuickContact offset.
See bug for demo mp4s.
Bug: 17417615
Change-Id: Ie39c130c23c9541bdd912bbb406a9bae0966e965
diff --git a/src/com/android/contacts/widget/MultiShrinkScroller.java b/src/com/android/contacts/widget/MultiShrinkScroller.java
index cf32aa1..dcc3b61 100644
--- a/src/com/android/contacts/widget/MultiShrinkScroller.java
+++ b/src/com/android/contacts/widget/MultiShrinkScroller.java
@@ -375,6 +375,13 @@
mTitleGradientView.setLayoutParams(titleGradientLayoutParams);
}
+ private void setTitleGradientViewBottomMargin(int bottomMargin) {
+ final FrameLayout.LayoutParams titleGradientLayoutParams
+ = (FrameLayout.LayoutParams) mTitleGradientView.getLayoutParams();
+ titleGradientLayoutParams.bottomMargin = bottomMargin;
+ mTitleGradientView.setLayoutParams(titleGradientLayoutParams);
+ }
+
public void setTitle(String title) {
mLargeTextView.setText(title);
mPhotoTouchInterceptOverlay.setContentDescription(title);
@@ -942,7 +949,18 @@
*/
private void updateHeaderTextSizeAndMargin() {
if (mIsTwoPanel) {
- // The text size stays at a constant size & location in two panel layouts.
+ // This is the amount of additional padding needed to keep the title text on screen.
+ final int transparentHeight = mTransparentView.getLayoutParams().height;
+ // We want to keep the title text on screen as we scroll, up to a point. Once we
+ // scroll farther off the screen than the semi collapsed starting height, stop
+ // compensating for scrolling.
+ final int scrollCompensation = Math.min(transparentHeight, mTransparentStartHeight);
+ mLargeTextView.setPadding(mLargeTextView.getPaddingLeft(),
+ mLargeTextView.getPaddingTop(), mLargeTextView.getPaddingRight(),
+ scrollCompensation);
+ // Use margin to offset the title gradient instead of padding. This is necessary since
+ // GradientDrawable appears to ignore the insets suggested by its View's padding.
+ setTitleGradientViewBottomMargin(scrollCompensation);
return;
}