diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 666339e..9ef57dd 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -29,9 +29,13 @@ android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode" android:exported="true" android:label="@string/app_name" - android:launchMode="singleTask" + android:launchMode="standard" android:screenOrientation="portrait" android:windowSoftInputMode="adjustResize"> + + diff --git a/android/app/src/main/java/io/netbird/client/LaunchActivity.java b/android/app/src/main/java/io/netbird/client/LaunchActivity.java new file mode 100644 index 0000000..8a4a6a1 --- /dev/null +++ b/android/app/src/main/java/io/netbird/client/LaunchActivity.java @@ -0,0 +1,19 @@ +package io.netbird.client; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; + +public class LaunchActivity extends Activity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + MainApplication application = (MainApplication) getApplication(); + // check that MainActivity is not started yet + if (!application.isActivityInBackStack(MainActivity.class)) { + Intent intent = new Intent(this, MainActivity.class); + startActivity(intent); + } + finish(); + } +} diff --git a/android/app/src/main/java/io/netbird/client/MainActivity.java b/android/app/src/main/java/io/netbird/client/MainActivity.java index 38399c9..53a405f 100644 --- a/android/app/src/main/java/io/netbird/client/MainActivity.java +++ b/android/app/src/main/java/io/netbird/client/MainActivity.java @@ -60,6 +60,8 @@ protected void onCreate(Bundle savedInstanceState) { SplashScreen.show(this); MainApplication application = (MainApplication) getApplication(); + application.addActivityToStack(this.getClass()); + sendEventActionSharedPref = getSharedPreferences(SEND_EVENT_ACTION, Context.MODE_PRIVATE); sendEventToReactMessageKey = sendEventActionSharedPref.getString(MESSAGE_KEY, ""); @@ -75,4 +77,12 @@ protected void onCreate(Bundle savedInstanceState) { } }); } + + @Override + protected void onDestroy() { + super.onDestroy(); + MainApplication application = (MainApplication) getApplication(); + + application.removeActivityFromStack(this.getClass()); + } } diff --git a/android/app/src/main/java/io/netbird/client/MainApplication.java b/android/app/src/main/java/io/netbird/client/MainApplication.java index f5c9a07..7b6ff66 100644 --- a/android/app/src/main/java/io/netbird/client/MainApplication.java +++ b/android/app/src/main/java/io/netbird/client/MainApplication.java @@ -11,6 +11,7 @@ import com.facebook.react.defaults.DefaultReactNativeHost; import com.facebook.soloader.SoLoader; +import java.util.ArrayList; import java.util.List; import io.netbird.client.tool.NetworkChangeNotifier; @@ -18,6 +19,20 @@ public class MainApplication extends Application implements ReactApplication { private final NotificationReceiver notificationReceiver = new NotificationReceiver(); + private ArrayList runningActivities = new ArrayList<>(); + + public void addActivityToStack (Class cls) { + if (!runningActivities.contains(cls)) runningActivities.add(cls); + } + + public void removeActivityFromStack (Class cls) { + if (runningActivities.contains(cls)) runningActivities.remove(cls); + } + + public boolean isActivityInBackStack (Class cls) { + return runningActivities.contains(cls); + } + private final ReactNativeHost mReactNativeHost = new DefaultReactNativeHost(this) { @Override diff --git a/src/components/InAppBrowser/utils.ts b/src/components/InAppBrowser/utils.ts index f197cd1..a424d95 100644 --- a/src/components/InAppBrowser/utils.ts +++ b/src/components/InAppBrowser/utils.ts @@ -43,7 +43,7 @@ export const openLink = async (url: string, animated = true) => { }, hasBackButton: true, browserPackage: undefined, - showInRecents: false, + showInRecents: true, includeReferrer: false, }); } else {