Skip to content

Commit

Permalink
Merge pull request #62609 from akien-mga/3.4-android-preset-target-sd…
Browse files Browse the repository at this point in the history
…k-warning
  • Loading branch information
akien-mga authored Jul 3, 2022
2 parents 7a87fd2 + 431558d commit 59ae873
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 10 deletions.
2 changes: 2 additions & 0 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6995,6 +6995,8 @@ EditorNode::EditorNode() {
execute_output_dialog = memnew(AcceptDialog);
execute_output_dialog->add_child(execute_outputs);
execute_output_dialog->set_title("");
// Prevent closing too fast and missing important information.
execute_output_dialog->set_exclusive(true);
gui_base->add_child(execute_output_dialog);

EditorFileSystem::get_singleton()->connect("sources_changed", this, "_sources_changed");
Expand Down
21 changes: 20 additions & 1 deletion editor/project_export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,12 @@ void ProjectExportDialog::_edit_preset(int p_index) {
}
error += " - " + items[i];
}

export_error->set_text(error);
export_error->show();
} else {
export_error->hide();
}
export_warning->hide();
if (needs_templates) {
export_templates_error->show();
} else {
Expand All @@ -262,6 +262,20 @@ void ProjectExportDialog::_edit_preset(int p_index) {
get_ok()->set_disabled(true);

} else {
if (error != String()) {
Vector<String> items = error.split("\n", false);
error = "";
for (int i = 0; i < items.size(); i++) {
if (i > 0) {
error += "\n";
}
error += " - " + items[i];
}
export_warning->set_text(error);
export_warning->show();
} else {
export_warning->hide();
}
export_error->hide();
export_templates_error->hide();
export_button->set_disabled(false);
Expand Down Expand Up @@ -1144,6 +1158,11 @@ ProjectExportDialog::ProjectExportDialog() {
export_error->hide();
export_error->add_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_color("error_color", "Editor"));

export_warning = memnew(Label);
main_vb->add_child(export_warning);
export_warning->hide();
export_warning->add_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_color("warning_color", "Editor"));

export_templates_error = memnew(HBoxContainer);
main_vb->add_child(export_templates_error);
export_templates_error->hide();
Expand Down
1 change: 1 addition & 0 deletions editor/project_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class ProjectExportDialog : public ConfirmationDialog {
Label *script_key_error;

Label *export_error;
Label *export_warning;
HBoxContainer *export_templates_error;

String default_filename;
Expand Down
32 changes: 23 additions & 9 deletions platform/android/export/export_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ static const char *AAB_ASSETS_DIRECTORY = "res://android/build/assetPacks/instal

static const int DEFAULT_MIN_SDK_VERSION = 19; // Should match the value in 'platform/android/java/app/config.gradle#minSdk'
static const int DEFAULT_TARGET_SDK_VERSION = 31; // Should match the value in 'platform/android/java/app/config.gradle#targetSdk'
const String SDK_VERSION_RANGE = vformat("%s,%s,1", DEFAULT_MIN_SDK_VERSION, DEFAULT_TARGET_SDK_VERSION);
const String SDK_VERSION_RANGE = vformat("%s,%s,1,or_greater", DEFAULT_MIN_SDK_VERSION, DEFAULT_TARGET_SDK_VERSION + 1);

void EditorExportPlatformAndroid::_check_for_changes_poll_thread(void *ud) {
EditorExportPlatformAndroid *ea = (EditorExportPlatformAndroid *)ud;
Expand Down Expand Up @@ -2249,20 +2249,34 @@ bool EditorExportPlatformAndroid::can_export(const Ref<EditorExportPreset> &p_pr
err += "\n";
}

// Check the min sdk version
// Check the min and target sdk version.

// They're only used for custom_build_enabled, but since we save their default values
// in the export preset, users would get an unexpected error when updating to a Godot
// version that has different values (GH-62465).
// So we don't make a blocking error, instead we just show a warning.

int min_sdk_version = p_preset->get("version/min_sdk");
if (min_sdk_version != DEFAULT_MIN_SDK_VERSION && !custom_build_enabled) {
valid = false;
err += TTR("Changing the \"Min Sdk\" is only valid when \"Use Custom Build\" is enabled.");
err += vformat(TTR("\"Min Sdk\" was changed from the default \"%d\" to \"%d\". This option requires \"Use Custom Build\" to be enabled.\n>> Change it to \"%d\" to silence this warning, or enable \"Use Custom Build\" to use this min SDK."), DEFAULT_MIN_SDK_VERSION, min_sdk_version, DEFAULT_MIN_SDK_VERSION);
err += "\n";
}

// Check the target sdk version
// Here we also handle compatibility with Godot 3.4 to 3.4.4 where target SDK was 30.
// Version 3.4.5 updated it to 31 to match platform requirements, so make sure that
// users notice it.
int target_sdk_version = p_preset->get("version/target_sdk");
if (target_sdk_version != DEFAULT_TARGET_SDK_VERSION && !custom_build_enabled) {
valid = false;
err += TTR("Changing the \"Target Sdk\" is only valid when \"Use Custom Build\" is enabled.");
err += "\n";
if (target_sdk_version != DEFAULT_TARGET_SDK_VERSION) {
if (!custom_build_enabled) {
err += vformat(TTR("\"Target Sdk\" was changed from the default \"%d\" to \"%d\". This option requires \"Use Custom Build\" to be enabled.\n>> Change it to \"%d\" to silence this warning, or enable \"Use Custom Build\" to use this target SDK."), DEFAULT_TARGET_SDK_VERSION, target_sdk_version, DEFAULT_TARGET_SDK_VERSION);
err += "\n";
} else if (target_sdk_version == 30) { // Compatibility with < 3.4.5.
err += vformat(TTR("\"Target Sdk\" is set to 30, while the current default is \"%d\". This might be due to upgrading from a previous Godot release.\n>> Consider changing it to \"%d\" to stay up-to-date with platform requirements."), DEFAULT_TARGET_SDK_VERSION, DEFAULT_TARGET_SDK_VERSION);
err += "\n";
} else if (target_sdk_version > DEFAULT_TARGET_SDK_VERSION) {
err += vformat(TTR("\"Target Sdk\" %d is higher than the default version %d. This may work, but wasn't tested and may be unstable."), target_sdk_version, DEFAULT_TARGET_SDK_VERSION);
err += "\n";
}
}

if (target_sdk_version < min_sdk_version) {
Expand Down

0 comments on commit 59ae873

Please sign in to comment.