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
load assets and bitmaps directly from apk
This commit is contained in:
@@ -103,4 +103,12 @@ void set_up_handle_cache(JNIEnv *env, char *apk_main_activity_class)
|
||||
handle_cache.view.setLayoutParams = _METHOD(handle_cache.view.class, "setLayoutParams", "(Landroid/view/ViewGroup$LayoutParams;)V");
|
||||
if((*env)->ExceptionCheck(env))
|
||||
(*env)->ExceptionDescribe(env);
|
||||
|
||||
handle_cache.asset_manager.class = _REF((*env)->FindClass(env, "android/content/res/AssetManager"));
|
||||
handle_cache.asset_manager.extractFromAPK = _STATIC_METHOD(handle_cache.asset_manager.class, "extractFromAPK", "(Ljava/lang/String;Ljava/lang/String;)V");
|
||||
}
|
||||
|
||||
void extract_from_apk(const char *path, const char *target) {
|
||||
JNIEnv *env = get_jni_env();
|
||||
(*env)->CallStaticObjectMethod(env, handle_cache.asset_manager.class, handle_cache.asset_manager.extractFromAPK, _JSTRING(path), _JSTRING(target));
|
||||
}
|
||||
|
||||
@@ -69,6 +69,10 @@ struct handle_cache {
|
||||
jclass class;
|
||||
jmethodID setLayoutParams;
|
||||
} view;
|
||||
struct {
|
||||
jclass class;
|
||||
jmethodID extractFromAPK;
|
||||
} asset_manager;
|
||||
};
|
||||
|
||||
extern struct handle_cache handle_cache;
|
||||
@@ -76,5 +80,6 @@ extern struct handle_cache handle_cache;
|
||||
const char * attribute_set_get_string(JNIEnv *env, jobject attrs, char *attribute, char *schema);
|
||||
int attribute_set_get_int(JNIEnv *env, jobject attrs, char *attribute, char *schema, int default_value);
|
||||
void set_up_handle_cache(JNIEnv *env, char *apk_main_activity_class);
|
||||
void extract_from_apk(const char *path, const char *target);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user