From d7e768e0f43ee212969eb669bbffc8607f370660 Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Thu, 28 May 2020 12:05:21 -0500 Subject: [PATCH] Fix Android build errors. --- .../src/games/lightsout/godot/tts/TTS.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/android/src/games/lightsout/godot/tts/TTS.java b/android/src/games/lightsout/godot/tts/TTS.java index 14b182f..16b8590 100644 --- a/android/src/games/lightsout/godot/tts/TTS.java +++ b/android/src/games/lightsout/godot/tts/TTS.java @@ -1,10 +1,15 @@ package games.lightsout.godot.tts; +import java.util.List; + +import android.accessibilityservice.AccessibilityServiceInfo; import android.app.Activity; import android.content.Intent; import android.content.Context; import android.speech.tts.TextToSpeech; import android.util.Log; +import android.view.accessibility.AccessibilityManager; + import com.godot.game.R; import javax.microedition.khronos.opengles.GL10; import org.godotengine.godot.Godot; @@ -18,6 +23,8 @@ public class TTS extends Godot.SingletonBase implements TextToSpeech.OnInitListe private TextToSpeech tts = null; + private float rate = 1f; + private Integer utteranceId = 0; public void speak(String text, boolean interrupt) { @@ -33,13 +40,24 @@ public class TTS extends Godot.SingletonBase implements TextToSpeech.OnInitListe } public float get_rate() { - return tts.getSpeechRate(); + return this.rate; } public void set_rate(Float rate) { + this.rate = rate; tts.setSpeechRate(rate); } + public boolean has_screen_reader() { + AccessibilityManager accessibilityManager = (AccessibilityManager) appContext + .getSystemService(Context.ACCESSIBILITY_SERVICE); + if (accessibilityManager != null) { + List screenReaders =accessibilityManager.getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_SPOKEN); + return screenReaders.size() != 0; + } else + return false; + } + public void getInstanceId(int pInstanceId) { // You will need to call this method from Godot and pass in the // get_instance_id().