start MatchActivity

This commit is contained in:
adrienmalin 2018-12-03 17:43:27 +01:00
parent 83d50e6294
commit ef230d5520
15 changed files with 714 additions and 250 deletions

Binary file not shown.

View File

@ -24,10 +24,14 @@ android {
}
dependencies {
def lifecycle_version = "2.0.0"
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
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 "androidx.lifecycle:lifecycle-extensions-ktx:$lifecycle_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

View File

@ -1,26 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="adrienmalin.pingpoints" >
package="adrienmalin.pingpoints">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:logo="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat"
>
<activity
android:name=".StarterNameActivity"
android:windowSoftInputMode="adjustResize" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:logo="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.NoActionBar">
<activity
android:name=".StarterNameActivity"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name=".MatchActivity"
android:label="@string/title_activity_match">
</activity>
</application>
</manifest>

View File

@ -0,0 +1,24 @@
package adrienmalin.pingpoints
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.support.v7.app.AppCompatDelegate
import android.view.View
import android.arch.lifecycle.ViewModelProviders
class MatchActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
setContentView(R.layout.activity_match)
setSupportActionBar(findViewById(R.id.toolbar))
val matchModel = ViewModelProviders.of(this).get(MatchModel::class.java)
}
fun updateScore(view: View) {
}
}

View File

@ -3,8 +3,15 @@ package adrienmalin.pingpoints
import android.arch.lifecycle.ViewModel
class MatchModel : ViewModel() {
var players: List<Player> = listOf(Player(), Player())
var server: Int = 0
var ttsEnabled: Boolean = false
var sttEnabled: Boolean = false
lateinit var players: List<Player>
lateinit var server: Int
lateinit var ttsEnabled: Boolean
lateinit var sttEnabled: Boolean
fun startMatch(player1Name: String, player2Name:String, starterId: Int, enableTTS: Boolean, enableSTT: Boolean) {
players = listOf(Player(player1Name), Player(player2Name))
server = starterId
ttsEnabled = enableTTS
sttEnabled = enableSTT
}
}

View File

