author | Lucas Rocha <lucasr@mozilla.com> |
Tue, 07 May 2013 18:04:10 +0100 | |
changeset 142086 | 0881dcd9a86cf902585453829caf8d49690cb07a |
parent 142085 | 85c771c2fffdcb0ac62e1310c3a7b46c8894d7e1 |
child 142087 | c7919d0dd4f2c1209ee50bca74a6cad0fb7d69f7 |
push id | 2579 |
push user | akeybl@mozilla.com |
push date | Mon, 24 Jun 2013 18:52:47 +0000 |
treeherder | mozilla-beta@b69b7de8a05a [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | mfinkle |
bugs | 868460 |
milestone | 23.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/mobile/android/base/BrowserToolbar.java +++ b/mobile/android/base/BrowserToolbar.java @@ -546,51 +546,42 @@ public class BrowserToolbar implements T if (url != null && url.length() > 0) { setTitle(url); } if (HardwareUtils.isTablet() || Build.VERSION.SDK_INT < 11) { return; } - AnimatorProxy proxy = null; - // If the awesomebar entry is not selected at this point, this means that // we had to reinflate the toolbar layout for some reason (device rotation // while in awesome screen, activity was killed in background, etc). In this // case, we have to ensure the toolbar is in the correct initial state to // shrink back. if (!mLayout.isSelected()) { // Keep the entry highlighted during the animation mLayout.setSelected(true); final int entryTranslation = getAwesomeBarEntryTranslation(); final int curveTranslation = getAwesomeBarCurveTranslation(); if (mAwesomeBarRightEdge != null) { - proxy = AnimatorProxy.create(mAwesomeBarRightEdge); - proxy.setTranslationX(entryTranslation); + ViewHelper.setTranslationX(mAwesomeBarRightEdge, entryTranslation); } - proxy = AnimatorProxy.create(mTabs); - proxy.setTranslationX(curveTranslation); - proxy = AnimatorProxy.create(mTabsCounter); - proxy.setTranslationX(curveTranslation); - proxy = AnimatorProxy.create(mActionItemBar); - proxy.setTranslationX(curveTranslation); + ViewHelper.setTranslationX(mTabs, curveTranslation); + ViewHelper.setTranslationX(mTabsCounter, curveTranslation); + ViewHelper.setTranslationX(mActionItemBar, curveTranslation); if (mHasSoftMenuButton) { - proxy = AnimatorProxy.create(mMenu); - proxy.setTranslationX(curveTranslation); + ViewHelper.setTranslationX(mMenu, curveTranslation); } - proxy = AnimatorProxy.create(mReader); - proxy.setAlpha(0); - proxy = AnimatorProxy.create(mStop); - proxy.setAlpha(0); + ViewHelper.setAlpha(mReader, 0); + ViewHelper.setAlpha(mStop, 0); } final PropertyAnimator contentAnimator = new PropertyAnimator(250); contentAnimator.setUseHardwareLayer(false); // Shrink the awesome entry back to its original size if (mAwesomeBarRightEdge != null) { @@ -670,20 +661,18 @@ public class BrowserToolbar implements T final int entryTranslation = getAwesomeBarEntryTranslation(); final int curveTranslation = getAwesomeBarCurveTranslation(); // Keep the entry highlighted during the animation mLayout.setSelected(true); // Hide stop/reader buttons immediately - AnimatorProxy proxy = AnimatorProxy.create(mReader); - proxy.setAlpha(0); - proxy = AnimatorProxy.create(mStop); - proxy.setAlpha(0); + ViewHelper.setAlpha(mReader, 0); + ViewHelper.setAlpha(mStop, 0); // Slide the right side elements of the toolbar if (mAwesomeBarRightEdge != null) { contentAnimator.attach(mAwesomeBarRightEdge, PropertyAnimator.Property.TRANSLATION_X, entryTranslation); } @@ -1004,29 +993,25 @@ public class BrowserToolbar implements T @Override public void onPropertyAnimationEnd() { if (enabled) { ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams)mAwesomeBarContent.getLayoutParams(); layoutParams.leftMargin = mAddressBarViewOffset; - AnimatorProxy proxy = AnimatorProxy.create(mTitle); - proxy.setTranslationX(0); - proxy = AnimatorProxy.create(mFavicon); - proxy.setTranslationX(0); - proxy = AnimatorProxy.create(mSiteSecurity); - proxy.setTranslationX(0); + ViewHelper.setTranslationX(mTitle, 0); + ViewHelper.setTranslationX(mFavicon, 0); + ViewHelper.setTranslationX(mSiteSecurity, 0); } ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams)mForward.getLayoutParams(); layoutParams.leftMargin = mDefaultForwardMargin + (mForward.isEnabled() ? mForward.getWidth() / 2 : 0); - AnimatorProxy proxy = AnimatorProxy.create(mForward); - proxy.setTranslationX(0); + ViewHelper.setTranslationX(mForward, 0); mAwesomeBarContent.requestLayout(); mForwardAnim = null; } }); prepareForwardAnimation(mForwardAnim, enabled, width); mForwardAnim.start(); @@ -1048,22 +1033,19 @@ public class BrowserToolbar implements T 0); anim.attach(mSiteSecurity, PropertyAnimator.Property.TRANSLATION_X, 0); // We're hiding the forward button. We're going to reset the margin before // the animation starts, so we shift these items to the right so that they don't // appear to move initially. - AnimatorProxy proxy = AnimatorProxy.create(mTitle); - proxy.setTranslationX(mAddressBarViewOffset); - proxy = AnimatorProxy.create(mFavicon); - proxy.setTranslationX(mAddressBarViewOffset); - proxy = AnimatorProxy.create(mSiteSecurity); - proxy.setTranslationX(mAddressBarViewOffset); + ViewHelper.setTranslationX(mTitle, mAddressBarViewOffset); + ViewHelper.setTranslationX(mFavicon, mAddressBarViewOffset); + ViewHelper.setTranslationX(mSiteSecurity, mAddressBarViewOffset); } else { anim.attach(mForward, PropertyAnimator.Property.TRANSLATION_X, width); anim.attach(mForward, PropertyAnimator.Property.ALPHA, 1); anim.attach(mTitle,
--- a/mobile/android/base/Makefile.in +++ b/mobile/android/base/Makefile.in @@ -161,16 +161,17 @@ FENNEC_JAVA_FILES = \ TailTouchDelegate.java \ Telemetry.java \ TextSelection.java \ TextSelectionHandle.java \ ThumbnailHelper.java \ TouchEventInterceptor.java \ UpdateServiceHelper.java \ VideoPlayer.java \ + ViewHelper.java \ WebAppAllocator.java \ WebAppImpl.java \ ZoomConstraints.java \ db/BrowserContract.java \ db/BrowserProvider.java \ db/FormHistoryProvider.java \ db/PerProfileContentProvider.java \ db/PasswordsProvider.java \
--- a/mobile/android/base/TabsPanel.java +++ b/mobile/android/base/TabsPanel.java @@ -374,37 +374,32 @@ public class TabsPanel extends LinearLay return; } final Resources resources = getContext().getResources(); final int toolbarHeight = resources.getDimensionPixelSize(R.dimen.browser_toolbar_height); final int tabsPanelWidth = getWidth(); if (mVisible) { - AnimatorProxy proxy; - - proxy = AnimatorProxy.create(mHeader); if (mIsSideBar) { - proxy.setTranslationX(-tabsPanelWidth); + ViewHelper.setTranslationX(mHeader, -tabsPanelWidth); } else { - proxy.setTranslationY(-toolbarHeight); + ViewHelper.setTranslationY(mHeader, -toolbarHeight); } - proxy = AnimatorProxy.create(mTabsContainer); if (mIsSideBar) { - proxy.setTranslationX(-tabsPanelWidth); + ViewHelper.setTranslationX(mTabsContainer, -tabsPanelWidth); } else { - proxy.setTranslationY((float) (-toolbarHeight)); - proxy.setAlpha(0); + ViewHelper.setTranslationY(mTabsContainer, -toolbarHeight); + ViewHelper.setAlpha(mTabsContainer, 0); } // The footer view is only present on the sidebar if (mIsSideBar) { - proxy = AnimatorProxy.create(mFooter); - proxy.setTranslationX(-tabsPanelWidth); + ViewHelper.setTranslationX(mFooter, -tabsPanelWidth); } } if (mIsSideBar) { final int translationX = (mVisible ? 0 : -tabsPanelWidth); animator.attach(mTabsContainer, PropertyAnimator.Property.TRANSLATION_X,
--- a/mobile/android/base/TabsTray.java +++ b/mobile/android/base/TabsTray.java @@ -331,25 +331,24 @@ public class TabsTray extends TwoWayView final int tabId = tab.id; final int originalSize = (isVertical ? view.getHeight() : view.getWidth()); animator.setPropertyAnimationListener(new PropertyAnimator.PropertyAnimationListener() { @Override public void onPropertyAnimationStart() { } @Override public void onPropertyAnimationEnd() { - AnimatorProxy proxy = AnimatorProxy.create(view); - proxy.setAlpha(1); + ViewHelper.setAlpha(view, 1); if (isVertical) { - proxy.setHeight(originalSize); - proxy.setTranslationX(0); + ViewHelper.setHeight(view, originalSize); + ViewHelper.setTranslationX(view, 0); } else { - proxy.setWidth(originalSize); - proxy.setTranslationY(0); + ViewHelper.setWidth(view, originalSize); + ViewHelper.setTranslationY(view, 0); } Tabs tabs = Tabs.getInstance(); Tab tab = tabs.getTab(tabId); tabs.closeTab(tab); } }); @@ -389,28 +388,26 @@ public class TabsTray extends TwoWayView private int mMaxFlingVelocity; private VelocityTracker mVelocityTracker; private int mListWidth = 1; private int mListHeight = 1; private View mSwipeView; - private AnimatorProxy mSwipeProxy; private int mSwipeViewPosition; private Runnable mPendingCheckForTap; private float mSwipeStartX; private float mSwipeStartY; private boolean mSwiping; private boolean mEnabled; public TabSwipeGestureListener() { mSwipeView = null; - mSwipeProxy = null; mSwipeViewPosition = TwoWayView.INVALID_POSITION; mSwiping = false; mEnabled = true; ViewConfiguration vc = ViewConfiguration.get(TabsTray.this.getContext()); mSwipeThreshold = vc.getScaledTouchSlop(); mMinFlingVelocity = (int) (getContext().getResources().getDisplayMetrics().density * MIN_VELOCITY); mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity(); @@ -488,30 +485,30 @@ public class TabsTray extends TwoWayView float velocityX = Math.abs(mVelocityTracker.getXVelocity()); float velocityY = Math.abs(mVelocityTracker.getYVelocity()); boolean dismiss = false; boolean dismissDirection = false; int dismissTranslation = 0; if (isVertical()) { - float deltaX = mSwipeProxy.getTranslationX(); + float deltaX = ViewHelper.getTranslationX(mSwipeView); if (Math.abs(deltaX) > mListWidth / 2) { dismiss = true; dismissDirection = (deltaX > 0); } else if (mMinFlingVelocity <= velocityX && velocityX <= mMaxFlingVelocity && velocityY < velocityX) { dismiss = mSwiping && (deltaX * mVelocityTracker.getXVelocity() > 0); dismissDirection = (mVelocityTracker.getXVelocity() > 0); } dismissTranslation = (dismissDirection ? mListWidth : -mListWidth); } else { - float deltaY = mSwipeProxy.getTranslationY(); + float deltaY = ViewHelper.getTranslationY(mSwipeView); if (Math.abs(deltaY) > mListHeight / 2) { dismiss = true; dismissDirection = (deltaY > 0); } else if (mMinFlingVelocity <= velocityY && velocityY <= mMaxFlingVelocity && velocityX < velocityY) { dismiss = mSwiping && (deltaY * mVelocityTracker.getYVelocity() > 0); dismissDirection = (mVelocityTracker.getYVelocity() > 0); @@ -523,17 +520,16 @@ public class TabsTray extends TwoWayView if (dismiss) animateClose(mSwipeView, dismissTranslation); else animateCancel(mSwipeView); mVelocityTracker = null; mSwipeView = null; mSwipeViewPosition = TwoWayView.INVALID_POSITION; - mSwipeProxy = null; mSwipeStartX = 0; mSwipeStartY = 0; mSwiping = false; break; } @@ -566,27 +562,25 @@ public class TabsTray extends TwoWayView tab.close.setVisibility(View.INVISIBLE); // Stops listview from highlighting the touched item // in the list when swiping. MotionEvent cancelEvent = MotionEvent.obtain(e); cancelEvent.setAction(MotionEvent.ACTION_CANCEL | (e.getActionIndex() << MotionEvent.ACTION_POINTER_INDEX_SHIFT)); TabsTray.this.onTouchEvent(cancelEvent); - - mSwipeProxy = AnimatorProxy.create(mSwipeView); } if (mSwiping) { if (isVertical) - mSwipeProxy.setTranslationX(delta); + ViewHelper.setTranslationX(mSwipeView, delta); else - mSwipeProxy.setTranslationY(delta); + ViewHelper.setTranslationY(mSwipeView, delta); - mSwipeProxy.setAlpha(Math.max(0.1f, Math.min(1f, + ViewHelper.setAlpha(mSwipeView, Math.max(0.1f, Math.min(1f, 1f - 2f * Math.abs(delta) / (isVertical ? mListWidth : mListHeight)))); return true; } break; } }
new file mode 100644 --- /dev/null +++ b/mobile/android/base/ViewHelper.java @@ -0,0 +1,62 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +package org.mozilla.gecko; + +import android.view.View; + +public final class ViewHelper { + private ViewHelper() { + } + + public static float getTranslationX(View view) { + AnimatorProxy proxy = AnimatorProxy.create(view); + return proxy.getTranslationX(); + } + + public static void setTranslationX(View view, float translationX) { + final AnimatorProxy proxy = AnimatorProxy.create(view); + proxy.setTranslationX(translationX); + } + + public static float getTranslationY(View view) { + final AnimatorProxy proxy = AnimatorProxy.create(view); + return proxy.getTranslationY(); + } + + public static void setTranslationY(View view, float translationY) { + final AnimatorProxy proxy = AnimatorProxy.create(view); + proxy.setTranslationY(translationY); + } + + public static float getAlpha(View view) { + final AnimatorProxy proxy = AnimatorProxy.create(view); + return proxy.getAlpha(); + } + + public static void setAlpha(View view, float alpha) { + final AnimatorProxy proxy = AnimatorProxy.create(view); + proxy.setAlpha(alpha); + } + + public static int getWidth(View view) { + final AnimatorProxy proxy = AnimatorProxy.create(view); + return proxy.getWidth(); + } + + public static void setWidth(View view, int width) { + final AnimatorProxy proxy = AnimatorProxy.create(view); + proxy.setWidth(width); + } + + public static int getHeight(View view) { + final AnimatorProxy proxy = AnimatorProxy.create(view); + return proxy.getHeight(); + } + + public static void setHeight(View view, int height) { + final AnimatorProxy proxy = AnimatorProxy.create(view); + proxy.setHeight(height); + } +}