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);
}
@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 {
// Whether to use the Theme.mThemeResId as primary theme.
boolean force;
// ---- delegate manager ----
private static final DelegateManager<Resources_Theme_Delegate> sManager =
@ -111,14 +108,29 @@ public class Resources_Theme_Delegate {
// ---- private helper methods ----
private static boolean setupResources(Theme thisTheme) {
Resources_Theme_Delegate themeDelegate = sManager.getDelegate(thisTheme.getNativeTheme());
StyleResourceValue style = resolveStyle(thisTheme.getAppliedStyleResId());
if (style != null) {
RenderSessionImpl.getCurrentContext().getRenderResources()
.applyStyle(style, themeDelegate.force);
return true;
// Key is a space-separated list of theme ids applied that have been merged into the
// BridgeContext's theme to make thisTheme.
String[] appliedStyles = thisTheme.getKey().split(" ");
boolean changed = false;
for (String s : appliedStyles) {
if (s.isEmpty()) {
continue;
}
// 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 false;
return 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.AssetManager#newTheme",
"android.content.res.AssetManager#deleteTheme",
"android.content.res.AssetManager#applyThemeStyle",
"android.content.res.TypedArray#getValueAt",
"android.content.res.TypedArray#obtain",
"android.graphics.BitmapFactory#finishDecode",