Fixed the android editor, now it can open projects again. Also smaller codestyle fixes.

This commit is contained in:
Relintai 2022-09-17 21:27:19 +02:00
parent f30076a9f5
commit 42a9dc5e8d
3 changed files with 18 additions and 18 deletions

View File

@ -70,8 +70,8 @@ open class PandemoniumEditor : FullScreenPandemoniumApp() {
override fun onCreate(savedInstanceState : Bundle?) {
PermissionsUtil.requestManifestPermissions(this);
//String[]
val params = getIntent().getStringArrayExtra(COMMAND_LINE_PARAMS);
val params : Array<String>? = getIntent().getStringArrayExtra(COMMAND_LINE_PARAMS);
updateCommandLineParams(params);
if (BuildConfig.BUILD_TYPE == "dev" && WAIT_FOR_DEBUGGER) {
@ -95,14 +95,15 @@ open class PandemoniumEditor : FullScreenPandemoniumApp() {
}
}
override fun getCommandLine() = commandLineParams
override fun onNewPandemoniumInstanceRequested(args: Array<String>) {
// Parse the arguments to figure out which activity to start.
var targetClass: Class<*> = PandemoniumGame::class.java
// Whether we should launch the new godot instance in an adjacent window
// https://developer.android.com/reference/android/content/Intent#FLAG_ACTIVITY_LAUNCH_ADJACENT
var launchAdjacent =
Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && (isInMultiWindowMode || isLargeScreen)
var launchAdjacent = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && (isInMultiWindowMode || isLargeScreen)
for (arg in args) {
if (EDITOR_ARG == arg) {
@ -119,12 +120,12 @@ open class PandemoniumEditor : FullScreenPandemoniumApp() {
}
// Launch a new activity
val newInstance = Intent(this, targetClass)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
.putExtra(COMMAND_LINE_PARAMS, args)
val newInstance = 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)
}

View File

@ -59,16 +59,13 @@ public abstract class FullScreenPandemoniumApp extends FragmentActivity implemen
setContentView(R.layout.pandemonium_app_layout);
Fragment currentFragment = getSupportFragmentManager().findFragmentById(R.id.pandemonium_fragment_container);
if (currentFragment instanceof Pandemonium) {
Log.v(TAG, "Reusing existing Pandemonium fragment instance.");
pandemoniumFragment = (Pandemonium)currentFragment;
} else {
Log.v(TAG, "Creating new Pandemonium fragment instance.");
pandemoniumFragment = initPandemoniumInstance();
if (pandemoniumFragment == null) {
throw new IllegalStateException("Pandemonium instance must be non-null.");
}
getSupportFragmentManager().beginTransaction().replace(R.id.pandemonium_fragment_container, pandemoniumFragment).setPrimaryNavigationFragment(pandemoniumFragment).commitNowAllowingStateLoss();
}
}

View File

@ -510,6 +510,7 @@ public class Pandemonium extends Fragment implements SensorEventListener, IDownl
protected String[] getCommandLine() {
String[] original = parseCommandLine();
String[] updated;
List<String> hostCommandLine = pandemoniumHost != null ? pandemoniumHost.getCommandLine() : null;
if (hostCommandLine == null || hostCommandLine.isEmpty()) {
updated = original;
@ -519,6 +520,7 @@ public class Pandemonium extends Fragment implements SensorEventListener, IDownl
updated[original.length + i] = hostCommandLine.get(i);
}
}
return updated;
}