Make AndroidManifest.xml more configurable.
Now if you need to add something to the `<application />` or `<activity />` tags, you can do it from project.xml. This will require new documentation, however.
This commit is contained in:
@@ -170,6 +170,32 @@ abstract ConfigData(Dynamic) to Dynamic from Dynamic
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public function getKeyValueArray(id:String, defaultValues:Dynamic = null):Array<{ key:Dynamic, value:Dynamic }>
|
||||
{
|
||||
var values = {};
|
||||
if (defaultValues != null)
|
||||
{
|
||||
ObjectTools.copyFields(defaultValues, values);
|
||||
}
|
||||
|
||||
var data = get(id);
|
||||
for (key in Reflect.fields(data))
|
||||
{
|
||||
if (!StringTools.endsWith (key, ARRAY))
|
||||
{
|
||||
Reflect.setField(values, key, Reflect.field(data, key));
|
||||
}
|
||||
}
|
||||
|
||||
var pairs = [];
|
||||
for (key in Reflect.fields(values))
|
||||
{
|
||||
pairs.push({ key: key, value: Reflect.field(values, key) });
|
||||
}
|
||||
|
||||
return pairs;
|
||||
}
|
||||
|
||||
private function log(v:Dynamic):Void
|
||||
{
|
||||
if (Log.verbose)
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
::foreach ANDROID_PERMISSIONS::<uses-permission android:name="::__current__::" />
|
||||
::end::
|
||||
|
||||
<application android:label="::APP_TITLE::" ::if (HAS_ICON):: android:icon="@drawable/icon"::end:: android:allowBackup="true" android:theme="@android:style/Theme.NoTitleBar::if (WIN_FULLSCREEN)::.Fullscreen::end::" android:hardwareAccelerated="true" ::if (ANDROID_TARGET_SDK_VERSION>=30):: android:allowNativeHeapPointerTagging="false" ::end::>
|
||||
<application ::foreach ANDROID_APPLICATION::::if (value)::::key::="::value::" ::end::::end::>
|
||||
|
||||
::if (WIN_ORIENTATION=="portrait")::
|
||||
<meta-data android:name="SDL_ENV.SDL_IOS_ORIENTATIONS" android:value= "Portrait PortraitUpsideDown" />
|
||||
@@ -17,7 +17,7 @@
|
||||
<meta-data android:name="SDL_ENV.SDL_IOS_ORIENTATIONS" android:value= "LandscapeLeft LandscapeRight" />
|
||||
::end::
|
||||
|
||||
<activity android:name="MainActivity" android:exported="true" android:launchMode="singleTask" android:label="::APP_TITLE::" android:configChanges="keyboardHidden|orientation|screenSize|screenLayout|uiMode"::if (WIN_ORIENTATION=="portrait"):: android:screenOrientation="sensorPortrait"::end::::if (WIN_ORIENTATION=="landscape"):: android:screenOrientation="sensorLandscape"::end::>
|
||||
<activity ::foreach ANDROID_ACTIVITY::::if (value)::::key::="::value::" ::end::::end::>
|
||||
|
||||
<intent-filter>
|
||||
|
||||
|
||||
@@ -464,6 +464,22 @@ class AndroidPlatform extends PlatformTarget
|
||||
context.ANDROID_USE_ANDROIDX = project.config.getString("android.useAndroidX", "true");
|
||||
context.ANDROID_ENABLE_JETIFIER = project.config.getString("android.enableJetifier", "false");
|
||||
|
||||
context.ANDROID_APPLICATION = project.config.getKeyValueArray("android.application", {
|
||||
"android:label": project.meta.title,
|
||||
"android:allowBackup": "true",
|
||||
"android:theme": "@android:style/Theme.NoTitleBar" + (project.window.fullscreen ? ".Fullscreen" : null),
|
||||
"android:hardwareAccelerated": "true",
|
||||
"android:allowNativeHeapPointerTagging": context.ANDROID_TARGET_SDK_VERSION >= 30 ? "false" : null
|
||||
});
|
||||
context.ANDROID_ACTIVITY = project.config.getKeyValueArray("android.activity", {
|
||||
"android:name": "MainActivity",
|
||||
"android:exported": "true",
|
||||
"android:launchMode": "singleTask",
|
||||
"android:label": project.meta.title,
|
||||
"android:configChanges": project.config.getArrayString("android.configChanges", ["keyboardHidden", "orientation", "screenSize", "screenLayout", "uiMode"]).join("|"),
|
||||
"android:screenOrientation": project.window.orientation == PORTRAIT ? "sensorPortrait" : (project.window.orientation == LANDSCAPE ? "sensorLandscape" : null)
|
||||
});
|
||||
|
||||
context.ANDROID_LIBRARY_PROJECTS = [];
|
||||
|
||||
if (!project.environment.exists("ANDROID_SDK") || !project.environment.exists("ANDROID_NDK_ROOT"))
|
||||
@@ -531,12 +547,24 @@ class AndroidPlatform extends PlatformTarget
|
||||
{
|
||||
icons = [new Icon(System.findTemplate(project.templatePaths, "default/icon.svg"))];
|
||||
}
|
||||
|
||||
for (i in 0...iconTypes.length)
|
||||
{
|
||||
if (IconHelper.createIcon(icons, iconSizes[i], iconSizes[i], sourceSet + "/res/drawable-" + iconTypes[i] + "/icon.png"))
|
||||
if (IconHelper.createIcon(icons, iconSizes[i], iconSizes[i], sourceSet + "/res/drawable-" + iconTypes[i] + "/icon.png") && context.HAS_ICON == null)
|
||||
{
|
||||
context.HAS_ICON = true;
|
||||
for (attribute in context.ANDROID_APPLICATION)
|
||||
{
|
||||
if (attribute.key == "android:icon")
|
||||
{
|
||||
context.HAS_ICON = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (context.HAS_ICON == null)
|
||||
{
|
||||
context.HAS_ICON = true;
|
||||
context.ANDROID_APPLICATION.push({ key: "android:icon", value: "@drawable/icon" });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user