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
implement AssetManager.getLocales()
This commit is contained in:
@@ -441,3 +441,18 @@ JNIEXPORT jlong JNICALL Java_android_content_res_AssetManager_openXmlAssetNative
|
|||||||
Asset_delete(asset);
|
Asset_delete(asset);
|
||||||
return _INTPTR(res_xml);
|
return _INTPTR(res_xml);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jobjectArray JNICALL Java_android_content_res_AssetManager_getLocales(JNIEnv *env, jobject this)
|
||||||
|
{
|
||||||
|
struct AssetManager *asset_manager = _PTR(_GET_LONG_FIELD(this, "mObject"));
|
||||||
|
char **locales = AssetManager_getLocales(asset_manager, true);
|
||||||
|
int i = 0;
|
||||||
|
while (locales[i] != NULL) i++;
|
||||||
|
jobjectArray array = (*env)->NewObjectArray(env, i, (*env)->FindClass(env, "java/lang/String"), NULL);
|
||||||
|
for (i = 0; locales[i] != NULL; i++) {
|
||||||
|
(*env)->SetObjectArrayElement(env, array, i, (*env)->NewStringUTF(env, locales[i]));
|
||||||
|
free(locales[i]);
|
||||||
|
}
|
||||||
|
free(locales);
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package android.graphics.drawable;
|
package android.graphics.drawable;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
@@ -27,10 +28,12 @@ public class VectorDrawable extends Drawable {
|
|||||||
int tint = a.getColor(R.styleable.VectorDrawable_tint, 0);
|
int tint = a.getColor(R.styleable.VectorDrawable_tint, 0);
|
||||||
float viewportWidth = a.getFloat(R.styleable.VectorDrawable_viewportWidth, 24);
|
float viewportWidth = a.getFloat(R.styleable.VectorDrawable_viewportWidth, 24);
|
||||||
float viewportHeight = a.getFloat(R.styleable.VectorDrawable_viewportHeight, 24);
|
float viewportHeight = a.getFloat(R.styleable.VectorDrawable_viewportHeight, 24);
|
||||||
|
float width = a.getDimension(R.styleable.VectorDrawable_width, 24);
|
||||||
|
float height = a.getDimension(R.styleable.VectorDrawable_height, 24);
|
||||||
a.recycle();
|
a.recycle();
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append(String.format("<svg id=\"vector\" xmlns=\"http://www.w3.org/2000/svg\" width=\"%f\" height=\"%f\" viewBox=\"0 0 %f %f\">",
|
sb.append(String.format(Locale.ENGLISH, "<svg id=\"vector\" xmlns=\"http://www.w3.org/2000/svg\" width=\"%f\" height=\"%f\" viewBox=\"0 0 %f %f\">",
|
||||||
viewportWidth, viewportHeight, viewportWidth, viewportHeight));
|
width, height, viewportWidth, viewportHeight));
|
||||||
while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
|
while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
|
||||||
&& (parser.getDepth() >= innerDepth
|
&& (parser.getDepth() >= innerDepth
|
||||||
|| type != XmlPullParser.END_TAG)) {
|
|| type != XmlPullParser.END_TAG)) {
|
||||||
@@ -42,7 +45,7 @@ public class VectorDrawable extends Drawable {
|
|||||||
int strokeColor = tint != 0 ? tint : a.getColor(R.styleable.VectorDrawablePath_strokeColor, 0);
|
int strokeColor = tint != 0 ? tint : a.getColor(R.styleable.VectorDrawablePath_strokeColor, 0);
|
||||||
float strokeWidth = a.getFloat(R.styleable.VectorDrawablePath_strokeWidth, 0);
|
float strokeWidth = a.getFloat(R.styleable.VectorDrawablePath_strokeWidth, 0);
|
||||||
a.recycle();
|
a.recycle();
|
||||||
sb.append(String.format("<path fill=\"#%06x%02x\" stroke=\"#%06x%02x\" stroke-width=\"%f\" d=\"%s\"/>",
|
sb.append(String.format(Locale.ENGLISH, "<path fill=\"#%06x%02x\" stroke=\"#%06x%02x\" stroke-width=\"%f\" d=\"%s\"/>",
|
||||||
fillColor & 0xFFFFFF, (fillColor >> 24) & 0xFF, strokeColor & 0xFFFFFF, (strokeColor >> 24) & 0xFF, strokeWidth, pathData));
|
fillColor & 0xFFFFFF, (fillColor >> 24) & 0xFF, strokeColor & 0xFFFFFF, (strokeColor >> 24) & 0xFF, strokeWidth, pathData));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user