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
src/main-executable: show actual package name as window title, preparation for showing app icon, re-add some missing stuff
This commit is contained in:
@@ -1,10 +1,23 @@
|
||||
package android.app;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import com.reandroid.apk.AndroidFrameworks;
|
||||
import com.reandroid.arsc.chunk.xml.AndroidManifestBlock;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
public class Application extends Context {
|
||||
private String app_icon_path = null;
|
||||
|
||||
private String get_app_icon_path() {
|
||||
return app_icon_path;
|
||||
}
|
||||
|
||||
public interface ActivityLifecycleCallbacks {
|
||||
void onActivityCreated(Activity activity, Bundle savedInstanceState);
|
||||
void onActivityStarted(Activity activity);
|
||||
@@ -28,7 +41,17 @@ public class Application extends Context {
|
||||
*/
|
||||
public void onProvideAssistData(Activity activity, Bundle data);
|
||||
}
|
||||
|
||||
public Application() {
|
||||
/* TODO: is this the right place to put this? */
|
||||
InputStream inStream = ClassLoader.getSystemClassLoader().getResourceAsStream("AndroidManifest.xml");
|
||||
try {
|
||||
AndroidManifestBlock manifest = AndroidManifestBlock.load(inStream);
|
||||
int app_icon_resid = manifest.getIconResourceId();
|
||||
app_icon_path = this.getResources().getString(app_icon_resid);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Called when the application is starting, before any activity, service,
|
||||
|
||||
@@ -33,10 +33,13 @@ import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.WindowManager;
|
||||
import android.view.WindowManagerImpl;
|
||||
import com.reandroid.arsc.chunk.xml.AndroidManifestBlock;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Context extends Object {
|
||||
private final static String TAG = "Context";
|
||||
@@ -46,6 +49,8 @@ public class Context extends Object {
|
||||
public static final String AUDIO_SERVICE = "audio";
|
||||
public static final String DISPLAY_SERVICE = "display";
|
||||
public static final String MEDIA_ROUTER_SERVICE = "media_router";
|
||||
public static final String WINDOW_SERVICE = "window";
|
||||
private static AndroidManifestBlock manifest = null;
|
||||
|
||||
static AssetManager assets;
|
||||
static DisplayMetrics dm;
|
||||
@@ -70,6 +75,13 @@ public class Context extends Object {
|
||||
r = new Resources(assets, dm, config);
|
||||
this_application = new Application(); // TODO: the application context is presumably not identical to the Activity context, what is the difference for us though?
|
||||
application_info = new ApplicationInfo();
|
||||
|
||||
InputStream inStream = ClassLoader.getSystemClassLoader().getResourceAsStream("AndroidManifest.xml");
|
||||
try {
|
||||
manifest = AndroidManifestBlock.load(inStream);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public Context() {
|
||||
@@ -156,7 +168,7 @@ public class Context extends Object {
|
||||
}
|
||||
|
||||
public String getPackageName() {
|
||||
return "com.example.demo_app";
|
||||
return manifest.getPackageName();
|
||||
}
|
||||
|
||||
public String getPackageCodePath() {
|
||||
@@ -254,7 +266,7 @@ public class Context extends Object {
|
||||
}
|
||||
|
||||
public SharedPreferences getSharedPreferences(String name, int mode) {
|
||||
System.out.println("\n\n...> getSharedPreferences(" + name + ",)\n\n");
|
||||
System.out.println("\n\n...> getSharedPreferences(" + name + ")\n\n");
|
||||
File prefsFile = getSharedPrefsFile(name);
|
||||
return new SharedPreferencesImpl(prefsFile, mode);
|
||||
}
|
||||
@@ -289,6 +301,18 @@ public class Context extends Object {
|
||||
|
||||
public void registerComponentCallbacks(ComponentCallbacks callbacks) {}
|
||||
|
||||
public boolean bindService(Intent dummy, ServiceConnection dummy2, int dummy3) {
|
||||
System.out.println("bindService("+dummy+", "+dummy2+", "+dummy3+")");
|
||||
return false; // maybe?
|
||||
}
|
||||
|
||||
public void startActivity(Intent intent) {
|
||||
System.out.println("------------------");
|
||||
System.out.println("app wants to startActivity("+intent+"), but we don't support that... :/");
|
||||
try { throw new java.lang.Exception(); } catch (java.lang.Exception e) { e.printStackTrace(); }
|
||||
System.out.println("------------------");
|
||||
}
|
||||
|
||||
// these may not look like typical stubs, but they definitely are stubs
|
||||
public final TypedArray obtainStyledAttributes(AttributeSet set, int[] attrs) { return new TypedArray(r, new int[1000], new int[1000], 0); }
|
||||
public final TypedArray obtainStyledAttributes(AttributeSet set, int[] attrs, int defStyleAttr, int defStyleRes) { return new TypedArray(r, new int[1000], new int[1000], 0); }
|
||||
|
||||
Reference in New Issue
Block a user