|
@@ -34,10 +34,13 @@ import org.godotengine.godot.FullScreenGodotApp;
|
|
import org.godotengine.godot.utils.PermissionsUtil;
|
|
import org.godotengine.godot.utils.PermissionsUtil;
|
|
|
|
|
|
import android.content.Intent;
|
|
import android.content.Intent;
|
|
|
|
+import android.os.Build;
|
|
import android.os.Bundle;
|
|
import android.os.Bundle;
|
|
import android.os.Debug;
|
|
import android.os.Debug;
|
|
|
|
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.Nullable;
|
|
|
|
+import androidx.window.layout.WindowMetrics;
|
|
|
|
+import androidx.window.layout.WindowMetricsCalculator;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
@@ -91,23 +94,47 @@ public class GodotEditor extends FullScreenGodotApp {
|
|
public void onNewGodotInstanceRequested(String[] args) {
|
|
public void onNewGodotInstanceRequested(String[] args) {
|
|
// Parse the arguments to figure out which activity to start.
|
|
// Parse the arguments to figure out which activity to start.
|
|
Class<?> targetClass = GodotGame.class;
|
|
Class<?> targetClass = GodotGame.class;
|
|
|
|
+ // Whether we should launch the new godot instance in an adjacent window
|
|
|
|
+ // https://developer.android.com/reference/android/content/Intent#FLAG_ACTIVITY_LAUNCH_ADJACENT
|
|
|
|
+ boolean launchAdjacent = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && (isInMultiWindowMode() || isLargeScreen());
|
|
|
|
+
|
|
for (String arg : args) {
|
|
for (String arg : args) {
|
|
if (EDITOR_ARG.equals(arg)) {
|
|
if (EDITOR_ARG.equals(arg)) {
|
|
targetClass = GodotEditor.class;
|
|
targetClass = GodotEditor.class;
|
|
|
|
+ launchAdjacent = false;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
if (PROJECT_MANAGER_ARG.equals(arg)) {
|
|
if (PROJECT_MANAGER_ARG.equals(arg)) {
|
|
targetClass = GodotProjectManager.class;
|
|
targetClass = GodotProjectManager.class;
|
|
|
|
+ launchAdjacent = false;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// Launch a new activity
|
|
// Launch a new activity
|
|
- Intent newInstance = new Intent(this, targetClass).putExtra(COMMAND_LINE_PARAMS, args);
|
|
|
|
|
|
+ Intent newInstance = new Intent(this, targetClass)
|
|
|
|
+ .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
|
|
+ .putExtra(COMMAND_LINE_PARAMS, args);
|
|
|
|
+ if (launchAdjacent) {
|
|
|
|
+ newInstance.addFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT);
|
|
|
|
+ }
|
|
startActivity(newInstance);
|
|
startActivity(newInstance);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ protected boolean isLargeScreen() {
|
|
|
|
+ WindowMetrics metrics =
|
|
|
|
+ WindowMetricsCalculator.getOrCreate().computeMaximumWindowMetrics(this);
|
|
|
|
+
|
|
|
|
+ // Get the screen's density scale
|
|
|
|
+ float scale = getResources().getDisplayMetrics().density;
|
|
|
|
+
|
|
|
|
+ // Get the minimum window size
|
|
|
|
+ float minSize = Math.min(metrics.getBounds().width(), metrics.getBounds().height());
|
|
|
|
+ float minSizeDp = minSize / scale;
|
|
|
|
+ return minSizeDp >= 840f; // Correspond to the EXPANDED window size class.
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void setRequestedOrientation(int requestedOrientation) {
|
|
public void setRequestedOrientation(int requestedOrientation) {
|
|
if (!overrideOrientationRequest()) {
|
|
if (!overrideOrientationRequest()) {
|