diff options
author | Andrew Lee <anwlee@google.com> | 2014-09-12 14:42:00 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-09-12 14:42:00 +0000 |
commit | 2342118268413692947a3e581de2ee35de69114d (patch) | |
tree | 3076036bbbbb1b4ad6be046dee7a323de49c7416 | |
parent | b8e5771a88541e967bfbe71e2723cfc177a0cb61 (diff) | |
parent | ecede942918b5af6d90f648d51a0776118ab2192 (diff) |
am ecede942: am b4bad679: Align shortcut card to top while scrolling.
* commit 'ecede942918b5af6d90f648d51a0776118ab2192':
Align shortcut card to top while scrolling.
-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) { |