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 layout XMLs directly from apk file
This commit is contained in:
@@ -4,6 +4,7 @@ import android.content.Context;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.XmlResourceParser;
|
||||
import android.os.Bundle;
|
||||
|
||||
import android.widget.TextView;
|
||||
@@ -136,15 +137,7 @@ public class Activity extends Context {
|
||||
public void setContentView(int layoutResID) throws Exception {
|
||||
System.out.println("- setContentView - yay!");
|
||||
|
||||
String layout_xml_file = android.os.Environment.getExternalStorageDirectory().getPath() + "/" + getString(layoutResID);
|
||||
|
||||
System.out.println("loading layout from: " + layout_xml_file);
|
||||
|
||||
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
|
||||
factory.setNamespaceAware(true);
|
||||
XmlPullParser xpp = factory.newPullParser();
|
||||
|
||||
xpp.setInput( new FileReader(layout_xml_file) );
|
||||
XmlResourceParser xpp = Context.this_application.getResources().getLayout(layoutResID);
|
||||
|
||||
root_view = layout_inflater.inflate(xpp, null, false);
|
||||
|
||||
|
||||
@@ -19,6 +19,9 @@ package android.content.res;
|
||||
import com.reandroid.arsc.chunk.TableBlock;
|
||||
import com.reandroid.arsc.value.ResValueMap;
|
||||
|
||||
import com.reandroid.arsc.chunk.xml.ResXmlPullParser;
|
||||
import com.reandroid.arsc.chunk.xml.ResXmlDocument;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserFactory;
|
||||
|
||||
@@ -479,13 +482,12 @@ public final class AssetManager {
|
||||
block.close();
|
||||
return rp;*/
|
||||
|
||||
XmlPullParserFactory factory = XmlPullParserFactory.newInstance("android.util.DecompiledXmlResourceParser", this.getClass());
|
||||
factory.setNamespaceAware(true);
|
||||
XmlPullParser xpp = factory.newPullParser();
|
||||
|
||||
xpp.setInput( new FileReader(android.os.Environment.getExternalStorageDirectory().getPath() + "/" + fileName) );
|
||||
|
||||
return (XmlResourceParser)xpp;
|
||||
InputStream inStream = ClassLoader.getSystemClassLoader().getResourceAsStream(fileName);
|
||||
ResXmlDocument resXmlDocument = new ResXmlDocument();
|
||||
resXmlDocument.readBytes(inStream);
|
||||
ResXmlPullParser xpp = new ResXmlPullParser();
|
||||
xpp.setResXmlDocument(resXmlDocument);
|
||||
return xpp;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -692,7 +692,7 @@ public class View extends Object {
|
||||
public View() {} // FIXME
|
||||
|
||||
public View(AttributeSet attrs) {
|
||||
id = attrs.getAttributeIntValue("http://schemas.android.com/apk/res/android", "id", 0);
|
||||
id = attrs.getAttributeResourceValue("http://schemas.android.com/apk/res/android", "id", 0);
|
||||
|
||||
if(id != 0)
|
||||
view_by_id.put(id, this);
|
||||
|
||||
Reference in New Issue
Block a user