@ -1,19 +1,26 @@
package adrienmalin.pingpoints
import android.Manifest
import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent
import android.content.SharedPreferences
import android.support.v7.app.AppCompatActivity
import android.content.pm.PackageManager
import android.os.Bundle
import android.speech.SpeechRecognizer
import android.speech.tts.TextToSpeech
import android.support.design.widget.Snackbar
import android.support.v4.app.ActivityCompat
import android.support.v4.content.ContextCompat
import android.support.v7.app.AlertDialog
import android.support.v7.app.AppCompatActivity
import android.text.method.LinkMovementMethod
import android.view.View
import android.widget.*
import android.speech.tts.TextToSpeech
import android.content.Intent
import android.speech.SpeechRecognizer
val CHECK_TTS = 1
const val CHECK_TTS = 1
const val ASK_PERMISSIONS_RECORD_AUDIO = 2
class StarterNameActivity : AppCompatActivity() {
@ -29,23 +36,21 @@ class StarterNameActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
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 {
setHtmlText(getString(R.string.iconCredits))
movementMethod = LinkMovementMethod.getInstance()
}
// Find views
player1NameInput = findViewById(R.id.player1Name)
player2NameInput = findViewById(R.id.player2Name)
starterRadioGroup = findViewById(R.id.starterRadioGroup)
enableTtsSwitch = findViewById(R.id.enableTtsSwitch)
enableSttSwitch = findViewById(R.id.enableSttSwitch)
// Check if function is available on switch checked or swapped
enableTtsSwitch?.setOnCheckedChangeListener { view, isChecked -> checkTTS() }
enableTtsSwitch?.setOnTouchListener { view, event -> checkTTS(); false}
enableSttSwitch?.setOnCheckedChangeListener { view, isChecked -> checkSTT() }
enableSttSwitch?.setOnTouchListener { view, event -> checkSTT(); false}
@ -94,15 +99,18 @@ class StarterNameActivity : AppCompatActivity() {
when (requestCode) {
CHECK_TTS -> {
if (resultCode != TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) {
Toast.makeText(applicationContext, R.string.TTS_unavailable, Toast.LENGTH_LONG).show()
Snackbar.make(
findViewById(R.id.coordinatorLayout),
R.string.TTS_unavailable,
Snackbar.LENGTH_SHORT
).show()
enableTtsSwitch?.isChecked = false
Intent().run {
action = TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA
startActivity(this)
}
}
}
else -> {
} else -> {
}
}
}
@ -111,28 +119,93 @@ class StarterNameActivity : AppCompatActivity() {
enableSttSwitch?.let {
if (it.isChecked) {
if (!SpeechRecognizer.isRecognitionAvailable(this)) {
Toast.makeText(applicationContext, R.string.STT_unavailable, Toast.LENGTH_LONG).show()
it.isChecked = false
Snackbar.make(
findViewById(R.id.coordinatorLayout),
R.string.STT_unavailable,
Snackbar.LENGTH_SHORT
).show()
enableSttSwitch?.isChecked = false
} else {
// Ask for record audio permission
if (ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) {
// Permission is not granted
// Should we show an explanation?
if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.RECORD_AUDIO)) {
AlertDialog.Builder(this)
.setTitle(R.string.STT)
.setMessage(R.string.explain_record_audio_request)
.setPositiveButton(R.string.OK) { dialog, id ->
ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.RECORD_AUDIO), ASK_PERMISSIONS_RECORD_AUDIO)
}
.setNegativeButton(R.string.cancel) { dialog, id ->
enableSttSwitch?.isChecked = false
}
.create()
.show()
} else {
// No explanation needed, we can request the permission.
ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.RECORD_AUDIO), ASK_PERMISSIONS_RECORD_AUDIO)
}
}
}
}
}
}
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
when (requestCode) {
ASK_PERMISSIONS_RECORD_AUDIO -> {
// If request is cancelled, the result arrays are empty.
if ((grantResults.isNotEmpty() && grantResults[0] != PackageManager.PERMISSION_GRANTED)) {
// permission denied
Snackbar.make(
findViewById(R.id.coordinatorLayout),
R.string.audio_record_permission_denied,
Snackbar.LENGTH_LONG
).show()
enableSttSwitch?.isChecked = false
}
return
} else -> {
}
}
}
fun startMatch(view: View) {
val player1Name = player1NameInput?.text.toString()
val player2Name = player2NameInput?.text.toString()
val radioStarterId = starterRadioGroup?.checkedRadioButtonId
val enableTTS = enableTtsSwitch?.isChecked
val enableSTT = enableSttSwitch?.isChecked
// Save
previousMatch?.edit()?.run{
putString("previousPlayer1", player1Name)
putString("previousPlayer2", player2Name)
starterRadioGroup?.let{ putInt("previousStarterId", it.checkedRadioButtonId) }
previousPlayers?.let { putStringSet("previousPlayers", it.plus(player1Name).plus(player2Name)) }
enableTtsSwitch?.let { putBoolean("enableTTS", it.isChecked) }
enableSttSwitch?.let { putBoolean("enableSTT", it.isChecked) }
previousMatch?.edit()?.apply{
player1Name.let { putString("previousPlayer1", it) }
player2Name.let { putString("previousPlayer2", it) }
radioStarterId?.let{ putInt("previousStarterId", it) }
putStringSet("previousPlayers", previousPlayers.plus(player1Name).plus(player2Name))
enableTTS?.let { putBoolean("enableTTS", it) }
enableSTT?.let { putBoolean("enableSTT", it) }
commit()
}
startActivity(
Intent(this, MatchActivity::class.java).apply {
putExtra("player1Name", player1Name)
putExtra("player2Name", player2Name)
putExtra(
"starterId",
when(radioStarterId) {
R.id.radioPlayer1Starts -> 0
R.id.radioPlayer2Starts -> 1
else -> 0
}
)
putExtra("enableTTS", enableTTS)
putExtra("enableSTT", enableSTT)
}
)
finish()
}
}

