From 3e3010d824f2f57a09a4ddba0d304b68f695d0ed Mon Sep 17 00:00:00 2001 From: calderwoodra Date: Thu, 31 Aug 2017 14:13:44 -0700 Subject: Last contact in search is now visible when dialpad is closed. When the dialpad closes and we enter regular search, the fragment translates downwards so the upper contact is not cropped. This resulted in the bottom contact being cropped. Now the fragment translates and resizes so all contacts fit in the provided space. from the bugbash: #20: last contact is hidden off screen when in regular search screenshot: http://screen/vbduKLKKor2 Bug: 64902476,36880551 Test: manual PiperOrigin-RevId: 167189351 Change-Id: I3ba5795ba4c2f781dc320add3928c5ad74070b46 --- .../searchfragment/list/NewSearchFragment.java | 24 +++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/java/com/android/dialer/searchfragment/list/NewSearchFragment.java b/java/com/android/dialer/searchfragment/list/NewSearchFragment.java index 910e454f8..5b3532cdb 100644 --- a/java/com/android/dialer/searchfragment/list/NewSearchFragment.java +++ b/java/com/android/dialer/searchfragment/list/NewSearchFragment.java @@ -32,6 +32,8 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.animation.Interpolator; +import android.widget.FrameLayout; +import android.widget.FrameLayout.LayoutParams; import com.android.contacts.common.extensions.PhoneDirectoryExtenderAccessor; import com.android.dialer.animation.AnimUtils; import com.android.dialer.callintent.CallInitiationType; @@ -198,6 +200,7 @@ public final class NewSearchFragment extends Fragment } } + /** Translate the search fragment and resize it to fit on the screen. */ public void animatePosition(int start, int end, int duration) { // Called before the view is ready, prepare a runnable to run in onCreateView if (getView() == null) { @@ -206,11 +209,30 @@ public final class NewSearchFragment extends Fragment } boolean slideUp = start > end; Interpolator interpolator = slideUp ? AnimUtils.EASE_IN : AnimUtils.EASE_OUT; + int startHeight = getView().getHeight(); + int endHeight = startHeight - (end - start); getView().setTranslationY(start); - getView().animate().translationY(end).setInterpolator(interpolator).setDuration(duration); + getView() + .animate() + .translationY(end) + .setInterpolator(interpolator) + .setDuration(duration) + .setUpdateListener( + animation -> setHeight(startHeight, endHeight, animation.getAnimatedFraction())); updatePositionRunnable = null; } + private void setHeight(int start, int end, float percentage) { + View view = getView(); + if (view == null) { + return; + } + + FrameLayout.LayoutParams params = (LayoutParams) view.getLayoutParams(); + params.height = (int) (start + (end - start) * percentage); + view.setLayoutParams(params); + } + @Override public void onDestroy() { super.onDestroy(); -- cgit v1.2.3