From f36245d21dcfde7766c4f1d4db57fa2cc7c89c6c Mon Sep 17 00:00:00 2001 From: Antonio Date: Mon, 27 Nov 2023 17:25:11 +0800 Subject: [PATCH] feat: Support setting the horizontal and vertical screen orientation in the plugin's AndroidManifest. fix: fix format-code fix: fix format-code --- .../sample-app/src/main/AndroidManifest.xml | 1 + .../core/loader/delegates/ShadowActivityDelegate.kt | 3 +++ .../shadow/core/manifest_parser/AndroidManifestKeys.kt | 1 + .../core/manifest_parser/AndroidManifestReader.kt | 1 + .../core/manifest_parser/PluginManifestGenerator.kt | 10 ++++++++-- .../tencent/shadow/core/runtime/PluginManifest.java | 7 ++++++- 6 files changed, 20 insertions(+), 3 deletions(-) diff --git a/projects/sample/source/sample-plugin/sample-app/src/main/AndroidManifest.xml b/projects/sample/source/sample-plugin/sample-app/src/main/AndroidManifest.xml index abac57e88..2d20257c4 100644 --- a/projects/sample/source/sample-plugin/sample-app/src/main/AndroidManifest.xml +++ b/projects/sample/source/sample-plugin/sample-app/src/main/AndroidManifest.xml @@ -24,6 +24,7 @@ activityMap.putAttributeIfNotNull(element, attributeKey) } diff --git a/projects/sdk/core/manifest-parser/src/main/kotlin/com/tencent/shadow/core/manifest_parser/PluginManifestGenerator.kt b/projects/sdk/core/manifest-parser/src/main/kotlin/com/tencent/shadow/core/manifest_parser/PluginManifestGenerator.kt index b6a7c5b8a..0a84018c3 100644 --- a/projects/sdk/core/manifest-parser/src/main/kotlin/com/tencent/shadow/core/manifest_parser/PluginManifestGenerator.kt +++ b/projects/sdk/core/manifest-parser/src/main/kotlin/com/tencent/shadow/core/manifest_parser/PluginManifestGenerator.kt @@ -183,13 +183,14 @@ private class PluginManifestBuilder(val manifestMap: ManifestMap) { private fun toNewActivityInfo(componentMap: ComponentMap): String { fun makeResIdLiteral( key: String, + defaultValue: String = "0", valueToResId: (value: String) -> String ): String { val value = componentMap[key] as String? val literal = if (value != null) { valueToResId(value) } else { - "0" + defaultValue } return literal } @@ -204,12 +205,17 @@ private class PluginManifestBuilder(val manifestMap: ManifestMap) { it } + val screenOrientation = makeResIdLiteral(AndroidManifestKeys.screenOrientation, "-1") { + it + } + return "new com.tencent.shadow.core.runtime.PluginManifest" + ".ActivityInfo(" + "\"${componentMap[AndroidManifestKeys.name]}\", " + "$themeLiteral ," + "$configChangesLiteral ," + - softInputModeLiteral + + "$softInputModeLiteral ," + + screenOrientation + ")" } diff --git a/projects/sdk/core/runtime/src/main/java/com/tencent/shadow/core/runtime/PluginManifest.java b/projects/sdk/core/runtime/src/main/java/com/tencent/shadow/core/runtime/PluginManifest.java index 67f8a31c0..f8acdf7ea 100644 --- a/projects/sdk/core/runtime/src/main/java/com/tencent/shadow/core/runtime/PluginManifest.java +++ b/projects/sdk/core/runtime/src/main/java/com/tencent/shadow/core/runtime/PluginManifest.java @@ -70,15 +70,18 @@ final class ActivityInfo extends ComponentInfo implements Parcelable { public final int theme; public final int configChanges; public final int softInputMode; + public final int screenOrientation; public ActivityInfo(String className, int theme, int configChanges, - int softInputMode) { + int softInputMode, + int screenOrientation) { super(className); this.theme = theme; this.configChanges = configChanges; this.softInputMode = softInputMode; + this.screenOrientation = screenOrientation; } protected ActivityInfo(Parcel in) { @@ -86,6 +89,7 @@ protected ActivityInfo(Parcel in) { theme = in.readInt(); configChanges = in.readInt(); softInputMode = in.readInt(); + screenOrientation = in.readInt(); } @Override @@ -94,6 +98,7 @@ public void writeToParcel(Parcel dest, int flags) { dest.writeInt(theme); dest.writeInt(configChanges); dest.writeInt(softInputMode); + dest.writeInt(screenOrientation); } @Override