View File

@ -0,0 +1,143 @@
<?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"
tools:context=".MatchActivity"
tools:layout_editor_absoluteY="73dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
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" />
<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/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="left"
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"/>
<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="right|center"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="@string/score" android:layout_marginRight="8dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="@+id/imgService1"
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/buttonPlayer1"
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/imgService1"
app:layout_constraintTop_toTopOf="parent"
tools:text="@string/button_text" android:layout_marginRight="8dp"/>
<Button
android:id="@+id/buttonPlayer2"
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/imgService2"
app:layout_constraintStart_toEndOf="@+id/buttonPlayer1"
tools:text="@string/button_text"/>
<ImageView
android:id="@+id/imgService2"
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>
</LinearLayout>
</android.support.constraint.ConstraintLayout>

View File

@ -1,103 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<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=".StarterNameActivity">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/WhoStarts" android:text="@string/who_starts"
android:layout_marginTop="8dp" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent" android:layout_marginLeft="8dp"
android:layout_marginStart="8dp" android:textAppearance="@style/TextAppearance.AppCompat.Headline"
/>
<RadioGroup
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/WhoStarts" android:id="@+id/starterRadioGroup"
android:layout_marginStart="8dp" app:layout_constraintStart_toStartOf="parent"
android:layout_marginLeft="8dp" app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
android:layout_marginRight="8dp" android:orientation="horizontal">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content" tools:layout_editor_absoluteY="93dp"
tools:layout_editor_absoluteX="16dp" android:id="@+id/radioPlayer1Starts" android:layout_weight="0"
android:checked="true"/>
<AutoCompleteTextView
android:text="@string/player_1_default_name"
<android.support.design.widget.CoordinatorLayout
android:id="@+id/myCoordinatorLayout"
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=".StarterNameActivity">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content" tools:layout_editor_absoluteY="48dp"
android:id="@+id/player1Name"
tools:layout_editor_absoluteX="143dp" android:hint="@string/player_1_default_name"
android:layout_weight="1"
android:completionThreshold="1"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content" app:srcCompat="@drawable/ic_swap_horiz"
android:layout_weight="0" android:id="@+id/swapNamesButton"
android:contentDescription="@string/swap_names" android:onClick="swapNames"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content" tools:layout_editor_absoluteY="93dp"
tools:layout_editor_absoluteX="16dp" android:id="@+id/radioPlayer2Starts"
android:layout_weight="0"/>
<AutoCompleteTextView
android:text="@string/player_2_default_name"
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" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/WhoStarts" android:text="@string/who_starts"
android:layout_marginTop="8dp"
app:layout_constraintStart_toStartOf="parent" android:layout_marginLeft="8dp"
android:layout_marginStart="8dp" android:textAppearance="@style/TextAppearance.AppCompat.Headline"
app:layout_constraintTop_toBottomOf="@+id/toolbar"/>
<RadioGroup
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/WhoStarts" android:id="@+id/starterRadioGroup"
android:layout_marginStart="8dp" app:layout_constraintStart_toStartOf="parent"
android:layout_marginLeft="8dp" app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
android:layout_marginRight="8dp" android:orientation="horizontal">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content" tools:layout_editor_absoluteY="93dp"
tools:layout_editor_absoluteX="16dp" android:id="@+id/radioPlayer1Starts" android:layout_weight="0"
android:checked="true"/>
<AutoCompleteTextView
android:text="@string/player_1_default_name"
android:layout_width="match_parent"
android:layout_height="wrap_content" tools:layout_editor_absoluteY="48dp"
android:id="@+id/player1Name"
tools:layout_editor_absoluteX="143dp" android:hint="@string/player_1_default_name"
android:layout_weight="1"
android:completionThreshold="1"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content" app:srcCompat="@drawable/ic_swap_horiz"
android:layout_weight="0" android:id="@+id/swapNamesButton"
android:contentDescription="@string/swap_names" android:onClick="swapNames"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content" tools:layout_editor_absoluteY="93dp"
tools:layout_editor_absoluteX="16dp" android:id="@+id/radioPlayer2Starts"
android:layout_weight="0"/>
<AutoCompleteTextView
android:text="@string/player_2_default_name"
android:layout_width="match_parent"
tools:layout_editor_absoluteX="136dp" android:id="@+id/player2Name"
android:hint="@string/player_2_default_name" android:layout_height="wrap_content" android:layout_weight="1"
android:completionThreshold="1"/>
</RadioGroup>
<Switch
android:text="@string/TTS"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/enableTtsSwitch"
android:layout_marginTop="8dp" app:layout_constraintTop_toBottomOf="@+id/starterRadioGroup"
android:layout_marginEnd="8dp" app:layout_constraintEnd_toEndOf="parent" android:layout_marginRight="8dp"
android:layout_marginStart="8dp" app:layout_constraintStart_toStartOf="parent"
android:layout_marginLeft="8dp"/>
<Switch
android:text="@string/STT"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/enableSttSwitch" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/enableTtsSwitch" 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"/>
<TextView
android:id="@+id/pingPointsCredit"
android:layout_width="match_parent"
tools:layout_editor_absoluteX="136dp" android:id="@+id/player2Name"
android:hint="@string/player_2_default_name" android:layout_height="wrap_content" android:layout_weight="1"
android:completionThreshold="1"/>
</RadioGroup>
<Switch
android:text="@string/TTS"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/enableTtsSwitch"
android:layout_marginTop="8dp" app:layout_constraintTop_toBottomOf="@+id/starterRadioGroup"
android:layout_marginEnd="8dp" app:layout_constraintEnd_toEndOf="parent" android:layout_marginRight="8dp"
android:layout_marginStart="8dp" app:layout_constraintStart_toStartOf="parent"
android:layout_marginLeft="8dp"/>
<Switch
android:text="@string/STT"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/enableSttSwitch" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/enableTtsSwitch" 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"/>
<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"
android:layout_height="wrap_content"
android:id="@+id/button2"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent" android:layout_marginEnd="8dp"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginRight="8dp"
style="@android:style/Widget.DeviceDefault.Button"
android:drawableStart="@drawable/ic_new_match"
android:drawableLeft="@drawable/ic_new_match"
android:onClick="startMatch"/>
</android.support.constraint.ConstraintLayout>
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"
android:layout_height="wrap_content"
android:id="@+id/button2"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent" android:layout_marginEnd="8dp"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginRight="8dp"
style="@android:style/Widget.DeviceDefault.Button"
android:drawableStart="@drawable/ic_new_match"
android:drawableLeft="@drawable/ic_new_match"
android:onClick="startMatch"/>
</android.support.constraint.ConstraintLayout>
</android.support.design.widget.CoordinatorLayout>

