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

View File

@ -59,16 +59,13 @@ public abstract class FullScreenPandemoniumApp extends FragmentActivity implemen
setContentView(R.layout.pandemonium_app_layout); setContentView(R.layout.pandemonium_app_layout);
Fragment currentFragment = getSupportFragmentManager().findFragmentById(R.id.pandemonium_fragment_container); Fragment currentFragment = getSupportFragmentManager().findFragmentById(R.id.pandemonium_fragment_container);
if (currentFragment instanceof Pandemonium) { if (currentFragment instanceof Pandemonium) {
Log.v(TAG, "Reusing existing Pandemonium fragment instance."); Log.v(TAG, "Reusing existing Pandemonium fragment instance.");
pandemoniumFragment = (Pandemonium)currentFragment; pandemoniumFragment = (Pandemonium)currentFragment;
} else { } else {
Log.v(TAG, "Creating new Pandemonium fragment instance."); Log.v(TAG, "Creating new Pandemonium fragment instance.");
pandemoniumFragment = initPandemoniumInstance(); 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(); 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() { protected String[] getCommandLine() {
String[] original = parseCommandLine(); String[] original = parseCommandLine();
String[] updated; String[] updated;
List<String> hostCommandLine = pandemoniumHost != null ? pandemoniumHost.getCommandLine() : null; List<String> hostCommandLine = pandemoniumHost != null ? pandemoniumHost.getCommandLine() : null;
if (hostCommandLine == null || hostCommandLine.isEmpty()) { if (hostCommandLine == null || hostCommandLine.isEmpty()) {
updated = original; updated = original;
@ -519,6 +520,7 @@ public class Pandemonium extends Fragment implements SensorEventListener, IDownl
updated[original.length + i] = hostCommandLine.get(i); updated[original.length + i] = hostCommandLine.get(i);
} }
} }
return updated; return updated;
} }