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
diff --git a/java/com/android/dialer/searchfragment/list/NewSearchFragment.java b/java/com/android/dialer/searchfragment/list/NewSearchFragment.java
index 910e454..5b3532c 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.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 @@
}
}
+ /** 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 @@
}
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();