View File

@ -0,0 +1,136 @@
<?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"
tools:context=".MatchActivity"
tools:layout_editor_absoluteY="73dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
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" />
<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/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="left"
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" />
<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="right|center"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="@string/score" android:layout_marginRight="8dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<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"
app:srcCompat="@drawable/ic_service_1"
tools:layout_editor_absoluteY="120dp"/>
<Button
android:id="@+id/buttonPlayer1"
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/imgService1"
app:layout_constraintTop_toTopOf="parent"
tools:text="@string/button_text" android:layout_margin="8dp"/>
<Button
android:id="@+id/buttonPlayer2"
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/imgService2"
app:layout_constraintStart_toEndOf="@+id/buttonPlayer1"
tools:text="@string/button_text" android:layout_margin="8dp"/>
<ImageView
android:id="@+id/imgService2"
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>
</LinearLayout>
</android.support.constraint.ConstraintLayout>

View File

@ -1,5 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
<android.support.design.widget.CoordinatorLayout
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"
@ -7,112 +15,125 @@
android:layout_height="match_parent"
tools:context=".StarterNameActivity">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/WhoStarts" android:text="@string/who_starts"
android:layout_marginTop="8dp" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent" android:layout_marginLeft="8dp"
android:layout_marginStart="8dp" android:textAppearance="@style/TextAppearance.AppCompat.Headline"
/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/WhoStarts"
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:id="@+id/linearLayout"
android:layout_margin="8dp">
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/WhoStarts" android:id="@+id/starterRadioGroup"
android:layout_marginStart="8dp" app:layout_constraintStart_toStartOf="parent"
android:layout_marginLeft="8dp" app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp" android:layout_marginBottom="8dp">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content" tools:layout_editor_absoluteY="93dp"
tools:layout_editor_absoluteX="16dp" android:id="@+id/radioPlayer1Starts"
android:layout_weight="1" android:gravity="top" android:checked="true"/>
<RadioButton
android:layout_height="wrap_content" tools:layout_editor_absoluteY="93dp"
tools:layout_editor_absoluteX="16dp" android:id="@+id/radioPlayer2Starts"
android:layout_width="wrap_content" android:layout_weight="1"
android:gravity="bottom"/>
</RadioGroup>
<LinearLayout
android:orientation="vertical"
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<AutoCompleteTextView
android:text="@string/player_1_default_name"
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" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/WhoStarts" android:text="@string/who_starts"
android:layout_marginTop="8dp"
app:layout_constraintStart_toStartOf="parent" android:layout_marginLeft="8dp"
android:layout_marginStart="8dp" android:textAppearance="@style/TextAppearance.AppCompat.Headline"
app:layout_constraintTop_toBottomOf="@+id/toolbar"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/WhoStarts"
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:id="@+id/linearLayout"
android:layout_margin="8dp">
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@+id/WhoStarts" android:id="@+id/starterRadioGroup"
android:layout_marginStart="8dp" app:layout_constraintStart_toStartOf="parent"
android:layout_marginLeft="8dp" app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp" android:layout_marginBottom="8dp">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content" tools:layout_editor_absoluteY="93dp"
tools:layout_editor_absoluteX="16dp" android:id="@+id/radioPlayer1Starts"
android:layout_weight="1" android:gravity="top" android:checked="true"/>
<RadioButton
android:layout_height="wrap_content" tools:layout_editor_absoluteY="93dp"
tools:layout_editor_absoluteX="16dp" android:id="@+id/radioPlayer2Starts"
android:layout_width="wrap_content" android:layout_weight="1"
android:gravity="bottom"/>
</RadioGroup>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content" tools:layout_editor_absoluteY="48dp"
android:id="@+id/player1Name"
tools:layout_editor_absoluteX="143dp" android:hint="@string/player_1_default_name"
android:selectAllOnFocus="true"
android:completionThreshold="1"/>
<ImageButton
android:layout_width="match_parent"
android:layout_height="wrap_content" app:srcCompat="@drawable/ic_swap_vert"
android:id="@+id/swapNamesButton" android:contentDescription="@string/swap_names"
android:onClick="swapNames"/>
<AutoCompleteTextView
android:text="@string/player_2_default_name"
tools:layout_editor_absoluteX="136dp" android:id="@+id/player2Name"
android:hint="@string/player_2_default_name" android:layout_height="wrap_content"
android:layout_width="match_parent" android:selectAllOnFocus="true"
android:completionThreshold="1"/>
android:layout_height="wrap_content">
<AutoCompleteTextView
android:text="@string/player_1_default_name"
android:layout_width="match_parent"
android:layout_height="wrap_content" tools:layout_editor_absoluteY="48dp"
android:id="@+id/player1Name"
tools:layout_editor_absoluteX="143dp" android:hint="@string/player_1_default_name"
android:selectAllOnFocus="true"
android:completionThreshold="1"/>
<ImageButton
android:layout_width="match_parent"
android:layout_height="wrap_content" app:srcCompat="@drawable/ic_swap_vert"
android:id="@+id/swapNamesButton" android:contentDescription="@string/swap_names"
android:onClick="swapNames"/>
<AutoCompleteTextView
android:text="@string/player_2_default_name"
tools:layout_editor_absoluteX="136dp" android:id="@+id/player2Name"
android:hint="@string/player_2_default_name" android:layout_height="wrap_content"
android:layout_width="match_parent" android:selectAllOnFocus="true"
android:completionThreshold="1"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<Switch
android:text="@string/TTS"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/enableTtsSwitch"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginLeft="8dp" android:layout_marginStart="8dp" app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="6dp" android:layout_marginRight="6dp" app:layout_constraintHorizontal_bias="0.0"
android:layout_marginTop="8dp" app:layout_constraintTop_toBottomOf="@+id/linearLayout"/>
<Switch
android:text="@string/STT"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/enableSttSwitch"
android:layout_marginTop="8dp"
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"
android:layout_height="wrap_content"
android:id="@+id/button"
style="@android:style/Widget.DeviceDefault.Button"
android:layout_marginEnd="8dp" app:layout_constraintEnd_toEndOf="parent" android:layout_marginRight="8dp"
android:layout_marginBottom="8dp" app:layout_constraintBottom_toBottomOf="parent"
android:drawableStart="@drawable/ic_new_match"
android:drawableLeft="@drawable/ic_new_match" android:onClick="startMatch"/>
</android.support.constraint.ConstraintLayout>
<Switch
android:text="@string/TTS"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/enableTtsSwitch"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginLeft="8dp" android:layout_marginStart="8dp" app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="6dp" android:layout_marginRight="6dp" app:layout_constraintHorizontal_bias="0.0"
android:layout_marginTop="8dp" app:layout_constraintTop_toBottomOf="@+id/linearLayout"/>
<Switch
android:text="@string/STT"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/enableSttSwitch"
android:layout_marginTop="8dp"
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"
android:layout_height="wrap_content"
android:id="@+id/button"
style="@android:style/Widget.DeviceDefault.Button"
android:layout_marginEnd="8dp" app:layout_constraintEnd_toEndOf="parent" android:layout_marginRight="8dp"
android:layout_marginBottom="8dp" app:layout_constraintBottom_toBottomOf="parent"
android:drawableStart="@drawable/ic_new_match"
android:drawableLeft="@drawable/ic_new_match" android:onClick="startMatch"/>
</android.support.constraint.ConstraintLayout>
</android.support.design.widget.CoordinatorLayout>

