MatchActivity almost finished. Started VictoryActivity

This commit is contained in:
adrienmalin 2018-12-04 15:50:07 +01:00
parent f2a2f8859b
commit 46333265bd
18 changed files with 505 additions and 344 deletions

Binary file not shown.

2
.idea/misc.xml generated
View File

@ -29,7 +29,7 @@
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

View File

@ -25,7 +25,7 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'

View File

@ -18,6 +18,7 @@
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
@ -25,6 +26,8 @@
android:name=".MatchActivity"
android:label="@string/title_activity_match">
</activity>
<activity android:name=".VictoryActivity">
</activity>
</application>
</manifest>

View File

@ -7,25 +7,37 @@ import android.view.View
import android.arch.lifecycle.ViewModelProviders
import android.speech.tts.TextToSpeech
import android.support.design.widget.Snackbar
import android.text.method.LinkMovementMethod
import android.view.Menu
import android.view.MenuItem
import android.widget.*
const val REQ_CODE_SPEECH_INPUT = 1
class MatchActivity : AppCompatActivity() {
var matchModel: MatchModel? = null
var textScore: android.widget.TextView? = null
var textService: android.widget.TextView? = null
var buttons: Array<Button> = emptyArray()
var imageViews: Array<ImageView?> = emptyArray()
var matchModel: MatchModel? = null
var tts: TextToSpeech? = null
var undo: MenuItem? = null
var redo: MenuItem? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
setContentView(R.layout.activity_match)
setSupportActionBar(findViewById(R.id.toolbar))
// Set HTML text for icons credits
findViewById<TextView>(R.id.iconsCredit).run {
setText(fromHtml(getString(R.string.iconCredits)))
movementMethod = LinkMovementMethod.getInstance()
}
// Find views
textScore = findViewById(R.id.textScore)
textService = findViewById(R.id.textService)
buttons = arrayOf(
@ -36,75 +48,122 @@ class MatchActivity : AppCompatActivity() {
findViewById(R.id.imgService0),
findViewById(R.id.imgService1)
)
val matchModel = ViewModelProviders.of(this).get(MatchModel::class.java)
if (!matchModel.matchStarted) {
matchModel.startMatch(
intent.getStringExtra("player1Name"),
intent.getStringExtra("player2Name"),
intent.getIntExtra("starterId", 0),
intent.getBooleanExtra("enableTTS", false),
intent.getBooleanExtra("enableSTT", false)
)
if (matchModel.ttsEnabled) {
tts = TextToSpeech(
this,
TextToSpeech.OnInitListener {
fun onInit(status: Int) {}
}
// Init or restore ViewModel
matchModel = ViewModelProviders.of(this).get(MatchModel::class.java)
matchModel?.let {
if (!it.matchStarted) {
it.startMatch(
intent.getStringExtra("player1Name"),
intent.getStringExtra("player2Name"),
intent.getIntExtra("starterId", 0),
intent.getBooleanExtra("enableTTS", false),
intent.getBooleanExtra("enableSTT", false)
)
if (it.ttsEnabled) {
tts = TextToSpeech(
this,
TextToSpeech.OnInitListener {
fun onInit(status: Int) {}
}
)
}
Snackbar.make(
findViewById(R.id.coordinatorLayout),
R.string.button_hint,
Snackbar.LENGTH_SHORT
).show()
}
Snackbar.make(
findViewById(R.id.coordinatorLayout),
R.string.button_hint,
Snackbar.LENGTH_SHORT
).show()
}
updateUI()
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.match_menu, menu)
undo = menu.findItem(R.id.action_undo)
redo = menu.findItem(R.id.action_redo)
return super.onCreateOptionsMenu(menu)
}
override fun onOptionsItemSelected(item: MenuItem) = when (item.itemId) {
R.id.action_undo -> {
matchModel?.undo()
updateUI()
true
}
R.id.action_redo -> {
matchModel?.redo()
updateUI()
true
}
else -> {
super.onOptionsItemSelected(item)
}
}
fun updateUI() {
matchModel?.apply {
textScore?.text = getString(
R.string.score,
players[serviceSide].score,
players[relaunchSide].score
)
textService?.text = getString(R.string.service, players[serviceSide].name)
if (matchFinished) {
for ((button, player) in buttons.zip(players)) {
button.text = fromHtml(getString(R.string.button_text, player.name, player.score))
}
when (serviceSide) {
0 -> {
imageViews[0]?.setImageResource(R.drawable.ic_service_0)
imageViews[1]?.setImageResource(0)
}
else -> {
imageViews[0]?.setImageResource(0)
imageViews[1]?.setImageResource(R.drawable.ic_service_1)
}
}
if (ttsEnabled) {
tts?.speak(
getString(
R.string.update_score_speech,
players[serviceSide].score,
players[relaunchSide].score,
players[serviceSide].name
),
TextToSpeech.QUEUE_FLUSH,
hashMapOf(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID to "MessageId")
} else {
textScore?.text = getString(
R.string.score,
players[serviceSide].score,
players[relaunchSide].score
)
textService?.text = getString(R.string.service, players[serviceSide].name)
for ((button, player) in buttons.zip(players)) {
button.text = fromHtml(getString(R.string.button_text, player.name, player.score))
}
when (serviceSide) {
0 -> {
imageViews[0]?.setImageResource(R.drawable.ic_service_0)
imageViews[1]?.setImageResource(0)
}
else -> {
imageViews[0]?.setImageResource(0)
imageViews[1]?.setImageResource(R.drawable.ic_service_1)
}
}
undo?.isVisible = when (playId) {
0 -> false
else -> true
}
redo?.isVisible = when (playId) {
history.size - 1 -> false
else -> true
}
if (ttsEnabled) {
tts?.speak(
getString(
R.string.update_score_speech,
players[serviceSide].score,
players[relaunchSide].score,
players[serviceSide].name
),
TextToSpeech.QUEUE_FLUSH,
hashMapOf(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID to "MessageId")
)
}
}
}
}
fun updateScore(view: View) {
matchModel?.apply {
if (!matchFinished) {
for (side in 0..1) {
if (view == buttons[side]) {
updateScore(side)
}
}
updateUI()
}
}
}
}

View File

@ -7,21 +7,69 @@ import android.arch.lifecycle.ViewModel
class MatchModel : ViewModel() {
var matchStarted: Boolean = false
var matchFinished: Boolean = false
var players: List<Player> = emptyList()
var serviceSide: Int = 0
var relaunchSide: Int = 1
var ttsEnabled: Boolean = false
var sttEnabled: Boolean = false
var playId: Int = 0
var history: MutableList<Play> = ArrayList()
fun startMatch(player1Name: String, player2Name:String, starterId: Int, enableTTS: Boolean, enableSTT: Boolean) {
matchStarted = true
players = listOf(Player(player1Name), Player(player2Name))
serviceSide = starterId
relaunchSide = when(starterId) {
relaunchSide = when(serviceSide) {
0 -> 1
else -> 0
}
ttsEnabled = enableTTS
sttEnabled = enableSTT
saveState()
}
fun updateScore(scorerId: Int) {
playId++
players[scorerId].score++
if ((players.sumBy { it.score } % 2 == 0) or (players.all { it.score >= 10 })) {
serviceSide = relaunchSide.also { relaunchSide = serviceSide }
}
saveState()
// Is match finished?
val (minScore, maxScore) = players.map { it.score }.sorted()
if ((maxScore >= 11) and (maxScore - minScore >= 2)) matchFinished = true
}
fun saveState() {
val play = Play(players.map { it.score }, serviceSide)
if (playId == history.size) {
history.add(play)
} else {
history[playId] = play
history = history.subList(0, playId+1).toMutableList()
}
}
fun undo() {
playId--
reloadState()
}
fun redo() {
playId++
reloadState()
}
fun reloadState() {
history[playId].let{
players.zip(it.score).forEach{(player, score) -> player.score = score}
serviceSide = it.serviceSide
relaunchSide = when(serviceSide) {
0 -> 1
else -> 0
}
}
}
}

View File

@ -2,5 +2,5 @@ package adrienmalin.pingpoints
data class Play (
val score: List<Int>,
val server: Int
val serviceSide: Int
)

View File

@ -1,6 +1,6 @@
package adrienmalin.pingpoints
data class Player (
var name: String = "",
var name: String,
var score: Int = 0
)

View File

@ -37,11 +37,7 @@ class StarterNameActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_starter_name)
setSupportActionBar(findViewById(R.id.toolbar))
// Set HTML text for icons credits
findViewById<TextView>(R.id.iconsCredit).run {
setText(fromHtml(getString(R.string.iconCredits)))
movementMethod = LinkMovementMethod.getInstance()
}
// Find views
player1NameInput = findViewById(R.id.player1Name)
player2NameInput = findViewById(R.id.player2Name)

View File

@ -0,0 +1,12 @@
package adrienmalin.pingpoints
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
class VictoryActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_victory)
}
}

View File

@ -1,152 +1,165 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
android:id="@+id/coordinatorLayout"
xmlns:tools="http://schemas.android.com/tools" android:id="@+id/coordinatorLayout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<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"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MatchActivity"
tools:layout_editor_absoluteY="73dp">
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_marginBottom="8dp"
android:background="@color/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" android:layout_weight="0"/>
<LinearLayout
android:id="@+id/linearLayoutText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:layout_editor_absoluteY="8dp" android:layout_weight="0">
<TextView
android:id="@+id/textScore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:layout_weight="1"
android:gravity="left"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginRight="8dp" android:text="@string/score"/>
<TextView
android:id="@+id/textService"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_weight="1"
android:gravity="right"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toEndOf="@+id/textScore"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginRight="8dp"
android:layout_marginLeft="8dp" android:text="@string/service"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
android:orientation="horizontal" android:layout_weight="1">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
<ImageView
android:id="@+id/imgService0"
android:layout_width="48dp"
android:layout_margin="8dp"
android:layout_weight="0"
android:contentDescription="@string/service_img_description"
app:srcCompat="@drawable/ic_service_1"
tools:layout_editor_absoluteY="120dp" android:layout_height="match_parent"/>
<Button
android:id="@+id/buttonPlayer0"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_height="match_parent"
android:layout_marginBottom="8dp"
android:background="@color/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_weight="1"
android:background="@color/colorAccent"
android:bufferType="spannable"
android:onClick="updateScore"
android:textAllCaps="false"
android:textAppearance="@style/TextAppearance.AppCompat.Button"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/imgService0"
app:layout_constraintTop_toTopOf="parent"
tools:text="@string/button_text" android:layout_marginRight="8dp"/>
<LinearLayout
android:id="@+id/linearLayoutText"
<Button
android:id="@+id/buttonPlayer1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:layout_editor_absoluteY="8dp">
android:layout_marginTop="8dp"
android:layout_weight="1"
android:background="@color/colorAccent"
android:bufferType="spannable"
android:onClick="updateScore"
android:textAllCaps="false"
android:textAppearance="@style/TextAppearance.AppCompat.Button"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/imgService1"
app:layout_constraintStart_toEndOf="@+id/buttonPlayer0"
tools:text="@string/button_text"/>
<TextView
android:id="@+id/textScore"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:layout_weight="1"
android:gravity="left"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="@string/score" android:layout_marginRight="8dp"/>
<TextView
android:id="@+id/textService"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_weight="1"
android:gravity="right"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toEndOf="@+id/textScore"
app:layout_constraintTop_toTopOf="parent"
tools:text="@string/service" android:layout_marginRight="8dp"
android:layout_marginLeft="8dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
<ImageView
android:id="@+id/imgService1"
android:layout_width="48dp"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="@+id/imgService0"
android:layout_width="48dp"
android:layout_margin="8dp"
android:layout_weight="0"
android:contentDescription="@string/service_img_description"
app:srcCompat="@drawable/ic_service_1"
tools:layout_editor_absoluteY="120dp" android:layout_height="match_parent"/>
<Button
android:id="@+id/buttonPlayer0"
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_weight="1"
android:background="@color/colorAccent"
android:bufferType="spannable"
android:onClick="updateScore"
android:textAllCaps="false"
android:textAppearance="@style/TextAppearance.AppCompat.Button"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/imgService0"
app:layout_constraintTop_toTopOf="parent"
tools:text="@string/button_text" android:layout_marginRight="8dp"/>
<Button
android:id="@+id/buttonPlayer1"
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_weight="1"
android:background="@color/colorAccent"
android:bufferType="spannable"
android:onClick="updateScore"
android:textAllCaps="false"
android:textAppearance="@style/TextAppearance.AppCompat.Button"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/imgService1"
app:layout_constraintStart_toEndOf="@+id/buttonPlayer0"
tools:text="@string/button_text"/>
<ImageView
android:id="@+id/imgService1"
android:layout_width="48dp"
android:layout_height="match_parent"
android:layout_margin="8dp"
android:layout_weight="0"
android:contentDescription="@string/service_img_description"
tools:layout_editor_absoluteY="120dp"/>
</LinearLayout>
android:layout_margin="8dp"
android:layout_weight="0"
android:contentDescription="@string/service_img_description"
tools:layout_editor_absoluteY="120dp"/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_weight="0">
<TextView
android:id="@+id/pingPointsCredit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/PingPointsCredits"
app:layout_constraintTop_toBottomOf="@+id/enableSttSwitch"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="8dp"
android:layout_weight="1" android:layout_margin="8dp" android:gravity="left"/>
<TextView
android:id="@+id/iconsCredit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/iconCredits"
app:layout_constraintTop_toBottomOf="@+id/PingPointsCredit"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp" app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="8dp"
android:layout_weight="1" android:layout_margin="8dp" android:gravity="right"/>
</LinearLayout>
</android.support.constraint.ConstraintLayout>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>

View File

@ -89,23 +89,6 @@
android:layout_marginEnd="8dp" android:layout_marginRight="8dp"
app:layout_constraintStart_toStartOf="parent" android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"/>
<TextView
android:id="@+id/pingPointsCredit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/PingPointsCredits"
app:layout_constraintTop_toBottomOf="@+id/enableSttSwitch" app:layout_constraintStart_toStartOf="parent"
android:layout_marginLeft="8dp" android:layout_marginStart="8dp" app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="8dp" android:layout_marginRight="8dp" android:layout_marginTop="24dp"/>
<TextView
android:id="@+id/iconsCredit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/iconCredits"
app:layout_constraintTop_toBottomOf="@+id/pingPointsCredit"
app:layout_constraintStart_toStartOf="parent" android:layout_marginLeft="8dp"
android:layout_marginStart="8dp" app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"/>
<Button
android:text="@string/start"
android:layout_width="wrap_content"

View File

@ -1,144 +1,148 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
android:id="@+id/coordinatorLayout"
xmlns:tools="http://schemas.android.com/tools" android:id="@+id/coordinatorLayout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<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"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MatchActivity"
tools:layout_editor_absoluteY="73dp">
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_marginBottom="8dp"
android:background="@color/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" android:layout_weight="0"/>
<LinearLayout
android:id="@+id/linearLayoutText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:layout_editor_absoluteY="8dp" android:layout_weight="0">
<TextView
android:id="@+id/textScore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:gravity="left"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginRight="8dp" android:text="@string/score"
android:layout_weight="1"/>
<TextView
android:id="@+id/textService"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toEndOf="@+id/textScore"
app:layout_constraintTop_toTopOf="parent"
android:gravity="right" android:text="@string/service"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
android:orientation="vertical" android:layout_weight="1">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
<ImageView
android:id="@+id/imgService0"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_marginBottom="8dp"
android:background="@color/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
android:layout_height="48dp"
android:layout_margin="8dp"
android:contentDescription="@string/service_img_description"
app:srcCompat="@drawable/ic_service_1"
tools:layout_editor_absoluteY="120dp"/>
<LinearLayout
android:id="@+id/linearLayoutText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:layout_editor_absoluteY="8dp">
<TextView
android:id="@+id/textScore"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:layout_weight="1"
android:gravity="left"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="@string/score" android:layout_marginRight="8dp"/>
<TextView
android:id="@+id/textService"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_weight="1"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toEndOf="@+id/textScore"
app:layout_constraintTop_toTopOf="parent"
tools:text="@string/service" android:gravity="right"/>
</LinearLayout>
<LinearLayout
<Button
android:id="@+id/buttonPlayer0"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
android:layout_marginStart="8dp"
android:background="@color/colorAccent"
android:bufferType="spannable"
android:onClick="updateScore"
android:textAllCaps="false"
android:textAppearance="@style/TextAppearance.AppCompat.Button"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/imgService0"
app:layout_constraintTop_toTopOf="parent"
tools:text="@string/button_text" android:layout_margin="8dp" android:layout_weight="1"/>
<ImageView
android:id="@+id/imgService0"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_margin="8dp"
android:layout_weight="0"
android:contentDescription="@string/service_img_description"
app:srcCompat="@drawable/ic_service_1"
tools:layout_editor_absoluteY="120dp"/>
<Button
android:id="@+id/buttonPlayer1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:background="@color/colorAccent"
android:bufferType="spannable"
android:onClick="updateScore"
android:textAllCaps="false"
android:textAppearance="@style/TextAppearance.AppCompat.Button"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/imgService1"
app:layout_constraintStart_toEndOf="@+id/buttonPlayer0"
tools:text="@string/button_text" android:layout_margin="8dp" android:layout_weight="1"/>
<Button
android:id="@+id/buttonPlayer0"
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="8dp"
android:layout_weight="1"
android:background="@color/colorAccent"
android:bufferType="spannable"
android:onClick="updateScore"
android:textAllCaps="false"
android:textAppearance="@style/TextAppearance.AppCompat.Button"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/imgService0"
app:layout_constraintTop_toTopOf="parent"
tools:text="@string/button_text" android:layout_margin="8dp"/>
<Button
android:id="@+id/buttonPlayer1"
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_weight="1"
android:background="@color/colorAccent"
android:bufferType="spannable"
android:onClick="updateScore"
android:textAllCaps="false"
android:textAppearance="@style/TextAppearance.AppCompat.Button"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/imgService1"
app:layout_constraintStart_toEndOf="@+id/buttonPlayer0"
tools:text="@string/button_text" android:layout_margin="8dp"/>
<ImageView
android:id="@+id/imgService1"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_margin="8dp"
android:layout_weight="0"
android:contentDescription="@string/service_img_description"
tools:layout_editor_absoluteY="120dp"/>
</LinearLayout>
<ImageView
android:id="@+id/imgService1"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_margin="8dp"
android:contentDescription="@string/service_img_description"
tools:layout_editor_absoluteY="120dp"/>
</LinearLayout>
<TextView
android:id="@+id/pingPointsCredit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/PingPointsCredits"
app:layout_constraintTop_toBottomOf="@+id/enableSttSwitch"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginLeft="8dp" android:layout_marginStart="8dp"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="8dp" android:layout_marginRight="8dp" android:layout_marginTop="24dp"
android:layout_weight="0"/>
<TextView
android:id="@+id/iconsCredit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/iconCredits"
app:layout_constraintTop_toBottomOf="@+id/PingPointsCredit"
app:layout_constraintStart_toStartOf="parent" android:layout_marginLeft="8dp"
android:layout_marginStart="8dp" app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp" android:layout_weight="0"/>
</android.support.constraint.ConstraintLayout>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>

View File

@ -106,23 +106,6 @@
app:layout_constraintTop_toBottomOf="@+id/enableTtsSwitch" android:layout_marginStart="8dp"
app:layout_constraintStart_toStartOf="parent" android:layout_marginLeft="8dp" android:layout_marginEnd="8dp"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginRight="8dp"/>
<TextView
android:id="@+id/PingPointsCredit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/PingPointsCredits"
app:layout_constraintTop_toBottomOf="@+id/enableSttSwitch" app:layout_constraintStart_toStartOf="parent"
android:layout_marginLeft="8dp" android:layout_marginStart="8dp" app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="8dp" android:layout_marginRight="8dp" android:layout_marginTop="24dp"/>
<TextView
android:id="@+id/iconsCredit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/iconCredits"
app:layout_constraintTop_toBottomOf="@+id/PingPointsCredit"
app:layout_constraintStart_toStartOf="parent" android:layout_marginLeft="8dp"
android:layout_marginStart="8dp" app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"/>
<Button
android:text="@string/start"
android:layout_width="wrap_content"

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:tools="http://schemas.android.com/tools" android:id="@+id/coordinatorLayout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".VictoryActivity">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_marginBottom="8dp"
android:background="@color/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" android:layout_weight="0"/>
<TextView
android:text="TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" tools:layout_editor_absoluteY="106dp"
tools:layout_editor_absoluteX="57dp" android:id="@+id/textView"/>
</android.support.constraint.ConstraintLayout>
</android.support.design.widget.CoordinatorLayout>

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/action_undo"
android:icon="@drawable/ic_undo"
android:title="@string/undo"
app:showAsAction="ifRoom"
android:visible="false" />
<item
android:id="@+id/action_redo"
android:icon="@drawable/ic_redo"
android:title="@string/redo"
app:showAsAction="ifRoom"
android:visible="false" />
</menu>

View File

@ -9,7 +9,7 @@
<string name="start">Allons-y !</string>
<string name="swap_names">Échanger les noms</string>
<string name="PingPointsCredits">Ping Points par Adrien Malin</string>
<string name="iconCredits">&lt;html&gt;Icônes par &lt;a href=&quot;http://www.freepik.com&quot; title=&quot;Freepik&quot;&gt;Freepik&lt;/a&gt; chez &lt;a href=&quot;https://www.flaticon.com/&quot; title=&quot;Flaticon&quot;&gt;flaticon.com&lt;/a&gt; Licence &lt;a href=&quot;http://creativecommons.org/licenses/by/3.0/&quot; title=&quot;Creative Commons BY 3.0&quot; target=&quot;_blank&quot;&gt;CC 3.0 BY&lt;/a&gt;&lt;/html&gt;</string>
<string name="iconCredits">Icônes par &lt;a href=&quot;http://www.freepik.com&quot; title=&quot;Freepik&quot;&gt;Freepik&lt;/a&gt; chez &lt;a href=&quot;https://www.flaticon.com/&quot; title=&quot;Flaticon&quot;&gt;flaticon.com&lt;/a&gt; Licence &lt;a href=&quot;http://creativecommons.org/licenses/by/3.0/&quot; title=&quot;Creative Commons BY 3.0&quot; target=&quot;_blank&quot;&gt;CC 3.0 BY&lt;/a&gt;</string>
<string name="TTS_unavailable">Désolé, votre appareil ne permet pas la synthèse vocale.</string>
<string name="STT_unavailable">Désolé, votre appareil ne permet pas la reconnaissance vocale.</string>
<string name="explain_record_audio_request">"Cette appli utilise l'API de Google pour la reconnaissance vocale : votre voix sera enregistrée et envoyée aux serveurs de Google pour analyse.
@ -27,4 +27,6 @@ Vous pouvez à tout moment changer la permission dans les paramètres Android."
<string name="title_activity_match">Ping Points</string>
<string name="update_score_speech">%d - %d. Service : %s</string>
<string name="button_hint">Cliquez sur le joueur qui a marqué</string>
<string name="redo">Rétablir</string>
<string name="undo">Annuler</string>
</resources>

View File

@ -8,10 +8,10 @@
<string name="start">Let\'s go!</string>
<string name="swap_names">Swap names</string>
<string name="PingPointsCredits">Ping Points by Adrien Malin</string>
<string name="iconCredits">"&lt;html&gt;Icons made by &lt;a href=&quot;http://www.freepik.com&quot; title=&quot;Freepik&quot;&gt;Freepik&lt;/a&gt;
<string name="iconCredits">Icons made by &lt;a href=&quot;http://www.freepik.com&quot; title=&quot;Freepik&quot;&gt;Freepik&lt;/a&gt;
from &lt;a href=&quot;https://www.flaticon.com/&quot; title=&quot;Flaticon&quot;&gt;flaticon.com&lt;/a&gt; is
licensed by &lt;a href=&quot;http://creativecommons.org/licenses/by/3.0/&quot; title=&quot;Creative Commons BY
3.0&quot; target=&quot;_blank&quot;&gt;CC 3.0 BY&lt;/a&gt;&lt;/html&gt;"
3.0&quot; target=&quot;_blank&quot;&gt;CC 3.0 BY&lt;/a&gt;
</string>
<string name="TTS_unavailable">Sorry, your device doesn\'t support text to speech.</string>
<string name="STT_unavailable">Sorry, your device doesn\'t support voice recognition.</string>
@ -27,8 +27,11 @@
<string name="service">Service: %s</string>
<string name="score">Score: %d - %d</string>
<string name="service_img_description">Service</string>
<string name="button_text" translatable="false">%s &lt;br /&gt; &lt;br /&gt; &lt;big&gt; &lt;big&gt; %d &lt;/big&gt; &lt;/big&gt;
<string name="button_text" translatable="false">%s &lt;br /&gt; &lt;br /&gt; &lt;big&gt; &lt;big&gt; %d &lt;/big&gt;
&lt;/big&gt;
</string>
<string name="update_score_speech">%d - %d. Service: %s</string>
<string name="button_hint">Click on the scoring player</string>
<string name="undo">Undo</string>
<string name="redo">Redo</string>
</resources>