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
remove custom AndroidManifest.xml parsing and instead use PackageParser
This has the advantage, that AndroidManifest.xml is only parsed once.
This commit is contained in:
@@ -2,23 +2,18 @@ package android.app;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.TypedArray;
|
||||
import android.content.res.XmlResourceParser;
|
||||
import android.R;
|
||||
import android.content.Context;
|
||||
import android.content.ContextWrapper;
|
||||
|
||||
public class Application extends ContextWrapper {
|
||||
private String app_icon_path = null;
|
||||
private String app_label = null;
|
||||
public long native_window;
|
||||
|
||||
private String get_app_icon_path() {
|
||||
return app_icon_path;
|
||||
return getString(pkg.applicationInfo.icon);
|
||||
}
|
||||
|
||||
private String get_app_label() {
|
||||
return app_label;
|
||||
return getString(pkg.applicationInfo.labelRes);
|
||||
}
|
||||
|
||||
public interface ActivityLifecycleCallbacks {
|
||||
@@ -47,19 +42,6 @@ public class Application extends ContextWrapper {
|
||||
|
||||
public Application() {
|
||||
super(new Context());
|
||||
/* TODO: is this the right place to put this? */
|
||||
try (XmlResourceParser parser = getAssets().openXmlResourceParser("AndroidManifest.xml")) {
|
||||
for (; parser.getEventType() != XmlResourceParser.END_DOCUMENT; parser.next()) {
|
||||
if (parser.getEventType() == XmlResourceParser.START_TAG && "application".equals(parser.getName())) {
|
||||
TypedArray a = getResources().obtainAttributes(parser, R.styleable.AndroidManifestApplication);
|
||||
app_icon_path = a.getString(R.styleable.AndroidManifestApplication_icon);
|
||||
app_label = a.getString(R.styleable.AndroidManifestApplication_label);
|
||||
a.recycle();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Called when the application is starting, before any activity, service,
|
||||
|
||||
Reference in New Issue
Block a user