Skip to content

Commit 762ca84

Browse files
chethaaseAndroid (Google) Code Review
authored andcommitted
Merge "Sped up ActionBar and StatusBar animations" into jb-dev
2 parents efc620a + e8118e1 commit 762ca84

File tree

9 files changed

+40
-37
lines changed

9 files changed

+40
-37
lines changed

core/java/com/android/internal/app/ActionBarImpl.java

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -673,36 +673,36 @@ public void doShow(boolean fromSystem) {
673673

674674
if (mCurWindowVisibility == View.VISIBLE && (mShowHideAnimationEnabled
675675
|| fromSystem)) {
676-
mTopVisibilityView.setAlpha(0);
677-
mTopVisibilityView.setTranslationY(-mTopVisibilityView.getHeight());
676+
mTopVisibilityView.setTranslationY(0); // because we're about to ask its window loc
677+
float startingY = -mTopVisibilityView.getHeight();
678+
if (fromSystem) {
679+
int topLeft[] = {0, 0};
680+
mTopVisibilityView.getLocationInWindow(topLeft);
681+
startingY -= topLeft[1];
682+
}
683+
mTopVisibilityView.setTranslationY(startingY);
678684
AnimatorSet anim = new AnimatorSet();
679-
AnimatorSet.Builder b = anim.play(ObjectAnimator.ofFloat(mTopVisibilityView, "alpha", 1));
680-
b.with(ObjectAnimator.ofFloat(mTopVisibilityView, "translationY", 0));
685+
AnimatorSet.Builder b = anim.play(ObjectAnimator.ofFloat(mTopVisibilityView,
686+
"translationY", 0));
681687
if (mContentView != null) {
682688
b.with(ObjectAnimator.ofFloat(mContentView, "translationY",
683-
-mTopVisibilityView.getHeight(), 0));
689+
startingY, 0));
684690
}
685691
if (mSplitView != null && mContextDisplayMode == CONTEXT_DISPLAY_SPLIT) {
686-
mSplitView.setAlpha(0);
687692
mSplitView.setTranslationY(mSplitView.getHeight());
688693
mSplitView.setVisibility(View.VISIBLE);
689-
b.with(ObjectAnimator.ofFloat(mSplitView, "alpha", 1));
690694
b.with(ObjectAnimator.ofFloat(mSplitView, "translationY", 0));
691695
}
692696
anim.setInterpolator(AnimationUtils.loadInterpolator(mContext,
693-
com.android.internal.R.interpolator.decelerate_quad));
694-
anim.setDuration(mContext.getResources().getInteger(
695-
com.android.internal.R.integer.config_mediumAnimTime));
697+
com.android.internal.R.interpolator.decelerate_cubic));
698+
anim.setDuration(250);
696699
// If this is being shown from the system, add a small delay.
697700
// This is because we will also be animating in the status bar,
698701
// and these two elements can't be done in lock-step. So we give
699702
// a little time for the status bar to start its animation before
700703
// the action bar animates. (This corresponds to the corresponding
701704
// case when hiding, where the status bar has a small delay before
702705
// starting.)
703-
if (fromSystem) {
704-
anim.setStartDelay(100);
705-
}
706706
anim.addListener(mShowListener);
707707
mCurrentShowAnim = anim;
708708
anim.start();
@@ -734,23 +734,26 @@ public void doHide(boolean fromSystem) {
734734
mTopVisibilityView.setAlpha(1);
735735
mContainerView.setTransitioning(true);
736736
AnimatorSet anim = new AnimatorSet();
737-
AnimatorSet.Builder b = anim.play(ObjectAnimator.ofFloat(mTopVisibilityView, "alpha", 0));
738-
b.with(ObjectAnimator.ofFloat(mTopVisibilityView, "translationY",
739-
-mTopVisibilityView.getHeight()));
737+
float endingY = -mTopVisibilityView.getHeight();
738+
if (fromSystem) {
739+
int topLeft[] = {0, 0};
740+
mTopVisibilityView.getLocationInWindow(topLeft);
741+
endingY -= topLeft[1];
742+
}
743+
AnimatorSet.Builder b = anim.play(ObjectAnimator.ofFloat(mTopVisibilityView,
744+
"translationY", endingY));
740745
if (mContentView != null) {
741746
b.with(ObjectAnimator.ofFloat(mContentView, "translationY",
742-
0, -mTopVisibilityView.getHeight()));
747+
0, endingY));
743748
}
744749
if (mSplitView != null && mSplitView.getVisibility() == View.VISIBLE) {
745750
mSplitView.setAlpha(1);
746-
b.with(ObjectAnimator.ofFloat(mSplitView, "alpha", 0));
747751
b.with(ObjectAnimator.ofFloat(mSplitView, "translationY",
748752
mSplitView.getHeight()));
749753
}
750754
anim.setInterpolator(AnimationUtils.loadInterpolator(mContext,
751-
com.android.internal.R.interpolator.accelerate_quad));
752-
anim.setDuration(mContext.getResources().getInteger(
753-
com.android.internal.R.integer.config_mediumAnimTime));
755+
com.android.internal.R.interpolator.accelerate_cubic));
756+
anim.setDuration(250);
754757
anim.addListener(mHideListener);
755758
mCurrentShowAnim = anim;
756759
anim.start();

