Remove menu, action bar, redo
This commit is contained in:
parent
04f388bc1e
commit
d2df43bf02
@ -12,7 +12,7 @@
|
|||||||
android:logo="@mipmap/ic_launcher"
|
android:logo="@mipmap/ic_launcher"
|
||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/Theme.AppCompat.NoActionBar">
|
android:theme="@style/PingPointsTheme">
|
||||||
<activity
|
<activity
|
||||||
android:name=".StarterNameActivity"
|
android:name=".StarterNameActivity"
|
||||||
android:windowSoftInputMode="adjustResize">
|
android:windowSoftInputMode="adjustResize">
|
||||||
|
@ -11,8 +11,6 @@ import android.support.design.widget.Snackbar
|
|||||||
import android.support.v7.app.AppCompatActivity
|
import android.support.v7.app.AppCompatActivity
|
||||||
import android.support.v7.app.AppCompatDelegate
|
import android.support.v7.app.AppCompatDelegate
|
||||||
import android.text.method.LinkMovementMethod
|
import android.text.method.LinkMovementMethod
|
||||||
import android.view.Menu
|
|
||||||
import android.view.MenuItem
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.Button
|
import android.widget.Button
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
@ -46,15 +44,12 @@ class MatchActivity : AppCompatActivity() {
|
|||||||
var buttons: Array<Button> = emptyArray()
|
var buttons: Array<Button> = emptyArray()
|
||||||
var imageViews: Array<ImageView?> = emptyArray()
|
var imageViews: Array<ImageView?> = emptyArray()
|
||||||
var tts: TextToSpeech? = null
|
var tts: TextToSpeech? = null
|
||||||
var undo: MenuItem? = null
|
|
||||||
var redo: MenuItem? = null
|
|
||||||
var numSttCancelled:Int = 0
|
var numSttCancelled:Int = 0
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
|
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
|
||||||
setContentView(R.layout.activity_match)
|
setContentView(R.layout.activity_match)
|
||||||
setSupportActionBar(findViewById(R.id.toolbar))
|
|
||||||
|
|
||||||
// Set HTML text for icons credits
|
// Set HTML text for icons credits
|
||||||
findViewById<TextView>(R.id.iconsCredit).run {
|
findViewById<TextView>(R.id.iconsCredit).run {
|
||||||
@ -103,31 +98,8 @@ class MatchActivity : AppCompatActivity() {
|
|||||||
updateUI()
|
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
if (matchModel?.playId == 0)
|
if (matchModel?.pointId == 0)
|
||||||
super.onBackPressed()
|
super.onBackPressed()
|
||||||
else {
|
else {
|
||||||
matchModel?.undo()
|
matchModel?.undo()
|
||||||
@ -137,15 +109,6 @@ class MatchActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
fun updateUI() {
|
fun updateUI() {
|
||||||
matchModel?.apply {
|
matchModel?.apply {
|
||||||
undo?.isVisible = when (playId) {
|
|
||||||
0 -> false
|
|
||||||
else -> true
|
|
||||||
}
|
|
||||||
redo?.isVisible = when (playId) {
|
|
||||||
history.size - 1 -> false
|
|
||||||
else -> true
|
|
||||||
}
|
|
||||||
|
|
||||||
textScore?.text = getString(
|
textScore?.text = getString(
|
||||||
R.string.score_score,
|
R.string.score_score,
|
||||||
players[serviceSide].score,
|
players[serviceSide].score,
|
||||||
|
@ -12,7 +12,7 @@ class MatchModel : ViewModel() {
|
|||||||
var relaunchSide: Int = 1
|
var relaunchSide: Int = 1
|
||||||
var ttsEnabled: Boolean = false
|
var ttsEnabled: Boolean = false
|
||||||
var sttEnabled: Boolean = false
|
var sttEnabled: Boolean = false
|
||||||
var playId: Int = 0
|
var pointId: Int = 0
|
||||||
var history: MutableList<Point> = ArrayList()
|
var history: MutableList<Point> = ArrayList()
|
||||||
|
|
||||||
fun startMatch(player1Name: String, player2Name:String, starterId: Int, enableTTS: Boolean, enableSTT: Boolean) {
|
fun startMatch(player1Name: String, player2Name:String, starterId: Int, enableTTS: Boolean, enableSTT: Boolean) {
|
||||||
@ -29,7 +29,7 @@ class MatchModel : ViewModel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun updateScore(scorer: Player) {
|
fun updateScore(scorer: Player) {
|
||||||
playId++
|
pointId++
|
||||||
scorer.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 }
|
||||||
@ -45,27 +45,16 @@ class MatchModel : ViewModel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun saveState() {
|
fun saveState() {
|
||||||
val play = Point(players.map { it.score }, serviceSide)
|
val point = Point(players.map { it.score }, serviceSide)
|
||||||
if (playId == history.size) {
|
if (pointId == history.size) {
|
||||||
history.add(play)
|
history.add(point)
|
||||||
} else {
|
} else {
|
||||||
history[playId] = play
|
history[pointId] = point
|
||||||
history = history.subList(0, playId+1).toMutableList()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun undo() {
|
fun undo() {
|
||||||
playId--
|
history[pointId--].let{
|
||||||
reloadState()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun redo() {
|
|
||||||
playId++
|
|
||||||
reloadState()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun reloadState() {
|
|
||||||
history[playId].let{
|
|
||||||
players.zip(it.score).forEach{(player, score) -> player.score = score}
|
players.zip(it.score).forEach{(player, score) -> player.score = score}
|
||||||
serviceSide = it.serviceSide
|
serviceSide = it.serviceSide
|
||||||
relaunchSide = when(serviceSide) {
|
relaunchSide = when(serviceSide) {
|
||||||
|
@ -32,7 +32,6 @@ class StarterNameActivity : AppCompatActivity() {
|
|||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_starter_name)
|
setContentView(R.layout.activity_starter_name)
|
||||||
setSupportActionBar(findViewById(R.id.toolbar))
|
|
||||||
|
|
||||||
// Find views
|
// Find views
|
||||||
player1NameInput = findViewById(R.id.player1Name)
|
player1NameInput = findViewById(R.id.player1Name)
|
||||||
|
@ -20,7 +20,6 @@ class VictoryActivity : AppCompatActivity() {
|
|||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
|
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
|
||||||
setContentView(R.layout.activity_victory)
|
setContentView(R.layout.activity_victory)
|
||||||
setSupportActionBar(findViewById(R.id.toolbar))
|
|
||||||
|
|
||||||
val previousMatch = getPreferences(Context.MODE_PRIVATE)
|
val previousMatch = getPreferences(Context.MODE_PRIVATE)
|
||||||
|
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
<vector android:autoMirrored="true" android:height="24dp"
|
|
||||||
android:tint="#FFFFFF" android:viewportHeight="24.0"
|
|
||||||
android:viewportWidth="24.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<path android:fillColor="#FF000000" android:pathData="M18.4,10.6C16.55,8.99 14.15,8 11.5,8c-4.65,0 -8.58,3.03 -9.96,7.22L3.9,16c1.05,-3.19 4.05,-5.5 7.6,-5.5 1.95,0 3.73,0.72 5.12,1.88L13,16h9V7l-3.6,3.6z"/>
|
|
||||||
</vector>
|
|
@ -1,5 +0,0 @@
|
|||||||
<vector android:autoMirrored="true" android:height="24dp"
|
|
||||||
android:tint="#FFFFFF" android:viewportHeight="24.0"
|
|
||||||
android:viewportWidth="24.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<path android:fillColor="#FF000000" android:pathData="M12.5,8c-2.65,0 -5.05,0.99 -6.9,2.6L2,7v9h9l-3.62,-3.62c1.39,-1.16 3.16,-1.88 5.12,-1.88 3.54,0 6.55,2.31 7.6,5.5l2.37,-0.78C21.08,11.03 17.15,8 12.5,8z"/>
|
|
||||||
</vector>
|
|
@ -12,16 +12,6 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
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
|
<LinearLayout
|
||||||
android:id="@+id/linearLayoutText"
|
android:id="@+id/linearLayoutText"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<android.support.design.widget.CoordinatorLayout
|
<android.support.design.widget.CoordinatorLayout
|
||||||
android:id="@+id/myCoordinatorLayout"
|
xmlns:tools="http://schemas.android.com/tools" android:id="@+id/myCoordinatorLayout"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -15,24 +15,13 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".StarterNameActivity">
|
tools:context=".StarterNameActivity">
|
||||||
|
|
||||||
<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" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/WhoStarts" android:text="@string/who_starts"
|
android:id="@+id/WhoStarts" android:text="@string/who_starts"
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
app:layout_constraintStart_toStartOf="parent" android:layout_marginLeft="8dp"
|
app:layout_constraintStart_toStartOf="parent" android:layout_marginLeft="8dp"
|
||||||
android:layout_marginStart="8dp" android:textAppearance="@style/TextAppearance.AppCompat.Headline"
|
android:layout_marginStart="8dp" android:textAppearance="@style/TextAppearance.AppCompat.Headline"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/toolbar"/>
|
android:layout_marginTop="8dp" app:layout_constraintTop_toTopOf="parent"/>
|
||||||
<RadioGroup
|
<RadioGroup
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -12,16 +12,6 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
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
|
<LinearLayout
|
||||||
android:id="@+id/linearLayoutText"
|
android:id="@+id/linearLayoutText"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<android.support.design.widget.CoordinatorLayout
|
<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:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -15,24 +15,13 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".StarterNameActivity">
|
tools:context=".StarterNameActivity">
|
||||||
|
|
||||||
<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" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/WhoStarts" android:text="@string/who_starts"
|
android:id="@+id/WhoStarts" android:text="@string/who_starts"
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
app:layout_constraintStart_toStartOf="parent" android:layout_marginLeft="8dp"
|
app:layout_constraintStart_toStartOf="parent" android:layout_marginLeft="8dp"
|
||||||
android:layout_marginStart="8dp" android:textAppearance="@style/TextAppearance.AppCompat.Headline"
|
android:layout_marginStart="8dp" android:textAppearance="@style/TextAppearance.AppCompat.Headline"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/toolbar"/>
|
android:layout_marginTop="8dp" app:layout_constraintTop_toTopOf="parent"/>
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -15,25 +15,16 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".VictoryActivity">
|
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
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/congrats"
|
android:id="@+id/congrats"
|
||||||
android:textAppearance="@style/TextAppearance.AppCompat.Headline"
|
android:textAppearance="@style/TextAppearance.AppCompat.Headline"
|
||||||
android:layout_marginTop="13dp" app:layout_constraintTop_toBottomOf="@+id/toolbar"
|
|
||||||
android:layout_marginEnd="8dp" app:layout_constraintEnd_toEndOf="parent"
|
android:layout_marginEnd="8dp" app:layout_constraintEnd_toEndOf="parent"
|
||||||
android:layout_marginRight="8dp" android:layout_marginStart="8dp"
|
android:layout_marginRight="8dp" android:layout_marginStart="8dp"
|
||||||
app:layout_constraintStart_toStartOf="parent" android:layout_marginLeft="8dp"
|
app:layout_constraintStart_toStartOf="parent" android:layout_marginLeft="8dp"
|
||||||
android:text="@string/congrats"/>
|
android:text="@string/congrats" android:layout_marginTop="8dp"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"/>
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
<?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>
|
|
@ -1,8 +1,16 @@
|
|||||||
<resources>
|
<resources>
|
||||||
|
<!-- the theme applied to the application or activity -->
|
||||||
<style name="AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
|
<style name="PingPointsTheme" parent="Base.V22.Theme.AppCompat">
|
||||||
|
<item name="android:actionBarStyle">@style/ColoredActionBarBackground</item>
|
||||||
<style name="PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
|
<!-- Support library compatibility -->
|
||||||
|
<item name="actionBarStyle">@style/ColoredActionBarBackground</item>
|
||||||
|
</style>
|
||||||
|
<style name="ColoredActionBarBackground"
|
||||||
|
parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
|
||||||
|
<item name="android:background">@color/colorPrimaryDark</item>
|
||||||
|
<!-- Support library compatibility -->
|
||||||
|
<item name="background">@color/colorPrimaryDark</item>
|
||||||
|
</style>
|
||||||
<style name="ScoreButton">
|
<style name="ScoreButton">
|
||||||
<item name="colorButtonNormal">@color/colorAccent</item>
|
<item name="colorButtonNormal">@color/colorAccent</item>
|
||||||
</style>
|
</style>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user