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
move startActivity function to Context class
This way it can also be called on Application Context
This commit is contained in:
@@ -31,7 +31,7 @@ public class Activity extends Context implements Window.Callback {
|
||||
LayoutInflater layout_inflater;
|
||||
Window window = new Window(this);
|
||||
int requested_orientation = -1 /*ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED*/; // dummy
|
||||
private Intent intent;
|
||||
public Intent intent;
|
||||
private Activity resultActivity;
|
||||
private int resultRequestCode;
|
||||
private int pendingRequestCode;
|
||||
@@ -294,25 +294,6 @@ public class Activity extends Context implements Window.Callback {
|
||||
setResult(resultCode, null);
|
||||
}
|
||||
|
||||
public void startActivity(Intent intent) {
|
||||
System.out.println("startActivity(" + intent + ") called");
|
||||
if (intent.getComponent() == null) {
|
||||
System.out.println("starting extern activity with intent: " + intent);
|
||||
nativeOpenURI(String.valueOf(intent.getData()));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Class<? extends Activity> cls = Class.forName(intent.getComponent().getClassName()).asSubclass(Activity.class);
|
||||
Constructor<? extends Activity> constructor = cls.getConstructor();
|
||||
Activity activity = constructor.newInstance();
|
||||
activity.intent = intent;
|
||||
activity.getWindow().native_window = getWindow().native_window;
|
||||
nativeStartActivity(activity);
|
||||
} catch (ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public final void showDialog(int id) {
|
||||
System.out.println("Activity.showDialog(" + id + ") called");
|
||||
}
|
||||
@@ -340,8 +321,8 @@ public class Activity extends Context implements Window.Callback {
|
||||
public boolean isChangingConfigurations() {return false;}
|
||||
|
||||
private native void nativeFinish(long native_window);
|
||||
private static native void nativeStartActivity(Activity activity);
|
||||
private static native void nativeOpenURI(String uri);
|
||||
public static native void nativeStartActivity(Activity activity);
|
||||
public static native void nativeOpenURI(String uri);
|
||||
|
||||
@Override
|
||||
public void onContentChanged() {
|
||||
|
||||
@@ -13,6 +13,7 @@ import android.content.ContextWrapper;
|
||||
|
||||
public class Application extends ContextWrapper {
|
||||
private String app_icon_path = null;
|
||||
public long native_window;
|
||||
|
||||
private String get_app_icon_path() {
|
||||
return app_icon_path;
|
||||
|
||||
Reference in New Issue
Block a user