Merge "Fix multiple styles case in resource resolution." into lmp-dev

This commit is contained in:
Deepanshu Gupta
2014-10-29 00:07:56 +00:00
committed by Android (Google) Code Review
3 changed files with 22 additions and 15 deletions

View File

@ -38,8 +38,4 @@ public class AssetManager_Delegate {
Resources_Theme_Delegate.getDelegateManager().removeJavaReferenceFor(theme); Resources_Theme_Delegate.getDelegateManager().removeJavaReferenceFor(theme);
} }
@LayoutlibDelegate
/*package*/ static void applyThemeStyle(long theme, int styleRes, boolean force) {
Resources_Theme_Delegate.getDelegateManager().getDelegate(theme).force = force;
}
} }

View File

@ -39,9 +39,6 @@ import android.util.TypedValue;
*/ */
public class Resources_Theme_Delegate { public class Resources_Theme_Delegate {
// Whether to use the Theme.mThemeResId as primary theme.
boolean force;
// ---- delegate manager ---- // ---- delegate manager ----
private static final DelegateManager<Resources_Theme_Delegate> sManager = private static final DelegateManager<Resources_Theme_Delegate> sManager =
@ -111,14 +108,29 @@ public class Resources_Theme_Delegate {
// ---- private helper methods ---- // ---- private helper methods ----
private static boolean setupResources(Theme thisTheme) { private static boolean setupResources(Theme thisTheme) {
Resources_Theme_Delegate themeDelegate = sManager.getDelegate(thisTheme.getNativeTheme()); // Key is a space-separated list of theme ids applied that have been merged into the
StyleResourceValue style = resolveStyle(thisTheme.getAppliedStyleResId()); // BridgeContext's theme to make thisTheme.
if (style != null) { String[] appliedStyles = thisTheme.getKey().split(" ");
RenderSessionImpl.getCurrentContext().getRenderResources() boolean changed = false;
.applyStyle(style, themeDelegate.force); for (String s : appliedStyles) {
return true; if (s.isEmpty()) {
continue;
} }
return false; // See the definition of force parameter in Theme.applyStyle().
boolean force = false;
if (s.charAt(s.length() - 1) == '!') {
force = true;
s = s.substring(0, s.length() - 1);
}
int styleId = Integer.parseInt(s, 16);
StyleResourceValue style = resolveStyle(styleId);
if (style != null) {
RenderSessionImpl.getCurrentContext().getRenderResources().applyStyle(style, force);
changed = true;
}
}
return changed;
} }
private static void restoreResources(boolean changed) { private static void restoreResources(boolean changed) {

View File

@ -143,7 +143,6 @@ public final class CreateInfo implements ICreateInfo {
"android.content.res.Resources$Theme#resolveAttributes", "android.content.res.Resources$Theme#resolveAttributes",
"android.content.res.AssetManager#newTheme", "android.content.res.AssetManager#newTheme",
"android.content.res.AssetManager#deleteTheme", "android.content.res.AssetManager#deleteTheme",
"android.content.res.AssetManager#applyThemeStyle",
"android.content.res.TypedArray#getValueAt", "android.content.res.TypedArray#getValueAt",
"android.content.res.TypedArray#obtain", "android.content.res.TypedArray#obtain",
"android.graphics.BitmapFactory#finishDecode", "android.graphics.BitmapFactory#finishDecode",