|
@@ -44,8 +44,6 @@ import androidx.annotation.Nullable;
|
|
import java.lang.reflect.Constructor;
|
|
import java.lang.reflect.Constructor;
|
|
import java.lang.reflect.InvocationTargetException;
|
|
import java.lang.reflect.InvocationTargetException;
|
|
import java.util.Collection;
|
|
import java.util.Collection;
|
|
-import java.util.HashSet;
|
|
|
|
-import java.util.Set;
|
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -57,13 +55,6 @@ public final class GodotPluginRegistry {
|
|
|
|
|
|
private static final String GODOT_PLUGIN_V1_NAME_PREFIX = "org.godotengine.plugin.v1.";
|
|
private static final String GODOT_PLUGIN_V1_NAME_PREFIX = "org.godotengine.plugin.v1.";
|
|
|
|
|
|
- /**
|
|
|
|
- * Name for the metadata containing the list of Godot plugins to enable.
|
|
|
|
- */
|
|
|
|
- private static final String GODOT_ENABLED_PLUGINS_LABEL = "plugins";
|
|
|
|
-
|
|
|
|
- private static final String PLUGIN_VALUE_SEPARATOR_REGEX = "\\|";
|
|
|
|
-
|
|
|
|
private static GodotPluginRegistry instance;
|
|
private static GodotPluginRegistry instance;
|
|
private final ConcurrentHashMap<String, GodotPlugin> registry;
|
|
private final ConcurrentHashMap<String, GodotPlugin> registry;
|
|
|
|
|
|
@@ -133,37 +124,11 @@ public final class GodotPluginRegistry {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- // When using the Godot editor for building and exporting the apk, this is used to check
|
|
|
|
- // which plugins to enable.
|
|
|
|
- // When using a custom process to generate the apk, the metadata is not needed since
|
|
|
|
- // it's assumed that the developer is aware of the dependencies included in the apk.
|
|
|
|
- final Set<String> enabledPluginsSet;
|
|
|
|
- if (metaData.containsKey(GODOT_ENABLED_PLUGINS_LABEL)) {
|
|
|
|
- String enabledPlugins = metaData.getString(GODOT_ENABLED_PLUGINS_LABEL, "");
|
|
|
|
- String[] enabledPluginsList = enabledPlugins.split(PLUGIN_VALUE_SEPARATOR_REGEX);
|
|
|
|
- if (enabledPluginsList.length == 0) {
|
|
|
|
- // No plugins to enable. Aborting early.
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- enabledPluginsSet = new HashSet<>();
|
|
|
|
- for (String enabledPlugin : enabledPluginsList) {
|
|
|
|
- enabledPluginsSet.add(enabledPlugin.trim());
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- enabledPluginsSet = null;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
int godotPluginV1NamePrefixLength = GODOT_PLUGIN_V1_NAME_PREFIX.length();
|
|
int godotPluginV1NamePrefixLength = GODOT_PLUGIN_V1_NAME_PREFIX.length();
|
|
for (String metaDataName : metaData.keySet()) {
|
|
for (String metaDataName : metaData.keySet()) {
|
|
// Parse the meta-data looking for entry with the Godot plugin name prefix.
|
|
// Parse the meta-data looking for entry with the Godot plugin name prefix.
|
|
if (metaDataName.startsWith(GODOT_PLUGIN_V1_NAME_PREFIX)) {
|
|
if (metaDataName.startsWith(GODOT_PLUGIN_V1_NAME_PREFIX)) {
|
|
String pluginName = metaDataName.substring(godotPluginV1NamePrefixLength).trim();
|
|
String pluginName = metaDataName.substring(godotPluginV1NamePrefixLength).trim();
|
|
- if (enabledPluginsSet != null && !enabledPluginsSet.contains(pluginName)) {
|
|
|
|
- Log.w(TAG, "Plugin " + pluginName + " is listed in the dependencies but is not enabled.");
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
Log.i(TAG, "Initializing Godot plugin " + pluginName);
|
|
Log.i(TAG, "Initializing Godot plugin " + pluginName);
|
|
|
|
|
|
// Retrieve the plugin class full name.
|
|
// Retrieve the plugin class full name.
|
|
@@ -178,8 +143,7 @@ public final class GodotPluginRegistry {
|
|
.getConstructor(Godot.class);
|
|
.getConstructor(Godot.class);
|
|
GodotPlugin pluginHandle = pluginConstructor.newInstance(godot);
|
|
GodotPlugin pluginHandle = pluginConstructor.newInstance(godot);
|
|
|
|
|
|
- // Load the plugin initializer into the registry using the plugin name
|
|
|
|
- // as key.
|
|
|
|
|
|
+ // Load the plugin initializer into the registry using the plugin name as key.
|
|
if (!pluginName.equals(pluginHandle.getPluginName())) {
|
|
if (!pluginName.equals(pluginHandle.getPluginName())) {
|
|
Log.w(TAG,
|
|
Log.w(TAG,
|
|
"Meta-data plugin name does not match the value returned by the plugin handle: " + pluginName + " =/= " + pluginHandle.getPluginName());
|
|
"Meta-data plugin name does not match the value returned by the plugin handle: " + pluginName + " =/= " + pluginHandle.getPluginName());
|