diff --git a/.gitignore b/.gitignore
index 66b3b14..059f321 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,4 @@ bazel-bin
bazel-godot-tts
bazel-out
bazel-testlogs
+*.aar
diff --git a/WORKSPACE b/WORKSPACE
new file mode 100644
index 0000000..b6f6897
--- /dev/null
+++ b/WORKSPACE
@@ -0,0 +1,13 @@
+# Load the Android build rules
+load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
+http_archive(
+ name = "build_bazel_rules_android",
+ urls = ["https://github.com/bazelbuild/rules_android/archive/v0.1.1.zip"],
+ sha256 = "cd06d15dd8bb59926e4d65f9003bfc20f9da4b2519985c27e190cddc8b7a7806",
+ strip_prefix = "rules_android-0.1.1",
+)
+
+# Configure Android SDK Path
+load("@build_bazel_rules_android//android:rules.bzl", "android_sdk_repository", "aar_import", "android_library")
+
+android_sdk_repository(name = "androidsdk")
\ No newline at end of file
diff --git a/src/android/games/lightsout/godot/tts/AndroidManifest.xml b/src/android/games/lightsout/godot/tts/AndroidManifest.xml
new file mode 100644
index 0000000..4112664
--- /dev/null
+++ b/src/android/games/lightsout/godot/tts/AndroidManifest.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/android/games/lightsout/godot/tts/BUILD b/src/android/games/lightsout/godot/tts/BUILD
new file mode 100644
index 0000000..ca92976
--- /dev/null
+++ b/src/android/games/lightsout/godot/tts/BUILD
@@ -0,0 +1,13 @@
+load("@build_bazel_rules_android//android:rules.bzl", "aar_import", "android_library")
+
+aar_import(
+ name = "godot",
+ aar = "godot-lib.3.2.2.stable.release.aar",
+)
+
+android_library(
+ name = "godot_tts",
+ srcs = ["TTS.java"],
+ manifest = "AndroidManifest.xml",
+ deps = [":godot"],
+)
diff --git a/android/src/games/lightsout/godot/tts/TTS.java b/src/android/games/lightsout/godot/tts/TTS.java
similarity index 58%
rename from android/src/games/lightsout/godot/tts/TTS.java
rename to src/android/games/lightsout/godot/tts/TTS.java
index b35fa6f..8d95276 100644
--- a/android/src/games/lightsout/godot/tts/TTS.java
+++ b/src/android/games/lightsout/godot/tts/TTS.java
@@ -1,8 +1,10 @@
package games.lightsout.godot.tts;
+import java.util.Arrays;
import java.util.List;
import org.godotengine.godot.Godot;
+import org.godotengine.godot.plugin.GodotPlugin;
import android.accessibilityservice.AccessibilityServiceInfo;
import android.app.Activity;
@@ -10,13 +12,7 @@ import android.content.Context;
import android.speech.tts.TextToSpeech;
import android.view.accessibility.AccessibilityManager;
-public class TTS extends Godot.SingletonBase implements TextToSpeech.OnInitListener {
-
- protected Activity appActivity;
- protected Context appContext;
- private Godot activity = null;
- private int instanceId = 0;
-
+public class TTS extends GodotPlugin implements TextToSpeech.OnInitListener {
private TextToSpeech tts = null;
private float rate = 1f;
@@ -49,7 +45,7 @@ public class TTS extends Godot.SingletonBase implements TextToSpeech.OnInitListe
}
public boolean has_screen_reader() {
- AccessibilityManager accessibilityManager = (AccessibilityManager) appContext
+ AccessibilityManager accessibilityManager = (AccessibilityManager) getActivity()
.getSystemService(Context.ACCESSIBILITY_SERVICE);
if (accessibilityManager != null) {
List screenReaders = accessibilityManager
@@ -60,29 +56,17 @@ public class TTS extends Godot.SingletonBase implements TextToSpeech.OnInitListe
}
}
- public void getInstanceId(int pInstanceId) {
- // You will need to call this method from Godot and pass in the
- // get_instance_id().
- instanceId = pInstanceId;
+ public TTS(Godot godot) {
+ super(godot);
+ this.tts = new TextToSpeech(this.getActivity(), this);
}
- static public Godot.SingletonBase initialize(Activity p_activity) {
- return new TTS(p_activity);
+ public String getPluginName() {
+ return "GodotTTS";
}
- public TTS(Activity p_activity) {
- this.activity = (Godot) p_activity;
- this.appActivity = p_activity;
- this.appContext = appActivity.getApplicationContext();
- this.tts = new TextToSpeech(this.appContext, this);
- // Register class name and functions to bind.
- registerClass("AndroidTTS", new String[] { "speak", "stop", "get_rate", "set_rate", "has_screen_reader",
- "is_speaking", "getInstanceId" });
- this.activity.runOnUiThread(new Runnable() {
- public void run() {
- }
- });
-
+ public List getPluginMethods() {
+ return Arrays.asList("speak", "stop", "get_rate", "set_rate", "has_screen_reader", "is_speaking");
}
public void onInit(int status) {