diff options
| author | 2009-05-12 11:10:34 -0700 | |
|---|---|---|
| committer | 2009-05-12 11:10:34 -0700 | |
| commit | c70b64441029b9748eea7f260f1b3521dc58eb91 (patch) | |
| tree | 155107a166445db3d2a39531a0f95950575db594 | |
| parent | 7813767b3ab2a0db3847ef62274b51a3d394a5e8 (diff) | |
| parent | 83b2107c4d2f07f46b6ae663115421749486f8b1 (diff) | |
Merge change 1463 into donut
* changes:
Fixes #1846038. DrawableContainer was wrongly returning its opacity by ignoring the visibility of the currently selected layer. This change simply reports a TRANSPARENT opacity if there is no currently selected layer of if the selected layer is not visible. Otherwise it reports the opacity computed by the state class.
| -rw-r--r-- | core/java/android/view/View.java | 1 | ||||
| -rw-r--r-- | core/java/android/widget/RelativeLayout.java | 2 | ||||
| -rw-r--r-- | graphics/java/android/graphics/drawable/DrawableContainer.java | 66 |
3 files changed, 30 insertions, 39 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 410adb097845..335b43c7c6e4 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -4556,6 +4556,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback { * * @hide Pending API council approval */ + @ViewDebug.ExportedProperty public boolean isOpaque() { return mBGDrawable != null && mBGDrawable.getOpacity() == PixelFormat.OPAQUE; } diff --git a/core/java/android/widget/RelativeLayout.java b/core/java/android/widget/RelativeLayout.java index c4f0abdd85a6..edbb3db255ab 100644 --- a/core/java/android/widget/RelativeLayout.java +++ b/core/java/android/widget/RelativeLayout.java @@ -823,7 +823,7 @@ public class RelativeLayout extends ViewGroup { @ViewDebug.IntToString(from = RIGHT_OF, to = "rightOf") }, mapping = { @ViewDebug.IntToString(from = TRUE, to = "true"), - @ViewDebug.IntToString(from = 0, to = "NO_ID") + @ViewDebug.IntToString(from = 0, to = "FALSE/NO_ID") }) private int[] mRules = new int[VERB_COUNT]; diff --git a/graphics/java/android/graphics/drawable/DrawableContainer.java b/graphics/java/android/graphics/drawable/DrawableContainer.java index 29f2a0018f17..f8b88d00a8f1 100644 --- a/graphics/java/android/graphics/drawable/DrawableContainer.java +++ b/graphics/java/android/graphics/drawable/DrawableContainer.java @@ -181,7 +181,8 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { @Override public int getOpacity() { - return mDrawableContainerState.getOpacity(); + return mCurrDrawable == null || !mCurrDrawable.isVisible() ? PixelFormat.TRANSPARENT : + mDrawableContainerState.getOpacity(); } public boolean selectDrawable(int idx) @@ -336,13 +337,11 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { return pos; } - public final int getChildCount() - { + public final int getChildCount() { return mNumChildren; } - public final Drawable[] getChildren() - { + public final Drawable[] getChildren() { return mDrawables; } @@ -350,13 +349,11 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { * all frames in the set (false), or to use the padding value of the frame * being shown (true). Default value is false. */ - public final void setVariablePadding(boolean variable) - { + public final void setVariablePadding(boolean variable) { mVariablePadding = variable; } - public final Rect getConstantPadding() - { + public final Rect getConstantPadding() { if (mVariablePadding) { return null; } @@ -364,11 +361,12 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { return mConstantPadding; } - Rect r = new Rect(0, 0, 0, 0); - Rect t = new Rect(); + final Rect r = new Rect(0, 0, 0, 0); + final Rect t = new Rect(); final int N = getChildCount(); - for (int i=0; i<N; i++) { - if (mDrawables[i].getPadding(t)) { + final Drawable[] drawables = mDrawables; + for (int i = 0; i < N; i++) { + if (drawables[i].getPadding(t)) { if (t.left > r.left) r.left = t.left; if (t.top > r.top) r.top = t.top; if (t.right > r.right) r.right = t.right; @@ -378,18 +376,15 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { return (mConstantPadding=r); } - public final void setConstantSize(boolean constant) - { + public final void setConstantSize(boolean constant) { mConstantSize = constant; } - public final boolean isConstantSize() - { + public final boolean isConstantSize() { return mConstantSize; } - public final int getConstantWidth() - { + public final int getConstantWidth() { if (!mComputedConstantSize) { computeConstantSize(); } @@ -397,8 +392,7 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { return mConstantWidth; } - public final int getConstantHeight() - { + public final int getConstantHeight() { if (!mComputedConstantSize) { computeConstantSize(); } @@ -406,8 +400,7 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { return mConstantHeight; } - public final int getConstantMinimumWidth() - { + public final int getConstantMinimumWidth() { if (!mComputedConstantSize) { computeConstantSize(); } @@ -415,8 +408,7 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { return mConstantMinimumWidth; } - public final int getConstantMinimumHeight() - { + public final int getConstantMinimumHeight() { if (!mComputedConstantSize) { computeConstantSize(); } @@ -424,15 +416,15 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { return mConstantMinimumHeight; } - private void computeConstantSize() - { + private void computeConstantSize() { mComputedConstantSize = true; final int N = getChildCount(); + final Drawable[] drawables = mDrawables; mConstantWidth = mConstantHeight = 0; mConstantMinimumWidth = mConstantMinimumHeight = 0; - for (int i=0; i<N; i++) { - Drawable dr = mDrawables[i]; + for (int i = 0; i < N; i++) { + Drawable dr = drawables[i]; int s = dr.getIntrinsicWidth(); if (s > mConstantWidth) mConstantWidth = s; s = dr.getIntrinsicHeight(); @@ -444,23 +436,22 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { } } - public final int getOpacity() - { + public final int getOpacity() { if (mHaveOpacity) { return mOpacity; } final int N = getChildCount(); - int op = N > 0 - ? mDrawables[0].getOpacity() : PixelFormat.TRANSPARENT; - for (int i=1; i<N; i++) { - op = Drawable.resolveOpacity(op, mDrawables[i].getOpacity()); + final Drawable[] drawables = mDrawables; + int op = N > 0 ? drawables[0].getOpacity() : PixelFormat.TRANSPARENT; + for (int i = 1; i < N; i++) { + op = Drawable.resolveOpacity(op, drawables[i].getOpacity()); } mOpacity = op; mHaveOpacity = true; return op; } - + public final boolean isStateful() { if (mHaveStateful) { return mStateful; @@ -480,8 +471,7 @@ public class DrawableContainer extends Drawable implements Drawable.Callback { return stateful; } - public void growArray(int oldSize, int newSize) - { + public void growArray(int oldSize, int newSize) { Drawable[] newDrawables = new Drawable[newSize]; System.arraycopy(mDrawables, 0, newDrawables, 0, oldSize); mDrawables = newDrawables; |