зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1072464 - Implement new tablet forward button dimensions and clean up animation code. r=lucasr
This commit is contained in:
Родитель
a66e9f2aa6
Коммит
8246da0b44
|
@ -11,7 +11,7 @@
|
|||
android:layout_height="match_parent"
|
||||
android:layout_alignLeft="@+id/back"
|
||||
android:layout_toLeftOf="@id/menu_items"
|
||||
android:layout_marginLeft="@dimen/back_button_width_half"
|
||||
android:layout_marginLeft="@dimen/new_tablet_nav_button_width_half"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:duplicateParentState="true"
|
||||
|
@ -25,8 +25,8 @@
|
|||
|
||||
<org.mozilla.gecko.toolbar.BackButton android:id="@id/back"
|
||||
style="@style/UrlBar.ImageButton.NewTablet"
|
||||
android:layout_width="@dimen/back_button_width"
|
||||
android:layout_height="@dimen/back_button_width"
|
||||
android:layout_width="@dimen/new_tablet_nav_button_width"
|
||||
android:layout_height="@dimen/new_tablet_nav_button_width"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="12dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
|
@ -43,8 +43,7 @@
|
|||
android:layout_toRightOf="@id/back"
|
||||
android:layout_toLeftOf="@id/menu_items"/>
|
||||
|
||||
<!-- Note: * Values of marginLeft are used to animate the forward button so don't change its value.
|
||||
* We set the padding on the site security icon to increase its tappable area. -->
|
||||
<!-- Note: we set the padding on the site security icon to increase its tappable area. -->
|
||||
<org.mozilla.gecko.toolbar.ToolbarDisplayLayout android:id="@+id/display_layout"
|
||||
style="@style/UrlBar.Button.Container"
|
||||
android:layout_toRightOf="@id/back"
|
||||
|
|
|
@ -8,10 +8,6 @@
|
|||
<dimen name="browser_toolbar_height">56dp</dimen>
|
||||
<dimen name="browser_toolbar_button_padding">16dp</dimen>
|
||||
|
||||
<!-- If you update one of these values, update the other. -->
|
||||
<dimen name="back_button_width">42dp</dimen>
|
||||
<dimen name="back_button_width_half">21dp</dimen>
|
||||
|
||||
<dimen name="tabs_counter_size">26sp</dimen>
|
||||
<dimen name="panel_grid_view_column_width">200dp</dimen>
|
||||
|
||||
|
|
|
@ -25,8 +25,9 @@
|
|||
<item name="android:layout_marginLeft">@dimen/forward_default_offset</item>
|
||||
</style>
|
||||
|
||||
<!-- Note: this style is for the visible and expanded forward button. We translate/hide
|
||||
the forward button in code - see BrowserToolbarNewTablet.animateForwardButton. -->
|
||||
<style name="UrlBar.ImageButton.Forward.NewTablet">
|
||||
<item name="android:layout_marginLeft">@dimen/new_tablet_forward_default_offset</item>
|
||||
<item name="android:layout_height">match_parent</item>
|
||||
<item name="android:paddingTop">0dp</item>
|
||||
<item name="android:paddingBottom">0dp</item>
|
||||
|
@ -34,6 +35,20 @@
|
|||
<item name="android:layout_marginBottom">11.5dp</item>
|
||||
<item name="android:src">@drawable/new_tablet_ic_menu_forward</item>
|
||||
<item name="android:background">@drawable/new_tablet_url_bar_nav_button</item>
|
||||
|
||||
<!-- The visible area of the forward button is a nav_button_width and the
|
||||
non-visible area slides halfway under the back button. This non-visible
|
||||
area is used to ensure the forward button background fully
|
||||
covers the space to the right of the back button. -->
|
||||
<item name="android:layout_width">@dimen/new_tablet_nav_button_width_plus_half</item>
|
||||
|
||||
<!-- (See note above) We left align with back,
|
||||
but only need to hide halfway underneath. -->
|
||||
<item name="android:layout_marginLeft">@dimen/new_tablet_nav_button_width_half</item>
|
||||
|
||||
<!-- We use left padding to center the arrow in the
|
||||
visible area as opposed to the true width. -->
|
||||
<item name="android:paddingLeft">18dp</item>
|
||||
</style>
|
||||
|
||||
<style name="UrlBar.ImageButton.TabCount.NewTablet">
|
||||
|
|
|
@ -17,11 +17,15 @@
|
|||
<dimen name="browser_toolbar_favicon_size">21.33dip</dimen>
|
||||
<dimen name="browser_toolbar_shadow_size">2dp</dimen>
|
||||
|
||||
<!-- If you update one of these values, update the others. -->
|
||||
<dimen name="new_tablet_nav_button_width">42dp</dimen>
|
||||
<dimen name="new_tablet_nav_button_width_half">21dp</dimen>
|
||||
<dimen name="new_tablet_nav_button_width_plus_half">63dp</dimen>
|
||||
|
||||
<dimen name="new_tablet_tab_strip_height">48dp</dimen>
|
||||
<dimen name="new_tablet_tab_strip_item_width">250dp</dimen>
|
||||
<dimen name="new_tablet_tab_strip_item_margin">-30dp</dimen>
|
||||
<dimen name="new_tablet_tab_strip_favicon_size">16dp</dimen>
|
||||
<dimen name="new_tablet_forward_default_offset">-6dp</dimen>
|
||||
<dimen name="new_tablet_site_security_height">60dp</dimen>
|
||||
<dimen name="new_tablet_site_security_width">34dp</dimen>
|
||||
<!-- We primarily use padding (instead of margins) to increase the hit area. -->
|
||||
|
|
|
@ -10,7 +10,6 @@ import org.mozilla.gecko.animation.PropertyAnimator;
|
|||
import org.mozilla.gecko.animation.ViewHelper;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
/**
|
||||
|
@ -21,15 +20,18 @@ class BrowserToolbarNewTablet extends BrowserToolbarTabletBase {
|
|||
|
||||
private static final int FORWARD_ANIMATION_DURATION = 450;
|
||||
|
||||
private final int urlBarViewOffset;
|
||||
private final int defaultForwardMargin;
|
||||
private final int forwardButtonTranslationWidth;
|
||||
|
||||
public BrowserToolbarNewTablet(final Context context, final AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
final Resources res = getResources();
|
||||
urlBarViewOffset = res.getDimensionPixelSize(R.dimen.url_bar_offset_left);
|
||||
defaultForwardMargin = res.getDimensionPixelSize(R.dimen.new_tablet_forward_default_offset);
|
||||
forwardButtonTranslationWidth =
|
||||
getResources().getDimensionPixelOffset(R.dimen.new_tablet_nav_button_width);
|
||||
|
||||
// The forward button is initially expanded (in the layout file)
|
||||
// so translate it for start of the expansion animation; future
|
||||
// iterations translate it to this position when hiding and will already be set up.
|
||||
ViewHelper.setTranslationX(forwardButton, -forwardButtonTranslationWidth);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -49,25 +51,24 @@ class BrowserToolbarNewTablet extends BrowserToolbarTabletBase {
|
|||
|
||||
@Override
|
||||
protected void animateForwardButton(final ForwardButtonAnimation animation) {
|
||||
final boolean showing = (animation == ForwardButtonAnimation.SHOW);
|
||||
final boolean willShowForward = (animation == ForwardButtonAnimation.SHOW);
|
||||
|
||||
// if the forward button's margin is non-zero, this means it has already
|
||||
// been animated to be visible¸ and vice-versa.
|
||||
MarginLayoutParams fwdParams = (MarginLayoutParams) forwardButton.getLayoutParams();
|
||||
if ((fwdParams.leftMargin > defaultForwardMargin && showing) ||
|
||||
(fwdParams.leftMargin == defaultForwardMargin && !showing)) {
|
||||
// If we're not in the appropriate state to start a particular animation,
|
||||
// then we must be in the opposite state and do not need to animate.
|
||||
final float forwardOffset = ViewHelper.getTranslationX(forwardButton);
|
||||
if ((forwardOffset >= 0 && willShowForward) ||
|
||||
forwardOffset < 0 && !willShowForward) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We want the forward button to show immediately when switching tabs
|
||||
final PropertyAnimator forwardAnim =
|
||||
new PropertyAnimator(isSwitchingTabs ? 10 : FORWARD_ANIMATION_DURATION);
|
||||
final int width = Math.round(forwardButton.getWidth() * .75f);
|
||||
|
||||
forwardAnim.addPropertyAnimationListener(new PropertyAnimator.PropertyAnimationListener() {
|
||||
@Override
|
||||
public void onPropertyAnimationStart() {
|
||||
if (!showing) {
|
||||
if (!willShowForward) {
|
||||
// Set the margin before the transition when hiding the forward button. We
|
||||
// have to do this so that the favicon isn't clipped during the transition
|
||||
MarginLayoutParams layoutParams =
|
||||
|
@ -87,26 +88,23 @@ class BrowserToolbarNewTablet extends BrowserToolbarTabletBase {
|
|||
|
||||
@Override
|
||||
public void onPropertyAnimationEnd() {
|
||||
if (showing) {
|
||||
if (willShowForward) {
|
||||
// Increase the margins to ensure the text does not run outside the View.
|
||||
MarginLayoutParams layoutParams =
|
||||
(MarginLayoutParams) urlDisplayLayout.getLayoutParams();
|
||||
layoutParams.leftMargin = urlBarViewOffset;
|
||||
layoutParams.leftMargin = forwardButtonTranslationWidth;
|
||||
|
||||
layoutParams = (MarginLayoutParams) urlEditLayout.getLayoutParams();
|
||||
layoutParams.leftMargin = urlBarViewOffset;
|
||||
layoutParams.leftMargin = forwardButtonTranslationWidth;
|
||||
}
|
||||
|
||||
urlDisplayLayout.finishForwardAnimation();
|
||||
|
||||
MarginLayoutParams layoutParams = (MarginLayoutParams) forwardButton.getLayoutParams();
|
||||
layoutParams.leftMargin = defaultForwardMargin + (showing ? width : 0);
|
||||
ViewHelper.setTranslationX(forwardButton, 0);
|
||||
|
||||
requestLayout();
|
||||
}
|
||||
});
|
||||
|
||||
prepareForwardAnimation(forwardAnim, animation, width);
|
||||
prepareForwardAnimation(forwardAnim, animation, forwardButtonTranslationWidth);
|
||||
forwardAnim.start();
|
||||
}
|
||||
|
||||
|
@ -122,7 +120,7 @@ class BrowserToolbarNewTablet extends BrowserToolbarTabletBase {
|
|||
} else {
|
||||
anim.attach(forwardButton,
|
||||
PropertyAnimator.Property.TRANSLATION_X,
|
||||
width);
|
||||
0);
|
||||
anim.attach(forwardButton,
|
||||
PropertyAnimator.Property.ALPHA,
|
||||
1);
|
||||
|
|
|
@ -535,6 +535,8 @@ public class ToolbarDisplayLayout extends ThemedLinearLayout
|
|||
mForwardAnim = anim;
|
||||
|
||||
if (animation == ForwardButtonAnimation.HIDE) {
|
||||
// We animate these items individually, rather than this entire view,
|
||||
// so that we don't animate certain views, e.g. the stop button.
|
||||
anim.attach(mTitle,
|
||||
PropertyAnimator.Property.TRANSLATION_X,
|
||||
0);
|
||||
|
|
Загрузка…
Ссылка в новой задаче