From e01a2693d59cc261f69c503910e2e0fb71911161 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9s=20Botero?= <0xafbf@gmail.com>
Date: Mon, 12 Jun 2023 20:50:31 -0500
Subject: [PATCH] Add options to show icon in Android TV and run app as Android
launcher
---
.../EditorExportPlatformAndroid.xml | 6 ++++
platform/android/export/export_plugin.cpp | 2 ++
.../android/export/gradle_export_util.cpp | 31 ++++++++++++-------
3 files changed, 27 insertions(+), 12 deletions(-)
diff --git a/platform/android/doc_classes/EditorExportPlatformAndroid.xml b/platform/android/doc_classes/EditorExportPlatformAndroid.xml
index 9d68cb78f6f..8f843a28e80 100644
--- a/platform/android/doc_classes/EditorExportPlatformAndroid.xml
+++ b/platform/android/doc_classes/EditorExportPlatformAndroid.xml
@@ -104,6 +104,12 @@
If [code]true[/code], when the user uninstalls an app, a prompt to keep the app's data will be shown.
+
+ If [code]true[/code], the user will be able to set this app as the system launcher in Android preferences.
+
+
+ If [code]true[/code], this app will show in Android TV launcher UI.
+
If [code]true[/code], package signing is enabled.
diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp
index 60302396958..7fc35d74aaa 100644
--- a/platform/android/export/export_plugin.cpp
+++ b/platform/android/export/export_plugin.cpp
@@ -1841,6 +1841,8 @@ void EditorExportPlatformAndroid::get_export_options(List *r_optio
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::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));
+ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "package/show_as_launcher_app"), false));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, launcher_icon_option, PROPERTY_HINT_FILE, "*.png"), ""));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, launcher_adaptive_icon_foreground_option, PROPERTY_HINT_FILE, "*.png"), ""));
diff --git a/platform/android/export/gradle_export_util.cpp b/platform/android/export/gradle_export_util.cpp
index ba4487cc4d3..8912877faaf 100644
--- a/platform/android/export/gradle_export_util.cpp
+++ b/platform/android/export/gradle_export_util.cpp
@@ -294,11 +294,12 @@ String _get_activity_tag(const Ref &p_preset, bool p_uses_xr
orientation,
bool_to_string(bool(GLOBAL_GET("display/window/size/resizable"))));
+ manifest_activity_text += " \n"
+ " \n"
+ " \n";
+
if (p_uses_xr) {
- manifest_activity_text += " \n"
- " \n"
- " \n"
- "\n"
+ manifest_activity_text += "\n"
" \n"
" \n"
@@ -308,16 +309,22 @@ String _get_activity_tag(const Ref &p_preset, bool p_uses_xr
" \n"
"\n"
" \n"
- " \n"
- " \n";
- } else {
- manifest_activity_text += " \n"
- " \n"
- " \n"
- " \n";
+ " \n";
}
- manifest_activity_text += " \n";
+ bool uses_leanback_category = p_preset->get("package/show_in_android_tv");
+ if (uses_leanback_category) {
+ manifest_activity_text += " \n";
+ }
+
+ bool uses_home_category = p_preset->get("package/show_as_launcher_app");
+ if (uses_home_category) {
+ manifest_activity_text += " \n";
+ manifest_activity_text += " \n";
+ }
+
+ manifest_activity_text += " \n"
+ " \n";
return manifest_activity_text;
}