From 649fc77497df79f2837f314a53fafdd2dd2c67aa Mon Sep 17 00:00:00 2001 From: Yorke Lee Date: Thu, 22 May 2014 18:03:17 -0700 Subject: Tweak card clipping effect Bug: 15165470 Change-Id: I5e61d23dc02237d0cd7c0e3646ce71b93a68a143 --- res/values/dimens.xml | 2 ++ src/com/android/dialer/list/ListsFragment.java | 4 ++-- src/com/android/dialer/list/ShortcutCardsAdapter.java | 9 ++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 6d7aa84fb..3c0ce053a 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -69,6 +69,8 @@ 5dp 8dp + + 20dp 12dp diff --git a/src/com/android/dialer/list/ListsFragment.java b/src/com/android/dialer/list/ListsFragment.java index ac3818c8b..78570e168 100644 --- a/src/com/android/dialer/list/ListsFragment.java +++ b/src/com/android/dialer/list/ListsFragment.java @@ -126,12 +126,12 @@ public class ListsFragment extends Fragment implements CallLogQueryHandler.Liste private PanelSlideListener mPanelSlideListener = new PanelSlideListener() { @Override public void onPanelSlide(View panel, float slideOffset) { - // For every 2 percent that the panel is slid upwards, clip 3 percent from each edge + // For every 1 percent that the panel is slid upwards, clip 2 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; + float ratioCardHidden = (1 - slideOffset) * 2f; if (mShortcutCardsListView.getCount() > 0) { 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 b4266d33d..4df44f0e2 100644 --- a/src/com/android/dialer/list/ShortcutCardsAdapter.java +++ b/src/com/android/dialer/list/ShortcutCardsAdapter.java @@ -55,6 +55,7 @@ public class ShortcutCardsAdapter extends BaseAdapter { private final ListsFragment mFragment; private final int mCallLogPadding; + private final int mCardMaxHorizontalClip; private final Context mContext; @@ -101,6 +102,8 @@ public class ShortcutCardsAdapter extends BaseAdapter { final Resources resources = context.getResources(); mContext = context; mFragment = fragment; + mCardMaxHorizontalClip = resources.getDimensionPixelSize( + R.dimen.recent_call_log_item_horizontal_clip_limit); mCallLogPadding = resources.getDimensionPixelSize(R.dimen.recent_call_log_item_padding); mCallLogAdapter = callLogAdapter; mObserver = new CustomDataSetObserver(); @@ -301,8 +304,8 @@ public class ShortcutCardsAdapter extends BaseAdapter { if (ratioHidden > 0.5f) { mClipRect.set(0, 0 , 0, 0); } else { - int newLeft = (int) (ratioHidden * width); - int newRight = (width - newLeft); + int newLeft = (int) (ratioHidden * mCardMaxHorizontalClip); + int newRight = width - newLeft; int newTop = (int) (ratioHidden * height); int newBottom = (height - newTop); mClipRect.set(newLeft, newTop, newRight, newBottom); @@ -313,7 +316,7 @@ public class ShortcutCardsAdapter extends BaseAdapter { final ViewGroup viewGroup = (ViewGroup) viewToClip; final int count = viewGroup.getChildCount(); for (int i = 0; i < count; i++) { - viewGroup.getChildAt(i).setAlpha(Math.max(0, 1 - 4 * ratioHidden)); + viewGroup.getChildAt(i).setAlpha(Math.max(0, 1 - 3 * ratioHidden)); } } } -- cgit v1.2.3