Remove ActionBar.LayoutParams MarginLayoutParams constructor

Adding this for L caused some fun issues with source compatibility.
Apps that previously passed another MarginLayoutParams subclass to
ActionBar.LayoutParams' constructor started statically linking to a
constructor overload that did not exist on older platform changes with
no other source changes. In the interests of avoiding these headaches
for developers, remove it.

Bug 15933193

Change-Id: I01cf8dfa2341b9d9629331639433b59352e7e15a
This commit is contained in:
Adam Powell
2014-07-01 15:22:50 -07:00
parent 009edbb276
commit d76008352e
4 changed files with 30 additions and 4 deletions

View File

@@ -3212,7 +3212,6 @@ package android.app {
ctor public ActionBar.LayoutParams(int);
ctor public ActionBar.LayoutParams(android.app.ActionBar.LayoutParams);
ctor public ActionBar.LayoutParams(android.view.ViewGroup.LayoutParams);
ctor public ActionBar.LayoutParams(android.view.ViewGroup.MarginLayoutParams);
field public int gravity;
}

View File

@@ -1334,8 +1334,14 @@ public abstract class ActionBar {
super(source);
}
public LayoutParams(MarginLayoutParams source) {
super(source);
}
/*
* Note for framework developers:
*
* You might notice that ActionBar.LayoutParams is missing a constructor overload
* for MarginLayoutParams. While it may seem like a good idea to add one, at this
* point it's dangerous for source compatibility. Upon building against a new
* version of the SDK an app can end up statically linking to the new MarginLayoutParams
* overload, causing a crash when running on older platform versions with no other changes.
*/
}
}

View File

@@ -6475,6 +6475,20 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
mMarginFlags &= ~RTL_COMPATIBILITY_MODE_MASK;
}
/**
* @hide Used internally.
*/
public final void copyMarginsFrom(MarginLayoutParams source) {
this.leftMargin = source.leftMargin;
this.topMargin = source.topMargin;
this.rightMargin = source.rightMargin;
this.bottomMargin = source.bottomMargin;
this.startMargin = source.startMargin;
this.endMargin = source.endMargin;
this.mMarginFlags = source.mMarginFlags;
}
/**
* Sets the margins, in pixels. A call to {@link android.view.View#requestLayout()} needs
* to be done so that the new margins are taken into account. Left and right margins may be

View File

@@ -1585,6 +1585,10 @@ public class Toolbar extends ViewGroup {
/**
* Layout information for child views of Toolbars.
*
* <p>Toolbar.LayoutParams extends ActionBar.LayoutParams for compatibility with existing
* ActionBar API. See {@link android.app.Activity#setActionBar(Toolbar) Activity.setActionBar}
* for more info on how to use a Toolbar as your Activity's ActionBar.</p>
*
* @attr ref android.R.styleable#Toolbar_LayoutParams_layout_gravity
*/
public static class LayoutParams extends ActionBar.LayoutParams {
@@ -1624,6 +1628,9 @@ public class Toolbar extends ViewGroup {
public LayoutParams(MarginLayoutParams source) {
super(source);
// ActionBar.LayoutParams doesn't have a MarginLayoutParams constructor.
// Fake it here and copy over the relevant data.
copyMarginsFrom(source);
}
public LayoutParams(ViewGroup.LayoutParams source) {