From 0a0e155cadecd32599a7354a1836232c885f4bd2 Mon Sep 17 00:00:00 2001 From: Alan Viverette Date: Wed, 7 Aug 2013 13:24:09 -0700 Subject: Add copy constructors for all widget-specific LayoutParams BUG: 10215589 Change-Id: I4c040091e216c87f851d6b617107f43729e55b0c --- api/current.txt | 3 +++ core/java/android/widget/FrameLayout.java | 12 ++++++++++++ core/java/android/widget/GridLayout.java | 14 +++++++++----- core/java/android/widget/LinearLayout.java | 15 ++++++++++++++- core/java/android/widget/RelativeLayout.java | 18 ++++++++++++++++++ 5 files changed, 56 insertions(+), 6 deletions(-) diff --git a/api/current.txt b/api/current.txt index 7f333b7..bf4389f 100644 --- a/api/current.txt +++ b/api/current.txt @@ -30539,6 +30539,7 @@ package android.widget { ctor public FrameLayout.LayoutParams(int, int, int); ctor public FrameLayout.LayoutParams(android.view.ViewGroup.LayoutParams); ctor public FrameLayout.LayoutParams(android.view.ViewGroup.MarginLayoutParams); + ctor public FrameLayout.LayoutParams(android.widget.FrameLayout.LayoutParams); field public int gravity; } @@ -30803,6 +30804,7 @@ package android.widget { ctor public LinearLayout.LayoutParams(int, int, float); ctor public LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams); ctor public LinearLayout.LayoutParams(android.view.ViewGroup.MarginLayoutParams); + ctor public LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams); method public java.lang.String debug(java.lang.String); field public int gravity; field public float weight; @@ -31235,6 +31237,7 @@ package android.widget { ctor public RelativeLayout.LayoutParams(int, int); ctor public RelativeLayout.LayoutParams(android.view.ViewGroup.LayoutParams); ctor public RelativeLayout.LayoutParams(android.view.ViewGroup.MarginLayoutParams); + ctor public RelativeLayout.LayoutParams(android.widget.RelativeLayout.LayoutParams); method public void addRule(int); method public void addRule(int, int); method public java.lang.String debug(java.lang.String); diff --git a/core/java/android/widget/FrameLayout.java b/core/java/android/widget/FrameLayout.java index 691c941..d9d4ad7 100644 --- a/core/java/android/widget/FrameLayout.java +++ b/core/java/android/widget/FrameLayout.java @@ -656,5 +656,17 @@ public class FrameLayout extends ViewGroup { public LayoutParams(ViewGroup.MarginLayoutParams source) { super(source); } + + /** + * Copy constructor. Clones the width, height, margin values, and + * gravity of the source. + * + * @param source The layout params to copy from. + */ + public LayoutParams(LayoutParams source) { + super(source); + + this.gravity = source.gravity; + } } } diff --git a/core/java/android/widget/GridLayout.java b/core/java/android/widget/GridLayout.java index b0ab70d..109fcfe 100644 --- a/core/java/android/widget/GridLayout.java +++ b/core/java/android/widget/GridLayout.java @@ -1961,12 +1961,16 @@ public class GridLayout extends ViewGroup { } /** - * {@inheritDoc} + * Copy constructor. Clones the width, height, margin values, row spec, + * and column spec of the source. + * + * @param source The layout params to copy from. */ - public LayoutParams(LayoutParams that) { - super(that); - this.rowSpec = that.rowSpec; - this.columnSpec = that.columnSpec; + public LayoutParams(LayoutParams source) { + super(source); + + this.rowSpec = source.rowSpec; + this.columnSpec = source.columnSpec; } // AttributeSet constructors diff --git a/core/java/android/widget/LinearLayout.java b/core/java/android/widget/LinearLayout.java index bc57c36..ad60a95 100644 --- a/core/java/android/widget/LinearLayout.java +++ b/core/java/android/widget/LinearLayout.java @@ -1871,10 +1871,23 @@ public class LinearLayout extends ViewGroup { /** * {@inheritDoc} */ - public LayoutParams(MarginLayoutParams source) { + public LayoutParams(ViewGroup.MarginLayoutParams source) { super(source); } + /** + * Copy constructor. Clones the width, height, margin values, weight, + * and gravity of the source. + * + * @param source The layout params to copy from. + */ + public LayoutParams(LayoutParams source) { + super(source); + + this.weight = source.weight; + this.gravity = source.gravity; + } + @Override public String debug(String output) { return output + "LinearLayout.LayoutParams={width=" + sizeToString(width) + diff --git a/core/java/android/widget/RelativeLayout.java b/core/java/android/widget/RelativeLayout.java index fd3dc03..f73e2c4 100644 --- a/core/java/android/widget/RelativeLayout.java +++ b/core/java/android/widget/RelativeLayout.java @@ -1321,6 +1321,24 @@ public class RelativeLayout extends ViewGroup { super(source); } + /** + * Copy constructor. Clones the width, height, margin values, and rules + * of the source. + * + * @param source The layout params to copy from. + */ + public LayoutParams(LayoutParams source) { + super(source); + + this.mIsRtlCompatibilityMode = source.mIsRtlCompatibilityMode; + this.mRulesChanged = source.mRulesChanged; + this.alignWithParent = source.alignWithParent; + + System.arraycopy(source.mRules, LEFT_OF, this.mRules, LEFT_OF, VERB_COUNT); + System.arraycopy( + source.mInitialRules, LEFT_OF, this.mInitialRules, LEFT_OF, VERB_COUNT); + } + @Override public String debug(String output) { return output + "ViewGroup.LayoutParams={ width=" + sizeToString(width) + -- cgit v1.1