Bug 1319302 - RTL support for Firefox for Android, r=sebastian

MozReview-Commit-ID: bKzW07YBDy

--HG--
extra : rebase_source : 591b8f98a7a287dbf2b7748a97211c81a3ac11aa
This commit is contained in:
maliu 2016-11-11 16:10:21 +08:00
Родитель f045a91867
Коммит 1bf966a5c8
57 изменённых файлов: 493 добавлений и 137 удалений

Просмотреть файл

@ -27,6 +27,7 @@
android:logo="@drawable/logo"
android:name="@MOZ_ANDROID_APPLICATION_CLASS@"
android:hardwareAccelerated="true"
android:supportsRtl="true"
android:allowBackup="false"
# The preprocessor does not yet support arbitrary parentheses, so this cannot
# be parenthesized thus to clarify that the logical AND operator has precedence:

Просмотреть файл

@ -15,6 +15,7 @@ import android.graphics.drawable.InsetDrawable;
import android.support.annotation.StringRes;
import android.support.design.widget.Snackbar;
import android.support.v4.content.ContextCompat;
import android.support.v4.widget.TextViewCompat;
import android.text.TextUtils;
import android.util.Log;
import android.util.TypedValue;
@ -214,7 +215,7 @@ public class SnackbarBuilder {
paddedIcon.setBounds(0, 0, leftPadding + icon.getIntrinsicWidth(), icon.getIntrinsicHeight());
TextView textView = (TextView) snackbar.getView().findViewById(android.support.design.R.id.snackbar_text);
textView.setCompoundDrawables(paddedIcon, null, null, null);
TextViewCompat.setCompoundDrawablesRelative(textView, paddedIcon, null, null, null);
}
if (backgroundColor != null) {

Просмотреть файл

@ -6,7 +6,9 @@ package org.mozilla.gecko.home;
import android.content.Context;
import android.database.Cursor;
import android.graphics.drawable.Drawable;
import android.support.v4.content.ContextCompat;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
@ -121,6 +123,10 @@ public abstract class CombinedHistoryItem extends RecyclerView.ViewHolder {
nameView.setTextColor(ContextCompat.getColor(context, isCollapsed ? R.color.tabs_tray_icon_grey : R.color.placeholder_active_grey));
if (client.tabs.size() > 0) {
deviceExpanded.setImageResource(isCollapsed ? R.drawable.home_group_collapsed : R.drawable.arrow_down);
Drawable expandedDrawable = deviceExpanded.getDrawable();
if (expandedDrawable != null) {
DrawableCompat.setAutoMirrored(expandedDrawable, true);
}
}
}
}

Просмотреть файл

@ -5,6 +5,7 @@
package org.mozilla.gecko.home;
import android.support.v4.view.ViewCompat;
import android.view.ViewGroup;
import android.widget.LinearLayout;
@ -79,10 +80,13 @@ class TabMenuStripLayout extends LinearLayout
}
if (getChildCount() == 0) {
button.setPadding(button.getPaddingLeft() + tabContentStart,
button.getPaddingTop(),
button.getPaddingRight(),
button.getPaddingBottom());
ViewCompat.setPaddingRelative(button,
ViewCompat.getPaddingStart(button) + tabContentStart,
button.getPaddingTop(),
ViewCompat.getPaddingEnd(button),
button.getPaddingBottom()
);
}
addView(button);
@ -107,9 +111,25 @@ class TabMenuStripLayout extends LinearLayout
selectedView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
if (strip != null) {
strip.setBounds(selectedView.getLeft() + (position == 0 ? tabContentStart : 0),
boolean isLayoutRtl = ViewCompat.getLayoutDirection(selectedView) == ViewCompat.LAYOUT_DIRECTION_RTL;
final int startPaddingOffset;
final int endPaddingOffset;
if (position != 0) {
startPaddingOffset = 0;
endPaddingOffset = 0;
} else {
if (isLayoutRtl) {
startPaddingOffset = 0;
endPaddingOffset = -tabContentStart;
} else {
startPaddingOffset = tabContentStart;
endPaddingOffset = 0;
}
}
strip.setBounds(selectedView.getLeft() + startPaddingOffset,
selectedView.getTop(),
selectedView.getRight(),
selectedView.getRight() + endPaddingOffset,
selectedView.getBottom());
}
@ -152,9 +172,11 @@ class TabMenuStripLayout extends LinearLayout
modifier = 0;
}
strip.setBounds((int) (fromTabLeft + ((toTabLeft - fromTabLeft) * progress)) + modifier,
boolean isLayoutRtl = ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL;
strip.setBounds(
(int) (fromTabLeft + ((toTabLeft - fromTabLeft) * progress)) + (isLayoutRtl ? 0 : modifier),
0,
(int) (fromTabRight + ((toTabRight - fromTabRight) * progress)),
(int) (fromTabRight + ((toTabRight - fromTabRight) * progress)) + (isLayoutRtl ? -modifier : 0),
getHeight());
invalidate();
}

Просмотреть файл

@ -7,6 +7,7 @@ package org.mozilla.gecko.home;
import android.content.Context;
import android.graphics.Bitmap;
import android.support.v4.widget.TextViewCompat;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
@ -277,7 +278,7 @@ public class TopSitesGridItemView extends RelativeLayout implements IconCallback
refreshDrawableState();
int pinResourceId = (type == TopSites.TYPE_PINNED ? R.drawable.pin : 0);
mTitleView.setCompoundDrawablesWithIntrinsicBounds(pinResourceId, 0, 0, 0);
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(mTitleView, pinResourceId, 0, 0, 0);
return true;
}

Просмотреть файл

