Bug 1107636 - Use MarginLayoutParams where applicable. r=sebastian

MarginLayoutParams is less specific than RelativeLayout.LayoutParams
and is easier to make changes with.

--HG--
extra : commitid : GY5tk9gY1Ji
extra : rebase_source : 1cf8940e8d570339fd72f4835033113c48be04d2
This commit is contained in:
Michael Comella 2015-11-06 16:16:30 -08:00
Родитель 5a4bcbfd7b
Коммит 3471c9e8c3
3 изменённых файлов: 8 добавлений и 8 удалений

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

@ -1378,7 +1378,7 @@ public class BrowserApp extends GeckoApp
} }
private void setToolbarMargin(int margin) { private void setToolbarMargin(int margin) {
((RelativeLayout.LayoutParams) mGeckoLayout.getLayoutParams()).topMargin = margin; ((ViewGroup.MarginLayoutParams) mGeckoLayout.getLayoutParams()).topMargin = margin;
mGeckoLayout.requestLayout(); mGeckoLayout.requestLayout();
} }

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

@ -4,6 +4,7 @@
package org.mozilla.gecko; package org.mozilla.gecko;
import android.view.ViewGroup;
import org.mozilla.gecko.animation.ViewHelper; import org.mozilla.gecko.animation.ViewHelper;
import org.mozilla.gecko.gfx.ImmutableViewportMetrics; import org.mozilla.gecko.gfx.ImmutableViewportMetrics;
import org.mozilla.gecko.gfx.LayerView; import org.mozilla.gecko.gfx.LayerView;
@ -19,7 +20,6 @@ import android.util.Log;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.RelativeLayout;
/** /**
* Text selection handles enable a user to change position of selected text in * Text selection handles enable a user to change position of selected text in
@ -57,7 +57,7 @@ class TextSelectionHandle extends ImageView implements View.OnTouchListener {
private PointF mGeckoPoint; private PointF mGeckoPoint;
private PointF mTouchStart; private PointF mTouchStart;
private RelativeLayout.LayoutParams mLayoutParams; private ViewGroup.MarginLayoutParams mLayoutParams;
private static final int IMAGE_LEVEL_LTR = 0; private static final int IMAGE_LEVEL_LTR = 0;
private static final int IMAGE_LEVEL_RTL = 1; private static final int IMAGE_LEVEL_RTL = 1;
@ -204,7 +204,7 @@ class TextSelectionHandle extends ImageView implements View.OnTouchListener {
private void setLayoutPosition() { private void setLayoutPosition() {
if (mLayoutParams == null) { if (mLayoutParams == null) {
mLayoutParams = (RelativeLayout.LayoutParams) getLayoutParams(); mLayoutParams = (ViewGroup.MarginLayoutParams) getLayoutParams();
// Set negative right/bottom margins so that the handles can be dragged outside of // Set negative right/bottom margins so that the handles can be dragged outside of
// the content area (if they are dragged to the left/top, the dyanmic margins set // the content area (if they are dragged to the left/top, the dyanmic margins set
// below will take care of that). // below will take care of that).

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

@ -200,7 +200,7 @@ public class ZoomedView extends FrameLayout implements LayerView.DynamicToolbarL
} }
private boolean moveZoomedView(MotionEvent event) { private boolean moveZoomedView(MotionEvent event) {
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) ZoomedView.this.getLayoutParams(); final MarginLayoutParams params = (MarginLayoutParams) ZoomedView.this.getLayoutParams();
if ((!dragged) && (Math.abs((int) (event.getRawX() - originRawX)) < PanZoomController.CLICK_THRESHOLD) if ((!dragged) && (Math.abs((int) (event.getRawX() - originRawX)) < PanZoomController.CLICK_THRESHOLD)
&& (Math.abs((int) (event.getRawY() - originRawY)) < PanZoomController.CLICK_THRESHOLD)) { && (Math.abs((int) (event.getRawY() - originRawY)) < PanZoomController.CLICK_THRESHOLD)) {
// When the user just touches the screen ACTION_MOVE can be detected for a very small delta on position. // When the user just touches the screen ACTION_MOVE can be detected for a very small delta on position.
@ -315,7 +315,7 @@ public class ZoomedView extends FrameLayout implements LayerView.DynamicToolbarL
ImmutableViewportMetrics metrics = layerView.getViewportMetrics(); ImmutableViewportMetrics metrics = layerView.getViewportMetrics();
final float parentWidth = metrics.getWidth(); final float parentWidth = metrics.getWidth();
final float parentHeight = metrics.getHeight(); final float parentHeight = metrics.getHeight();
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) getLayoutParams(); final MarginLayoutParams params = (MarginLayoutParams) getLayoutParams();
// The number of unzoomed content pixels that can be displayed in the // The number of unzoomed content pixels that can be displayed in the
// zoomed area. // zoomed area.
@ -382,7 +382,7 @@ public class ZoomedView extends FrameLayout implements LayerView.DynamicToolbarL
private void moveZoomedView(ImmutableViewportMetrics metrics, float newLeftMargin, float newTopMargin, private void moveZoomedView(ImmutableViewportMetrics metrics, float newLeftMargin, float newTopMargin,
StartPointUpdate animateStartPoint) { StartPointUpdate animateStartPoint) {
RelativeLayout.LayoutParams newLayoutParams = (RelativeLayout.LayoutParams) getLayoutParams(); final MarginLayoutParams newLayoutParams = (MarginLayoutParams) getLayoutParams();
newLayoutParams.leftMargin = (int) newLeftMargin; newLayoutParams.leftMargin = (int) newLeftMargin;
newLayoutParams.topMargin = (int) newTopMargin; newLayoutParams.topMargin = (int) newTopMargin;
int topMarginMin = (int)(layerView.getSurfaceTranslation() + dynamicToolbarOverlap); int topMarginMin = (int)(layerView.getSurfaceTranslation() + dynamicToolbarOverlap);
@ -478,7 +478,7 @@ public class ZoomedView extends FrameLayout implements LayerView.DynamicToolbarL
return; return;
} }
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) getLayoutParams(); final MarginLayoutParams params = (MarginLayoutParams) getLayoutParams();
setCapturedSize(viewport); setCapturedSize(viewport);
moveZoomedView(viewport, params.leftMargin, params.topMargin, StartPointUpdate.NO_CHANGE); moveZoomedView(viewport, params.leftMargin, params.topMargin, StartPointUpdate.NO_CHANGE);
} }