summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/com/android/dialer/DialtactsActivity.java8
-rw-r--r--src/com/android/dialer/dialpad/DialpadFragment.java17
2 files changed, 19 insertions, 6 deletions
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java
index 726c17687..79d8d6977 100644
--- a/src/com/android/dialer/DialtactsActivity.java
+++ b/src/com/android/dialer/DialtactsActivity.java
@@ -422,15 +422,19 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
}
private void showDialpadFragment(boolean animate) {
+ mDialpadFragment.setAdjustTranslationForAnimation(animate);
final FragmentTransaction ft = getFragmentManager().beginTransaction();
if (animate) {
ft.setCustomAnimations(R.anim.slide_in, 0);
+ } else {
+ mDialpadFragment.setYFraction(0);
}
ft.show(mDialpadFragment);
ft.commit();
}
private void hideDialpadFragment(boolean animate) {
+ mDialpadFragment.setAdjustTranslationForAnimation(animate);
final FragmentTransaction ft = getFragmentManager().beginTransaction();
if (animate) {
ft.setCustomAnimations(0, R.anim.slide_out);
@@ -619,9 +623,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
if (mDialpadFragment != null && (phoneIsInUse() || isDialIntent(intent))) {
mDialpadFragment.setStartedFromNewIntent(true);
- // TODO krelease: This should use showDialpadFragment(false) to avoid animating
- // the dialpad in. Need to fix the onPreDrawListener in NewDialpadFragment first.
- showDialpadFragment(true);
+ showDialpadFragment(false);
}
}
diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java
index 3052c67f0..e11337427 100644
--- a/src/com/android/dialer/dialpad/DialpadFragment.java
+++ b/src/com/android/dialer/dialpad/DialpadFragment.java
@@ -262,6 +262,7 @@ public class DialpadFragment extends Fragment
private boolean mStartedFromNewIntent = false;
private boolean mFirstLaunch = false;
+ private boolean mAdjustTranslationForAnimation = false;
private static final String PREF_DIGITS_FILLED_BY_INTENT = "pref_digits_filled_by_intent";
@@ -350,15 +351,17 @@ public class DialpadFragment extends Fragment
false);
fragmentView.buildLayer();
- // TODO krelease: Get rid of this ugly hack which is to prevent the first frame of the
- // animation from drawing the fragment at translationY = 0
final ViewTreeObserver vto = fragmentView.getViewTreeObserver();
+ // Adjust the translation of the DialpadFragment in a preDrawListener instead of in
+ // DialtactsActivity, because at the point in time when the DialpadFragment is added,
+ // its views have not been laid out yet.
final OnPreDrawListener preDrawListener = new OnPreDrawListener() {
@Override
public boolean onPreDraw() {
+
if (isHidden()) return true;
- if (fragmentView.getTranslationY() == 0) {
+ if (mAdjustTranslationForAnimation && fragmentView.getTranslationY() == 0) {
((DialpadSlidingLinearLayout) fragmentView).setYFraction(
DIALPAD_SLIDE_FRACTION);
}
@@ -1691,4 +1694,12 @@ public class DialpadFragment extends Fragment
activity.hideSearchBar();
}
}
+
+ public void setAdjustTranslationForAnimation(boolean value) {
+ mAdjustTranslationForAnimation = value;
+ }
+
+ public void setYFraction(float yFraction) {
+ ((DialpadSlidingLinearLayout) getView()).setYFraction(yFraction);
+ }
}