@ -10,6 +10,10 @@ import java.util.concurrent.Future;
import android.content.Context;
import android.database.Cursor;
import android.support.v4.app.ActivityCompat;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v4.view.ViewCompat;
import android.support.v4.widget.TextViewCompat;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.Gravity;
@ -66,7 +70,7 @@ public class TwoLinePageRow extends LinearLayout
LayoutInflater.from(context).inflate(R.layout.two_line_page_row, this);
// Merge layouts lose their padding, so set it dynamically.
setPadding(0, 0, (int) getResources().getDimension(R.dimen.page_row_edge_padding), 0);
ViewCompat.setPaddingRelative(this, 0, 0, (int) getResources().getDimension(R.dimen.page_row_edge_padding), 0);
mTitle = (TextView) findViewById(R.id.title);
mUrl = (TextView) findViewById(R.id.url);
@ -163,7 +167,10 @@ public class TwoLinePageRow extends LinearLayout
}
mSwitchToTabIconId = iconId;
mUrl.setCompoundDrawablesWithIntrinsicBounds(mSwitchToTabIconId, 0, 0, 0);
if (mSwitchToTabIconId != 0) {
DrawableCompat.setAutoMirrored(ActivityCompat.getDrawable(getContext(), mSwitchToTabIconId), true);
}
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(mUrl, mSwitchToTabIconId, 0, 0, 0);
}
private void updateStatusIcon(boolean isBookmark, boolean isReaderItem) {

Просмотреть файл

@ -10,6 +10,7 @@ import org.mozilla.gecko.widget.themed.ThemedImageButton;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.util.AttributeSet;
public class MenuItemActionBar extends ThemedImageButton
@ -46,6 +47,10 @@ public class MenuItemActionBar extends ThemedImageButton
setVisibility(VISIBLE);
setImageDrawable(icon);
}
icon = getDrawable();
if (icon != null) {
DrawableCompat.setAutoMirrored(icon, true);
}
}
void setIcon(int icon) {

Просмотреть файл

@ -11,6 +11,8 @@ import android.content.Context;
import android.content.res.Resources;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v4.widget.TextViewCompat;
import android.util.AttributeSet;
import android.widget.TextView;
@ -51,13 +53,15 @@ public class MenuItemDefault extends TextView
mState = res.getDrawable(R.drawable.menu_item_state).mutate();
mState.setBounds(stateIconBounds);
// Support RTL
DrawableCompat.setAutoMirrored(mState, true);
if (sIconBounds == null) {
int iconSize = res.getDimensionPixelSize(R.dimen.menu_item_icon);
sIconBounds = new Rect(0, 0, iconSize, iconSize);
}
setCompoundDrawables(mIcon, null, mState, null);
TextViewCompat.setCompoundDrawablesRelative(this, mIcon, null, mState, null);
}
@Override
@ -88,7 +92,7 @@ public class MenuItemDefault extends TextView
}
private void refreshIcon() {
setCompoundDrawables(mShowIcon ? mIcon : null, null, mState, null);
TextViewCompat.setCompoundDrawablesRelative(this, mShowIcon ? mIcon : null, null, mState, null);
}
void setIcon(Drawable icon) {
@ -114,8 +118,9 @@ public class MenuItemDefault extends TextView
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
if (mIcon != null)
if (mIcon != null) {
mIcon.setAlpha(enabled ? 255 : 99);
}
if (mState != null)
mState.setAlpha(enabled ? 255 : 99);

Просмотреть файл

@ -8,7 +8,10 @@ package org.mozilla.gecko.preferences;
import org.mozilla.gecko.R;
import android.content.Context;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
class AlignRightLinkPreference extends LinkPreference {
@ -21,4 +24,11 @@ class AlignRightLinkPreference extends LinkPreference {
super(context, attrs, defStyle);
setLayoutResource(R.layout.preference_rightalign_icon);
}
@Override
protected void onBindView(View view) {
super.onBindView(view);
ImageView imageView = (ImageView) view.findViewById(R.id.menu_icon_more);
DrawableCompat.setAutoMirrored(imageView.getDrawable(), true);
}
}

Просмотреть файл

@ -12,6 +12,10 @@ import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.support.v4.content.ContextCompat;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v4.view.ViewCompat;
import android.support.v4.widget.TextViewCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -81,9 +85,10 @@ public class PromptListAdapter extends ArrayAdapter<PromptListItem> {
return VIEW_TYPE_COUNT;
}
private Drawable getMoreDrawable(Resources res) {
private Drawable getMoreDrawable(Context context) {
if (mMoreDrawable == null) {
mMoreDrawable = res.getDrawable(R.drawable.menu_item_more);
mMoreDrawable = ContextCompat.getDrawable(context, R.drawable.menu_item_more);
DrawableCompat.setAutoMirrored(mMoreDrawable, true);
}
return mMoreDrawable;
}
@ -102,7 +107,7 @@ public class PromptListAdapter extends ArrayAdapter<PromptListItem> {
private void maybeUpdateIcon(PromptListItem item, TextView t) {
if (item.getIcon() == null && !item.inGroup && !item.isParent) {
t.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(t, null, null, null, null);
return;
}
@ -122,11 +127,11 @@ public class PromptListAdapter extends ArrayAdapter<PromptListItem> {
Drawable moreDrawable = null;
if (item.isParent) {
moreDrawable = getMoreDrawable(res);
moreDrawable = getMoreDrawable(getContext());
}
if (d != null || moreDrawable != null) {
t.setCompoundDrawablesWithIntrinsicBounds(d, null, moreDrawable, null);
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(t, d, null, moreDrawable, null);
}
}
@ -243,7 +248,7 @@ public class PromptListAdapter extends ArrayAdapter<PromptListItem> {
TextView tv = (TextView) convertView.findViewById(android.R.id.text1);
tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize);
viewHolder = new ViewHolder(tv, tv.getPaddingLeft(), tv.getPaddingRight(),
viewHolder = new ViewHolder(tv, ViewCompat.getPaddingStart(tv), ViewCompat.getPaddingEnd(tv),
tv.getPaddingTop(), tv.getPaddingBottom());
convertView.setTag(viewHolder);

Просмотреть файл

@ -10,6 +10,8 @@ import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
import android.view.ViewGroup;
import android.widget.ImageButton;
@ -32,6 +34,8 @@ public class TabPanelBackButton extends ImageButton {
if (divider != null) {
dividerWidth = divider.getIntrinsicWidth();
}
// Support RTL
DrawableCompat.setAutoMirrored(getDrawable(), true);
}
@Override
@ -45,11 +49,23 @@ public class TabPanelBackButton extends ImageButton {
super.onDraw(canvas);
if (divider != null) {
final ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) getLayoutParams();
final int left = getRight() - lp.rightMargin - dividerWidth;
divider.setBounds(left, getPaddingTop() + dividerPadding,
left + dividerWidth, getHeight() - getPaddingBottom() - dividerPadding);
divider.draw(canvas);
if (ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL) {
final int start = getLeft() + lp.getMarginStart();
divider.setBounds(
start,
getPaddingTop() + dividerPadding,
start + dividerWidth,
getHeight() - getPaddingBottom() - dividerPadding
);
divider.draw(canvas);
} else {
final int left = getRight() - lp.rightMargin - dividerWidth;
divider.setBounds(left, getPaddingTop() + dividerPadding,
left + dividerWidth, getHeight() - getPaddingBottom() - dividerPadding);
divider.draw(canvas);
}
}
}
}

Просмотреть файл

@ -26,6 +26,8 @@ import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Path;
import android.graphics.Region;
import android.support.v4.view.ViewCompat;
import android.support.v4.widget.TextViewCompat;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
@ -210,9 +212,9 @@ public class TabStripItemView extends ThemedLinearLayout
// TODO: Set content description to indicate audio is playing.
if (tab.isAudioPlaying()) {
titleView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.tab_audio_playing, 0, 0, 0);
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(titleView, R.drawable.tab_audio_playing, 0, 0, 0);
} else {
titleView.setCompoundDrawables(null, null, null, null);
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(titleView, null, null, null, null);
}
}

Просмотреть файл

@ -14,6 +14,7 @@ import org.mozilla.gecko.widget.themed.ThemedRelativeLayout;
import android.content.Context;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.v4.widget.TextViewCompat;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.View;
@ -144,12 +145,12 @@ public class TabsLayoutItemView extends LinearLayout
mCloseButton.setTag(this);
if (tab.isAudioPlaying()) {
mTitle.setCompoundDrawablesWithIntrinsicBounds(R.drawable.tab_audio_playing, 0, 0, 0);
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(mTitle, R.drawable.tab_audio_playing, 0, 0, 0);
final String tabTitleWithAudio =
getResources().getString(R.string.tab_title_prefix_is_playing_audio, tabTitle);
mTitle.setContentDescription(tabTitleWithAudio);
} else {
mTitle.setCompoundDrawables(null, null, null, null);
TextViewCompat.setCompoundDrawablesRelative(mTitle, null, null, null, null);
mTitle.setContentDescription(tabTitle);
}
}

Просмотреть файл

