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
startActivity(): implement Intent.FLAG_ACTIVITY_CLEAR_TOP
This commit is contained in:
@@ -151,6 +151,9 @@ static jobject activity_not_created = NULL;
|
||||
|
||||
void activity_start(JNIEnv *env, jobject activity_object)
|
||||
{
|
||||
if (activity_current)
|
||||
activity_unfocus(env, activity_current);
|
||||
activity_current = NULL;
|
||||
/* -- run the activity's onCreate -- */
|
||||
(*env)->CallVoidMethod(env, activity_object, handle_cache.activity.onCreate, NULL);
|
||||
if((*env)->ExceptionCheck(env))
|
||||
@@ -198,6 +201,35 @@ JNIEXPORT void JNICALL Java_android_app_Activity_nativeStartActivity(JNIEnv *env
|
||||
activity_start(env, activity);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_android_app_Activity_nativeResumeActivity(JNIEnv *env, jclass class, jclass activity_class, jobject intent)
|
||||
{
|
||||
GList *l;
|
||||
GList *activities_to_close = NULL;
|
||||
for (l = activity_backlog; l != NULL; l = l->next) {
|
||||
if ((*env)->IsSameObject(env, activity_class, _CLASS(l->data))) {
|
||||
if (l != activity_backlog) {
|
||||
activities_to_close = activity_backlog;
|
||||
activity_backlog = l;
|
||||
l->prev->next = NULL;
|
||||
l->prev = NULL;
|
||||
}
|
||||
|
||||
/* -- run the activity's onNewIntent -- */
|
||||
(*env)->CallVoidMethod(env, l->data, handle_cache.activity.onNewIntent, intent);
|
||||
if((*env)->ExceptionCheck(env))
|
||||
(*env)->ExceptionDescribe(env);
|
||||
break;
|
||||
}
|
||||
}
|
||||
activity_update_current(env);
|
||||
|
||||
for (l = activities_to_close; l != NULL; l = l->next) {
|
||||
activity_close(env, l->data);
|
||||
_UNREF(l->data);
|
||||
}
|
||||
g_list_free(activities_to_close);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_android_app_Activity_nativeOpenURI(JNIEnv *env, jclass class, jstring uriString)
|
||||
{
|
||||
static XdpPortal *portal = NULL;
|
||||
|
||||
@@ -29,6 +29,14 @@ JNIEXPORT void JNICALL Java_android_app_Activity_nativeFinish
|
||||
JNIEXPORT void JNICALL Java_android_app_Activity_nativeStartActivity
|
||||
(JNIEnv *, jclass, jobject);
|
||||
|
||||
/*
|
||||
* Class: android_app_Activity
|
||||
* Method: nativeResumeActivity
|
||||
* Signature: (Ljava/lang/Class;Landroid/content/Intent;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_android_app_Activity_nativeResumeActivity
|
||||
(JNIEnv *, jclass, jclass, jobject);
|
||||
|
||||
/*
|
||||
* Class: android_app_Activity
|
||||
* Method: nativeOpenURI
|
||||
|
||||
@@ -17,6 +17,7 @@ void set_up_handle_cache(JNIEnv *env)
|
||||
handle_cache.activity.onStop = _METHOD(handle_cache.activity.class, "onStop", "()V");
|
||||
handle_cache.activity.onPause = _METHOD(handle_cache.activity.class, "onPause", "()V");
|
||||
handle_cache.activity.onBackPressed = _METHOD(handle_cache.activity.class, "onBackPressed", "()V");
|
||||
handle_cache.activity.onNewIntent = _METHOD(handle_cache.activity.class, "onNewIntent", "(Landroid/content/Intent;)V");
|
||||
|
||||
handle_cache.attribute_set.class = _REF((*env)->FindClass(env, "android/util/AttributeSet"));
|
||||
if((*env)->ExceptionCheck(env))
|
||||
|
||||
@@ -13,6 +13,7 @@ struct handle_cache {
|
||||
jmethodID onStop;
|
||||
jmethodID onPause;
|
||||
jmethodID onBackPressed;
|
||||
jmethodID onNewIntent;
|
||||
} activity;
|
||||
struct {
|
||||
jclass class;
|
||||
|
||||
@@ -586,6 +586,7 @@ public class Activity extends ContextThemeWrapper implements Window.Callback, La
|
||||
|
||||
private native void nativeFinish(long native_window);
|
||||
public static native void nativeStartActivity(Activity activity);
|
||||
public static native void nativeResumeActivity(Class<? extends Activity> activityClass, Intent intent);
|
||||
public static native void nativeOpenURI(String uri);
|
||||
public native void nativeFileChooser(int action, String type, String title, int requestCode);
|
||||
public void reportFullyDrawn() {}
|
||||
|
||||
@@ -622,8 +622,12 @@ public class Context extends Object {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Activity activity = Activity.internalCreateActivity(className_, this_application.native_window, intent_);
|
||||
Activity.nativeStartActivity(activity);
|
||||
if ((intent_.getFlags() & Intent.FLAG_ACTIVITY_CLEAR_TOP) != 0 && intent_.getComponent() != null) {
|
||||
Activity.nativeResumeActivity(Class.forName(intent_.getComponent().getClassName()).asSubclass(Activity.class), intent_);
|
||||
} else {
|
||||
Activity activity = Activity.internalCreateActivity(className_, this_application.native_window, intent_);
|
||||
Activity.nativeStartActivity(activity);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import java.util.Set;
|
||||
public class Intent implements Parcelable {
|
||||
public static final String ACTION_MAIN = "android.intent.action.MAIN";
|
||||
public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
|
||||
public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
|
||||
|
||||
private ComponentName component;
|
||||
private Bundle extras = new Bundle();
|
||||
|
||||
Reference in New Issue
Block a user