diff options
author | Andrew Lee <anwlee@google.com> | 2014-08-21 17:13:57 -0700 |
---|---|---|
committer | Andrew Lee <anwlee@google.com> | 2014-09-11 15:50:03 -0700 |
commit | b4bad67915864a3f726de70ef2cf08a3a941ea70 (patch) | |
tree | 771e398de2082c04d251ae241425299ba89ad0b3 | |
parent | 3dc601795b113f8139e8a1f31c84b77f6793109c (diff) |
Align shortcut card to top while scrolling.
Bug: 16462679
Change-Id: I031909df291a25bf4894fbd34d06d163a195d94d
-rw-r--r-- | src/com/android/dialer/list/ListsFragment.java | 11 | ||||
-rw-r--r-- | src/com/android/dialer/list/ShortcutCardsAdapter.java | 21 |
2 files changed, 16 insertions, 16 deletions
diff --git a/src/com/android/dialer/list/ListsFragment.java b/src/com/android/dialer/list/ListsFragment.java index ed95dc2a4..5246b5583 100644 --- a/src/com/android/dialer/list/ListsFragment.java +++ b/src/com/android/dialer/list/ListsFragment.java @@ -111,12 +111,11 @@ public class ListsFragment extends AnalyticsFragment implements CallLogQueryHand private PanelSlideListener mPanelSlideListener = new PanelSlideListener() { @Override public void onPanelSlide(View panel, float slideOffset) { - // For every 1 percent that the panel is slid upwards, clip 1.5 percent from each edge - // of the shortcut card, to achieve the animated effect of the shortcut card - // rapidly shrinking and disappearing from view when the panel is slid upwards. - // slideOffset is 1 when the shortcut card is fully exposed, and 0 when completely - // hidden. - float ratioCardHidden = (1 - slideOffset) * 1.5f; + // For every 1 percent that the panel is slid upwards, clip 1 percent off the top + // edge of the shortcut card, to achieve the animated effect of the shortcut card + // being pushed out of view when the panel is slid upwards. slideOffset is 1 when + // the shortcut card is fully exposed, and 0 when completely hidden. + float ratioCardHidden = (1 - slideOffset); if (mShortcutCardsListView.getChildCount() > 0) { final SwipeableShortcutCard v = (SwipeableShortcutCard) mShortcutCardsListView.getChildAt(0); diff --git a/src/com/android/dialer/list/ShortcutCardsAdapter.java b/src/com/android/dialer/list/ShortcutCardsAdapter.java index 4bd914f25..d1ffa794a 100644 --- a/src/com/android/dialer/list/ShortcutCardsAdapter.java +++ b/src/com/android/dialer/list/ShortcutCardsAdapter.java @@ -52,6 +52,10 @@ public class ShortcutCardsAdapter extends BaseAdapter { } private static final String TAG = ShortcutCardsAdapter.class.getSimpleName(); + private static final float CLIP_CARD_BARELY_HIDDEN_RATIO = 0.001f; + private static final float CLIP_CARD_MOSTLY_HIDDEN_RATIO = 0.9f; + // Fade out 5x faster than the hidden ratio. + private static final float CLIP_CARD_OPACITY_RATIO = 5f; private final CallLogAdapter mCallLogAdapter; @@ -339,34 +343,31 @@ public class ShortcutCardsAdapter extends BaseAdapter { int width = viewToClip.getWidth(); int height = viewToClip.getHeight(); - if (ratioHidden <= 0.001f) { + if (ratioHidden <= CLIP_CARD_BARELY_HIDDEN_RATIO) { viewToClip.setTranslationZ(mPreviousTranslationZ); } else if (viewToClip.getTranslationZ() != 0){ mPreviousTranslationZ = viewToClip.getTranslationZ(); viewToClip.setTranslationZ(0); } - if (ratioHidden > 0.5f) { + if (ratioHidden > CLIP_CARD_MOSTLY_HIDDEN_RATIO) { mClipRect.set(0, 0 , 0, 0); setVisibility(View.INVISIBLE); } else { setVisibility(View.VISIBLE); - int newLeft = (int) (ratioHidden * mCardMaxHorizontalClip); - int newRight = width - newLeft; int newTop = (int) (ratioHidden * height); - int newBottom = (height - newTop); - mClipRect.set(newLeft, newTop, newRight, newBottom); + mClipRect.set(0, newTop, width, height); // Since the pane will be overlapping with the action bar, apply a vertical offset - // to visually center the clipped card in the viewable area; - int verticalOffset = -newTop / 2; - viewToClip.setTranslationY(verticalOffset); + // to top align the clipped card in the viewable area; + viewToClip.setTranslationY(-newTop); } viewToClip.setClipBounds(mClipRect); // If the view has any children, fade them out of view. final ViewGroup viewGroup = (ViewGroup) viewToClip; - setChildrenOpacity(viewGroup, Math.max(0, 1 - 4.5f * ratioHidden)); + setChildrenOpacity( + viewGroup, Math.max(0, 1 - (CLIP_CARD_OPACITY_RATIO * ratioHidden))); } private void setChildrenOpacity(ViewGroup viewGroup, float alpha) { |