mirror of
https://github.com/lightsoutgames/godot-tts
synced 2024-11-08 17:55:56 +00:00
Add Bazel build for standalone Android plugin.
This commit is contained in:
parent
b78848f583
commit
e0f419aaf6
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -5,3 +5,4 @@ bazel-bin
|
|||
bazel-godot-tts
|
||||
bazel-out
|
||||
bazel-testlogs
|
||||
*.aar
|
||||
|
|
13
WORKSPACE
Normal file
13
WORKSPACE
Normal file
|
@ -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")
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="games.lightsout.godot.tts">
|
||||
<application>
|
||||
<meta-data android:name="org.godotengine.plugin.v1.GodotTTS" android:value="games.lightsout.godot.tts.TTS" />
|
||||
</application>
|
||||
</manifest>
|
13
src/android/games/lightsout/godot/tts/BUILD
Normal file
13
src/android/games/lightsout/godot/tts/BUILD
Normal file
|
@ -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"],
|
||||
)
|
|
@ -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<AccessibilityServiceInfo> 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<String> getPluginMethods() {
|
||||
return Arrays.asList("speak", "stop", "get_rate", "set_rate", "has_screen_reader", "is_speaking");
|
||||
}
|
||||
|
||||
public void onInit(int status) {
|
Loading…
Reference in New Issue
Block a user