From 6f787eb276cf038ee91256ab15bfb9cc961a1ee0 Mon Sep 17 00:00:00 2001
From: Mirko Galimberti <me@mirkogalimberti.com>
Date: Wed, 19 Aug 2020 18:25:30 +0200
Subject: [PATCH] Add manifestPlaceholders feature

---
 buildozer/default.spec       | 6 ++++++
 buildozer/targets/android.py | 6 ++++++
 2 files changed, 12 insertions(+)

diff --git a/buildozer/default.spec b/buildozer/default.spec
index 612f79e2f..d9976f5bd 100644
--- a/buildozer/default.spec
+++ b/buildozer/default.spec
@@ -231,6 +231,12 @@ android.arch = armeabi-v7a
 # (bool) enables Android auto backup feature (Android API >=23)
 android.allow_backup = True
 
+# (str) If you need to insert variables into your AndroidManifest.xml file,
+# you can do so with the manifestPlaceholders property.
+# This property takes a map of key-value pairs. (via a string)
+# Usage example : android.manifest_placeholders = [myCustomUrl:\"org.kivy.customurl\"]
+# android.manifest_placeholders = [:]
+
 #
 # Python for android (p4a) specific
 #
diff --git a/buildozer/targets/android.py b/buildozer/targets/android.py
index 6d9be36ad..a1a7b6723 100644
--- a/buildozer/targets/android.py
+++ b/buildozer/targets/android.py
@@ -891,6 +891,12 @@ def execute_build_package(self, build_cmd):
             cmd.append('--depend')
             cmd.append(gradle_dependency)
 
+        # support for manifestPlaceholders
+        manifest_placeholders = self.buildozer.config.getdefault('app', 'android.manifest_placeholders', '[:]')
+        if manifest_placeholders:
+            cmd.append('--manifest-placeholders')
+            cmd.append("{}".format(manifest_placeholders))
+
         cmd.append('--arch')
         cmd.append(self._arch)