Fix slight screen jank when sliding dialpad upwards
Apply the translation animation to mSearchAndRemoveViewContainer
(which houses the entire searchbox and its margins), so that the
translation takes into account the entire height of the searchbox
as well as its margins.
Also refactored hideSearchBar slightly to remove an unused codepath.
Bug: 13284310
Change-Id: I7b8873154059f616d8a52c4a0239ea6be89c8efc
diff --git a/res/layout/dialtacts_activity.xml b/res/layout/dialtacts_activity.xml
index 21f84bb..8f9f39c 100644
--- a/res/layout/dialtacts_activity.xml
+++ b/res/layout/dialtacts_activity.xml
@@ -39,6 +39,7 @@
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:id="@+id/search_and_remove_view_container"
>
<LinearLayout
android:layout_width="match_parent"
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java
index 4542137..c510355 100644
--- a/src/com/android/dialer/DialtactsActivity.java
+++ b/src/com/android/dialer/DialtactsActivity.java
@@ -168,6 +168,9 @@
private boolean mFirstLaunch;
private View mSearchViewContainer;
private RemoveView mRemoveViewContainer;
+ // This view points to the Framelayout that houses both the search view and remove view
+ // containers.
+ private View mSearchAndRemoveViewContainer;
private View mSearchViewCloseButton;
private View mVoiceSearchButton;
private EditText mSearchView;
@@ -310,6 +313,7 @@
mFragmentsFrame = findViewById(R.id.dialtacts_frame);
mRemoveViewContainer = (RemoveView) findViewById(R.id.remove_view_container);
+ mSearchAndRemoveViewContainer = (View) findViewById(R.id.search_and_remove_view_container);
prepareSearchView();
if (UI.FILTER_CONTACTS_ACTION.equals(intent.getAction())
@@ -564,7 +568,7 @@
final AnimatorListener mHideListener = new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
- mSearchViewContainer.setVisibility(View.GONE);
+ mSearchAndRemoveViewContainer.setVisibility(View.GONE);
}
};
@@ -583,43 +587,38 @@
}
public void hideSearchBar() {
- hideSearchBar(true);
- }
+ final int height = mSearchAndRemoveViewContainer.getHeight();
+ mSearchAndRemoveViewContainer.animate().cancel();
+ mSearchAndRemoveViewContainer.setAlpha(1);
+ mSearchAndRemoveViewContainer.setTranslationY(0);
+ mSearchAndRemoveViewContainer.animate().withLayer().alpha(0)
+ .translationY(-height).setDuration(200)
+ .setListener(mHideListener);
- public void hideSearchBar(boolean shiftView) {
- if (shiftView) {
- mSearchViewContainer.animate().cancel();
- mSearchViewContainer.setAlpha(1);
- mSearchViewContainer.setTranslationY(0);
- mSearchViewContainer.animate().withLayer().alpha(0).translationY(-mSearchView.getHeight())
- .setDuration(200).setListener(mHideListener);
-
- mFragmentsFrame.animate().withLayer()
- .translationY(-mSearchViewContainer.getHeight()).setDuration(200).setListener(
- new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- mFragmentsFrame.setTranslationY(0);
- }
- });
- } else {
- mSearchViewContainer.setTranslationY(-mSearchView.getHeight());
- }
+ mFragmentsFrame.animate().withLayer()
+ .translationY(-height).setDuration(200).setListener(
+ new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ mFragmentsFrame.setTranslationY(0);
+ }
+ });
}
public void showSearchBar() {
- mSearchViewContainer.animate().cancel();
- mSearchViewContainer.setAlpha(0);
- mSearchViewContainer.setTranslationY(-mSearchViewContainer.getHeight());
- mSearchViewContainer.animate().withLayer().alpha(1).translationY(0).setDuration(200)
- .setListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationStart(Animator animation) {
- mSearchViewContainer.setVisibility(View.VISIBLE);
- }
- });
+ final int height = mSearchAndRemoveViewContainer.getHeight();
+ mSearchAndRemoveViewContainer.animate().cancel();
+ mSearchAndRemoveViewContainer.setAlpha(0);
+ mSearchAndRemoveViewContainer.setTranslationY(-height);
+ mSearchAndRemoveViewContainer.animate().withLayer().alpha(1).translationY(0)
+ .setDuration(200).setListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationStart(Animator animation) {
+ mSearchAndRemoveViewContainer.setVisibility(View.VISIBLE);
+ }
+ });
- mFragmentsFrame.setTranslationY(-mSearchViewContainer.getHeight());
+ mFragmentsFrame.setTranslationY(-height);
mFragmentsFrame.animate().withLayer().translationY(0).setDuration(200)
.setListener(
new AnimatorListenerAdapter() {