From b2cb858572fa01858f3cbea61054ea5dab18d0f6 Mon Sep 17 00:00:00 2001 From: Anish Mishra Date: Fri, 8 Nov 2024 21:52:12 +0530 Subject: [PATCH] Android: Add app_category "Undefined" --- platform/android/export/export_plugin.cpp | 2 +- platform/android/export/gradle_export_util.cpp | 16 +++++++++++----- platform/android/export/gradle_export_util.h | 1 + 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp index aea09583b76..5c04098c4fe 100644 --- a/platform/android/export/export_plugin.cpp +++ b/platform/android/export/export_plugin.cpp @@ -1898,7 +1898,7 @@ void EditorExportPlatformAndroid::get_export_options(List *r_optio r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/unique_name", PROPERTY_HINT_PLACEHOLDER_TEXT, "ext.domain.name"), "com.example.$genname", false, true)); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/name", PROPERTY_HINT_PLACEHOLDER_TEXT, "Game Name [default if blank]"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "package/signed"), true)); - r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "package/app_category", PROPERTY_HINT_ENUM, "Accessibility,Audio,Game,Image,Maps,News,Productivity,Social,Video"), APP_CATEGORY_GAME)); + r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "package/app_category", PROPERTY_HINT_ENUM, "Accessibility,Audio,Game,Image,Maps,News,Productivity,Social,Video,Undefined"), APP_CATEGORY_GAME)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "package/retain_data_on_uninstall"), false)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "package/exclude_from_recents"), false)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "package/show_in_android_tv"), false)); diff --git a/platform/android/export/gradle_export_util.cpp b/platform/android/export/gradle_export_util.cpp index 9eddef6a4c8..b2aed9a0dcd 100644 --- a/platform/android/export/gradle_export_util.cpp +++ b/platform/android/export/gradle_export_util.cpp @@ -88,6 +88,8 @@ int _get_app_category_value(int category_index) { return 7; case APP_CATEGORY_SOCIAL: return 4; + case APP_CATEGORY_UNDEFINED: + return -1; case APP_CATEGORY_VIDEO: return 2; case APP_CATEGORY_GAME: @@ -311,17 +313,21 @@ String _get_application_tag(const Ref &p_export_platform, " \n\n", + " android:requestLegacyExternalStorage=\"%s\"\n", bool_to_string(p_preset->get("user_data_backup/allow")), - _get_app_category_label(app_category_index), bool_to_string(is_game), bool_to_string(p_preset->get("package/retain_data_on_uninstall")), bool_to_string(p_has_read_write_storage_permission)); + if (app_category_index != APP_CATEGORY_UNDEFINED) { + manifest_application_text += vformat(" android:appCategory=\"%s\"\n", _get_app_category_label(app_category_index)); + manifest_application_text += " tools:replace=\"android:allowBackup,android:appCategory,android:isGame,android:hasFragileUserData,android:requestLegacyExternalStorage\"\n"; + } else { + manifest_application_text += " tools:remove=\"android:appCategory\"\n"; + manifest_application_text += " tools:replace=\"android:allowBackup,android:isGame,android:hasFragileUserData,android:requestLegacyExternalStorage\"\n"; + } + manifest_application_text += " tools:ignore=\"GoogleAppIndexingWarning\">\n\n"; Vector> export_plugins = EditorExport::get_singleton()->get_export_plugins(); for (int i = 0; i < export_plugins.size(); i++) { diff --git a/platform/android/export/gradle_export_util.h b/platform/android/export/gradle_export_util.h index 9f8e476f73f..a17fdf0e270 100644 --- a/platform/android/export/gradle_export_util.h +++ b/platform/android/export/gradle_export_util.h @@ -55,6 +55,7 @@ static const int APP_CATEGORY_NEWS = 5; static const int APP_CATEGORY_PRODUCTIVITY = 6; static const int APP_CATEGORY_SOCIAL = 7; static const int APP_CATEGORY_VIDEO = 8; +static const int APP_CATEGORY_UNDEFINED = 9; // Supported XR modes. // This should match the entries in 'platform/android/java/lib/src/org/godotengine/godot/xr/XRMode.java'