STT
This commit is contained in:
		| @ -5,18 +5,22 @@ import android.support.v7.app.AppCompatActivity | |||||||
| import android.support.v7.app.AppCompatDelegate | import android.support.v7.app.AppCompatDelegate | ||||||
| import android.view.View | import android.view.View | ||||||
| import android.arch.lifecycle.ViewModelProviders | import android.arch.lifecycle.ViewModelProviders | ||||||
|  | import android.content.ActivityNotFoundException | ||||||
| import android.content.Intent | import android.content.Intent | ||||||
|  | import android.speech.RecognizerIntent | ||||||
| import android.speech.tts.TextToSpeech | import android.speech.tts.TextToSpeech | ||||||
| import android.support.design.widget.Snackbar | import android.support.design.widget.Snackbar | ||||||
| import android.text.method.LinkMovementMethod | import android.text.method.LinkMovementMethod | ||||||
| import android.view.Menu | import android.view.Menu | ||||||
| import android.view.MenuItem | import android.view.MenuItem | ||||||
| import android.widget.* | import android.widget.* | ||||||
|  | import java.util.* | ||||||
| const val REQ_CODE_SPEECH_INPUT = 1 | import java.util.regex.Pattern | ||||||
|  |  | ||||||
|  |  | ||||||
| class MatchActivity : AppCompatActivity() { | class MatchActivity : AppCompatActivity() { | ||||||
|  |     val REQ_CODE_SPEECH_INPUT = 1 | ||||||
|  |  | ||||||
|     var matchModel: MatchModel? = null |     var matchModel: MatchModel? = null | ||||||
|     var textScore: android.widget.TextView? = null |     var textScore: android.widget.TextView? = null | ||||||
|     var textService: android.widget.TextView? = null |     var textService: android.widget.TextView? = null | ||||||
| @ -63,15 +67,16 @@ class MatchActivity : AppCompatActivity() { | |||||||
|                         getBooleanExtra("enableSTT", false) |                         getBooleanExtra("enableSTT", false) | ||||||
|                     ) |                     ) | ||||||
|                 } |                 } | ||||||
|                 if (it.ttsEnabled) { |  | ||||||
|                     tts = TextToSpeech(this, TextToSpeech.OnInitListener { fun onInit(status: Int) {} }) |  | ||||||
|                 } |  | ||||||
|                 Snackbar.make( |                 Snackbar.make( | ||||||
|                     findViewById(R.id.coordinatorLayout), |                     findViewById(R.id.coordinatorLayout), | ||||||
|                     R.string.button_hint, |                     R.string.button_hint, | ||||||
|                     Snackbar.LENGTH_SHORT |                     Snackbar.LENGTH_SHORT | ||||||
|                 ).show() |                 ).show() | ||||||
|             } |             } | ||||||
|  |             if (it.ttsEnabled) { | ||||||
|  |                 tts = TextToSpeech(this, TextToSpeech.OnInitListener { fun onInit(status: Int) {} }) | ||||||
|  |                 if (it.sttEnabled) tts?.setOnUtteranceProgressListener(WaitForTTS(::launchStt)) | ||||||
|  |             } | ||||||
|         } |         } | ||||||
|         updateUI() |         updateUI() | ||||||
|     } |     } | ||||||
| @ -100,19 +105,19 @@ class MatchActivity : AppCompatActivity() { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     fun updateUI() { |     fun updateUI() { | ||||||
|         matchModel?.let { |         matchModel?.apply { | ||||||
|             textScore?.text = getString( |             textScore?.text = getString( | ||||||
|                 R.string.score, |                 R.string.score, | ||||||
|                 it.players[it.serviceSide].score, |                 players[serviceSide].score, | ||||||
|                 it.players[it.relaunchSide].score |                 players[relaunchSide].score | ||||||
|             ) |             ) | ||||||
|             textService?.text = getString(R.string.service, it.players[it.serviceSide].name) |             textService?.text = getString(R.string.service, players[serviceSide].name) | ||||||
|  |  | ||||||
|             for ((button, player) in buttons.zip(it.players)) { |             for ((button, player) in buttons.zip(players)) { | ||||||
|                 button.text = fromHtml(getString(R.string.button_text, player.name, player.score)) |                 button.text = fromHtml(getString(R.string.button_text, player.name, player.score)) | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             when (it.serviceSide) { |             when (serviceSide) { | ||||||
|                 0 -> { |                 0 -> { | ||||||
|                     imageViews[0]?.setImageResource(R.drawable.ic_service_0) |                     imageViews[0]?.setImageResource(R.drawable.ic_service_0) | ||||||
|                     imageViews[1]?.setImageResource(0) |                     imageViews[1]?.setImageResource(0) | ||||||
| @ -123,18 +128,26 @@ class MatchActivity : AppCompatActivity() { | |||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             undo?.isVisible = when (it.playId) { |             undo?.isVisible = when (playId) { | ||||||
|                 0 -> false |                 0 -> false | ||||||
|                 else -> true |                 else -> true | ||||||
|             } |             } | ||||||
|             redo?.isVisible = when (it.playId) { |             redo?.isVisible = when (playId) { | ||||||
|                 it.history.size - 1 -> false |                 history.size - 1 -> false | ||||||
|                 else -> true |                 else -> true | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             if (it.ttsEnabled) { |             if (ttsEnabled) ttsSpeak() | ||||||
|                 if (it.matchFinished()) { |  | ||||||
|                     val (loser, winner) = it.players.sortedBy { player -> player.score } |             if (matchFinished()) endMatch() | ||||||
|  |             else if (sttEnabled and !ttsEnabled) launchStt() | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     fun ttsSpeak() { | ||||||
|  |         matchModel?.apply { | ||||||
|  |             if (matchFinished()) { | ||||||
|  |                 val (loser, winner) = players.sortedBy { it.score } | ||||||
|                 tts?.speak( |                 tts?.speak( | ||||||
|                     getString( |                     getString( | ||||||
|                         R.string.victory_speech, |                         R.string.victory_speech, | ||||||
| @ -149,14 +162,14 @@ class MatchActivity : AppCompatActivity() { | |||||||
|                 tts?.speak( |                 tts?.speak( | ||||||
|                     getString( |                     getString( | ||||||
|                         R.string.update_score_speech, |                         R.string.update_score_speech, | ||||||
|                             it.players[it.serviceSide].score, |                         players[serviceSide].score, | ||||||
|                             it.players[it.relaunchSide].score, |                         players[relaunchSide].score, | ||||||
|                             it.players[it.serviceSide].name |                         players[serviceSide].name | ||||||
|                     ), |                     ), | ||||||
|                     TextToSpeech.QUEUE_FLUSH, |                     TextToSpeech.QUEUE_FLUSH, | ||||||
|                     hashMapOf(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID to "MessageId") |                     hashMapOf(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID to "MessageId") | ||||||
|                 ) |                 ) | ||||||
|                     if (it.matchPoint()) { |                 if (matchPoint()) { | ||||||
|                     tts?.speak( |                     tts?.speak( | ||||||
|                         getString(R.string.match_point), |                         getString(R.string.match_point), | ||||||
|                         TextToSpeech.QUEUE_ADD, |                         TextToSpeech.QUEUE_ADD, | ||||||
| @ -165,8 +178,57 @@ class MatchActivity : AppCompatActivity() { | |||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|             if (it.matchFinished()) endMatch() |     fun launchStt() { | ||||||
|  |         matchModel?.apply { | ||||||
|  |             if (sttEnabled) { | ||||||
|  |                 val intent = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH) | ||||||
|  |                 intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM) | ||||||
|  |                 intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault().getDisplayLanguage()) | ||||||
|  |                 intent.putExtra( | ||||||
|  |                     RecognizerIntent.EXTRA_PROMPT, | ||||||
|  |                     getString( | ||||||
|  |                         R.string.STT_hint, | ||||||
|  |                         players[0].name, | ||||||
|  |                         players[1].name | ||||||
|  |                     ) | ||||||
|  |                 ) | ||||||
|  |                 try { | ||||||
|  |                     startActivityForResult(intent, REQ_CODE_SPEECH_INPUT); | ||||||
|  |                 } catch (e: ActivityNotFoundException) { | ||||||
|  |                     sttEnabled = false | ||||||
|  |                     Snackbar.make( | ||||||
|  |                         findViewById(R.id.coordinatorLayout), | ||||||
|  |                         R.string.STT_unavailable, | ||||||
|  |                         Snackbar.LENGTH_SHORT | ||||||
|  |                     ).show() | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { | ||||||
|  |         super.onActivityResult(requestCode, resultCode, data) | ||||||
|  |         when (requestCode) { | ||||||
|  |             REQ_CODE_SPEECH_INPUT -> { | ||||||
|  |                 matchModel?.let { | ||||||
|  |                     var understood: Boolean = false | ||||||
|  |                     if (resultCode == RESULT_OK && data != null) { | ||||||
|  |                         val result: String = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS)[0] | ||||||
|  |                         for (player in it.players) { | ||||||
|  |                             if (Pattern.compile(getString(R.string.pattern, player.name)).matcher(result).find()) { | ||||||
|  |                                 it.updateScore(player) | ||||||
|  |                                 understood = true | ||||||
|  |                                 break | ||||||
|  |                             } | ||||||
|  |                         } | ||||||
|  |                     } | ||||||
|  |                     if (!understood) launchStt() | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             else -> { | ||||||
|  |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @ -175,7 +237,7 @@ class MatchActivity : AppCompatActivity() { | |||||||
|             if (!matchFinished()) { |             if (!matchFinished()) { | ||||||
|                 for (side in 0..1) { |                 for (side in 0..1) { | ||||||
|                     if (view == buttons[side]) { |                     if (view == buttons[side]) { | ||||||
|                         updateScore(side) |                         updateScore(players[side]) | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|                 updateUI() |                 updateUI() | ||||||
| @ -189,8 +251,9 @@ class MatchActivity : AppCompatActivity() { | |||||||
|                 Intent(this, VictoryActivity::class.java).apply { |                 Intent(this, VictoryActivity::class.java).apply { | ||||||
|                     putExtra("winnerName", it.players.maxBy{ player -> player.score }?.name) |                     putExtra("winnerName", it.players.maxBy{ player -> player.score }?.name) | ||||||
|                     putExtra("player1Name", it.players[0].name) |                     putExtra("player1Name", it.players[0].name) | ||||||
|  |                     putExtra("player1Score", it.players[0].score) | ||||||
|                     putExtra("player2Name", it.players[1].name) |                     putExtra("player2Name", it.players[1].name) | ||||||
|                     putExtra("score", getString(R.string.score_only, it.players[0].score, it.players[1].score)) |                     putExtra("player2Score", it.players[1].score) | ||||||
|                 } |                 } | ||||||
|             ) |             ) | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -15,7 +15,7 @@ class MatchModel : ViewModel() { | |||||||
|  |  | ||||||
|     fun startMatch(player1Name: String, player2Name:String, starterId: Int, enableTTS: Boolean, enableSTT: Boolean) { |     fun startMatch(player1Name: String, player2Name:String, starterId: Int, enableTTS: Boolean, enableSTT: Boolean) { | ||||||
|         matchStarted = true |         matchStarted = true | ||||||
|         players = listOf(Player(player1Name), Player(player2Name)) |         players = listOf(Player(player1Name, 0), Player(player2Name, 0)) | ||||||
|         serviceSide = starterId |         serviceSide = starterId | ||||||
|         relaunchSide = when(serviceSide) { |         relaunchSide = when(serviceSide) { | ||||||
|             0 -> 1 |             0 -> 1 | ||||||
| @ -26,9 +26,9 @@ class MatchModel : ViewModel() { | |||||||
|         saveState() |         saveState() | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     fun updateScore(scorerId: Int) { |     fun updateScore(scorer: player) { | ||||||
|         playId++ |         playId++ | ||||||
|         players[scorerId].score++ |         scorer.score++ | ||||||
|         if ((players.sumBy { it.score } % 2 == 0) or (players.all { it.score >= 10 })) { |         if ((players.sumBy { it.score } % 2 == 0) or (players.all { it.score >= 10 })) { | ||||||
|             serviceSide = relaunchSide.also { relaunchSide = serviceSide } |             serviceSide = relaunchSide.also { relaunchSide = serviceSide } | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -2,5 +2,5 @@ package adrienmalin.pingpoints | |||||||
|  |  | ||||||
| data class Player ( | data class Player ( | ||||||
|     var name: String, |     var name: String, | ||||||
|     var score: Int = 0 |     var score: Int | ||||||
| ) | ) | ||||||
| @ -14,16 +14,14 @@ import android.support.v4.app.ActivityCompat | |||||||
| import android.support.v4.content.ContextCompat | import android.support.v4.content.ContextCompat | ||||||
| import android.support.v7.app.AlertDialog | import android.support.v7.app.AlertDialog | ||||||
| import android.support.v7.app.AppCompatActivity | import android.support.v7.app.AppCompatActivity | ||||||
| import android.text.method.LinkMovementMethod |  | ||||||
| import android.view.View | import android.view.View | ||||||
| import android.widget.* | import android.widget.* | ||||||
|  |  | ||||||
|  |  | ||||||
| const val CHECK_TTS = 1 |  | ||||||
| const val ASK_PERMISSIONS_RECORD_AUDIO = 2 |  | ||||||
|  |  | ||||||
|  |  | ||||||
| class StarterNameActivity : AppCompatActivity() { | class StarterNameActivity : AppCompatActivity() { | ||||||
|  |     val CHECK_TTS = 1 | ||||||
|  |     val ASK_PERMISSIONS_RECORD_AUDIO = 2 | ||||||
|  |  | ||||||
|     var player1NameInput: AutoCompleteTextView? = null |     var player1NameInput: AutoCompleteTextView? = null | ||||||
|     var player2NameInput: AutoCompleteTextView? = null |     var player2NameInput: AutoCompleteTextView? = null | ||||||
|     var starterRadioGroup: RadioGroup? = null |     var starterRadioGroup: RadioGroup? = null | ||||||
|  | |||||||
| @ -31,9 +31,16 @@ class VictoryActivity : AppCompatActivity() { | |||||||
|             if (!it.matchFinished) { |             if (!it.matchFinished) { | ||||||
|                 it.matchFinished = true |                 it.matchFinished = true | ||||||
|                 it.winnerName = intent.getStringExtra("winnerName") |                 it.winnerName = intent.getStringExtra("winnerName") | ||||||
|                 it.player1Name = intent.getStringExtra("player1Name") |                 it.players = listOf( | ||||||
|                 it.player2Name = intent.getStringExtra("player2Name") |                     Player( | ||||||
|                 it.score = intent.getStringExtra("score") |                         intent.getStringExtra("player1Name"), | ||||||
|  |                         intent.getIntExtra("player1Score", 0) | ||||||
|  |                     ), | ||||||
|  |                     Player( | ||||||
|  |                         intent.getStringExtra("player2Name"), | ||||||
|  |                         intent.getIntExtra("player2Score", 0) | ||||||
|  |                     ) | ||||||
|  |                 ) | ||||||
|  |  | ||||||
|                 it.previousMatches = previousMatch.getString("previousMatches", "") |                 it.previousMatches = previousMatch.getString("previousMatches", "") | ||||||
|                 previousMatch.edit().apply { |                 previousMatch.edit().apply { | ||||||
| @ -41,10 +48,11 @@ class VictoryActivity : AppCompatActivity() { | |||||||
|                         "previousMatches", |                         "previousMatches", | ||||||
|                         getString( |                         getString( | ||||||
|                             R.string.result, |                             R.string.result, | ||||||
|                             it.player1Name, |                             it.players[0].name, | ||||||
|                             it.score, |                             it.players[0].score, | ||||||
|                             it.player2Name |                             it.players[1].score, | ||||||
|                         ) + '\n' + it.previousMatches |                             it.players[1].name | ||||||
|  |                         ) + it.previousMatches | ||||||
|                     ) |                     ) | ||||||
|                     commit() |                     commit() | ||||||
|                 } |                 } | ||||||
| @ -54,12 +62,18 @@ class VictoryActivity : AppCompatActivity() { | |||||||
|             findViewById<TextView>(R.id.congrats).text = getString(R.string.congrats, it.winnerName) |             findViewById<TextView>(R.id.congrats).text = getString(R.string.congrats, it.winnerName) | ||||||
|             findViewById<GridView>(R.id.resultGrid).adapter = ArrayAdapter<String>( |             findViewById<GridView>(R.id.resultGrid).adapter = ArrayAdapter<String>( | ||||||
|                 this, |                 this, | ||||||
|                 android.R.layout.simple_list_item_1, |                 R.layout.grid_item, | ||||||
|                 arrayOf(it.player1Name, it.score, it.player2Name) |                 R.id.grid_item_text, | ||||||
|  |                 arrayOf<String>( | ||||||
|  |                     it.players[0].name, | ||||||
|  |                     it.players[0].score.toString() + " - " + it.players[1].score.toString(), | ||||||
|  |                     it.players[1].name | ||||||
|  |                 ) | ||||||
|             ) |             ) | ||||||
|             findViewById<GridView>(R.id.previousMatchesGrid).adapter = ArrayAdapter<String>( |             findViewById<GridView>(R.id.previousMatchesGrid).adapter = ArrayAdapter<String>( | ||||||
|                 this, |                 this, | ||||||
|                 android.R.layout.simple_list_item_1, |                 R.layout.grid_item, | ||||||
|  |                 R.id.grid_item_text, | ||||||
|                 it.previousMatches.split("\t|\n".toRegex()) |                 it.previousMatches.split("\t|\n".toRegex()) | ||||||
|             ) |             ) | ||||||
|         } |         } | ||||||
| @ -80,18 +94,19 @@ class VictoryActivity : AppCompatActivity() { | |||||||
|                         Intent.EXTRA_SUBJECT, |                         Intent.EXTRA_SUBJECT, | ||||||
|                         getString( |                         getString( | ||||||
|                             R.string.share_subject, |                             R.string.share_subject, | ||||||
|                             it.player1Name, |                             it.players[0].name, | ||||||
|                             it.player2Name |                             it.players[1].name | ||||||
|                         ) |                         ) | ||||||
|                     ) |                     ) | ||||||
|                     putExtra( |                     putExtra( | ||||||
|                         Intent.EXTRA_TEXT, |                         Intent.EXTRA_TEXT, | ||||||
|                         getString( |                         getString( | ||||||
|                             R.string.share_message, |                             R.string.share_message, | ||||||
|                             it.player1Name, |                             it.players[0].name, | ||||||
|                             it.player2Name, |                             it.players[1].name, | ||||||
|                             it.winnerName, |                             it.winnerName, | ||||||
|                             it.score |                             it.players[0].score, | ||||||
|  |                             it.players[1].score | ||||||
|                         ) |                         ) | ||||||
|                     ) |                     ) | ||||||
|                     type = "text/plain" |                     type = "text/plain" | ||||||
|  | |||||||
| @ -5,8 +5,6 @@ import android.arch.lifecycle.ViewModel | |||||||
| class VictoryModel : ViewModel() { | class VictoryModel : ViewModel() { | ||||||
|     var matchFinished: Boolean = false |     var matchFinished: Boolean = false | ||||||
|     var winnerName:String = "" |     var winnerName:String = "" | ||||||
|     var player1Name = "" |     var players: List<Player> = emptyList() | ||||||
|     var player2Name = "" |  | ||||||
|     var score = "" |  | ||||||
|     var previousMatches: String = "" |     var previousMatches: String = "" | ||||||
| } | } | ||||||
							
								
								
									
										11
									
								
								app/src/main/java/adrienmalin/pingpoints/WaitForTts.kt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								app/src/main/java/adrienmalin/pingpoints/WaitForTts.kt
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,11 @@ | |||||||
|  | package adrienmalin.pingpoints | ||||||
|  |  | ||||||
|  | import android.speech.tts.UtteranceProgressListener | ||||||
|  |  | ||||||
|  | class WaitForTTS(val callback: () -> Unit) : UtteranceProgressListener() { | ||||||
|  |     override fun onDone(id: String) { | ||||||
|  |         callback() | ||||||
|  |     } | ||||||
|  |     override fun onStart(id: String) {} | ||||||
|  |     override fun onError(id: String) {} | ||||||
|  | } | ||||||
| @ -88,7 +88,6 @@ | |||||||
|                     android:layout_marginStart="8dp" |                     android:layout_marginStart="8dp" | ||||||
|                     android:layout_marginTop="8dp" |                     android:layout_marginTop="8dp" | ||||||
|                     android:layout_weight="1" |                     android:layout_weight="1" | ||||||
|                     android:background="@color/colorAccent" |  | ||||||
|                     android:bufferType="spannable" |                     android:bufferType="spannable" | ||||||
|                     android:onClick="updateScore" |                     android:onClick="updateScore" | ||||||
|                     android:textAllCaps="false" |                     android:textAllCaps="false" | ||||||
| @ -98,7 +97,8 @@ | |||||||
|                     app:layout_constraintBottom_toBottomOf="parent" |                     app:layout_constraintBottom_toBottomOf="parent" | ||||||
|                     app:layout_constraintStart_toEndOf="@+id/imgService0" |                     app:layout_constraintStart_toEndOf="@+id/imgService0" | ||||||
|                     app:layout_constraintTop_toTopOf="parent" |                     app:layout_constraintTop_toTopOf="parent" | ||||||
|                     tools:text="@string/button_text" android:layout_marginRight="8dp"/> |                     tools:text="@string/button_text" android:layout_marginRight="8dp" | ||||||
|  |                     android:theme="@style/ScoreButton"/> | ||||||
|  |  | ||||||
|             <Button |             <Button | ||||||
|                     android:id="@+id/buttonPlayer1" |                     android:id="@+id/buttonPlayer1" | ||||||
| @ -111,7 +111,6 @@ | |||||||
|                     android:layout_marginStart="8dp" |                     android:layout_marginStart="8dp" | ||||||
|                     android:layout_marginTop="8dp" |                     android:layout_marginTop="8dp" | ||||||
|                     android:layout_weight="1" |                     android:layout_weight="1" | ||||||
|                     android:background="@color/colorAccent" |  | ||||||
|                     android:bufferType="spannable" |                     android:bufferType="spannable" | ||||||
|                     android:onClick="updateScore" |                     android:onClick="updateScore" | ||||||
|                     android:textAllCaps="false" |                     android:textAllCaps="false" | ||||||
| @ -121,7 +120,7 @@ | |||||||
|                     app:layout_constraintBottom_toBottomOf="parent" |                     app:layout_constraintBottom_toBottomOf="parent" | ||||||
|                     app:layout_constraintEnd_toStartOf="@+id/imgService1" |                     app:layout_constraintEnd_toStartOf="@+id/imgService1" | ||||||
|                     app:layout_constraintStart_toEndOf="@+id/buttonPlayer0" |                     app:layout_constraintStart_toEndOf="@+id/buttonPlayer0" | ||||||
|                     tools:text="@string/button_text"/> |                     tools:text="@string/button_text" android:theme="@style/ScoreButton"/> | ||||||
|  |  | ||||||
|             <ImageView |             <ImageView | ||||||
|                     android:id="@+id/imgService1" |                     android:id="@+id/imgService1" | ||||||
|  | |||||||
| @ -82,7 +82,6 @@ | |||||||
|                     android:layout_width="match_parent" |                     android:layout_width="match_parent" | ||||||
|                     android:layout_height="match_parent" |                     android:layout_height="match_parent" | ||||||
|                     android:layout_marginStart="8dp" |                     android:layout_marginStart="8dp" | ||||||
|                     android:background="@color/colorAccent" |  | ||||||
|                     android:bufferType="spannable" |                     android:bufferType="spannable" | ||||||
|                     android:onClick="updateScore" |                     android:onClick="updateScore" | ||||||
|                     android:textAllCaps="false" |                     android:textAllCaps="false" | ||||||
| @ -92,7 +91,9 @@ | |||||||
|                     app:layout_constraintBottom_toBottomOf="parent" |                     app:layout_constraintBottom_toBottomOf="parent" | ||||||
|                     app:layout_constraintStart_toEndOf="@+id/imgService0" |                     app:layout_constraintStart_toEndOf="@+id/imgService0" | ||||||
|                     app:layout_constraintTop_toTopOf="parent" |                     app:layout_constraintTop_toTopOf="parent" | ||||||
|                     tools:text="@string/button_text" android:layout_margin="8dp" android:layout_weight="1"/> |                     tools:text="@string/button_text" android:layout_margin="8dp" android:layout_weight="1" | ||||||
|  |                     android:clickable="true" android:focusableInTouchMode="true" | ||||||
|  |                     android:theme="@style/ScoreButton"/> | ||||||
|  |  | ||||||
|             <Button |             <Button | ||||||
|                     android:id="@+id/buttonPlayer1" |                     android:id="@+id/buttonPlayer1" | ||||||
| @ -100,7 +101,6 @@ | |||||||
|                     android:layout_height="match_parent" |                     android:layout_height="match_parent" | ||||||
|                     android:layout_marginEnd="8dp" |                     android:layout_marginEnd="8dp" | ||||||
|                     android:layout_marginStart="8dp" |                     android:layout_marginStart="8dp" | ||||||
|                     android:background="@color/colorAccent" |  | ||||||
|                     android:bufferType="spannable" |                     android:bufferType="spannable" | ||||||
|                     android:onClick="updateScore" |                     android:onClick="updateScore" | ||||||
|                     android:textAllCaps="false" |                     android:textAllCaps="false" | ||||||
| @ -110,7 +110,9 @@ | |||||||
|                     app:layout_constraintBottom_toBottomOf="parent" |                     app:layout_constraintBottom_toBottomOf="parent" | ||||||
|                     app:layout_constraintEnd_toStartOf="@+id/imgService1" |                     app:layout_constraintEnd_toStartOf="@+id/imgService1" | ||||||
|                     app:layout_constraintStart_toEndOf="@+id/buttonPlayer0" |                     app:layout_constraintStart_toEndOf="@+id/buttonPlayer0" | ||||||
|                     tools:text="@string/button_text" android:layout_margin="8dp" android:layout_weight="1"/> |                     tools:text="@string/button_text" android:layout_margin="8dp" android:layout_weight="1" | ||||||
|  |                     android:clickable="true" android:focusableInTouchMode="true" | ||||||
|  |                     android:theme="@style/ScoreButton"/> | ||||||
|  |  | ||||||
|             <ImageView |             <ImageView | ||||||
|                     android:id="@+id/imgService1" |                     android:id="@+id/imgService1" | ||||||
|  | |||||||
| @ -37,11 +37,13 @@ | |||||||
|         <GridView |         <GridView | ||||||
|                 android:layout_width="0dp" |                 android:layout_width="0dp" | ||||||
|                 android:layout_height="wrap_content" |                 android:layout_height="wrap_content" | ||||||
|                 app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp" |                 android:layout_marginTop="16dp" | ||||||
|                 android:layout_marginRight="8dp" app:layout_constraintStart_toStartOf="parent" |  | ||||||
|                 android:layout_marginLeft="8dp" android:layout_marginStart="8dp" android:layout_marginTop="8dp" |  | ||||||
|                 app:layout_constraintTop_toBottomOf="@+id/congrats" android:id="@+id/resultGrid" |                 app:layout_constraintTop_toBottomOf="@+id/congrats" android:id="@+id/resultGrid" | ||||||
|                 android:numColumns="3"/> |                 android:numColumns="3" | ||||||
|  |                 android:textFilterEnabled="false" android:gravity="center" app:layout_constraintStart_toStartOf="parent" | ||||||
|  |                 android:layout_marginLeft="24dp" android:layout_marginStart="24dp" | ||||||
|  |                 app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="24dp" | ||||||
|  |                 android:layout_marginRight="24dp"/> | ||||||
|         <TextView |         <TextView | ||||||
|                 android:text="@string/previous_matches" |                 android:text="@string/previous_matches" | ||||||
|                 android:layout_width="wrap_content" |                 android:layout_width="wrap_content" | ||||||
| @ -71,12 +73,16 @@ | |||||||
|                 android:drawableStart="@drawable/ic_share" android:onClick="share"/> |                 android:drawableStart="@drawable/ic_share" android:onClick="share"/> | ||||||
|         <GridView |         <GridView | ||||||
|                 android:layout_width="0dp" |                 android:layout_width="0dp" | ||||||
|                 android:layout_height="0dp" app:layout_constraintEnd_toEndOf="parent" |                 android:layout_height="wrap_content" | ||||||
|                 app:layout_constraintStart_toStartOf="parent" android:layout_marginTop="8dp" |                 android:layout_marginTop="8dp" | ||||||
|                 app:layout_constraintTop_toBottomOf="@+id/textView3" android:layout_marginLeft="8dp" |                 app:layout_constraintTop_toBottomOf="@+id/textView3" | ||||||
|                 android:layout_marginStart="8dp" android:layout_marginEnd="8dp" android:layout_marginRight="8dp" |  | ||||||
|                 android:layout_marginBottom="8dp" app:layout_constraintBottom_toBottomOf="parent" |                 android:layout_marginBottom="8dp" app:layout_constraintBottom_toBottomOf="parent" | ||||||
|                 android:numColumns="5" android:id="@+id/previousMatchesGrid" android:clickable="false"/> |                 android:numColumns="3" android:id="@+id/previousMatchesGrid" android:clickable="false" | ||||||
|  |                 android:gravity="center" app:layout_constraintVertical_bias="0.0" | ||||||
|  |                 app:layout_constraintStart_toStartOf="parent" | ||||||
|  |                 android:layout_marginLeft="8dp" android:layout_marginStart="8dp" | ||||||
|  |                 android:layout_marginEnd="8dp" app:layout_constraintEnd_toEndOf="parent" | ||||||
|  |                 android:layout_marginRight="8dp"/> | ||||||
|  |  | ||||||
|     </android.support.constraint.ConstraintLayout> |     </android.support.constraint.ConstraintLayout> | ||||||
|  |  | ||||||
|  | |||||||
							
								
								
									
										14
									
								
								app/src/main/res/layout/grid_item.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								app/src/main/res/layout/grid_item.xml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,14 @@ | |||||||
|  | <?xml version="1.0" encoding="utf-8"?> | ||||||
|  | <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||||||
|  |                                              xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" | ||||||
|  |                                              android:layout_height="match_parent"> | ||||||
|  |  | ||||||
|  |     <TextView | ||||||
|  |             android:text="TextView" | ||||||
|  |             android:layout_width="0dp" | ||||||
|  |             android:layout_height="wrap_content" tools:layout_editor_absoluteY="254dp" | ||||||
|  |             android:id="@+id/grid_item_text" android:gravity="center" app:layout_constraintEnd_toEndOf="parent" | ||||||
|  |             android:layout_marginEnd="8dp" android:layout_marginRight="8dp" | ||||||
|  |             app:layout_constraintStart_toStartOf="parent" android:layout_marginLeft="8dp" | ||||||
|  |             android:layout_marginStart="8dp"/> | ||||||
|  | </android.support.constraint.ConstraintLayout> | ||||||
| @ -35,7 +35,8 @@ Vous pouvez à tout moment changer la permission dans les paramètres Android." | |||||||
|     <string name="share">Partager</string> |     <string name="share">Partager</string> | ||||||
|     <string name="victory_speech">%s gagne par %d à %d.</string> |     <string name="victory_speech">%s gagne par %d à %d.</string> | ||||||
|     <string name="share_subject">Match Ping Points : %s contre %s</string> |     <string name="share_subject">Match Ping Points : %s contre %s</string> | ||||||
|     <string name="share_message">"%s contre %s:\n%s a gagné par %s\nPing Points est disponible sur Google Play\n "</string> |     <string name="share_message">"%s contre %s:\n%s a gagné par %d à %d\nPing Points est disponible sur Google Play\n "</string> | ||||||
|     <string name="score_only">%d - %d</string> |  | ||||||
|     <string name="match_point">Balle de match</string> |     <string name="match_point">Balle de match</string> | ||||||
|  |     <string name="STT_hint">Dîtes : \"Point pour %s\"\nou \"Point pour %s\"</string> | ||||||
|  |     <string name="pattern">Point pour %s</string> | ||||||
| </resources> | </resources> | ||||||
| @ -38,10 +38,11 @@ | |||||||
|     <string name="previous_matches">Previous matches</string> |     <string name="previous_matches">Previous matches</string> | ||||||
|     <string name="new_match">New match</string> |     <string name="new_match">New match</string> | ||||||
|     <string name="share">Share</string> |     <string name="share">Share</string> | ||||||
|     <string name="result" translatable="false">"%s\t%s\t%s"</string> |     <string name="result" translatable="false">"%s\t%d - %d\t%s\n"</string> | ||||||
|     <string name="victory_speech">%s wins by %d to %d.</string> |     <string name="victory_speech">%s wins by %d to %d.</string> | ||||||
|     <string name="share_subject">Ping Points Match: %s vs. %s</string> |     <string name="share_subject">Ping Points Match: %s vs. %s</string> | ||||||
|     <string name="share_message">%s vs. %s:\n%s won by %s\nGet Ping Points on Google Play</string> |     <string name="share_message">%s vs. %s:\n%s won by %d to %d\nGet Ping Points on Google Play</string> | ||||||
|     <string name="score_only">"%d\t-\t%d"</string> |  | ||||||
|     <string name="match_point">Match point</string> |     <string name="match_point">Match point</string> | ||||||
|  |     <string name="STT_hint">Say: \"Point for %s\"\nor \"Point for %s\"</string> | ||||||
|  |     <string name="pattern">Point for %s</string> | ||||||
| </resources> | </resources> | ||||||
|  | |||||||
| @ -3,4 +3,7 @@ | |||||||
|     <style name="AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> |     <style name="AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> | ||||||
|  |  | ||||||
|     <style name="PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> |     <style name="PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> | ||||||
|  |     <style name="ScoreButton"> | ||||||
|  |         <item name="colorButtonNormal">@color/colorAccent</item> | ||||||
|  |     </style> | ||||||
| </resources> | </resources> | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user