зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1324280 - Revert MarginLayoutParamsCompat with setting margin left/right by current layout direction, r=sebastian
MozReview-Commit-ID: amwDqXRxE5 --HG-- extra : rebase_source : 8561d5541d7aae658c9002d57add058980384fc0
This commit is contained in:
Родитель
90a0e4020f
Коммит
03b008aa5c
|
@ -8,6 +8,7 @@ package org.mozilla.gecko.toolbar;
|
|||
import org.mozilla.gecko.R;
|
||||
import org.mozilla.gecko.animation.PropertyAnimator;
|
||||
import org.mozilla.gecko.animation.ViewHelper;
|
||||
import org.mozilla.gecko.util.ViewUtil;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
@ -97,13 +98,12 @@ class BrowserToolbarTablet extends BrowserToolbarTabletBase {
|
|||
if (!willShowForward) {
|
||||
// Set the margin before the transition when hiding the forward button. We
|
||||
// have to do this so that the favicon isn't clipped during the transition
|
||||
MarginLayoutParams layoutParams =
|
||||
(MarginLayoutParams) urlDisplayLayout.getLayoutParams();
|
||||
MarginLayoutParamsCompat.setMarginStart(layoutParams, 0);
|
||||
MarginLayoutParams layoutParams = (MarginLayoutParams) urlDisplayLayout.getLayoutParams();
|
||||
ViewUtil.setMarginStart(layoutParams, 0, isLayoutRtl());
|
||||
|
||||
// Do the same on the URL edit container
|
||||
layoutParams = (MarginLayoutParams) urlEditLayout.getLayoutParams();
|
||||
MarginLayoutParamsCompat.setMarginStart(layoutParams, 0);
|
||||
ViewUtil.setMarginStart(layoutParams, 0, isLayoutRtl());
|
||||
|
||||
requestLayout();
|
||||
// Note, we already translated the favicon, site security, and text field
|
||||
|
@ -117,12 +117,11 @@ class BrowserToolbarTablet extends BrowserToolbarTabletBase {
|
|||
final ForwardButtonState newForwardButtonState;
|
||||
if (willShowForward) {
|
||||
// Increase the margins to ensure the text does not run outside the View.
|
||||
MarginLayoutParams layoutParams =
|
||||
(MarginLayoutParams) urlDisplayLayout.getLayoutParams();
|
||||
MarginLayoutParamsCompat.setMarginStart(layoutParams, forwardButtonTranslationWidth);
|
||||
MarginLayoutParams layoutParams = (MarginLayoutParams) urlDisplayLayout.getLayoutParams();
|
||||
ViewUtil.setMarginStart(layoutParams, forwardButtonTranslationWidth, isLayoutRtl());
|
||||
|
||||
layoutParams = (MarginLayoutParams) urlEditLayout.getLayoutParams();
|
||||
MarginLayoutParamsCompat.setMarginStart(layoutParams, forwardButtonTranslationWidth);
|
||||
ViewUtil.setMarginStart(layoutParams, forwardButtonTranslationWidth, isLayoutRtl());
|
||||
|
||||
newForwardButtonState = ForwardButtonState.DISPLAYED;
|
||||
} else {
|
||||
|
|
|
@ -5,7 +5,10 @@
|
|||
package org.mozilla.gecko.util;
|
||||
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.Build;
|
||||
import android.support.v4.view.MarginLayoutParamsCompat;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import org.mozilla.gecko.AppConstants;
|
||||
import org.mozilla.gecko.R;
|
||||
|
@ -30,4 +33,22 @@ public class ViewUtil {
|
|||
// until API 16.
|
||||
view.setBackgroundDrawable(backgroundDrawableArray.getDrawable(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Android framework have a bug margin start/end for RTL between 19~22. We can only use MarginLayoutParamsCompat before 17 and after 23.
|
||||
* @param layoutParams
|
||||
* @param marginStart
|
||||
* @param isLayoutRtl
|
||||
*/
|
||||
public static void setMarginStart(ViewGroup.MarginLayoutParams layoutParams, int marginStart, boolean isLayoutRtl) {
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && Build.VERSION.SDK_INT < Build.VERSION_CODES.M){
|
||||
if(isLayoutRtl){
|
||||
layoutParams.rightMargin = marginStart;
|
||||
} else {
|
||||
layoutParams.leftMargin = marginStart;
|
||||
}
|
||||
} else {
|
||||
MarginLayoutParamsCompat.setMarginStart(layoutParams, marginStart);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче