Repository: godotengine/godot
File: editor/export/project_export.cpp (C++)

Code before:
	}
}

void ProjectExportDialog::_open_export_template_manager() {
	hide();
	EditorNode::get_singleton()->open_export_template_manager();
}

void ProjectExportDialog::_export_project() {
	Ref<EditorExportPreset> current = get_current_preset();
	ERR_FAIL_COND(current.is_null());
	Ref<EditorExportPlatform> platform = current->get_platform();
	ERR_FAIL_COND(platform.is_null());

	export_project->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
	export_project->clear_filters();

	List<String> extension_list = platform->get_binary_extensions(current);
	for (const String &extension : extension_list) {
		// TRANSLATORS: This is the name of a project export file format. %s will be replaced by the platform name.
		export_project->add_filter("*." + extension, vformat(TTR("%s Export"), platform->get_name()));
	}

	if (!current->get_export_path().is_empty()) {
		String path = current->get_export_path();
		if (platform->get_class_name() == "EditorExportPlatformAndroid") {
			if (int(current->get("gradle_build/export_format")) == 0) {
				path = path.get_basename() + ".apk";
			} else {
				path = path.get_basename() + ".aab";
			}
		}
		export_project->set_current_path(path);
	} else {
		if (extension_list.size() >= 1) {
			export_project->set_current_file(default_filename + "." + extension_list.front()->get());
		} else {
			export_project->set_current_file(default_filename);
		}
	}
	export_project->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
	export_project->popup_file_dialog();
}

void ProjectExportDialog::_export_project_to_path(const String &p_path) {
	// Save this name for use in future exports (but drop the file extension)
	default_filename = p_path.get_file().get_basename();
	EditorSettings::get_singleton()->set_project_metadata("export_options", "default_filename", default_filename);

	Ref<EditorExportPreset> current = get_current_preset();
	ERR_FAIL_COND_MSG(current.is_null(), "Failed to start the export: current preset is invalid.");

Review comment (suggestion):
I think @m4gr3d may have meant something like this:

```suggestion
		if (platform->is_class("EditorExportPlatformAndroid")) {
```

... or maybe:

```suggestion
		if (Object::cast_to<EditorExportPlatformAndroid>(platform)) {
```

Otherwise, this only works for exactly the `EditorExportPlatformAndroid` class and not any classes that derive from it

Code after:
	}
}

void ProjectExportDialog::_open_export_template_manager() {
	hide();
	EditorNode::get_singleton()->open_export_template_manager();
}

void ProjectExportDialog::_export_project() {
	Ref<EditorExportPreset> current = get_current_preset();
	ERR_FAIL_COND(current.is_null());
	Ref<EditorExportPlatform> platform = current->get_platform();
	ERR_FAIL_COND(platform.is_null());

	export_project->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
	export_project->clear_filters();

	List<String> extension_list = platform->get_binary_extensions(current);
	for (const String &extension : extension_list) {
		// TRANSLATORS: This is the name of a project export file format. %s will be replaced by the platform name.
		export_project->add_filter("*." + extension, vformat(TTR("%s Export"), platform->get_name()));
	}

	String path = current->get_export_path();
	if (!path.is_empty()) {
		if (extension_list.find(path.get_extension()) == nullptr && extension_list.size() >= 1) {
			path = path.get_basename() + "." + extension_list.front()->get();
		}
		export_project->set_current_path(path);
	} else {
		if (extension_list.size() >= 1) {
			export_project->set_current_file(default_filename + "." + extension_list.front()->get());
		} else {
			export_project->set_current_file(default_filename);
		}
	}
	export_project->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
	export_project->popup_file_dialog();
}

void ProjectExportDialog::_export_project_to_path(const String &p_path) {
	// Save this name for use in future exports (but drop the file extension)
	default_filename = p_path.get_file().get_basename();
	EditorSettings::get_singleton()->set_project_metadata("export_options", "default_filename", default_filename);

	Ref<EditorExportPreset> current = get_current_preset();
	ERR_FAIL_COND_MSG(current.is_null(), "Failed to start the export: current preset is invalid.");
	Ref<EditorExportPlatform> platform = current->get_platform();
	ERR_FAIL_COND_MSG(platform.is_null(), "Failed to start the export: current preset has no valid platform.");
	current->set_export_path(p_path);