summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/searchfragment
diff options
context:
space:
mode:
authorcalderwoodra <calderwoodra@google.com>2017-08-31 14:13:44 -0700
committerEric Erfanian <erfanian@google.com>2017-09-06 16:44:04 -0700
commit3e3010d824f2f57a09a4ddba0d304b68f695d0ed (patch)
tree62aaf4c39b2c92c3d5fe58891fee50c687bf669b /java/com/android/dialer/searchfragment
parentcc2cde0555bd49362f7631c64d24221b24ed71c8 (diff)
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
Diffstat (limited to 'java/com/android/dialer/searchfragment')
-rw-r--r--java/com/android/dialer/searchfragment/list/NewSearchFragment.java24
1 files changed, 23 insertions, 1 deletions
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();