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 spacial handling for Activity.recreateActivity()
This prevents the onStart() method being called twice for the toplevel Activity.
This commit is contained in:
@@ -11,7 +11,6 @@
|
||||
|
||||
static GList *activity_backlog = NULL;
|
||||
static jobject activity_current = NULL;
|
||||
static jobject activity_toplevel_current = NULL;
|
||||
|
||||
static void activity_close(JNIEnv *env, jobject activity)
|
||||
{
|
||||
@@ -66,7 +65,6 @@ static void activity_focus(JNIEnv *env, jobject activity)
|
||||
static void activity_update_current(JNIEnv *env)
|
||||
{
|
||||
jobject activity_new = activity_backlog ? g_list_first(activity_backlog)->data : NULL;
|
||||
jobject activity_toplevel_new = activity_backlog ? g_list_last(activity_backlog)->data : NULL;
|
||||
|
||||
if (activity_current != activity_new) {
|
||||
if (activity_current)
|
||||
@@ -77,17 +75,6 @@ static void activity_update_current(JNIEnv *env)
|
||||
|
||||
activity_current = activity_new;
|
||||
}
|
||||
|
||||
/* for Activity.recreate */
|
||||
if(activity_toplevel_current != activity_toplevel_new) {
|
||||
if (activity_toplevel_current)
|
||||
activity_unfocus(env, activity_toplevel_current);
|
||||
|
||||
if (activity_toplevel_new)
|
||||
activity_focus(env, activity_toplevel_new);
|
||||
|
||||
activity_toplevel_current = activity_toplevel_new;
|
||||
}
|
||||
}
|
||||
|
||||
void activity_window_ready(void)
|
||||
@@ -120,7 +107,7 @@ void activity_close_all(void)
|
||||
|
||||
static jobject activity_not_created = NULL;
|
||||
|
||||
void _activity_start(JNIEnv *env, jobject activity_object, bool recreate)
|
||||
void activity_start(JNIEnv *env, jobject activity_object)
|
||||
{
|
||||
/* -- run the activity's onCreate -- */
|
||||
(*env)->CallVoidMethod(env, activity_object, handle_cache.activity.onCreate, NULL);
|
||||
@@ -137,20 +124,12 @@ void _activity_start(JNIEnv *env, jobject activity_object, bool recreate)
|
||||
if((*env)->ExceptionCheck(env))
|
||||
(*env)->ExceptionDescribe(env);
|
||||
|
||||
if(recreate) // only allowed for toplevel, so we know for sure where in the stack it belongs
|
||||
activity_backlog = g_list_append(activity_backlog, _REF(activity_object));
|
||||
else
|
||||
activity_backlog = g_list_prepend(activity_backlog, _REF(activity_object));
|
||||
activity_backlog = g_list_prepend(activity_backlog, _REF(activity_object));
|
||||
|
||||
activity_update_current(env);
|
||||
|
||||
}
|
||||
|
||||
void activity_start(JNIEnv *env, jobject activity_object)
|
||||
{
|
||||
_activity_start(env, activity_object, false);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_android_app_Activity_nativeFinish(JNIEnv *env, jobject this, jlong window)
|
||||
{
|
||||
GList *l;
|
||||
@@ -173,12 +152,6 @@ JNIEXPORT void JNICALL Java_android_app_Activity_nativeFinish(JNIEnv *env, jobje
|
||||
gtk_window_close(GTK_WINDOW(_PTR(window)));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_android_app_Activity_nativeRecreateActivity(JNIEnv *env, jclass class, jobject activity)
|
||||
{
|
||||
_activity_start(env, activity, true);
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT void JNICALL Java_android_app_Activity_nativeStartActivity(JNIEnv *env, jclass class, jobject activity)
|
||||
{
|
||||
activity_start(env, activity);
|
||||
|
||||
@@ -17,14 +17,6 @@ extern "C" {
|
||||
JNIEXPORT void JNICALL Java_android_app_Activity_nativeFinish
|
||||
(JNIEnv *, jobject, jlong);
|
||||
|
||||
/*
|
||||
* Class: android_app_Activity
|
||||
* Method: nativeRecreateActivity
|
||||
* Signature: (Landroid/app/Activity;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_android_app_Activity_nativeRecreateActivity
|
||||
(JNIEnv *, jclass, jobject);
|
||||
|
||||
/*
|
||||
* Class: android_app_Activity
|
||||
* Method: nativeStartActivity
|
||||
|
||||
@@ -500,7 +500,7 @@ public class Activity extends ContextThemeWrapper implements Window.Callback {
|
||||
activity.getWindow().native_window = getWindow().native_window;
|
||||
System.out.println("activity.getWindow().native_window >"+activity.getWindow().native_window+"<");
|
||||
nativeFinish(0);
|
||||
nativeRecreateActivity(activity);
|
||||
nativeStartActivity(activity);
|
||||
} catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
||||
System.out.println("exception in Activity.recreate, this is kinda sus");
|
||||
e.printStackTrace();
|
||||
@@ -556,7 +556,6 @@ public class Activity extends ContextThemeWrapper implements Window.Callback {
|
||||
public void setTaskDescription(ActivityManager.TaskDescription description) {}
|
||||
|
||||
private native void nativeFinish(long native_window);
|
||||
public static native void nativeRecreateActivity(Activity activity);
|
||||
public static native void nativeStartActivity(Activity activity);
|
||||
public static native void nativeOpenURI(String uri);
|
||||
public native void nativeFileChooser(int action, String type, String title, int requestCode);
|
||||
|
||||
Reference in New Issue
Block a user