core/res/res/anim/dock_bottom_enter.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
<!-- Animation for when a dock window at the bottom of the screen is entering. -->
2020
<set xmlns:android="http://schemas.android.com/apk/res/android"
21-
android:interpolator="@android:interpolator/decelerate_quad">
21+
android:interpolator="@android:interpolator/decelerate_cubic">
2222
<translate android:fromYDelta="100%" android:toYDelta="0"
23-
android:duration="@android:integer/config_mediumAnimTime"/>
23+
android:duration="250"/>
2424
</set>

core/res/res/anim/dock_bottom_exit.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
<!-- Animation for when a dock window at the bottom of the screen is exiting. -->
2020
<set xmlns:android="http://schemas.android.com/apk/res/android"
21-
android:interpolator="@android:interpolator/accelerate_quad">
21+
android:interpolator="@android:interpolator/accelerate_cubic">
2222
<translate android:fromYDelta="0" android:toYDelta="100%"
23-
android:startOffset="100" android:duration="@android:integer/config_mediumAnimTime"/>
23+
android:startOffset="100" android:duration="250"/>
2424
</set>

core/res/res/anim/dock_left_enter.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
<!-- Animation for when a dock window at the left of the screen is entering. -->
2020
<set xmlns:android="http://schemas.android.com/apk/res/android"
21-
android:interpolator="@android:interpolator/decelerate_quad">
21+
android:interpolator="@android:interpolator/decelerate_cubic">
2222
<translate android:fromXDelta="-100%" android:toXDelta="0"
23-
android:duration="@android:integer/config_mediumAnimTime"/>
23+
android:duration="250"/>
2424
</set>

core/res/res/anim/dock_left_exit.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
<!-- Animation for when a dock window at the right of the screen is exiting. -->
2020
<set xmlns:android="http://schemas.android.com/apk/res/android"
21-
android:interpolator="@android:interpolator/accelerate_quad">
21+
android:interpolator="@android:interpolator/accelerate_cubic">
2222
<translate android:fromXDelta="0" android:toXDelta="-100%"
23-
android:startOffset="100" android:duration="@android:integer/config_mediumAnimTime"/>
23+
android:startOffset="100" android:duration="250"/>
2424
</set>

core/res/res/anim/dock_right_enter.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
<!-- Animation for when a dock window at the right of the screen is entering. -->
2020
<set xmlns:android="http://schemas.android.com/apk/res/android"
21-
android:interpolator="@android:interpolator/decelerate_quad">
21+
android:interpolator="@android:interpolator/decelerate_cubic">
2222
<translate android:fromXDelta="100%" android:toXDelta="0"
23-
android:duration="@android:integer/config_mediumAnimTime"/>
23+
android:duration="250"/>
2424
</set>

core/res/res/anim/dock_right_exit.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
<!-- Animation for when a dock window at the right of the screen is exiting. -->
2020
<set xmlns:android="http://schemas.android.com/apk/res/android"
21-
android:interpolator="@android:interpolator/accelerate_quad">
21+
android:interpolator="@android:interpolator/accelerate_cubic">
2222
<translate android:fromXDelta="0" android:toXDelta="100%"
23-
android:startOffset="100" android:duration="@android:integer/config_mediumAnimTime"/>
23+
android:startOffset="100" android:duration="250"/>
2424
</set>

core/res/res/anim/dock_top_enter.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
<!-- Animation for when a dock window at the top of the screen is entering. -->
2020
<set xmlns:android="http://schemas.android.com/apk/res/android"
21-
android:interpolator="@android:interpolator/decelerate_quad">
21+
android:interpolator="@android:interpolator/decelerate_cubic">
2222
<translate android:fromYDelta="-100%" android:toYDelta="0"
23-
android:duration="@android:integer/config_mediumAnimTime"/>
23+
android:duration="250"/>
2424
</set>

core/res/res/anim/dock_top_exit.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
<!-- Animation for when a dock window at the top of the screen is exiting. -->
2020
<set xmlns:android="http://schemas.android.com/apk/res/android"
21-
android:interpolator="@android:interpolator/accelerate_quad">
21+
android:interpolator="@android:interpolator/accelerate_cubic">
2222
<translate android:fromYDelta="0" android:toYDelta="-100%"
23-
android:startOffset="100" android:duration="@android:integer/config_mediumAnimTime"/>
23+
android:startOffset="100" android:duration="250"/>
2424
</set>

0 commit comments

Comments
 (0)