Add backgroundColor getter to View
Change-Id: I3a75169a2e91ec712fb1db4d130089a1261fc66b
diff --git a/api/current.txt b/api/current.txt
index 72cd85a..cacb557 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -33645,6 +33645,7 @@
method public android.view.animation.Animation getAnimation();
method public android.os.IBinder getApplicationWindowToken();
method public android.graphics.drawable.Drawable getBackground();
+ method public int getBackgroundColor();
method public android.content.res.ColorStateList getBackgroundTintList();
method public android.graphics.PorterDuff.Mode getBackgroundTintMode();
method public int getBaseline();
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 7033676..d867adf 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -16235,6 +16235,19 @@
}
/**
+ * If the view has a ColorDrawable background, returns the color of that
+ * drawable.
+ *
+ * @return The color of the ColorDrawable background, if set, otherwise 0.
+ */
+ public int getBackgroundColor() {
+ if (mBackground instanceof ColorDrawable) {
+ return ((ColorDrawable) mBackground).getColor();
+ }
+ return 0;
+ }
+
+ /**
* Set the background to a given resource. The resource should refer to
* a Drawable object or 0 to remove the background.
* @param resid The identifier of the resource.
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java b/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java
index 465a141..e021cd4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java
@@ -388,7 +388,7 @@
}
private void updateBackgroundTint() {
- int color = getBackgroundColor();
+ int color = getBgColor();
int rippleColor = getRippleColor();
if (color == mNormalColor) {
// We don't need to tint a normal notification
@@ -652,7 +652,7 @@
}
private void updateAppearAnimationAlpha() {
- int backgroundColor = getBackgroundColor();
+ int backgroundColor = getBgColor();
if (backgroundColor != -1) {
float contentAlphaProgress = mAppearAnimationFraction;
contentAlphaProgress = contentAlphaProgress / (1.0f - ALPHA_ANIMATION_END);
@@ -666,7 +666,7 @@
}
}
- private int getBackgroundColor() {
+ private int getBgColor() {
if (mBgTint != 0) {
return mBgTint;
} else if (mShowingLegacyBackground) {