From 073a526ba77c338e45114ea0885890336d219c47 Mon Sep 17 00:00:00 2001 From: Winson Date: Mon, 29 Feb 2016 16:04:40 -0800 Subject: [PATCH] Disable extracting the bg color from the window background. Bug: 27406401 Change-Id: Id03a7d5d199d324d67301c060551db2d3a52e5ac --- core/java/android/app/Activity.java | 78 ++++++++++--------------------------- core/res/res/values/attrs.xml | 9 ++--- 2 files changed, 24 insertions(+), 63 deletions(-) diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index 4792dc98c0ee..90d5d59e7d76 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -1119,34 +1119,6 @@ public class Activity extends ContextThemeWrapper } /** - * Attempts to extract the color from a given drawable. - * - * @return the extracted color or 0 if no color could be extracted. - */ - private int tryExtractColorFromDrawable(Drawable drawable) { - if (drawable instanceof ColorDrawable) { - return ((ColorDrawable) drawable).getColor(); - } else if (drawable instanceof InsetDrawable) { - return tryExtractColorFromDrawable(((InsetDrawable) drawable).getDrawable()); - } else if (drawable instanceof ShapeDrawable) { - Paint p = ((ShapeDrawable) drawable).getPaint(); - if (p != null) { - return p.getColor(); - } - } else if (drawable instanceof LayerDrawable) { - LayerDrawable ld = (LayerDrawable) drawable; - int numLayers = ld.getNumberOfLayers(); - for (int i = 0; i < numLayers; i++) { - int color = tryExtractColorFromDrawable(ld.getDrawable(i)); - if (color != 0) { - return color; - } - } - } - return 0; - } - - /** * Called when activity start-up is complete (after {@link #onStart} * and {@link #onRestoreInstanceState} have been called). Applications will * generally not implement this method; it is intended for system @@ -1168,35 +1140,6 @@ public class Activity extends ContextThemeWrapper onTitleChanged(getTitle(), getTitleColor()); } - Resources.Theme theme = getTheme(); - if (theme != null) { - // Get the primary color and update the TaskDescription for this activity - TypedArray a = theme.obtainStyledAttributes( - com.android.internal.R.styleable.ActivityTaskDescription); - if (mTaskDescription.getPrimaryColor() == 0) { - int colorPrimary = a.getColor( - com.android.internal.R.styleable.ActivityTaskDescription_colorPrimary, 0); - if (colorPrimary != 0 && Color.alpha(colorPrimary) == 0xFF) { - mTaskDescription.setPrimaryColor(colorPrimary); - } - } - if (mTaskDescription.getBackgroundColor() == 0) { - int windowBgResourceId = a.getResourceId( - com.android.internal.R.styleable.ActivityTaskDescription_windowBackground, - 0); - int windowBgFallbackResourceId = a.getResourceId( - com.android.internal.R.styleable.ActivityTaskDescription_windowBackgroundFallback, - 0); - int colorBg = tryExtractColorFromDrawable(DecorView.getResizingBackgroundDrawable( - this, windowBgResourceId, windowBgFallbackResourceId)); - if (colorBg != 0 && Color.alpha(colorBg) == 0xFF) { - mTaskDescription.setBackgroundColor(colorBg); - } - } - a.recycle(); - setTaskDescription(mTaskDescription); - } - mCalled = true; } @@ -4036,6 +3979,27 @@ public class Activity extends ContextThemeWrapper } theme.applyStyle(resid, false); } + + // Get the primary color and update the TaskDescription for this activity + TypedArray a = theme.obtainStyledAttributes( + com.android.internal.R.styleable.ActivityTaskDescription); + if (mTaskDescription.getPrimaryColor() == 0) { + int colorPrimary = a.getColor( + com.android.internal.R.styleable.ActivityTaskDescription_colorPrimary, 0); + if (colorPrimary != 0 && Color.alpha(colorPrimary) == 0xFF) { + mTaskDescription.setPrimaryColor(colorPrimary); + } + } + // For dev-preview only. + if (mTaskDescription.getBackgroundColor() == 0) { + int colorBackground = a.getColor( + com.android.internal.R.styleable.ActivityTaskDescription_colorBackground, 0); + if (colorBackground != 0 && Color.alpha(colorBackground) == 0xFF) { + mTaskDescription.setBackgroundColor(colorBackground); + } + } + a.recycle(); + setTaskDescription(mTaskDescription); } /** diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index 7c0212801851..90a573ba8fbd 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -8189,11 +8189,8 @@ i - - - - + + -- 2.11.0