Bug 889621 - Fade in homepager while expanding URL bar on tap (r=sriram)

This commit is contained in:
Lucas Rocha 2013-07-26 12:46:28 +01:00
parent b1a1af430e
commit 0ab5a6346c
3 changed files with 41 additions and 35 deletions

View File

@ -1313,8 +1313,13 @@ abstract public class BrowserApp extends GeckoApp
} }
} }
mBrowserToolbar.startEditing(url); final PropertyAnimator animator = new PropertyAnimator(300);
animateShowHomePager(HomePager.Page.VISITED); animator.setUseHardwareLayer(false);
mBrowserToolbar.startEditing(url, animator);
showHomePagerWithAnimator(HomePager.Page.VISITED, animator);
animator.start();
} }
void commitEditingMode() { void commitEditingMode() {
@ -1352,15 +1357,11 @@ abstract public class BrowserApp extends GeckoApp
} }
} }
private void animateShowHomePager(HomePager.Page page) {
showHomePagerWithAnimation(true, page);
}
private void showHomePager(HomePager.Page page) { private void showHomePager(HomePager.Page page) {
showHomePagerWithAnimation(false, page); showHomePagerWithAnimator(page, null);
} }
private void showHomePagerWithAnimation(boolean animate, HomePager.Page page) { private void showHomePagerWithAnimator(HomePager.Page page, PropertyAnimator animator) {
if (mHomePager.isVisible()) { if (mHomePager.isVisible()) {
return; return;
} }
@ -1374,8 +1375,7 @@ abstract public class BrowserApp extends GeckoApp
mLayerView.getLayerMarginsAnimator().showMargins(true); mLayerView.getLayerMarginsAnimator().showMargins(true);
} }
// FIXME: do animation if animate is true mHomePager.show(getSupportFragmentManager(), page, animator);
mHomePager.show(getSupportFragmentManager(), page);
} }
private void animateHideHomePager() { private void animateHideHomePager() {

View File

@ -1204,7 +1204,7 @@ public class BrowserToolbar extends GeckoRelativeLayout
return isSelected(); return isSelected();
} }
public void startEditing(String url) { public void startEditing(String url, PropertyAnimator animator) {
if (isEditing()) { if (isEditing()) {
return; return;
} }
@ -1221,9 +1221,6 @@ public class BrowserToolbar extends GeckoRelativeLayout
if (mAnimatingEntry) if (mAnimatingEntry)
return; return;
final PropertyAnimator contentAnimator = new PropertyAnimator(250);
contentAnimator.setUseHardwareLayer(false);
final int entryTranslation = getUrlBarEntryTranslation(); final int entryTranslation = getUrlBarEntryTranslation();
final int curveTranslation = getUrlBarCurveTranslation(); final int curveTranslation = getUrlBarCurveTranslation();
@ -1237,32 +1234,32 @@ public class BrowserToolbar extends GeckoRelativeLayout
// Slide the right side elements of the toolbar // Slide the right side elements of the toolbar
if (mUrlBarRightEdge != null) { if (mUrlBarRightEdge != null) {
contentAnimator.attach(mUrlBarRightEdge, animator.attach(mUrlBarRightEdge,
PropertyAnimator.Property.TRANSLATION_X, PropertyAnimator.Property.TRANSLATION_X,
entryTranslation); entryTranslation);
} }
contentAnimator.attach(mTabs, animator.attach(mTabs,
PropertyAnimator.Property.TRANSLATION_X, PropertyAnimator.Property.TRANSLATION_X,
curveTranslation); curveTranslation);
contentAnimator.attach(mTabsCounter, animator.attach(mTabsCounter,
PropertyAnimator.Property.TRANSLATION_X, PropertyAnimator.Property.TRANSLATION_X,
curveTranslation); curveTranslation);
contentAnimator.attach(mActionItemBar, animator.attach(mActionItemBar,
PropertyAnimator.Property.TRANSLATION_X, PropertyAnimator.Property.TRANSLATION_X,
curveTranslation); curveTranslation);
if (mHasSoftMenuButton) { if (mHasSoftMenuButton) {
contentAnimator.attach(mMenu, animator.attach(mMenu,
PropertyAnimator.Property.TRANSLATION_X, PropertyAnimator.Property.TRANSLATION_X,
curveTranslation); curveTranslation);
contentAnimator.attach(mMenuIcon, animator.attach(mMenuIcon,
PropertyAnimator.Property.TRANSLATION_X, PropertyAnimator.Property.TRANSLATION_X,
curveTranslation); curveTranslation);
} }
contentAnimator.addPropertyAnimationListener(new PropertyAnimator.PropertyAnimationListener() { animator.addPropertyAnimationListener(new PropertyAnimator.PropertyAnimationListener() {
@Override @Override
public void onPropertyAnimationStart() { public void onPropertyAnimationStart() {
} }
@ -1275,7 +1272,6 @@ public class BrowserToolbar extends GeckoRelativeLayout
}); });
mAnimatingEntry = true; mAnimatingEntry = true;
contentAnimator.start();
} }
/** /**

View File

@ -6,6 +6,8 @@
package org.mozilla.gecko.home; package org.mozilla.gecko.home;
import org.mozilla.gecko.R; import org.mozilla.gecko.R;
import org.mozilla.gecko.animation.PropertyAnimator;
import org.mozilla.gecko.animation.ViewHelper;
import android.content.Context; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
@ -59,7 +61,7 @@ public class HomePager extends ViewPager {
* *
* @param fm FragmentManager for the adapter * @param fm FragmentManager for the adapter
*/ */
public void show(FragmentManager fm, Page page) { public void show(FragmentManager fm, Page page, PropertyAnimator animator) {
mLoaded = true; mLoaded = true;
TabsAdapter adapter = new TabsAdapter(fm); TabsAdapter adapter = new TabsAdapter(fm);
@ -72,6 +74,14 @@ public class HomePager extends ViewPager {
setCurrentItem(adapter.getItemPosition(page), false); setCurrentItem(adapter.getItemPosition(page), false);
setVisibility(VISIBLE); setVisibility(VISIBLE);
if (animator != null) {
ViewHelper.setAlpha(this, 0.0f);
animator.attach(this,
PropertyAnimator.Property.ALPHA,
1.0f);
}
} }
/** /**