This commit is contained in:
adrienmalin 2018-12-06 23:57:45 +01:00
parent 0bfb13f678
commit ff57c29ce1
3 changed files with 31 additions and 35 deletions

View File

@ -131,7 +131,7 @@ class MatchActivity : AppCompatActivity() {
if (matchFinished) { if (matchFinished) {
val (loser, winner) = players.sortedBy { it.score } val (loser, winner) = players.sortedBy { it.score }
if (sttEnabled) { if (ttsEnabled) {
speakText( speakText(
getString( getString(
R.string.victory_speech, R.string.victory_speech,

View File

@ -36,6 +36,7 @@ class SttDialog : DialogFragment() {
} }
override fun onPartialResults(data: Bundle) { override fun onPartialResults(data: Bundle) {
if (!data.isEmpty)
partialResultsTextView?.text = data.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION)[0] partialResultsTextView?.text = data.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION)[0]
} }
@ -77,18 +78,15 @@ class SttDialog : DialogFragment() {
} }
override fun onCreateDialog(savedInstanceState: Bundle?) = AlertDialog.Builder(activity).apply { override fun onCreateDialog(savedInstanceState: Bundle?) = AlertDialog.Builder(activity).apply {
val view: View = (context?.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater).inflate( (context?.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater).inflate(R.layout.dialog_stt, null). apply {
R.layout.dialog_stt, partialResultsTextView = findViewById(R.id.partialResultTextView)
null icStt = findViewById(R.id.icStt)
)
partialResultsTextView = view.findViewById(R.id.partialResultTextView)
icStt = view.findViewById(R.id.icStt)
setView(view) setView(this)
matchActivity = (activity as MatchActivity).apply { matchActivity = (activity as MatchActivity).apply {
matchModel?.apply { matchModel?.apply {
view.findViewById<TextView>(R.id.sttHintTextView).text = getString( findViewById<TextView>(R.id.sttHintTextView).text = getString(
R.string.STT_hint, R.string.STT_hint,
players[0].name, players[0].name,
players[1].name players[1].name
@ -112,6 +110,7 @@ class SttDialog : DialogFragment() {
} }
} }
} }
}
}.create()!! }.create()!!
override fun onStop() { override fun onStop() {

View File

@ -40,9 +40,6 @@
<string name="STT_hint">Say: \"Point for %s\"\nor \"Point for %s\"</string> <string name="STT_hint">Say: \"Point for %s\"\nor \"Point for %s\"</string>
<string name="pattern">(?i:Point for %s)</string> <string name="pattern">(?i:Point for %s)</string>
<string name="not_understood">Can you repeat, please?</string> <string name="not_understood">Can you repeat, please?</string>
<string name="score" translatable="false">%d - %d</string> <string name="score" translatable="false">%2d - %2d</string>
<string name="STT_disabled">Voice recognition disabled.</string> <string name="STT_disabled">Voice recognition disabled.</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
</resources> </resources>