Fix Android build errors.

This commit is contained in:
Nolan Darilek 2020-05-28 12:05:21 -05:00
parent fefa09779d
commit d7e768e0f4

View File

@ -1,10 +1,15 @@
package games.lightsout.godot.tts; package games.lightsout.godot.tts;
import java.util.List;
import android.accessibilityservice.AccessibilityServiceInfo;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.content.Context; import android.content.Context;
import android.speech.tts.TextToSpeech; import android.speech.tts.TextToSpeech;
import android.util.Log; import android.util.Log;
import android.view.accessibility.AccessibilityManager;
import com.godot.game.R; import com.godot.game.R;
import javax.microedition.khronos.opengles.GL10; import javax.microedition.khronos.opengles.GL10;
import org.godotengine.godot.Godot; import org.godotengine.godot.Godot;
@ -18,6 +23,8 @@ public class TTS extends Godot.SingletonBase implements TextToSpeech.OnInitListe
private TextToSpeech tts = null; private TextToSpeech tts = null;
private float rate = 1f;
private Integer utteranceId = 0; private Integer utteranceId = 0;
public void speak(String text, boolean interrupt) { public void speak(String text, boolean interrupt) {
@ -33,13 +40,24 @@ public class TTS extends Godot.SingletonBase implements TextToSpeech.OnInitListe
} }
public float get_rate() { public float get_rate() {
return tts.getSpeechRate(); return this.rate;
} }
public void set_rate(Float rate) { public void set_rate(Float rate) {
this.rate = rate;
tts.setSpeechRate(rate); tts.setSpeechRate(rate);
} }
public boolean has_screen_reader() {
AccessibilityManager accessibilityManager = (AccessibilityManager) appContext
.getSystemService(Context.ACCESSIBILITY_SERVICE);
if (accessibilityManager != null) {
List<AccessibilityServiceInfo> screenReaders =accessibilityManager.getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_SPOKEN);
return screenReaders.size() != 0;
} else
return false;
}
public void getInstanceId(int pInstanceId) { public void getInstanceId(int pInstanceId) {
// You will need to call this method from Godot and pass in the // You will need to call this method from Godot and pass in the
// get_instance_id(). // get_instance_id().