summaryrefslogtreecommitdiffstats
path: root/graphics/java
diff options
context:
space:
mode:
authorAlan Viverette <alanv@google.com>2014-09-13 02:33:52 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-09-13 02:33:52 +0000
commit068a02618726dccc9362118fe1c8c42b5726c535 (patch)
treea819eece174ed42627bf9211f1113cf14eb8c441 /graphics/java
parent449c6b9d500c01976a6bade7415581e2d788d9b6 (diff)
parentd5d668a0a4987d86a45123541f88f47af3a2a698 (diff)
downloadframeworks_base-068a02618726dccc9362118fe1c8c42b5726c535.zip
frameworks_base-068a02618726dccc9362118fe1c8c42b5726c535.tar.gz
frameworks_base-068a02618726dccc9362118fe1c8c42b5726c535.tar.bz2
am 2b4de8b4: am f559f89c: Merge "Report button opacity for current state, fix button shadows" into lmp-dev
* commit '2b4de8b4ee417695cdc88e9aef0aded47036e8ef': Report button opacity for current state, fix button shadows
Diffstat (limited to 'graphics/java')
-rw-r--r--graphics/java/android/graphics/drawable/GradientDrawable.java38
1 files changed, 19 insertions, 19 deletions
diff --git a/graphics/java/android/graphics/drawable/GradientDrawable.java b/graphics/java/android/graphics/drawable/GradientDrawable.java
index edc8d72..3092f96 100644
--- a/graphics/java/android/graphics/drawable/GradientDrawable.java
+++ b/graphics/java/android/graphics/drawable/GradientDrawable.java
@@ -825,7 +825,7 @@ public class GradientDrawable extends Drawable {
@Override
public int getOpacity() {
- return (mAlpha == 255 && mGradientState.mOpaqueOverBounds) ?
+ return (mAlpha == 255 && mGradientState.mOpaqueOverBounds && isOpaqueForState()) ?
PixelFormat.OPAQUE : PixelFormat.TRANSLUCENT;
}
@@ -1414,12 +1414,25 @@ public class GradientDrawable extends Drawable {
return mGradientState;
}
+ private boolean isOpaqueForState() {
+ if (mGradientState.mStrokeWidth >= 0 && mStrokePaint != null
+ && !isOpaque(mStrokePaint.getColor())) {
+ return false;
+ }
+
+ if (!isOpaque(mFillPaint.getColor())) {
+ return false;
+ }
+
+ return true;
+ }
+
@Override
public void getOutline(Outline outline) {
final GradientState st = mGradientState;
final Rect bounds = getBounds();
// only report non-zero alpha if shape being drawn is opaque
- outline.setAlpha(st.mOpaqueOverShape ? (mAlpha / 255.0f) : 0.0f);
+ outline.setAlpha(st.mOpaqueOverShape && isOpaqueForState() ? (mAlpha / 255.0f) : 0.0f);
switch (st.mShape) {
case RECTANGLE:
@@ -1617,19 +1630,6 @@ public class GradientDrawable extends Drawable {
mOpaqueOverBounds = false;
mOpaqueOverShape = false;
- // First test opacity of all colors
- if (mStrokeWidth > 0) {
- if (mStrokeColorStateList != null) {
- if (!mStrokeColorStateList.isOpaque()) {
- return;
- }
- }
- }
-
- if (mColorStateList != null && !mColorStateList.isOpaque()) {
- return;
- }
-
if (mColors != null) {
for (int i = 0; i < mColors.length; i++) {
if (!isOpaque(mColors[i])) {
@@ -1651,10 +1651,6 @@ public class GradientDrawable extends Drawable {
&& mRadiusArray == null;
}
- private static boolean isOpaque(int color) {
- return ((color >> 24) & 0xff) == 0xff;
- }
-
public void setStroke(
int width, ColorStateList colorStateList, float dashWidth, float dashGap) {
mStrokeWidth = width;
@@ -1690,6 +1686,10 @@ public class GradientDrawable extends Drawable {
}
}
+ static boolean isOpaque(int color) {
+ return ((color >> 24) & 0xff) == 0xff;
+ }
+
/**
* Creates a new themed GradientDrawable based on the specified constant state.
* <p>