diff --git a/mobile/android/base/BrowserApp.java b/mobile/android/base/BrowserApp.java index c9025df7ea00..31e8e25c2cf0 100644 --- a/mobile/android/base/BrowserApp.java +++ b/mobile/android/base/BrowserApp.java @@ -342,7 +342,7 @@ abstract public class BrowserApp extends GeckoApp super.onCreate(savedInstanceState); - RelativeLayout actionBar = (RelativeLayout) getActionBarLayout(); + LinearLayout actionBar = (LinearLayout) getActionBarLayout(); mMainLayout.addView(actionBar, 2); ((GeckoApp.MainLayout) mMainLayout).setTouchEventInterceptor(new HideTabsTouchListener()); @@ -683,9 +683,16 @@ abstract public class BrowserApp extends GeckoApp } public View getActionBarLayout() { - RelativeLayout actionBar = (RelativeLayout) LayoutInflater.from(this).inflate(R.layout.browser_toolbar_menu, null); - actionBar.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, - (int) getResources().getDimension(R.dimen.browser_toolbar_height))); + int actionBarRes; + + if (!HardwareUtils.hasMenuButton() || HardwareUtils.isTablet()) + actionBarRes = R.layout.browser_toolbar_menu; + else + actionBarRes = R.layout.browser_toolbar; + + LinearLayout actionBar = (LinearLayout) LayoutInflater.from(this).inflate(actionBarRes, null); + actionBar.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, + (int) getResources().getDimension(R.dimen.browser_toolbar_height))); return actionBar; } diff --git a/mobile/android/base/BrowserToolbar.java b/mobile/android/base/BrowserToolbar.java index 147ef19a2055..8529e534c282 100644 --- a/mobile/android/base/BrowserToolbar.java +++ b/mobile/android/base/BrowserToolbar.java @@ -40,7 +40,6 @@ import android.widget.ImageButton; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.PopupWindow; -import android.widget.RelativeLayout; import android.widget.RelativeLayout.LayoutParams; import android.widget.ViewSwitcher; @@ -53,12 +52,16 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory, GeckoMenu.ActionItemBarPresenter, Animation.AnimationListener { private static final String LOGTAG = "GeckoToolbar"; - private GeckoRelativeLayout mLayout; + private LinearLayout mLayout; + private View mAwesomeBar; private LayoutParams mAwesomeBarParams; - private View mAwesomeBarContent; private View mAwesomeBarEntry; - private ImageView mAwesomeBarRightEdge; + private int mAwesomeBarEntryRightMargin; + private GeckoFrameLayout mAwesomeBarRightEdge; private BrowserToolbarBackground mAddressBarBg; + private View mAddressBarView; + private BrowserToolbarBackground.CurveTowards mAddressBarBgCurveTowards; + private int mAddressBarBgRightMargin; private GeckoTextView mTitle; private int mTitlePadding; private boolean mSiteSecurityVisible; @@ -102,6 +105,7 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory, private TranslateAnimation mTitleSlideRight; private int mAddressBarViewOffset; + private int mAddressBarViewOffsetNoForward; private int mDefaultForwardMargin; private PropertyAnimator mForwardAnim = null; @@ -127,23 +131,49 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory, mAnimatingEntry = false; } - public void from(RelativeLayout layout) { + public void from(LinearLayout layout) { if (mLayout != null) { // make sure we retain the visibility property on rotation layout.setVisibility(mLayout.getVisibility()); } + mLayout = layout; + mLayout.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + } + }); - mLayout = (GeckoRelativeLayout) layout; + mShowSiteSecurity = false; + mShowReader = false; - mLayout.setOnClickListener(new Button.OnClickListener() { + mAnimatingEntry = false; + + mAddressBarBg = (BrowserToolbarBackground) mLayout.findViewById(R.id.address_bar_bg); + 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); + + // This will hold the translation width inside the toolbar when the tabs + // pane is visible. It will affect the padding applied to the title TextView. + mTabsPaneWidth = 0; + + mTitle = (GeckoTextView) mLayout.findViewById(R.id.awesome_bar_title); + mTitlePadding = mTitle.getPaddingRight(); + if (Build.VERSION.SDK_INT >= 16) + mTitle.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO); + + mAwesomeBar = mLayout.findViewById(R.id.awesome_bar); + mAwesomeBar.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { mActivity.autoHideTabs(); onAwesomeBarSearch(); } }); - - mLayout.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() { + mAwesomeBar.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() { @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { MenuInflater inflater = mActivity.getMenuInflater(); @@ -176,30 +206,6 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory, } }); - mShowSiteSecurity = false; - mShowReader = false; - - mAnimatingEntry = false; - - mAddressBarBg = (BrowserToolbarBackground) mLayout.findViewById(R.id.address_bar_bg); - mAddressBarViewOffset = mActivity.getResources().getDimensionPixelSize(R.dimen.addressbar_offset_left); - mDefaultForwardMargin = mActivity.getResources().getDimensionPixelSize(R.dimen.forward_default_offset); - mAwesomeBarContent = mLayout.findViewById(R.id.awesome_bar_content); - mAwesomeBarEntry = mLayout.findViewById(R.id.awesome_bar_entry); - - // This will clip the right edge's image at half of its width - mAwesomeBarRightEdge = (ImageView) mLayout.findViewById(R.id.awesome_bar_right_edge); - mAwesomeBarRightEdge.getDrawable().setLevel(5000); - - // This will hold the translation width inside the toolbar when the tabs - // pane is visible. It will affect the padding applied to the title TextView. - mTabsPaneWidth = 0; - - mTitle = (GeckoTextView) mLayout.findViewById(R.id.awesome_bar_title); - mTitlePadding = mTitle.getPaddingRight(); - if (Build.VERSION.SDK_INT >= 16) - mTitle.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO); - mTabs = (ShapedButton) mLayout.findViewById(R.id.tabs); mTabs.setOnClickListener(new Button.OnClickListener() { @Override @@ -317,11 +323,6 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory, }); mShadow = (ImageView) mLayout.findViewById(R.id.shadow); - mShadow.setOnClickListener(new Button.OnClickListener() { - @Override - public void onClick(View v) { - } - }); mHandler = new Handler(); mSlideUpIn = new TranslateAnimation(0, 0, 40, 0); @@ -380,7 +381,7 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory, int tail = (width - height) / 2; Rect bounds = new Rect(0, 0, tail, height); - TailTouchDelegate delegate = new TailTouchDelegate(bounds, mShadow); + TailTouchDelegate delegate = new TailTouchDelegate(bounds, mAddressBarView); mTabs.setTouchDelegate(delegate); } }); @@ -412,7 +413,7 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory, } } - mFocusOrder = Arrays.asList(mBack, mForward, mLayout, mReader, mSiteSecurity, mStop, mTabs); + mFocusOrder = Arrays.asList(mBack, mForward, mAwesomeBar, mReader, mSiteSecurity, mStop, mTabs); } public View getLayout() { @@ -498,7 +499,7 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory, } public void setNextFocusDownId(int nextId) { - mLayout.setNextFocusDownId(nextId); + mAwesomeBar.setNextFocusDownId(nextId); mTabs.setNextFocusDownId(nextId); mBack.setNextFocusDownId(nextId); mForward.setNextFocusDownId(nextId); @@ -543,8 +544,52 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory, return mInflater.inflate(R.layout.tabs_counter, null); } - private int getAwesomeBarAnimTranslation() { - return mLayout.getWidth() - mAwesomeBarEntry.getRight(); + private int prepareAwesomeBarAnimation() { + // Keep the entry highlighted during the animation + mAwesomeBar.setSelected(true); + + // Expand the entry to fill all the horizontal space available during the + // animation. The fake right edge will slide on top of it to give the effect + // of expanding the entry. + MarginLayoutParams entryParams = (MarginLayoutParams) mAwesomeBarEntry.getLayoutParams(); + mAwesomeBarEntryRightMargin = entryParams.rightMargin; + entryParams.rightMargin = 0; + mAwesomeBarEntry.requestLayout(); + + // Remove any curves from the toolbar background and expand it to fill all + // the horizontal space. + MarginLayoutParams barParams = (MarginLayoutParams) mAddressBarBg.getLayoutParams(); + mAddressBarBgRightMargin = barParams.rightMargin; + barParams.rightMargin = 0; + mAddressBarBgCurveTowards = mAddressBarBg.getCurveTowards(); + mAddressBarBg.setCurveTowards(BrowserToolbarBackground.CurveTowards.NONE); + + // If we don't have any menu_items, then we simply slide all elements on the + // rigth side of the toolbar out of screen. + int translation = mAwesomeBarEntryRightMargin; + + if (mActionItemBar.getVisibility() == View.VISIBLE) { + // If the toolbar has action items (e.g. on the tablet UI), the translation will + // be in relation to the left side of their container (i.e. mActionItemBar). + MarginLayoutParams itemBarParams = (MarginLayoutParams) mActionItemBar.getLayoutParams(); + translation = itemBarParams.rightMargin + mActionItemBar.getWidth() - entryParams.leftMargin; + + // Expand the whole entry container to fill all the horizontal space available + View awesomeBarParent = (View) mAwesomeBar.getParent(); + mAwesomeBarParams = (LayoutParams) awesomeBarParent.getLayoutParams(); + awesomeBarParent.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT)); + + // Align the fake right edge to the right side of the entry bar + MarginLayoutParams rightEdgeParams = (MarginLayoutParams) mAwesomeBarRightEdge.getLayoutParams(); + rightEdgeParams.rightMargin = itemBarParams.rightMargin + mActionItemBar.getWidth() - 100; + mAwesomeBarRightEdge.requestLayout(); + } + + // Make the right edge visible to start the animation + mAwesomeBarRightEdge.setVisibility(View.VISIBLE); + + return translation; } public void fromAwesomeBarSearch(String url) { @@ -565,11 +610,8 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory, // 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 translation = getAwesomeBarAnimTranslation(); + if (!mAwesomeBar.isSelected()) { + int translation = prepareAwesomeBarAnimation(); proxy = AnimatorProxy.create(mAwesomeBarRightEdge); proxy.setTranslationX(translation); @@ -631,7 +673,27 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory, @Override public void onPropertyAnimationEnd() { // Turn off selected state on the entry - mLayout.setSelected(false); + mAwesomeBar.setSelected(false); + + // Restore entry state + MarginLayoutParams entryParams = (MarginLayoutParams) mAwesomeBarEntry.getLayoutParams(); + entryParams.rightMargin = mAwesomeBarEntryRightMargin; + mAwesomeBarEntry.requestLayout(); + + // Restore the background state + MarginLayoutParams barParams = (MarginLayoutParams) mAddressBarBg.getLayoutParams(); + barParams.rightMargin = mAddressBarBgRightMargin; + mAddressBarBg.setCurveTowards(mAddressBarBgCurveTowards); + + // If there are action bar items in the toolbar, we have to restore the + // alignment of the entry in relation to them. mAwesomeBarParams might + // be null if the activity holding the toolbar is killed before returning + // from awesome screen (e.g. "Don't keep activities" is on) + if (mActionItemBar.getVisibility() == View.VISIBLE) + ((View) mAwesomeBar.getParent()).setLayoutParams(mAwesomeBarParams); + + // Hide fake right edge, we only use for the animation + mAwesomeBarRightEdge.setVisibility(View.INVISIBLE); PropertyAnimator buttonsAnimator = new PropertyAnimator(150); @@ -673,10 +735,7 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory, final PropertyAnimator contentAnimator = new PropertyAnimator(250); contentAnimator.setUseHardwareLayer(false); - final int translation = getAwesomeBarAnimTranslation(); - - // Keep the entry highlighted during the animation - mLayout.setSelected(true); + int translation = prepareAwesomeBarAnimation(); if (mActionItemBar.getVisibility() == View.VISIBLE) { contentAnimator.attach(mFavicon, @@ -800,7 +859,13 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory, } public void prepareTabsAnimation(PropertyAnimator animator, int width) { - animator.attach(mAwesomeBarEntry, + // This is negative before we want to keep the right edge in the same + // position while animating the left-most elements below. + animator.attach(mAwesomeBarRightEdge, + PropertyAnimator.Property.TRANSLATION_X, + -width); + + animator.attach(mAwesomeBar, PropertyAnimator.Property.TRANSLATION_X, width); animator.attach(mAddressBarBg, @@ -842,7 +907,8 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory, public void adjustTabsAnimation(boolean reset) { int width = reset ? 0 : mTabsPaneWidth; - mAwesomeBarEntry.setTranslationX(width); + mAwesomeBarRightEdge.setTranslationX(-width); + mAwesomeBar.setTranslationX(width); mAddressBarBg.setTranslationX(width); mTabs.setTranslationX(width); mTabsCount.setTranslationX(width); @@ -1005,7 +1071,7 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory, title = null; mTitle.setText(title); - mLayout.setContentDescription(title != null ? title : mTitle.getHint()); + mAwesomeBar.setContentDescription(title != null ? title : mTitle.getHint()); } private void setFavicon(Bitmap image) { @@ -1041,7 +1107,7 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory, } public void requestFocusFromTouch() { - mLayout.requestFocusFromTouch(); + mAwesomeBar.requestFocusFromTouch(); } public void updateBackButton(boolean enabled) { @@ -1064,7 +1130,7 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory, return; mForwardAnim = new PropertyAnimator(FORWARD_ANIMATION_DURATION); - final int width = mForward.getWidth() / 2; + final int width = mForward.getWidth()/2; mForwardAnim.setPropertyAnimationListener(new PropertyAnimator.PropertyAnimationListener() { @Override @@ -1073,9 +1139,9 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory, // 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 ViewGroup.MarginLayoutParams layoutParams = - (ViewGroup.MarginLayoutParams)mAwesomeBarContent.getLayoutParams(); - layoutParams.leftMargin = 0; - mAwesomeBarContent.requestLayout(); + (ViewGroup.MarginLayoutParams)mAddressBarView.getLayoutParams(); + layoutParams.leftMargin = mAddressBarViewOffsetNoForward; + mAddressBarView.requestLayout(); // Note, we already translated the favicon, site security, and text field // in prepareForwardAnimation, so they should appear to have not moved at // all at this point. @@ -1086,7 +1152,7 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory, public void onPropertyAnimationEnd() { if (enabled) { ViewGroup.MarginLayoutParams layoutParams = - (ViewGroup.MarginLayoutParams)mAwesomeBarContent.getLayoutParams(); + (ViewGroup.MarginLayoutParams)mAddressBarView.getLayoutParams(); layoutParams.leftMargin = mAddressBarViewOffset; AnimatorProxy proxy = AnimatorProxy.create(mTitle); @@ -1095,19 +1161,19 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory, proxy.setTranslationX(0); proxy = AnimatorProxy.create(mSiteSecurity); proxy.setTranslationX(0); + } ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams)mForward.getLayoutParams(); - layoutParams.leftMargin = mDefaultForwardMargin + (mForward.isEnabled() ? mForward.getWidth() / 2 : 0); + layoutParams.leftMargin = mDefaultForwardMargin + (mForward.isEnabled() ? mForward.getWidth()/2 : 0); AnimatorProxy proxy = AnimatorProxy.create(mForward); proxy.setTranslationX(0); - mAwesomeBarContent.requestLayout(); + mAddressBarView.requestLayout(); mForwardAnim = null; } }); - prepareForwardAnimation(mForwardAnim, enabled, width); mForwardAnim.start(); } @@ -1116,7 +1182,7 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory, if (!enabled) { anim.attach(mForward, PropertyAnimator.Property.TRANSLATION_X, - -width); + -1*width); anim.attach(mForward, PropertyAnimator.Property.ALPHA, 0); @@ -1133,12 +1199,13 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory, // 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. + int startTrans = mAddressBarViewOffset - mAddressBarViewOffsetNoForward; AnimatorProxy proxy = AnimatorProxy.create(mTitle); - proxy.setTranslationX(mAddressBarViewOffset); + proxy.setTranslationX(startTrans); proxy = AnimatorProxy.create(mFavicon); - proxy.setTranslationX(mAddressBarViewOffset); + proxy.setTranslationX(startTrans); proxy = AnimatorProxy.create(mSiteSecurity); - proxy.setTranslationX(mAddressBarViewOffset); + proxy.setTranslationX(startTrans); } else { anim.attach(mForward, PropertyAnimator.Property.TRANSLATION_X, @@ -1148,13 +1215,13 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory, 1); anim.attach(mTitle, PropertyAnimator.Property.TRANSLATION_X, - mAddressBarViewOffset); + mAddressBarViewOffset - mAddressBarViewOffsetNoForward); anim.attach(mFavicon, PropertyAnimator.Property.TRANSLATION_X, - mAddressBarViewOffset); + mAddressBarViewOffset - mAddressBarViewOffsetNoForward); anim.attach(mSiteSecurity, PropertyAnimator.Property.TRANSLATION_X, - mAddressBarViewOffset); + mAddressBarViewOffset - mAddressBarViewOffsetNoForward); } } @@ -1201,7 +1268,11 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory, mAddressBarBg.setPrivateMode(tab.isPrivate()); - mLayout.setPrivateMode(tab.isPrivate()); + if (mAwesomeBar instanceof GeckoButton) + ((GeckoButton) mAwesomeBar).setPrivateMode(tab.isPrivate()); + else if (mAwesomeBar instanceof GeckoRelativeLayout) + ((GeckoRelativeLayout) mAwesomeBar).setPrivateMode(tab.isPrivate()); + mTabs.setPrivateMode(tab.isPrivate()); mTitle.setPrivateMode(tab.isPrivate()); mMenu.setPrivateMode(tab.isPrivate()); @@ -1238,4 +1309,43 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory, return true; } + + public static class RightEdge extends GeckoFrameLayout { + private BrowserApp mActivity; + + public RightEdge(Context context, AttributeSet attrs) { + super(context, attrs); + mActivity = (BrowserApp) context; + } + + @Override + public void onLightweightThemeChanged() { + Drawable drawable = mActivity.getLightweightTheme().getDrawable(this); + if (drawable == null) + return; + + StateListDrawable stateList = new StateListDrawable(); + stateList.addState(new int[] { R.attr.state_private }, new ColorDrawable(mActivity.getResources().getColor(R.color.background_private))); + stateList.addState(new int[] {}, drawable); + + int[] padding = new int[] { getPaddingLeft(), + getPaddingTop(), + getPaddingRight(), + getPaddingBottom() + }; + setBackgroundDrawable(stateList); + setPadding(padding[0], padding[1], padding[2], padding[3]); + } + + @Override + public void onLightweightThemeReset() { + int[] padding = new int[] { getPaddingLeft(), + getPaddingTop(), + getPaddingRight(), + getPaddingBottom() + }; + setBackgroundResource(R.drawable.address_bar_bg); + setPadding(padding[0], padding[1], padding[2], padding[3]); + } + } } diff --git a/mobile/android/base/BrowserToolbarBackground.java b/mobile/android/base/BrowserToolbarBackground.java index e56a0689dbfa..8a3fc54c4e15 100644 --- a/mobile/android/base/BrowserToolbarBackground.java +++ b/mobile/android/base/BrowserToolbarBackground.java @@ -14,14 +14,72 @@ import android.graphics.drawable.Drawable; import android.graphics.drawable.StateListDrawable; import android.util.AttributeSet; -public class BrowserToolbarBackground extends GeckoLinearLayout { +public class BrowserToolbarBackground extends GeckoLinearLayout + implements CanvasDelegate.DrawManager { private GeckoActivity mActivity; + private Path mPath; + private CurveTowards mSide; + private CanvasDelegate mCanvasDelegate; + + public enum CurveTowards { NONE, LEFT, RIGHT }; public BrowserToolbarBackground(Context context, AttributeSet attrs) { super(context, attrs); + + TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BrowserToolbarCurve); + int curveTowards = a.getInt(R.styleable.BrowserToolbarCurve_curveTowards, 0x02); + a.recycle(); + + if (curveTowards == 0x00) + mSide = CurveTowards.NONE; + else if (curveTowards == 0x01) + mSide = CurveTowards.LEFT; + else + mSide = CurveTowards.RIGHT; + + // Path is clipped. + mPath = new Path(); + mCanvasDelegate = new CanvasDelegate(this, Mode.DST_OUT); mActivity = (GeckoActivity) context; } + @Override + public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + + int width = getMeasuredWidth(); + int height = getMeasuredHeight(); + int curve = (int) (height * 1.125f); + + mPath.reset(); + + if (mSide == CurveTowards.LEFT) { + mPath.moveTo(0, height); + mPath.cubicTo(curve * 0.75f, height, + curve * 0.25f, 0, + curve, 0); + mPath.lineTo(0, 0); + mPath.lineTo(0, height); + } else if (mSide == CurveTowards.RIGHT) { + mPath.moveTo(width, height); + mPath.cubicTo((width - (curve * 0.75f)), height, + (width - (curve * 0.25f)), 0, + (width - curve), 0); + mPath.lineTo(width, 0); + mPath.lineTo(width, height); + } + } + + @Override + public void draw(Canvas canvas) { + mCanvasDelegate.draw(canvas, mPath, getWidth(), getHeight()); + } + + @Override + public void defaultDraw(Canvas canvas) { + super.draw(canvas); + } + @Override public void onLightweightThemeChanged() { Drawable drawable = mActivity.getLightweightTheme().getDrawable(this); @@ -32,11 +90,35 @@ public class BrowserToolbarBackground extends GeckoLinearLayout { stateList.addState(new int[] { R.attr.state_private }, new ColorDrawable(mActivity.getResources().getColor(R.color.background_private))); stateList.addState(new int[] {}, drawable); + int[] padding = new int[] { getPaddingLeft(), + getPaddingTop(), + getPaddingRight(), + getPaddingBottom() + }; setBackgroundDrawable(stateList); + setPadding(padding[0], padding[1], padding[2], padding[3]); } @Override public void onLightweightThemeReset() { + int[] padding = new int[] { getPaddingLeft(), + getPaddingTop(), + getPaddingRight(), + getPaddingBottom() + }; setBackgroundResource(R.drawable.address_bar_bg); + setPadding(padding[0], padding[1], padding[2], padding[3]); + } + + public CurveTowards getCurveTowards() { + return mSide; + } + + public void setCurveTowards(CurveTowards side) { + if (side == mSide) + return; + + mSide = side; + requestLayout(); } } diff --git a/mobile/android/base/BrowserToolbarLayout.java b/mobile/android/base/BrowserToolbarLayout.java index 1895e0541707..d2d54985d7f9 100644 --- a/mobile/android/base/BrowserToolbarLayout.java +++ b/mobile/android/base/BrowserToolbarLayout.java @@ -8,9 +8,9 @@ package org.mozilla.gecko; import android.content.Context; import android.util.AttributeSet; import android.view.MotionEvent; -import android.widget.RelativeLayout; +import android.widget.LinearLayout; -public class BrowserToolbarLayout extends GeckoRelativeLayout { +public class BrowserToolbarLayout extends LinearLayout { private static final String LOGTAG = "GeckoToolbarLayout"; public BrowserToolbarLayout(Context context, AttributeSet attrs) { diff --git a/mobile/android/base/GeckoViewsFactory.java b/mobile/android/base/GeckoViewsFactory.java index 14a10081a25d..ea35eda79e3c 100644 --- a/mobile/android/base/GeckoViewsFactory.java +++ b/mobile/android/base/GeckoViewsFactory.java @@ -56,6 +56,7 @@ public final class GeckoViewsFactory implements LayoutInflater.Factory { mFactoryMap.put("AwesomeBarTabs$BackgroundLayout", AwesomeBarTabs.BackgroundLayout.class.getConstructor(arg1Class, arg2Class)); mFactoryMap.put("BackButton", BackButton.class.getConstructor(arg1Class, arg2Class)); mFactoryMap.put("BrowserToolbarBackground", BrowserToolbarBackground.class.getConstructor(arg1Class, arg2Class)); + mFactoryMap.put("BrowserToolbar$RightEdge", BrowserToolbar.RightEdge.class.getConstructor(arg1Class, arg2Class)); mFactoryMap.put("CheckableLinearLayout", CheckableLinearLayout.class.getConstructor(arg1Class, arg2Class)); mFactoryMap.put("FormAssistPopup", FormAssistPopup.class.getConstructor(arg1Class, arg2Class)); mFactoryMap.put("ForwardButton", ForwardButton.class.getConstructor(arg1Class, arg2Class)); diff --git a/mobile/android/base/Makefile.in b/mobile/android/base/Makefile.in index 8e9d09a29c81..57c1c6479b55 100644 --- a/mobile/android/base/Makefile.in +++ b/mobile/android/base/Makefile.in @@ -401,6 +401,7 @@ RES_LAYOUT = \ res/layout/awesomebar_tab_indicator.xml \ res/layout/awesomebar_tabs.xml \ res/layout/bookmark_edit.xml \ + res/layout/browser_toolbar.xml \ res/layout/browser_toolbar_menu.xml \ res/layout/datetime_picker.xml \ res/layout/doorhangerpopup.xml \ @@ -999,7 +1000,6 @@ MOZ_ANDROID_DRAWABLES += \ mobile/android/base/resources/drawable/address_bar_bg.xml \ mobile/android/base/resources/drawable/address_bar_bg_shadow_repeat.xml \ mobile/android/base/resources/drawable/address_bar_nav_button.xml \ - mobile/android/base/resources/drawable/address_bar_right_edge.xml \ mobile/android/base/resources/drawable/address_bar_url.xml \ mobile/android/base/resources/drawable/awesomebar_header_row.xml \ mobile/android/base/resources/drawable/awesomebar_row_favicon_bg.xml \ diff --git a/mobile/android/base/resources/drawable/address_bar_right_edge.xml b/mobile/android/base/resources/drawable/address_bar_right_edge.xml deleted file mode 100644 index 567f7bd2e5fd..000000000000 --- a/mobile/android/base/resources/drawable/address_bar_right_edge.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - \ No newline at end of file diff --git a/mobile/android/base/resources/layout-large-v11/browser_toolbar_menu.xml b/mobile/android/base/resources/layout-large-v11/browser_toolbar_menu.xml index 4446e7ce7803..7636ff2f54eb 100644 --- a/mobile/android/base/resources/layout-large-v11/browser_toolbar_menu.xml +++ b/mobile/android/base/resources/layout-large-v11/browser_toolbar_menu.xml @@ -6,162 +6,176 @@ + style="@style/BrowserToolbar"> - + - + - + - + - + - + - + - - - + android:clickable="true" + android:focusable="true"> - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + diff --git a/mobile/android/base/resources/layout/browser_toolbar.xml b/mobile/android/base/resources/layout/browser_toolbar.xml new file mode 100644 index 000000000000..ce4fda728a07 --- /dev/null +++ b/mobile/android/base/resources/layout/browser_toolbar.xml @@ -0,0 +1,165 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mobile/android/base/resources/layout/browser_toolbar_menu.xml b/mobile/android/base/resources/layout/browser_toolbar_menu.xml index db6c8107ae14..3ea9b5546c75 100644 --- a/mobile/android/base/resources/layout/browser_toolbar_menu.xml +++ b/mobile/android/base/resources/layout/browser_toolbar_menu.xml @@ -6,142 +6,167 @@ + style="@style/BrowserToolbar"> - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + diff --git a/mobile/android/base/resources/values-large-v11/dimens.xml b/mobile/android/base/resources/values-large-v11/dimens.xml index 9dda026d144c..4a689a256b4b 100644 --- a/mobile/android/base/resources/values-large-v11/dimens.xml +++ b/mobile/android/base/resources/values-large-v11/dimens.xml @@ -7,7 +7,10 @@ 56dp 16dp + 45dp 8dip 26sp + 90dp + 50dip diff --git a/mobile/android/base/resources/values-large-v11/styles.xml b/mobile/android/base/resources/values-large-v11/styles.xml index 4a1b8e55882a..ee50b4652c79 100644 --- a/mobile/android/base/resources/values-large-v11/styles.xml +++ b/mobile/android/base/resources/values-large-v11/styles.xml @@ -33,9 +33,9 @@ diff --git a/mobile/android/base/resources/values/dimens.xml b/mobile/android/base/resources/values/dimens.xml index 3fbd99bc7294..d6cd2ffb07f3 100644 --- a/mobile/android/base/resources/values/dimens.xml +++ b/mobile/android/base/resources/values/dimens.xml @@ -30,7 +30,7 @@ 38dp 48dp 12dp - 48dp + 36dp 20dp 29.33dip @@ -69,6 +69,7 @@ 2dp 50dp 6dp - -13dip - 32dp + -11dip + 90dp + 50dip diff --git a/mobile/android/base/resources/values/styles.xml b/mobile/android/base/resources/values/styles.xml index c172caf54e25..c25a4b9290ee 100644 --- a/mobile/android/base/resources/values/styles.xml +++ b/mobile/android/base/resources/values/styles.xml @@ -175,6 +175,15 @@ @android:color/transparent + + - -