@ -21,6 +21,8 @@ import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
@ -49,6 +51,8 @@ abstract class BrowserToolbarPhoneBase extends BrowserToolbar {
// This will clip the translating edge's image at 60% of its width
urlBarTranslatingEdge.getDrawable().setLevel(6000);
// Support RTL
DrawableCompat.setAutoMirrored(urlBarTranslatingEdge.getDrawable(), true);
editCancel = (ThemedImageView) findViewById(R.id.edit_cancel);
@ -57,10 +61,7 @@ abstract class BrowserToolbarPhoneBase extends BrowserToolbar {
focusOrder.addAll(Arrays.asList(tabsButton, menuButton));
roundCornerShape = new Path();
roundCornerShape.moveTo(0, 0);
roundCornerShape.lineTo(30, 0);
roundCornerShape.cubicTo(0, 0, 0, 0, 0, 30);
roundCornerShape.lineTo(0, 0);
updateRoundCornerShape();
roundCornerPaint = new Paint();
roundCornerPaint.setAntiAlias(true);
@ -68,6 +69,28 @@ abstract class BrowserToolbarPhoneBase extends BrowserToolbar {
roundCornerPaint.setStrokeWidth(0.0f);
}
private void updateRoundCornerShape() {
roundCornerShape.reset();
if (ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL) {
int right = getRight();
roundCornerShape.moveTo(right, 0);
roundCornerShape.lineTo(right - 30, 0);
roundCornerShape.cubicTo(right, 0, right, 0, right, 30);
roundCornerShape.lineTo(right, 0);
} else {
roundCornerShape.moveTo(0, 0);
roundCornerShape.lineTo(30, 0);
roundCornerShape.cubicTo(0, 0, 0, 0, 0, 30);
roundCornerShape.lineTo(0, 0);
}
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
updateRoundCornerShape();
}
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
@ -151,11 +174,19 @@ abstract class BrowserToolbarPhoneBase extends BrowserToolbar {
// Find the distance from the right-edge of the url bar (where we're translating from) to
// the left-edge of the cancel button (where we're translating to; note that the cancel
// button must be laid out, i.e. not View.GONE).
return editCancel.getLeft() - urlBarEntry.getRight();
if (ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL) {
return editCancel.getRight() - urlBarEntry.getLeft();
} else {
return editCancel.getLeft() - urlBarEntry.getRight();
}
}
protected int getUrlBarCurveTranslation() {
return getWidth() - tabsButton.getLeft();
if (ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL) {
return 0 - tabsButton.getRight();
} else {
return getWidth() - tabsButton.getLeft();
}
}
protected void updateTabCountAndAnimate(final int count) {

Просмотреть файл

@ -11,6 +11,8 @@ import org.mozilla.gecko.animation.ViewHelper;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.v4.view.MarginLayoutParamsCompat;
import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
/**
@ -41,7 +43,7 @@ class BrowserToolbarTablet extends BrowserToolbarTabletBase {
// 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);
ViewHelper.setTranslationX(forwardButton, forwardButtonTranslationWidth * (isLayoutRtl() ? 1 : -1));
// TODO: Move this to *TabletBase when old tablet is removed.
// We don't want users clicking the forward button in transitions, but we don't want it to
@ -52,6 +54,10 @@ class BrowserToolbarTablet extends BrowserToolbarTabletBase {
updateForwardButtonState(ForwardButtonState.HIDDEN);
}
private boolean isLayoutRtl() {
return ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL;
}
private void updateForwardButtonState(final ForwardButtonState state) {
forwardButtonState = state;
forwardButton.setEnabled(forwardButtonState == ForwardButtonState.DISPLAYED);
@ -93,11 +99,11 @@ class BrowserToolbarTablet extends BrowserToolbarTabletBase {
// have to do this so that the favicon isn't clipped during the transition
MarginLayoutParams layoutParams =
(MarginLayoutParams) urlDisplayLayout.getLayoutParams();
layoutParams.leftMargin = 0;
MarginLayoutParamsCompat.setMarginStart(layoutParams, 0);
// Do the same on the URL edit container
layoutParams = (MarginLayoutParams) urlEditLayout.getLayoutParams();
layoutParams.leftMargin = 0;
MarginLayoutParamsCompat.setMarginStart(layoutParams, 0);
requestLayout();
// Note, we already translated the favicon, site security, and text field
@ -113,10 +119,10 @@ class BrowserToolbarTablet extends BrowserToolbarTabletBase {
// Increase the margins to ensure the text does not run outside the View.
MarginLayoutParams layoutParams =
(MarginLayoutParams) urlDisplayLayout.getLayoutParams();
layoutParams.leftMargin = forwardButtonTranslationWidth;
MarginLayoutParamsCompat.setMarginStart(layoutParams, forwardButtonTranslationWidth);
layoutParams = (MarginLayoutParams) urlEditLayout.getLayoutParams();
layoutParams.leftMargin = forwardButtonTranslationWidth;
MarginLayoutParamsCompat.setMarginStart(layoutParams, forwardButtonTranslationWidth);
newForwardButtonState = ForwardButtonState.DISPLAYED;
} else {
@ -135,10 +141,11 @@ class BrowserToolbarTablet extends BrowserToolbarTabletBase {
}
private void prepareForwardAnimation(PropertyAnimator anim, ForwardButtonAnimation animation, int width) {
boolean isLayoutRtl = isLayoutRtl();
if (animation == ForwardButtonAnimation.HIDE) {
anim.attach(forwardButton,
PropertyAnimator.Property.TRANSLATION_X,
-width);
width * (isLayoutRtl ? 1 : -1));
anim.attach(forwardButton,
PropertyAnimator.Property.ALPHA,
0);

Просмотреть файл

@ -5,6 +5,7 @@
package org.mozilla.gecko.toolbar;
import android.content.Context;
import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
public class ForwardButton extends NavButton {
@ -16,8 +17,15 @@ public class ForwardButton extends NavButton {
protected void onSizeChanged(int width, int height, int oldWidth, int oldHeight) {
super.onSizeChanged(width, height, oldWidth, oldHeight);
boolean isLayoutRtl = ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL;
mBorderPath.reset();
mBorderPath.moveTo(width - mBorderWidth, 0);
mBorderPath.lineTo(width - mBorderWidth, height);
final float startX;
if (isLayoutRtl) {
startX = 0 + mBorderWidth;
} else {
startX = width - mBorderWidth;
}
mBorderPath.moveTo(startX, 0);
mBorderPath.lineTo(startX, height);
}
}

Просмотреть файл

@ -14,6 +14,7 @@ import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.StateListDrawable;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.util.AttributeSet;
abstract class NavButton extends ShapedButton {

Просмотреть файл

@ -5,7 +5,13 @@
package org.mozilla.gecko.toolbar;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Point;
import android.graphics.drawable.Drawable;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
import android.view.View;
import org.mozilla.gecko.tabs.TabCurve;
@ -17,13 +23,58 @@ public class PhoneTabsButton extends ShapedButton {
@Override
protected void onSizeChanged(int width, int height, int oldWidth, int oldHeight) {
super.onSizeChanged(width, height, oldWidth, oldHeight);
redrawTabs(width, height);
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
redrawTabs(getWidth(), getHeight());
}
private void redrawTabs(int width, int height) {
final int layoutDirection = ViewCompat.getLayoutDirection(this);
Point[] nodes = getDirectionalNodes(width, height, layoutDirection);
TabCurve.Direction directionalCurve = getDirectionalCurve(layoutDirection);
mPath.reset();
mPath.moveTo(0, 0);
TabCurve.drawFromTop(mPath, 0, height, TabCurve.Direction.RIGHT);
mPath.lineTo(width, height);
mPath.lineTo(width, 0);
mPath.lineTo(0, 0);
mPath.moveTo(nodes[0].x, nodes[0].y);
TabCurve.drawFromTop(mPath, nodes[1].x, nodes[1].y, directionalCurve);
mPath.lineTo(nodes[2].x, nodes[2].y);
mPath.lineTo(nodes[3].x, nodes[3].y);
mPath.lineTo(nodes[0].x, nodes[0].y);
}
private static TabCurve.Direction getDirectionalCurve(int direction) {
if (direction == ViewCompat.LAYOUT_DIRECTION_RTL) {
// right to LEFT
return TabCurve.Direction.LEFT;
} else {
// left to RIGHT
return TabCurve.Direction.RIGHT;
}
}
private static Point[] getDirectionalNodes(int width, int height, int layoutDirection) {
final Point[] nodes;
if (layoutDirection == ViewCompat.LAYOUT_DIRECTION_RTL) {
nodes = new Point[] {
new Point(width, 0)
, new Point(width, height)
, new Point(0, height)
, new Point(0, 0)
};
} else {
nodes = new Point[]{
new Point(0, 0)
, new Point(0, height)
, new Point(width, height)
, new Point(width, 0)
};
}
return nodes;
}
}

Просмотреть файл

@ -17,6 +17,8 @@ import android.graphics.Path;
import android.graphics.PorterDuff.Mode;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.StateListDrawable;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
/**
@ -42,6 +44,10 @@ public class ShapedButton extends ThemedImageButton
mCanvasDelegate = new CanvasDelegate(this, Mode.DST_IN, paint);
setWillNotDraw(false);
Drawable drawable = getDrawable();
if (drawable != null) {
DrawableCompat.setAutoMirrored(drawable, true);
}
}
@Override
@ -91,15 +97,15 @@ public class ShapedButton extends ThemedImageButton
return;
}
int[] padding = new int[] { getPaddingLeft(),
int[] padding = new int[] { ViewCompat.getPaddingStart(this),
getPaddingTop(),
getPaddingRight(),
ViewCompat.getPaddingEnd(this),
getPaddingBottom()
};
drawable.setLevel(getBackground().getLevel());
super.setBackgroundDrawable(drawable);
setPadding(padding[0], padding[1], padding[2], padding[3]);
ViewCompat.setPaddingRelative(this, padding[0], padding[1], padding[2], padding[3]);
}
@Override

Просмотреть файл

@ -12,6 +12,7 @@ import org.mozilla.gecko.widget.themed.ThemedFrameLayout;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.StateListDrawable;
import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
/** A FrameLayout with lightweight theme support. Note that {@link ShapedButton}'s lwt support is basically the same so
@ -56,15 +57,15 @@ public class ShapedButtonFrameLayout extends ThemedFrameLayout {
return;
}
int[] padding = new int[] { getPaddingLeft(),
int[] padding = new int[] { ViewCompat.getPaddingStart(this),
getPaddingTop(),
getPaddingRight(),
ViewCompat.getPaddingEnd(this),
getPaddingBottom()
};
drawable.setLevel(getBackground().getLevel());
super.setBackgroundDrawable(drawable);
setPadding(padding[0], padding[1], padding[2], padding[3]);
ViewCompat.setPaddingRelative(this, padding[0], padding[1], padding[2], padding[3]);
}
@Override

Просмотреть файл

@ -12,6 +12,7 @@ import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.support.design.widget.Snackbar;
import android.support.v4.content.ContextCompat;
import android.support.v4.widget.TextViewCompat;
import android.widget.ImageView;
import android.widget.Toast;
import org.json.JSONException;
@ -385,13 +386,13 @@ public class SiteIdentityPopup extends AnchoredPopup implements GeckoEventListen
private void clearSecurityStateIcon() {
mSecurityState.setCompoundDrawablePadding(0);
mSecurityState.setCompoundDrawables(null, null, null, null);
TextViewCompat.setCompoundDrawablesRelative(mSecurityState, null, null, null, null);
}
private void setSecurityStateIcon(int resource, int factor) {
final Drawable stateIcon = ContextCompat.getDrawable(mContext, resource);
stateIcon.setBounds(0, 0, stateIcon.getIntrinsicWidth() / factor, stateIcon.getIntrinsicHeight() / factor);
mSecurityState.setCompoundDrawables(stateIcon, null, null, null);
TextViewCompat.setCompoundDrawablesRelative(mSecurityState, stateIcon, null, null, null);
mSecurityState.setCompoundDrawablePadding((int) mResources.getDimension(R.dimen.doorhanger_drawable_padding));
}
private void updateIdentityInformation(final SiteIdentity siteIdentity) {
@ -514,7 +515,7 @@ public class SiteIdentityPopup extends AnchoredPopup implements GeckoEventListen
final int dimen = (int) mResources.getDimension(R.dimen.browser_toolbar_favicon_size);
faviconDrawable.setBounds(0, 0, dimen, dimen);
mTitle.setCompoundDrawables(faviconDrawable, null, null, null);
TextViewCompat.setCompoundDrawablesRelative(mTitle, faviconDrawable, null, null, null);
mTitle.setCompoundDrawablePadding((int) mContext.getResources().getDimension(R.dimen.doorhanger_drawable_padding));
}
}
@ -562,7 +563,7 @@ public class SiteIdentityPopup extends AnchoredPopup implements GeckoEventListen
super.dismiss();
removeTrackingContentNotification();
removeSelectLoginDoorhanger();
mTitle.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(mTitle, null, null, null, null);
mDivider.setVisibility(View.GONE);
}

Просмотреть файл

@ -31,6 +31,7 @@ import org.mozilla.gecko.widget.themed.ThemedTextView;
import android.content.Context;
import android.os.SystemClock;
import android.support.annotation.NonNull;
import android.support.v4.view.ViewCompat;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
@ -469,16 +470,20 @@ public class ToolbarDisplayLayout extends ThemedLinearLayout {
mSiteIdentityPopup.setAnchor(view);
}
private boolean isLayoutRtl() {
return ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL;
}
void prepareForwardAnimation(PropertyAnimator anim, ForwardButtonAnimation animation, int width) {
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);
isLayoutRtl() ? width : 0);
anim.attach(mSiteSecurity,
PropertyAnimator.Property.TRANSLATION_X,
0);
isLayoutRtl() ? width : 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
@ -488,10 +493,10 @@ public class ToolbarDisplayLayout extends ThemedLinearLayout {
} else {
anim.attach(mTitle,
PropertyAnimator.Property.TRANSLATION_X,
width);
isLayoutRtl() ? 0 : width);
anim.attach(mSiteSecurity,
PropertyAnimator.Property.TRANSLATION_X,
width);
isLayoutRtl() ? 0 : width);
}
}

Просмотреть файл

@ -30,6 +30,8 @@ import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Message;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
import android.view.View;
import android.view.animation.Animation;
@ -50,7 +52,7 @@ public class ToolbarProgressView extends ThemedImageView {
private int mTargetProgress;
private int mIncrement;
private Rect mBounds;
private ProgressBounds mBounds;
private Handler mHandler;
private int mCurrentProgress;
@ -67,7 +69,8 @@ public class ToolbarProgressView extends ThemedImageView {
}
private void init(Context ctx) {
mBounds = new Rect(0, 0, 0, 0);
mBounds = new ProgressBounds();
mTargetProgress = 0;
mPrivateBrowsingColorFilter = new PorterDuffColorFilter(
@ -78,23 +81,22 @@ public class ToolbarProgressView extends ThemedImageView {
@Override
public void onLayout(boolean f, int l, int t, int r, int b) {
mBounds.left = 0;
mBounds.right = (r - l) * mCurrentProgress / MAX_PROGRESS;
mBounds.top = 0;
mBounds.bottom = b - t;
mBounds.setLayoutRtl(ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL);
mBounds.onLayout(f, l, t, r, b);
}
@Override
public void onDraw(Canvas canvas) {
final Drawable d = getDrawable();
d.setBounds(mBounds);
DrawableCompat.setAutoMirrored(d, true);
d.setBounds(mBounds.getBounds());
d.draw(canvas);
}
/**
* Immediately sets the progress bar to the given progress percentage.
*
* @param progress Percentage (0-100) to which progress bar should be set
* @param progressPercentage Percentage (0-100) to which progress bar should be set
*/
void setProgress(int progressPercentage) {
mCurrentProgress = mTargetProgress = getAbsoluteProgress(progressPercentage);
@ -107,7 +109,7 @@ public class ToolbarProgressView extends ThemedImageView {
* Animates the progress bar from the current progress value to the given
* progress percentage.
*
* @param progress Percentage (0-100) to which progress bar should be animated
* @param progressPercentage Percentage (0-100) to which progress bar should be animated
*/
void animateProgress(int progressPercentage) {
final int absoluteProgress = getAbsoluteProgress(progressPercentage);
@ -144,7 +146,7 @@ public class ToolbarProgressView extends ThemedImageView {
}
private void updateBounds() {
mBounds.right = getWidth() * mCurrentProgress / MAX_PROGRESS;
mBounds.updateBounds();
invalidate();
}
@ -192,4 +194,45 @@ public class ToolbarProgressView extends ThemedImageView {
}
}
};
private final class ProgressBounds {
final Rect bounds;
boolean isLayoutRtl = false;
ProgressBounds() {
bounds = new Rect();
}
public Rect getBounds() {
return bounds;
}
void setLayoutRtl(boolean isLayoutRtl) {
this.isLayoutRtl = isLayoutRtl;
}
void updateBounds() {
int progressWidth = getWidth() * mCurrentProgress / MAX_PROGRESS;
if (isLayoutRtl) {
bounds.left = getWidth() - progressWidth;
} else {
bounds.right = progressWidth;
}
}
void onLayout(boolean f, int l, int t, int r, int b) {
bounds.top = 0;
bounds.bottom = b - t;
int progressWidth = (r - l) * mCurrentProgress / MAX_PROGRESS;
;
if (isLayoutRtl) {
bounds.left = r - progressWidth;
bounds.right = r;
} else {
bounds.left = 0;
bounds.right = progressWidth;
}
}
}
}

Просмотреть файл

@ -17,6 +17,7 @@ import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.v4.widget.TextViewCompat;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
@ -131,7 +132,7 @@ public class BasicColorPicker extends ListView {
check = getCheckDrawable();
}
checked.setCompoundDrawables(check, null, null, null);
TextViewCompat.setCompoundDrawablesRelative(checked, check, null, null, null);
checked.setText("");
return v;

Просмотреть файл

@ -10,6 +10,7 @@ import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.support.v4.content.ContextCompat;
import android.support.v4.widget.TextViewCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewStub;
@ -207,7 +208,7 @@ public abstract class DoorHanger extends LinearLayout {
public void showTitle(Bitmap favicon, String title) {
mDoorhangerTitle.setText(title);
mDoorhangerTitle.setCompoundDrawablesWithIntrinsicBounds(new BitmapDrawable(getResources(), favicon), null, null, null);
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(mDoorhangerTitle, new BitmapDrawable(getResources(), favicon), null, null, null);
if (favicon != null) {
mDoorhangerTitle.setCompoundDrawablePadding((int) mContext.getResources().getDimension(R.dimen.doorhanger_drawable_padding));
}

Просмотреть файл

@ -9,7 +9,9 @@ import android.content.Context;
import android.graphics.Canvas;
import android.graphics.LinearGradient;
import android.graphics.Shader;
import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
import android.view.View;
/**
* Fades the end of the text by gecko:fadeWidth amount,
@ -37,7 +39,8 @@ public class FadedSingleColorTextView extends FadedTextView {
final boolean needsEllipsis = needsEllipsis();
if (needsEllipsis && needsNewGradient) {
mTextGradient = new FadedTextGradient(width, fadeWidth, color);
final boolean isRTL = ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL;
mTextGradient = new FadedTextGradient(width, fadeWidth, color, isRTL);
}
getPaint().setShader(needsEllipsis ? mTextGradient : null);
@ -53,10 +56,11 @@ public class FadedSingleColorTextView extends FadedTextView {
private final int mWidth;
private final int mColor;
public FadedTextGradient(int width, int fadeWidth, int color) {
super(0, 0, width, 0,
new int[] { color, color, 0x0 },
new float[] { 0, ((float) (width - fadeWidth) / width), 1.0f },
public FadedTextGradient(int width, int fadeWidth, int color, boolean isRTL) {
super(isRTL ? width : 0, 0,
isRTL ? 0 : width, 0,
new int[]{color, color, 0x0},
new float[]{0, ((float) (width - fadeWidth) / width), 1.0f},
Shader.TileMode.CLAMP);
mWidth = width;

Просмотреть файл

@ -6,4 +6,4 @@
<clip xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/url_bar_entry"
android:clipOrientation="horizontal"
android:gravity="right"/>
android:gravity="right|end"/>

Просмотреть файл

@ -10,7 +10,10 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignLeft="@+id/back"
android:layout_alignStart="@+id/back"
android:layout_toLeftOf="@id/menu_items"
android:layout_toStartOf="@id/menu_items"
android:layout_marginStart="@dimen/tablet_nav_button_width_half"
android:layout_marginLeft="@dimen/tablet_nav_button_width_half"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
@ -40,6 +43,7 @@
style="@style/UrlBar.ImageButton.BrowserToolbarColors"
android:id="@+id/forward"
android:layout_alignLeft="@id/back"
android:layout_alignStart="@id/back"
android:contentDescription="@string/forward"
android:layout_height="match_parent"
android:paddingTop="0dp"
@ -53,7 +57,12 @@
android:alpha="0"
android:layout_width="@dimen/tablet_nav_button_width_plus_half"
android:layout_marginLeft="@dimen/tablet_nav_button_width_half"
android:paddingLeft="18dp"/>
android:layout_marginStart="@dimen/tablet_nav_button_width_half"
android:paddingLeft="@dimen/tablet_fwd_button_padding_start"
android:paddingStart="@dimen/tablet_fwd_button_padding_start"
android:paddingRight="@dimen/tablet_fwd_button_padding_end"
android:paddingEnd="@dimen/tablet_fwd_button_padding_end"
/>
<org.mozilla.gecko.toolbar.BackButton android:id="@id/back"
style="@style/UrlBar.ImageButton.BrowserToolbarColors"
@ -61,38 +70,50 @@
android:layout_height="@dimen/tablet_nav_button_width"
android:layout_centerVertical="true"
android:layout_marginLeft="12dp"
android:layout_marginStart="12dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:src="@drawable/ic_menu_back"
android:contentDescription="@string/back"
android:background="@drawable/url_bar_nav_button"/>
android:background="@drawable/url_bar_nav_button"
/>
<org.mozilla.gecko.toolbar.ToolbarEditLayout android:id="@+id/edit_layout"
style="@style/UrlBar.Button"
android:paddingRight="12dp"
android:paddingEnd="12dp"
android:visibility="gone"
android:orientation="horizontal"
android:layout_toLeftOf="@id/menu_items"
android:layout_toStartOf="@id/menu_items"
android:layout_toRightOf="@id/back"
android:layout_toLeftOf="@id/menu_items"/>
android:layout_toEndOf="@id/back"/>
<!-- 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"
android:layout_toLeftOf="@id/menu_items"
android:paddingRight="4dip"/>
android:layout_toRightOf="@id/back"
android:layout_toEndOf="@id/back"
android:layout_toLeftOf="@id/menu_items"
android:layout_toStartOf="@id/menu_items"
android:paddingRight="4dip"
android:paddingEnd="4dip"/>
<LinearLayout android:id="@+id/menu_items"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:layout_marginLeft="6dp"
android:orientation="horizontal"
android:layout_toLeftOf="@id/tabs"/>
android:layout_marginStart="6dp"
android:layout_toLeftOf="@id/tabs"
android:layout_toStartOf="@id/tabs"
android:orientation="horizontal"/>
<org.mozilla.gecko.widget.themed.ThemedImageButton
android:id="@+id/tabs"
style="@style/UrlBar.ImageButton"
android:layout_toLeftOf="@id/menu"
android:layout_toStartOf="@id/menu"
android:layout_alignWithParentIfMissing="true"
android:background="@drawable/browser_toolbar_action_bar_button"/>
@ -100,13 +121,17 @@
<org.mozilla.gecko.toolbar.TabCounter android:id="@+id/tabs_counter"
style="@style/UrlBar.ImageButton"
android:layout_alignLeft="@id/tabs"
android:layout_alignStart="@id/tabs"
android:layout_alignRight="@id/tabs"
android:layout_alignEnd="@id/tabs"
android:layout_alignTop="@id/tabs"
android:layout_alignBottom="@id/tabs"
android:layout_marginTop="18dp"
android:layout_marginBottom="18dp"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_marginRight="16dp"
android:layout_marginEnd="16dp"
android:background="@drawable/tabs_count"/>
<!-- Bug 1144707. Use clickable View instead of menu button margin to prevent
@ -115,6 +140,7 @@
android:layout_width="6dp"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:clickable="true"
android:visibility="gone"/>
@ -122,6 +148,7 @@
android:id="@+id/menu"
style="@style/UrlBar.ImageButton"
android:layout_toLeftOf="@id/menu_margin"
android:layout_toStartOf="@id/menu_margin"
android:layout_alignWithParentIfMissing="true"
android:contentDescription="@string/menu"
android:background="@drawable/browser_toolbar_action_bar_button">
@ -146,6 +173,7 @@
android:layout_height="@dimen/browser_toolbar_height"
android:layout_weight="0.0"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:src="@drawable/close_edit_mode_selector"
android:contentDescription="@string/edit_mode_cancel"
android:visibility="gone"/>

Просмотреть файл

@ -41,7 +41,7 @@
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_gravity="right|top"
android:layout_gravity="right|end|top"
android:contentDescription="@string/menu"
android:src="@drawable/menu"
android:padding="@dimen/activity_stream_base_margin" />

Просмотреть файл

@ -52,7 +52,7 @@
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_gravity="right|top"
android:layout_gravity="right|end|top"
android:padding="6dp"
android:contentDescription="@string/menu"
android:src="@drawable/menu" />

Просмотреть файл

@ -7,7 +7,9 @@
style="@style/Widget.FolderView"
android:layout_width="match_parent"
android:paddingLeft="0dp"
android:paddingStart="0dp"
android:paddingRight="16dp"
android:paddingEnd="16dp"
android:paddingTop="0dp"
android:paddingBottom="0dp"
android:paddingRight="16dp"
android:gravity="center_vertical"/>

Просмотреть файл

@ -10,10 +10,13 @@
<ImageView android:id="@+id/url_bar_entry"
style="@style/UrlBar.Button"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:layout_marginRight="-6dp"
android:layout_marginEnd="-6dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_toLeftOf="@+id/tabs"
android:layout_toStartOf="@+id/tabs"
android:duplicateParentState="true"
android:clickable="false"
android:focusable="false"
@ -26,7 +29,9 @@
<ImageView android:id="@+id/url_bar_translating_edge"
style="@style/UrlBar.Button"
android:layout_alignLeft="@id/url_bar_entry"
android:layout_alignStart="@id/url_bar_entry"
android:layout_alignRight="@+id/url_bar_entry"
android:layout_alignEnd="@+id/url_bar_entry"
android:layout_alignTop="@id/url_bar_entry"
android:layout_alignBottom="@id/url_bar_entry"
android:duplicateParentState="true"
@ -40,6 +45,7 @@
android:id="@+id/menu"
style="@style/UrlBar.ImageButton"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:contentDescription="@string/menu"
android:background="@drawable/shaped_button">
@ -59,6 +65,7 @@
style="@style/UrlBar.ImageButton"
android:layout_width="64dip"
android:layout_toLeftOf="@id/menu"
android:layout_toStartOf="@id/menu"
android:layout_alignWithParentIfMissing="true"
android:background="@drawable/shaped_button"/>
@ -74,7 +81,9 @@
android:layout_height="24dip"
android:layout_centerVertical="true"
android:layout_marginRight="8dip"
android:layout_marginEnd="8dip"
android:layout_alignRight="@id/tabs"
android:layout_alignEnd="@id/tabs"
android:background="@drawable/tabs_count"
android:gravity="center_horizontal"
android:clipChildren="false"
@ -86,6 +95,7 @@
android:id="@+id/edit_cancel"
style="@style/UrlBar.ImageButton"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:src="@drawable/close_edit_mode_selector"
android:contentDescription="@string/edit_mode_cancel"
android:background="@drawable/action_bar_button"
@ -97,16 +107,24 @@
<org.mozilla.gecko.toolbar.ToolbarEditLayout android:id="@+id/edit_layout"
style="@style/UrlBar.Button"
android:layout_alignLeft="@id/url_bar_entry"
android:layout_alignStart="@id/url_bar_entry"
android:layout_toLeftOf="@id/edit_cancel"
android:layout_toStartOf="@id/edit_cancel"
android:visibility="invisible"
android:paddingLeft="8dp"
android:paddingRight="8dp"/>
android:paddingStart="8dp"
android:paddingRight="8dp"
android:paddingEnd="8dp"/>
<org.mozilla.gecko.toolbar.ToolbarDisplayLayout android:id="@+id/display_layout"
style="@style/UrlBar.Button"
android:layout_alignLeft="@id/url_bar_entry"
android:layout_alignStart="@id/url_bar_entry"
android:layout_alignRight="@id/url_bar_entry"
android:layout_alignEnd="@id/url_bar_entry"
android:paddingLeft="1dip"
android:paddingRight="4dip"/>
android:paddingStart="1dip"
android:paddingRight="4dip"
android:paddingEnd="4dip" />
</merge>

Просмотреть файл

@ -19,7 +19,7 @@
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="@dimen/doorhanger_section_padding_medium"
android:gravity="right"
android:gravity="right|end"
android:visibility="gone"/>
<android.support.v7.widget.AppCompatCheckBox

Просмотреть файл

@ -6,25 +6,30 @@
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:layout_marginLeft="@dimen/find_in_page_text_margin_left"
android:layout_marginRight="@dimen/find_in_page_text_margin_right"
android:layout_marginLeft="@dimen/find_in_page_text_margin_start"
android:layout_marginStart="@dimen/find_in_page_text_margin_start"
android:layout_marginRight="@dimen/find_in_page_text_margin_end"
android:layout_marginEnd="@dimen/find_in_page_text_margin_end"
android:contentDescription="@string/find_text"
android:background="@drawable/url_bar_entry"
android:singleLine="true"
android:textColor="#000000"
android:textCursorDrawable="@null"
android:inputType="text"
android:paddingLeft="@dimen/find_in_page_text_padding_left"
android:paddingRight="@dimen/find_in_page_text_padding_right"
android:paddingLeft="@dimen/find_in_page_text_padding_start"
android:paddingStart="@dimen/find_in_page_text_padding_start"
android:paddingRight="@dimen/find_in_page_text_padding_end"
android:paddingEnd="@dimen/find_in_page_text_padding_end"
android:textColorHighlight="@color/fennec_ui_orange"
android:imeOptions="actionSearch"
android:selectAllOnFocus="true"
android:gravity="center_vertical|left"/>
android:gravity="center_vertical|left|start"/>
<TextView android:id="@+id/find_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/find_in_page_status_margin_right"
android:layout_marginRight="@dimen/find_in_page_status_margin_end"
android:layout_marginEnd="@dimen/find_in_page_status_margin_end"
android:textColor="@color/tabs_tray_icon_grey"
android:visibility="gone"/>

Просмотреть файл

@ -8,6 +8,8 @@
android:layout_width="match_parent"
android:text="@string/home_history_back_to"
android:paddingLeft="24dp"
android:paddingStart="24dp"
android:drawablePadding="24dp"
android:drawableLeft="@drawable/arrow_up"
android:drawableStart="@drawable/arrow_up"
android:gravity="center_vertical"/>

Просмотреть файл

@ -9,6 +9,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="2dip"
android:paddingBottom="2dip"
android:paddingLeft="5dip"
style="?android:attr/listSeparatorTextViewStyle" />
android:paddingBottom="2dip"
android:paddingLeft="5dip"
android:paddingStart="5dip"
style="?android:attr/listSeparatorTextViewStyle" />

Просмотреть файл

@ -10,6 +10,7 @@
android:layout_height="44dp"
android:layout_marginTop="10dip"
android:layout_marginLeft="10dip"
android:layout_marginStart="10dip"
android:scaleType="centerCrop"/>
<TextView android:id="@+id/title"

Просмотреть файл

@ -31,7 +31,7 @@
android:inputType="textUri|textNoSuggestions"
android:imeOptions="actionGo|flagNoExtractUi|flagNoFullscreen"
android:singleLine="true"
android:gravity="center_vertical|left"/>
android:gravity="center_vertical|left|start"/>
</LinearLayout>

Просмотреть файл

@ -10,21 +10,26 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingRight="?android:attr/scrollbarSize">
android:paddingRight="?android:attr/scrollbarSize"
android:paddingEnd="?android:attr/scrollbarSize"
>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="right"
android:gravity="right|end"
android:layout_marginLeft="15dip"
android:layout_marginStart="15dip"
android:layout_marginRight="6dip"
android:layout_marginEnd="6dip"
android:layout_marginTop="6dip"
android:layout_marginBottom="6dip"
android:paddingRight="6dip"
android:paddingEnd="6dip"
android:layout_weight="1">
<TextView android:id="@+android:id/title"
android:layout_gravity="right"
android:layout_gravity="right|end"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
@ -34,10 +39,13 @@
</RelativeLayout>
<ImageView android:src="@drawable/menu_item_more"
<ImageView
android:id="@+id/menu_icon_more"
android:src="@drawable/menu_item_more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:paddingRight="16dp" />
android:paddingRight="16dp"
android:paddingEnd="16dp" />
</LinearLayout>

Просмотреть файл

@ -50,7 +50,7 @@
android:background="@android:color/transparent"
android:padding="15dp"
android:src="@drawable/ic_action_settings"
android:layout_gravity="bottom|right"
android:layout_gravity="bottom|right|end"
android:contentDescription="@string/search_pref_button_content_description"/>
<View

Просмотреть файл

@ -12,6 +12,9 @@
android:imeOptions="actionSearch"
android:inputType="textNoSuggestions"
android:drawableLeft="@drawable/search_icon_inactive"
android:drawableStart="@drawable/search_icon_inactive"
android:paddingRight="30dp"
android:paddingEnd="30dp"
android:drawablePadding="5dp"
android:textSize="@dimen/query_text_size"
android:focusable="false"
@ -19,14 +22,16 @@
android:textColorHighlight="@color/fennec_ui_orange"
android:textSelectHandle="@drawable/handle_middle"
android:textSelectHandleLeft="@drawable/handle_start"
android:textSelectHandleRight="@drawable/handle_end" />
android:textSelectHandleRight="@drawable/handle_end"
/>
<ImageButton
android:id="@+id/clear_button"
android:layout_width="30dp"
android:layout_height="30dp"
android:paddingLeft="10dp"
android:layout_gravity="right|center_vertical"
android:paddingStart="10dp"
android:layout_gravity="right|end|center_vertical"
android:background="@android:color/transparent"
android:src="@drawable/search_clear"
android:scaleType="centerInside"
@ -36,7 +41,7 @@
android:id="@+id/engine_icon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="right|center_vertical"
android:layout_gravity="right|end|center_vertical"
android:background="@android:color/transparent"
android:visibility="gone"/>

Просмотреть файл

@ -9,6 +9,7 @@
android:layout_height="wrap_content"
android:background="@drawable/search_row_background"
android:drawableLeft="@drawable/search_history"
android:drawableStart="@drawable/search_history"
android:drawablePadding="@dimen/search_history_drawable_padding"
android:padding="@dimen/search_row_padding"
android:textSize="@dimen/query_text_size"/>

Просмотреть файл

@ -22,8 +22,9 @@
android:id="@+id/auto_complete_row_jump_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:layout_gravity="right|end|center_vertical"
android:paddingLeft="@dimen/search_row_padding"
android:paddingStart="@dimen/search_row_padding"
android:src="@drawable/search_plus"
android:contentDescription="@string/search_plus_content_description"
android:background="@android:color/transparent" />

Просмотреть файл

@ -7,7 +7,9 @@
android:orientation="horizontal"
android:gravity="center_vertical"
android:paddingLeft="16dip"
android:paddingStart="16dip"
android:paddingRight="12dip"
android:paddingEnd="12dip"
android:minHeight="?android:attr/listPreferredItemHeight"
android:focusable="false">
@ -25,7 +27,7 @@
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
style="Widget.ListItem"
android:gravity="center_vertical|left"
android:gravity="center_vertical|left|start"
android:singleLine="true"
android:ellipsize="marquee"/>
@ -35,7 +37,7 @@
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
style="Widget.ListItem"
android:gravity="center_vertical|left"
android:gravity="center_vertical|left|start"
android:singleLine="true"
android:ellipsize="marquee"/>
@ -46,6 +48,7 @@
android:layout_width="35dip"
android:layout_height="wrap_content"
android:paddingRight="12dip"
android:paddingEnd="12dip"
android:gravity="center_vertical"
android:focusable="false"
android:clickable="false"/>

Просмотреть файл

@ -14,8 +14,11 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="@dimen/tab_history_combo_margin_left"
android:layout_marginRight="@dimen/tab_history_combo_margin_right" >
android:layout_marginLeft="@dimen/tab_history_combo_margin_start"
android:layout_marginStart="@dimen/tab_history_combo_margin_start"
android:layout_marginRight="@dimen/tab_history_combo_margin_end"
android:layout_marginEnd="@dimen/tab_history_combo_margin_end"
>
<ImageView android:id="@+id/tab_history_timeline_top"
android:layout_width="@dimen/tab_history_timeline_width"
@ -49,7 +52,8 @@
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="@null"
android:paddingRight="@dimen/tab_history_title_margin_right"
android:paddingRight="@dimen/tab_history_title_margin_end"
android:paddingEnd="@dimen/tab_history_title_margin_end"
android:text="@+id/tab_history_title"
android:textSize="@dimen/tab_history_title_text_size"
android:textColor="@color/text_and_tabs_tray_grey"

Просмотреть файл

@ -8,8 +8,8 @@
android:layout_height="match_parent"
android:minWidth="@dimen/tabs_strip_button_width"
android:background="@drawable/tabs_strip_indicator"
android:paddingLeft="@dimen/tabs_strip_button_padding"
android:paddingRight="@dimen/tabs_strip_button_padding"
android:paddingStart="@dimen/tabs_strip_button_padding"
android:paddingEnd="@dimen/tabs_strip_button_padding"
android:gravity="center"
android:focusable="true"
style="@style/TextAppearance.Widget.HomePagerTabMenuStrip"/>

Просмотреть файл

@ -10,4 +10,7 @@
android:layout_width="@dimen/tablet_tab_strip_item_width"
android:layout_height="match_parent"
android:paddingLeft="28dp"
android:paddingRight="12dp"/>
android:paddingStart="28dp"
android:paddingRight="12dp"
android:paddingEnd="12dp"
/>

Просмотреть файл

@ -11,6 +11,7 @@
android:layout_width="@dimen/browser_toolbar_favicon_size"
android:layout_height="match_parent"
android:layout_marginRight="8dp"
android:layout_marginEnd="8dp"
android:scaleType="centerInside"
android:duplicateParentState="true"/>
@ -20,6 +21,7 @@
android:layout_height="match_parent"
android:layout_weight="1.0"
android:layout_marginRight="-5dp"
android:layout_marginEnd="-5dp"
android:drawablePadding="6dp"
android:gravity="center_vertical"
android:textSize="14sp"

Просмотреть файл

@ -15,10 +15,13 @@
android:layout_width="@dimen/browser_toolbar_site_security_width"
android:layout_height="@dimen/browser_toolbar_site_security_height"
android:scaleType="fitCenter"
android:layout_marginRight="@dimen/browser_toolbar_site_security_margin_right"
android:layout_marginRight="@dimen/browser_toolbar_site_security_margin_end"
android:layout_marginEnd="@dimen/browser_toolbar_site_security_margin_end"
android:layout_marginBottom="@dimen/browser_toolbar_site_security_margin_bottom"
android:paddingLeft="@dimen/browser_toolbar_site_security_padding_horizontal"
android:paddingStart="@dimen/browser_toolbar_site_security_padding_horizontal"
android:paddingRight="@dimen/browser_toolbar_site_security_padding_horizontal"
android:paddingEnd="@dimen/browser_toolbar_site_security_padding_horizontal"
android:paddingTop="@dimen/browser_toolbar_site_security_padding_vertical"
android:paddingBottom="@dimen/browser_toolbar_site_security_padding_vertical"
android:src="@drawable/site_security_level"

Просмотреть файл

@ -12,10 +12,13 @@
android:layout_width="@dimen/browser_toolbar_site_security_width"
android:layout_height="@dimen/browser_toolbar_site_security_height"
android:layout_marginBottom="@dimen/browser_toolbar_site_security_margin_bottom"
android:layout_marginRight="@dimen/browser_toolbar_site_security_margin_right"
android:layout_marginRight="@dimen/browser_toolbar_site_security_margin_end"
android:layout_marginEnd="@dimen/browser_toolbar_site_security_margin_end"
android:paddingBottom="@dimen/browser_toolbar_site_security_padding_vertical"
android:paddingLeft="@dimen/browser_toolbar_site_security_padding_horizontal"
android:paddingStart="@dimen/browser_toolbar_site_security_padding_horizontal"
android:paddingRight="@dimen/browser_toolbar_site_security_padding_horizontal"
android:paddingEnd="@dimen/browser_toolbar_site_security_padding_horizontal"
android:paddingTop="@dimen/browser_toolbar_site_security_padding_vertical"
android:scaleType="fitCenter"
android:src="@drawable/search_icon_inactive"
@ -32,6 +35,7 @@
android:selectAllOnFocus="true"
android:contentDescription="@string/url_bar_default_text"
android:paddingRight="8dp"
android:paddingEnd="8dp"
gecko:autoUpdateTheme="false"/>
<ImageButton android:id="@+id/qrcode"

Просмотреть файл

@ -98,7 +98,9 @@
android:textSize="16sp"
android:layout_marginLeft="32dp"
android:layout_marginStart="32dp"
android:layout_marginRight="32dp"
android:layout_marginEnd="32dp"
tools:text="Got it"/>
</LinearLayout>

Просмотреть файл

@ -20,6 +20,7 @@
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:paddingRight="10dp"
android:paddingEnd="10dp"
android:orientation="vertical">
<org.mozilla.gecko.widget.FadedSingleColorTextView

Просмотреть файл

@ -19,6 +19,7 @@
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:paddingRight="10dp"
android:paddingEnd="10dp"
android:orientation="vertical">
<org.mozilla.gecko.widget.FadedSingleColorTextView
@ -37,7 +38,9 @@
android:maxLength="1024"
gecko:fadeWidth="90dp"
tools:text="http://test.com/test"
tools:drawableLeft="@drawable/ic_url_bar_tab"/>
tools:drawableLeft="@drawable/ic_url_bar_tab"
tools:drawableStart="@drawable/ic_url_bar_tab"
/>
</LinearLayout>

Просмотреть файл

@ -19,7 +19,7 @@
<dimen name="browser_toolbar_site_security_height">60dp</dimen>
<dimen name="browser_toolbar_site_security_width">34dp</dimen>
<dimen name="browser_toolbar_site_security_margin_right">1dp</dimen>
<dimen name="browser_toolbar_site_security_margin_end">1dp</dimen>
<!-- We primarily use padding (instead of margins) to increase the hit area. -->
<dimen name="browser_toolbar_site_security_padding_vertical">21dp</dimen>
<dimen name="browser_toolbar_site_security_padding_horizontal">8dp</dimen>

Просмотреть файл

@ -33,6 +33,9 @@
<dimen name="tablet_nav_button_width_half">21dp</dimen>
<dimen name="tablet_nav_button_width_plus_half">63dp</dimen>
<dimen name="tablet_fwd_button_padding_start">18dp</dimen>
<dimen name="tablet_fwd_button_padding_end">0dp</dimen>
<!-- This is the system default for the vertical padding for the divider of the TabWidget.
Used to mimic the divider padding on the tablet tabs panel back button. -->
<dimen name="tab_panel_divider_vertical_padding">12dp</dimen>
@ -70,7 +73,7 @@
<!-- Site security icon -->
<dimen name="browser_toolbar_site_security_height">32dp</dimen>
<dimen name="browser_toolbar_site_security_width">32dp</dimen>
<dimen name="browser_toolbar_site_security_margin_right">0dp</dimen>
<dimen name="browser_toolbar_site_security_margin_end">0dp</dimen>
<dimen name="browser_toolbar_site_security_padding_vertical">7dp</dimen>
<dimen name="browser_toolbar_site_security_padding_horizontal">7dp</dimen>
@ -185,10 +188,10 @@
<dimen name="tab_history_favicon_padding">5dp</dimen>
<dimen name="tab_history_favicon_border_enabled">3dp</dimen>
<dimen name="tab_history_favicon_border_disabled">1dp</dimen>
<dimen name="tab_history_combo_margin_left">15dp</dimen>
<dimen name="tab_history_combo_margin_right">15dp</dimen>
<dimen name="tab_history_combo_margin_start">15dp</dimen>
<dimen name="tab_history_combo_margin_end">15dp</dimen>
<dimen name="tab_history_title_fading_width">50dp</dimen>
<dimen name="tab_history_title_margin_right">15dp</dimen>
<dimen name="tab_history_title_margin_end">15dp</dimen>
<dimen name="tab_history_title_text_size">14sp</dimen>
<dimen name="tab_history_bg_width">2dp</dimen>
<dimen name="tab_history_border_padding">2dp</dimen>
@ -198,11 +201,11 @@
<dimen name="drawable_dropshadow_size">3dp</dimen>
<!-- Find-In-Page dialog dimensions. -->
<dimen name="find_in_page_text_margin_left">5dip</dimen>
<dimen name="find_in_page_text_margin_right">12dip</dimen>
<dimen name="find_in_page_text_padding_left">10dip</dimen>
<dimen name="find_in_page_text_padding_right">10dip</dimen>
<dimen name="find_in_page_status_margin_right">10dip</dimen>
<dimen name="find_in_page_text_margin_start">5dip</dimen>
<dimen name="find_in_page_text_margin_end">12dip</dimen>
<dimen name="find_in_page_text_padding_start">10dip</dimen>
<dimen name="find_in_page_text_padding_end">10dip</dimen>
<dimen name="find_in_page_status_margin_end">10dip</dimen>
<dimen name="find_in_page_control_margin_top">2dip</dimen>
<dimen name="progress_bar_scroll_offset">1.5dp</dimen>

Просмотреть файл

@ -17,6 +17,7 @@ import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.support.v4.widget.TextViewCompat;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.AttributeSet;
@ -163,8 +164,8 @@ public class SearchBar extends FrameLayout {
editText.setFocusable(active);
editText.setFocusableInTouchMode(active);
final int leftDrawable = active ? R.drawable.search_icon_active : R.drawable.search_icon_inactive;
editText.setCompoundDrawablesWithIntrinsicBounds(leftDrawable, 0, 0, 0);
final int startDrawable = active ? R.drawable.search_icon_active : R.drawable.search_icon_inactive;
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(editText, startDrawable, 0, 0, 0);
// We can't use a selector drawable because we apply a color filter to the focused
// background at run time.

Просмотреть файл

@ -25,8 +25,11 @@
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_marginRight="30dp"
android:layout_marginEnd="30dp"
android:layout_marginTop="30dp"
android:ellipsize="end"
android:maxLines="2"
@ -39,8 +42,10 @@
android:layout_height="wrap_content"
android:layout_marginBottom="6dp"
android:layout_marginLeft="30dp"
android:layout_marginStart="30dp"
android:layout_marginTop="30dp"
android:layout_toLeftOf="@id/close"
android:layout_toStartOf="@id/close"
android:fontFamily="sans-serif-light"
android:textColor="@color/text_and_tabs_tray_grey"
android:textSize="20sp"
@ -53,7 +58,9 @@
android:layout_below="@id/title"
android:layout_marginBottom="20dp"
android:layout_marginLeft="30dp"
android:layout_marginStart="30dp"
android:layout_marginRight="30dp"
android:layout_marginEnd="30dp"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@color/placeholder_grey"
@ -67,6 +74,7 @@
android:layout_below="@id/host"
android:layout_marginBottom="20dp"
android:layout_marginLeft="30dp"
android:layout_marginStart="30dp"
android:src="@drawable/icon" />
<Button
@ -75,13 +83,18 @@
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_below="@id/host"
android:layout_marginBottom="20dp"
android:layout_marginLeft="100dp"
android:layout_marginStart="100dp"
android:layout_marginRight="30dp"
android:layout_marginEnd="30dp"
android:background="@drawable/button_background_action_orange_round"
android:paddingLeft="16dp"
android:paddingStart="16dp"
android:paddingRight="16dp"
android:paddingEnd="16dp"
android:text="@string/promotion_add_to_homescreen"
android:maxLines="2"
android:ellipsize="end"