diff options
author | John Reck <jreck@google.com> | 2011-03-11 15:09:46 -0800 |
---|---|---|
committer | John Reck <jreck@google.com> | 2011-03-14 10:16:50 -0700 |
commit | e5c21d900adadbae92fb395d3dce44a75e90a9e7 (patch) | |
tree | 9dc1bc0658e442c08b6c3a282e7419c4bd6a1363 /src/com/android/browser/XLargeUi.java | |
parent | 7352480ad5b576f3ec4f964e7b5481b057fd2e13 (diff) | |
download | packages_apps_Browser-e5c21d900adadbae92fb395d3dce44a75e90a9e7.zip packages_apps_Browser-e5c21d900adadbae92fb395d3dce44a75e90a9e7.tar.gz packages_apps_Browser-e5c21d900adadbae92fb395d3dce44a75e90a9e7.tar.bz2 |
Animate url bar hide/show
Bug: 3443911
Change-Id: I3121371a784d17183a62dd8f9323de900b792b21
Diffstat (limited to 'src/com/android/browser/XLargeUi.java')
-rw-r--r-- | src/com/android/browser/XLargeUi.java | 57 |
1 files changed, 56 insertions, 1 deletions
diff --git a/src/com/android/browser/XLargeUi.java b/src/com/android/browser/XLargeUi.java index a9a55e8..9023f17 100644 --- a/src/com/android/browser/XLargeUi.java +++ b/src/com/android/browser/XLargeUi.java @@ -18,6 +18,9 @@ package com.android.browser; import com.android.browser.ScrollWebView.ScrollListener; +import android.animation.Animator; +import android.animation.Animator.AnimatorListener; +import android.animation.ObjectAnimator; import android.app.ActionBar; import android.app.Activity; import android.content.pm.PackageManager; @@ -47,6 +50,7 @@ public class XLargeUi extends BaseUi implements ScrollListener { private TabBar mTabBar; private TitleBarXLarge mTitleBar; + private Animator mTitleBarAnimator; private boolean mUseQuickControls; private PieControl mPieControl; @@ -317,6 +321,18 @@ public class XLargeUi extends BaseUi implements ScrollListener { if (mUseQuickControls) { mContentView.addView(mTitleBar); } else { + if (mTitleBarAnimator != null) { + mTitleBarAnimator.cancel(); + } + int visibleHeight = getVisibleTitleHeight(); + float startPos = (-mTitleBar.getEmbeddedHeight() + visibleHeight); + if (mTitleBar.getTranslationY() != 0) { + startPos = Math.max(startPos, mTitleBar.getTranslationY()); + } + mTitleBarAnimator = ObjectAnimator.ofFloat(mTitleBar, + "translationY", + startPos, 0); + mTitleBarAnimator.start(); setTitleGravity(Gravity.TOP); } super.showTitleBar(); @@ -331,12 +347,51 @@ public class XLargeUi extends BaseUi implements ScrollListener { if (mUseQuickControls) { mContentView.removeView(mTitleBar); } else { - setTitleGravity(Gravity.NO_GRAVITY); + if (mTitleBarAnimator != null) { + mTitleBarAnimator.cancel(); + } + int visibleHeight = getVisibleTitleHeight(); + mTitleBarAnimator = ObjectAnimator.ofFloat(mTitleBar, + "translationY", mTitleBar.getTranslationY(), + (-mTitleBar.getEmbeddedHeight() + visibleHeight)); + mTitleBarAnimator.addListener(mHideTileBarAnimatorListener); + mTitleBarAnimator.start(); } super.hideTitleBar(); } } + private int getVisibleTitleHeight() { + WebView webview = mActiveTab != null ? mActiveTab.getWebView() : null; + return webview != null ? webview.getVisibleTitleHeight() : 0; + } + + private AnimatorListener mHideTileBarAnimatorListener = new AnimatorListener() { + + boolean mWasCanceled; + @Override + public void onAnimationStart(Animator animation) { + mWasCanceled = false; + } + + @Override + public void onAnimationRepeat(Animator animation) { + } + + @Override + public void onAnimationEnd(Animator animation) { + if (!mWasCanceled) { + mTitleBar.setTranslationY(0); + setTitleGravity(Gravity.NO_GRAVITY); + } + } + + @Override + public void onAnimationCancel(Animator animation) { + mWasCanceled = true; + } + }; + public boolean isEditingUrl() { return mTitleBar.isEditingUrl(); } |