diff options
author | Jon Miranda <jonmiranda@google.com> | 2014-08-11 12:32:26 -0700 |
---|---|---|
committer | Jon Miranda <jonmiranda@google.com> | 2014-08-18 18:32:53 -0700 |
commit | 836c0a8b949d71293c996761691e065f0651acef (patch) | |
tree | 93763acf0cf757820d200e67b7e12dfb147779ad /core/java/android/content | |
parent | f6040e9c116e8723b3312499987c370d2e9ee7c7 (diff) | |
download | frameworks_base-836c0a8b949d71293c996761691e065f0651acef.zip frameworks_base-836c0a8b949d71293c996761691e065f0651acef.tar.gz frameworks_base-836c0a8b949d71293c996761691e065f0651acef.tar.bz2 |
Exposes style and theme data, adds developer option.
Adds support for a String[] return type in ViewDebug; and in addition to that,
the hasAdjacentMapping method can use the String array as means to map a key to
its value.
Adds DEBUG_VIEW_ATTRIBUTES to Settings so that the heavy per-view
computations only affect those who opt in. This setting is used in
CoreSettingsObserver to avoid impacting start time.
Change-Id: I8f507e4e5361414c30d247e8d9815205feb5e91f
Diffstat (limited to 'core/java/android/content')
-rw-r--r-- | core/java/android/content/Context.java | 2 | ||||
-rw-r--r-- | core/java/android/content/res/Resources.java | 34 |
2 files changed, 34 insertions, 2 deletions
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index 5f046c5..a13a928 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -45,6 +45,7 @@ import android.provider.MediaStore; import android.util.AttributeSet; import android.view.DisplayAdjustments; import android.view.Display; +import android.view.ViewDebug; import android.view.WindowManager; import java.io.File; @@ -420,6 +421,7 @@ public abstract class Context { /** * Return the Theme object associated with this Context. */ + @ViewDebug.ExportedProperty(deepExport = true) public abstract Resources.Theme getTheme(); /** diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java index fff21aa..31813c1 100644 --- a/core/java/android/content/res/Resources.java +++ b/core/java/android/content/res/Resources.java @@ -16,6 +16,7 @@ package android.content.res; +import android.view.ViewDebug; import com.android.internal.util.XmlUtils; import org.xmlpull.v1.XmlPullParser; @@ -1638,12 +1639,41 @@ public class Resources { /*package*/ String getKey() { return mKey; } + + private String getResourceNameFromHexString(String hexString) { + return getResourceName(Integer.parseInt(hexString, 16)); + } + + /** + * Parses {@link #mKey} and returns a String array that holds pairs of adjacent Theme data: + * resource name followed by whether or not it was forced, as specified by + * {@link #applyStyle(int, boolean)}. + * + * @hide + */ + @ViewDebug.ExportedProperty(category = "theme", hasAdjacentMapping = true) + public String[] getTheme() { + String[] themeData = mKey.split(" "); + String[] themes = new String[themeData.length * 2]; + String theme; + boolean forced; + + for (int i = 0, j = themeData.length - 1; i < themes.length; i += 2, --j) { + theme = themeData[j]; + forced = theme.endsWith("!"); + themes[i] = forced ? + getResourceNameFromHexString(theme.substring(0, theme.length() - 1)) : + getResourceNameFromHexString(theme); + themes[i + 1] = forced ? "forced" : "not forced"; + } + return themes; + } } /** * Generate a new Theme object for this set of Resources. It initially * starts out empty. - * + * * @return Theme The newly created Theme container. */ public final Theme newTheme() { @@ -1653,7 +1683,7 @@ public class Resources { /** * Retrieve a set of basic attribute values from an AttributeSet, not * performing styling of them using a theme and/or style resources. - * + * * @param set The current attribute values to retrieve. * @param attrs The specific attributes to be retrieved. * @return Returns a TypedArray holding an array of the attribute values. |