You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
use libandroidfw also for themes
This commit is contained in:
@@ -224,3 +224,49 @@ JNIEXPORT jobject JNICALL Java_android_content_res_AssetManager_getPooledString(
|
||||
const char16_t *string = ResStringPool_stringAt(string_pool, index, &len);
|
||||
return (*env)->NewString(env, string, len);
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_android_content_res_AssetManager_newTheme(JNIEnv *env, jobject this)
|
||||
{
|
||||
struct AssetManager *asset_manager = _PTR(_GET_LONG_FIELD(this, "mObject"));
|
||||
struct Theme *theme = Theme_new(AssetManager_getResources(asset_manager, true));
|
||||
return _INTPTR(theme);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_android_content_res_AssetManager_deleteTheme(JNIEnv *env, jobject this, jlong theme_ptr)
|
||||
{
|
||||
Theme_delete(_PTR(theme_ptr));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_android_content_res_AssetManager_applyThemeStyle(JNIEnv *env, jobject this, jlong theme_ptr, jint styleRes, jboolean force)
|
||||
{
|
||||
Theme_applyStyle(_PTR(theme_ptr), styleRes, force);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_android_content_res_AssetManager_loadThemeAttributeValue(JNIEnv *env, jobject this, jlong theme_ptr, jint ident, jobject outValue, jboolean resolve)
|
||||
{
|
||||
struct AssetManager *asset_manager = _PTR(_GET_LONG_FIELD(this, "mObject"));
|
||||
const struct ResTable *res_table = AssetManager_getResources(asset_manager, true);
|
||||
struct Theme *theme = _PTR(theme_ptr);
|
||||
uint32_t resId = ident;
|
||||
struct Res_value value;
|
||||
uint32_t outSpecFlags;
|
||||
struct ResTable_config outConfig;
|
||||
int block = Theme_getAttribute(theme, resId, &value, &outSpecFlags);
|
||||
if (resolve) {
|
||||
block = Theme_resolveAttributeReference(theme, &value, block, &resId, &outSpecFlags, &outConfig);
|
||||
}
|
||||
if (block >= 0) {
|
||||
_SET_INT_FIELD(outValue, "type", value.dataType);
|
||||
_SET_INT_FIELD(outValue, "data", value.data);
|
||||
_SET_INT_FIELD(outValue, "resourceId", resId);
|
||||
if (value.dataType == TYPE_STRING) {
|
||||
const struct ResStringPool *string_pool = ResTable_getTableStringBlock(res_table, block);
|
||||
size_t len;
|
||||
const char16_t *string = ResStringPool_stringAt(string_pool, value.data, &len);
|
||||
_SET_OBJ_FIELD(outValue, "string", "Ljava/lang/CharSequence;", (*env)->NewString(env, string, len));
|
||||
} else {
|
||||
_SET_OBJ_FIELD(outValue, "string", "Ljava/lang/CharSequence;", NULL);
|
||||
}
|
||||
}
|
||||
return block;
|
||||
}
|
||||
|
||||
@@ -252,50 +252,50 @@ JNIEXPORT jint JNICALL Java_android_content_res_AssetManager_getGlobalAssetManag
|
||||
/*
|
||||
* Class: android_content_res_AssetManager
|
||||
* Method: newTheme
|
||||
* Signature: ()I
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_android_content_res_AssetManager_newTheme
|
||||
JNIEXPORT jlong JNICALL Java_android_content_res_AssetManager_newTheme
|
||||
(JNIEnv *, jobject);
|
||||
|
||||
/*
|
||||
* Class: android_content_res_AssetManager
|
||||
* Method: deleteTheme
|
||||
* Signature: (I)V
|
||||
* Signature: (J)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_android_content_res_AssetManager_deleteTheme
|
||||
(JNIEnv *, jobject, jint);
|
||||
(JNIEnv *, jobject, jlong);
|
||||
|
||||
/*
|
||||
* Class: android_content_res_AssetManager
|
||||
* Method: applyThemeStyle
|
||||
* Signature: (IIZ)V
|
||||
* Signature: (JIZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_android_content_res_AssetManager_applyThemeStyle
|
||||
(JNIEnv *, jclass, jint, jint, jboolean);
|
||||
(JNIEnv *, jclass, jlong, jint, jboolean);
|
||||
|
||||
/*
|
||||
* Class: android_content_res_AssetManager
|
||||
* Method: copyTheme
|
||||
* Signature: (II)V
|
||||
* Signature: (JJ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_android_content_res_AssetManager_copyTheme
|
||||
(JNIEnv *, jclass, jint, jint);
|
||||
(JNIEnv *, jclass, jlong, jlong);
|
||||
|
||||
/*
|
||||
* Class: android_content_res_AssetManager
|
||||
* Method: loadThemeAttributeValue
|
||||
* Signature: (IILandroid/util/TypedValue;Z)I
|
||||
* Signature: (JILandroid/util/TypedValue;Z)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_android_content_res_AssetManager_loadThemeAttributeValue
|
||||
(JNIEnv *, jclass, jint, jint, jobject, jboolean);
|
||||
(JNIEnv *, jobject, jlong, jint, jobject, jboolean);
|
||||
|
||||
/*
|
||||
* Class: android_content_res_AssetManager
|
||||
* Method: dumpTheme
|
||||
* Signature: (IILjava/lang/String;Ljava/lang/String;)V
|
||||
* Signature: (JILjava/lang/String;Ljava/lang/String;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_android_content_res_AssetManager_dumpTheme
|
||||
(JNIEnv *, jclass, jint, jint, jstring, jstring);
|
||||
(JNIEnv *, jclass, jlong, jint, jstring, jstring);
|
||||
|
||||
/*
|
||||
* Class: android_content_res_AssetManager
|
||||
|
||||
Reference in New Issue
Block a user