View File

@ -12,4 +12,17 @@
<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="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.
Cela requiert une connexion internet et la permission d'enregistrer des fichiers audio.
Vous pouvez à tout moment changer la permission dans les paramètres Android."
</string>
<string name="OK">OK</string>
<string name="cancel">Annuler</string>
<string name="audio_record_permission_denied">La reconnaissance vocale a besoin de la permission d\'enregistrer des
fichiers audio pour fonctionner.
</string>
<string name="service">Service : %s</string>
<string name="score">Score : %d - %d</string>
<string name="service_img_description">Service</string>
<string name="title_activity_match">Ping Points</string>
</resources>

View File

@ -2,5 +2,5 @@
<resources>
<color name="colorPrimary">#016df5</color>
<color name="colorPrimaryDark">#004aa7</color>
<color name="colorAccent">#0088FF</color>
<color name="colorAccent">#0088ff</color>
</resources>

View File

@ -8,7 +8,25 @@
<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; 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;"</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;
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;"
</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>
<string name="explain_record_audio_request">"This app uses Google API for voice recognition: your voice will be
recorded and analyzed by Google's servers.
It requires an internet connection and permission for audio recording.
You can always change permission in Android settings."
</string>
<string name="OK">OK</string>
<string name="cancel">Cancel</string>
<string name="audio_record_permission_denied">Audio recording permission required to use voice recognition.</string>
<string name="title_activity_match">Ping Points</string>
<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>
</resources>