Bug 825176 - Update margin after foward button animation. r=sriram

This commit is contained in:
Wes Johnston 2013-01-02 12:03:19 -08:00
parent d9413a98c6
commit 1b9cace7cc
3 changed files with 17 additions and 7 deletions

View File

@ -100,6 +100,7 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory,
private int mAddressBarViewOffset;
private int mAddressBarViewOffsetNoForward;
private int mDefaultForwardMargin;
private PropertyAnimator mForwardAnim = null;
private int mCount;
@ -134,6 +135,7 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory,
mAddressBarView = mLayout.findViewById(R.id.addressbar);
mAddressBarViewOffset = mActivity.getResources().getDimensionPixelSize(R.dimen.addressbar_offset_left);
mAddressBarViewOffsetNoForward = mActivity.getResources().getDimensionPixelSize(R.dimen.addressbar_offset_left_noforward);
mDefaultForwardMargin = mActivity.getResources().getDimensionPixelSize(R.dimen.forward_default_offset);
mAwesomeBarRightEdge = (GeckoFrameLayout) mLayout.findViewById(R.id.awesome_bar_right_edge);
mAwesomeBarEntry = mLayout.findViewById(R.id.awesome_bar_entry);
@ -1004,7 +1006,7 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory,
return;
mForwardAnim = new PropertyAnimator(FORWARD_ANIMATION_DURATION);
final int width = enabled ? mForward.getWidth()/2 : 0;
final int width = mForward.getWidth()/2;
mForwardAnim.setPropertyAnimationListener(new PropertyAnimator.PropertyAnimationListener() {
@Override
@ -1036,20 +1038,27 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory,
proxy = AnimatorProxy.create(mSiteSecurity);
proxy.setTranslationX(0);
mAddressBarView.requestLayout();
}
ViewGroup.MarginLayoutParams layoutParams =
(ViewGroup.MarginLayoutParams)mForward.getLayoutParams();
layoutParams.leftMargin = mDefaultForwardMargin + (mForward.isEnabled() ? width : 0);
AnimatorProxy proxy = AnimatorProxy.create(mForward);
proxy.setTranslationX(0);
mAddressBarView.requestLayout();
mForwardAnim = null;
}
});
prepareForwardAnimation(mForwardAnim, width);
prepareForwardAnimation(mForwardAnim, enabled, width);
mForwardAnim.start();
}
private void prepareForwardAnimation(PropertyAnimator anim, int width) {
if (width == 0) {
private void prepareForwardAnimation(PropertyAnimator anim, boolean enabled, int width) {
if (!enabled) {
anim.attach(mForward,
PropertyAnimator.Property.TRANSLATION_X,
0);
-width);
anim.attach(mForward,
PropertyAnimator.Property.ALPHA,
0);

View File

@ -12,5 +12,6 @@
<dimen name="tabs_counter_size">26sp</dimen>
<dimen name="addressbar_offset_left">90dp</dimen>
<dimen name="addressbar_offset_left_noforward">50dip</dimen>
<dimen name="forward_default_offset">-11dip</dimen>
</resources>

View File

@ -42,7 +42,7 @@
<item name="android:background">@drawable/address_bar_nav_button</item>
<!-- Start with the button hidden -->
<item name="android:alpha">0</item>
<item name="android:layout_marginLeft">-11dp</item>
<item name="android:layout_marginLeft">@dimen/forward_default_offset</item>
</style>
<style name="AddressBar.Button.Container">