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
fix multi Activity support
jobjects have to be compared with env->IsSameObject() and each Activity needs its own Window instance. The GtkWindow is still shared between all Activities
This commit is contained in:
@@ -86,10 +86,19 @@ void activity_start(JNIEnv *env, jobject activity_object) {
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_android_app_Activity_nativeFinish(JNIEnv *env, jobject this, jlong window) {
|
||||
activity_backlog = g_list_remove(activity_backlog, this);
|
||||
GList *l;
|
||||
jobject removed_activity = NULL;
|
||||
for (l = activity_backlog; l != NULL; l = l->next) {
|
||||
if ((*env)->IsSameObject(env, this, l->data)) {
|
||||
removed_activity = l->data;
|
||||
activity_backlog = g_list_delete_link(activity_backlog, l);
|
||||
break;
|
||||
}
|
||||
}
|
||||
activity_update_current(env);
|
||||
activity_close(env, this);
|
||||
_UNREF(this);
|
||||
if (removed_activity)
|
||||
_UNREF(removed_activity);
|
||||
if (activity_backlog == NULL)
|
||||
gtk_window_close(GTK_WINDOW(_PTR(window)));
|
||||
}
|
||||
|
||||
@@ -110,6 +110,8 @@ public class Activity extends Context {
|
||||
|
||||
protected void onStart() {
|
||||
System.out.println("- onStart - yay!");
|
||||
if (window.contentView != null)
|
||||
window.setContentView(window.contentView);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -232,7 +234,7 @@ public class Activity extends Context {
|
||||
Constructor<? extends Activity> constructor = cls.getConstructor();
|
||||
Activity activity = constructor.newInstance();
|
||||
activity.intent = intent;
|
||||
activity.window = getWindow();
|
||||
activity.getWindow().native_window = getWindow().native_window;
|
||||
nativeStartActivity(activity);
|
||||
} catch (ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
||||
onActivityResult(requestCode, 0 /*RESULT_CANCELED*/, new Intent()); // RESULT_CANCELED is the only pre-defined return value, so hopefully it works out for us
|
||||
@@ -250,7 +252,7 @@ public class Activity extends Context {
|
||||
Constructor<? extends Activity> constructor = cls.getConstructor();
|
||||
Activity activity = constructor.newInstance();
|
||||
activity.intent = intent;
|
||||
activity.window = getWindow();
|
||||
activity.getWindow().native_window = getWindow().native_window;
|
||||
nativeStartActivity(activity);
|
||||
} catch (ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -20,6 +20,7 @@ public class Window {
|
||||
|
||||
// FIXME private
|
||||
public long native_window;
|
||||
public View contentView;
|
||||
|
||||
private Window.Callback callback;
|
||||
|
||||
@@ -39,6 +40,7 @@ public class Window {
|
||||
}
|
||||
|
||||
public void setContentView(View view) {
|
||||
contentView = view;
|
||||
set_widget_as_root(native_window, view.widget);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user