Loading core/java/android/content/res/AssetManager.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -24,7 +24,6 @@ import android.util.TypedValue; import java.io.FileNotFoundException; import java.io.FileNotFoundException; import java.io.IOException; import java.io.IOException; import java.io.InputStream; import java.io.InputStream; import java.util.Locale; /** /** * Provides access to an application's raw asset files; see {@link Resources} * Provides access to an application's raw asset files; see {@link Resources} Loading Loading @@ -702,6 +701,7 @@ public final class AssetManager { private native final int newTheme(); private native final int newTheme(); private native final void deleteTheme(int theme); private native final void deleteTheme(int theme); /*package*/ native static final void applyThemeStyle(int theme, int styleRes, boolean force); /*package*/ native static final void applyThemeStyle(int theme, int styleRes, boolean force); /*package*/ native static final void setAttributeValue(int theme, int attr, int color); /*package*/ native static final void copyTheme(int dest, int source); /*package*/ native static final void copyTheme(int dest, int source); /*package*/ native static final int loadThemeAttributeValue(int theme, int ident, /*package*/ native static final int loadThemeAttributeValue(int theme, int ident, TypedValue outValue, TypedValue outValue, Loading core/java/android/content/res/Resources.java +5 −0 Original line number Original line Diff line number Diff line Loading @@ -931,6 +931,11 @@ public class Resources { AssetManager.applyThemeStyle(mTheme, resid, force); AssetManager.applyThemeStyle(mTheme, resid, force); } } /** @hide */ public void setAttributeValue(int attr, int color) { AssetManager.setAttributeValue(mTheme, attr, color); } /** /** * Set this theme to hold the same contents as the theme * Set this theme to hold the same contents as the theme * <var>other</var>. If both of these themes are from the same * <var>other</var>. If both of these themes are from the same Loading core/jni/android_util_AssetManager.cpp +12 −0 Original line number Original line Diff line number Diff line Loading @@ -827,6 +827,16 @@ static void android_content_AssetManager_applyThemeStyle(JNIEnv* env, jobject cl theme->applyStyle(styleRes, force ? true : false); theme->applyStyle(styleRes, force ? true : false); } } static void android_content_AssetManager_setAttributeValue(JNIEnv* env, jobject clazz, jint themeInt, jint attribute, jint value) { ResTable::Theme* theme = (ResTable::Theme*)themeInt; theme->setAttributeValue(attribute, value); } static void android_content_AssetManager_copyTheme(JNIEnv* env, jobject clazz, static void android_content_AssetManager_copyTheme(JNIEnv* env, jobject clazz, jint destInt, jint srcInt) jint destInt, jint srcInt) { { Loading Loading @@ -1715,6 +1725,8 @@ static JNINativeMethod gAssetManagerMethods[] = { (void*) android_content_AssetManager_getArraySize }, (void*) android_content_AssetManager_getArraySize }, { "retrieveArray","(I[I)I", { "retrieveArray","(I[I)I", (void*) android_content_AssetManager_retrieveArray }, (void*) android_content_AssetManager_retrieveArray }, { "setAttributeValue", "(III)V", (void*) android_content_AssetManager_setAttributeValue }, // XML files. // XML files. { "openXmlAssetNative", "(ILjava/lang/String;)I", { "openXmlAssetNative", "(ILjava/lang/String;)I", Loading include/utils/ResourceTypes.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -1524,6 +1524,7 @@ public: status_t applyStyle(uint32_t resID, bool force=false); status_t applyStyle(uint32_t resID, bool force=false); status_t setTo(const Theme& other); status_t setTo(const Theme& other); void setAttributeValue(uint32_t attribute, uint32_t value); /** /** * Retrieve a value in the theme. If the theme defines this * Retrieve a value in the theme. If the theme defines this Loading libs/utils/ResourceTypes.cpp +23 −0 Original line number Original line Diff line number Diff line Loading @@ -1294,6 +1294,29 @@ ResTable::Theme::package_info* ResTable::Theme::copy_package(package_info* pi) return newpi; return newpi; } } void ResTable::Theme::setAttributeValue(uint32_t attrID, uint32_t value) { const ssize_t p = mTable.getResourcePackageIndex(attrID); const uint32_t t = Res_GETTYPE(attrID); const uint32_t e = Res_GETENTRY(attrID); TABLE_NOISY(LOGV("Looking up attr 0x%08x in theme %p", attrID, this)); if (p >= 0) { const package_info* const pi = mPackages[p]; if (pi != NULL) { if (t < pi->numTypes) { const type_info& ti = pi->types[t]; if (e < ti.numEntries) { theme_entry& te = ti.entries[e]; te.value.data = value; te.value.dataType = Res_value::TYPE_FIRST_INT; } } } } } status_t ResTable::Theme::applyStyle(uint32_t resID, bool force) status_t ResTable::Theme::applyStyle(uint32_t resID, bool force) { { const bag_entry* bag; const bag_entry* bag; Loading Loading
core/java/android/content/res/AssetManager.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -24,7 +24,6 @@ import android.util.TypedValue; import java.io.FileNotFoundException; import java.io.FileNotFoundException; import java.io.IOException; import java.io.IOException; import java.io.InputStream; import java.io.InputStream; import java.util.Locale; /** /** * Provides access to an application's raw asset files; see {@link Resources} * Provides access to an application's raw asset files; see {@link Resources} Loading Loading @@ -702,6 +701,7 @@ public final class AssetManager { private native final int newTheme(); private native final int newTheme(); private native final void deleteTheme(int theme); private native final void deleteTheme(int theme); /*package*/ native static final void applyThemeStyle(int theme, int styleRes, boolean force); /*package*/ native static final void applyThemeStyle(int theme, int styleRes, boolean force); /*package*/ native static final void setAttributeValue(int theme, int attr, int color); /*package*/ native static final void copyTheme(int dest, int source); /*package*/ native static final void copyTheme(int dest, int source); /*package*/ native static final int loadThemeAttributeValue(int theme, int ident, /*package*/ native static final int loadThemeAttributeValue(int theme, int ident, TypedValue outValue, TypedValue outValue, Loading
core/java/android/content/res/Resources.java +5 −0 Original line number Original line Diff line number Diff line Loading @@ -931,6 +931,11 @@ public class Resources { AssetManager.applyThemeStyle(mTheme, resid, force); AssetManager.applyThemeStyle(mTheme, resid, force); } } /** @hide */ public void setAttributeValue(int attr, int color) { AssetManager.setAttributeValue(mTheme, attr, color); } /** /** * Set this theme to hold the same contents as the theme * Set this theme to hold the same contents as the theme * <var>other</var>. If both of these themes are from the same * <var>other</var>. If both of these themes are from the same Loading
core/jni/android_util_AssetManager.cpp +12 −0 Original line number Original line Diff line number Diff line Loading @@ -827,6 +827,16 @@ static void android_content_AssetManager_applyThemeStyle(JNIEnv* env, jobject cl theme->applyStyle(styleRes, force ? true : false); theme->applyStyle(styleRes, force ? true : false); } } static void android_content_AssetManager_setAttributeValue(JNIEnv* env, jobject clazz, jint themeInt, jint attribute, jint value) { ResTable::Theme* theme = (ResTable::Theme*)themeInt; theme->setAttributeValue(attribute, value); } static void android_content_AssetManager_copyTheme(JNIEnv* env, jobject clazz, static void android_content_AssetManager_copyTheme(JNIEnv* env, jobject clazz, jint destInt, jint srcInt) jint destInt, jint srcInt) { { Loading Loading @@ -1715,6 +1725,8 @@ static JNINativeMethod gAssetManagerMethods[] = { (void*) android_content_AssetManager_getArraySize }, (void*) android_content_AssetManager_getArraySize }, { "retrieveArray","(I[I)I", { "retrieveArray","(I[I)I", (void*) android_content_AssetManager_retrieveArray }, (void*) android_content_AssetManager_retrieveArray }, { "setAttributeValue", "(III)V", (void*) android_content_AssetManager_setAttributeValue }, // XML files. // XML files. { "openXmlAssetNative", "(ILjava/lang/String;)I", { "openXmlAssetNative", "(ILjava/lang/String;)I", Loading
include/utils/ResourceTypes.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -1524,6 +1524,7 @@ public: status_t applyStyle(uint32_t resID, bool force=false); status_t applyStyle(uint32_t resID, bool force=false); status_t setTo(const Theme& other); status_t setTo(const Theme& other); void setAttributeValue(uint32_t attribute, uint32_t value); /** /** * Retrieve a value in the theme. If the theme defines this * Retrieve a value in the theme. If the theme defines this Loading
libs/utils/ResourceTypes.cpp +23 −0 Original line number Original line Diff line number Diff line Loading @@ -1294,6 +1294,29 @@ ResTable::Theme::package_info* ResTable::Theme::copy_package(package_info* pi) return newpi; return newpi; } } void ResTable::Theme::setAttributeValue(uint32_t attrID, uint32_t value) { const ssize_t p = mTable.getResourcePackageIndex(attrID); const uint32_t t = Res_GETTYPE(attrID); const uint32_t e = Res_GETENTRY(attrID); TABLE_NOISY(LOGV("Looking up attr 0x%08x in theme %p", attrID, this)); if (p >= 0) { const package_info* const pi = mPackages[p]; if (pi != NULL) { if (t < pi->numTypes) { const type_info& ti = pi->types[t]; if (e < ti.numEntries) { theme_entry& te = ti.entries[e]; te.value.data = value; te.value.dataType = Res_value::TYPE_FIRST_INT; } } } } } status_t ResTable::Theme::applyStyle(uint32_t resID, bool force) status_t ResTable::Theme::applyStyle(uint32_t resID, bool force) { { const bag_entry* bag; const bag_entry* bag; Loading