- Add clear entry in menu
- clean string.xml file -
This commit is contained in:
@@ -3,6 +3,7 @@ package me.zobrist.tichucounter
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
|
import android.view.MenuItem
|
||||||
import androidx.core.widget.doOnTextChanged
|
import androidx.core.widget.doOnTextChanged
|
||||||
import kotlinx.android.synthetic.main.content_main.*
|
import kotlinx.android.synthetic.main.content_main.*
|
||||||
import kotlinx.coroutines.sync.Mutex
|
import kotlinx.coroutines.sync.Mutex
|
||||||
@@ -60,8 +61,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
inputTeamB.setText(temp.toString())
|
inputTeamB.setText(temp.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTemp()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub100.setOnClickListener {
|
sub100.setOnClickListener {
|
||||||
@@ -85,8 +84,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
inputTeamB.setText(temp.toString())
|
inputTeamB.setText(temp.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTemp()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
add.setOnClickListener {
|
add.setOnClickListener {
|
||||||
@@ -107,7 +104,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
inputTeamA.setText("")
|
inputTeamA.setText("")
|
||||||
inputTeamB.setText("")
|
inputTeamB.setText("")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,6 +113,26 @@ class MainActivity : AppCompatActivity() {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
|
return when (item.itemId) {
|
||||||
|
R.id.action_clear -> {
|
||||||
|
clearAll()
|
||||||
|
true
|
||||||
|
}
|
||||||
|
else -> super.onOptionsItemSelected(item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun clearAll() {
|
||||||
|
historyA.text = ""
|
||||||
|
historyB.text = ""
|
||||||
|
inputTeamA.setText("")
|
||||||
|
inputTeamB.setText("")
|
||||||
|
scoreA.text = "50"
|
||||||
|
scoreB.text = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun updateNumber(inputText: CharSequence?, offset: Int): String {
|
private fun updateNumber(inputText: CharSequence?, offset: Int): String {
|
||||||
var toSet: Int = 0
|
var toSet: Int = 0
|
||||||
|
|
||||||
@@ -131,11 +147,4 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
return "$toSet"
|
return "$toSet"
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateTemp() {
|
|
||||||
nameTeamA.text = tempCounterTeamA.toString()
|
|
||||||
nameTeamB.text = tempCounterTeamB.toString()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="0.5"
|
android:layout_weight="0.5"
|
||||||
android:text="@string/teama"
|
android:text="@string/team_a"
|
||||||
android:textAppearance="@style/TextAppearance.AppCompat.Display1" />
|
android:textAppearance="@style/TextAppearance.AppCompat.Display1" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@@ -61,7 +61,6 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="0.5"
|
android:layout_weight="0.5"
|
||||||
android:text="0"
|
|
||||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
||||||
android:textSize="18sp" />
|
android:textSize="18sp" />
|
||||||
|
|
||||||
@@ -70,7 +69,6 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="0.5"
|
android:layout_weight="0.5"
|
||||||
android:text="0"
|
|
||||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
||||||
android:textSize="18sp" />
|
android:textSize="18sp" />
|
||||||
</TableRow>
|
</TableRow>
|
||||||
@@ -85,6 +83,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="0.5"
|
android:layout_weight="0.5"
|
||||||
android:ems="10"
|
android:ems="10"
|
||||||
|
android:hint="0"
|
||||||
android:importantForAutofill="no"
|
android:importantForAutofill="no"
|
||||||
android:inputType="numberSigned" />
|
android:inputType="numberSigned" />
|
||||||
|
|
||||||
@@ -94,6 +93,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="0.5"
|
android:layout_weight="0.5"
|
||||||
android:ems="10"
|
android:ems="10"
|
||||||
|
android:hint="0"
|
||||||
android:importantForAutofill="no"
|
android:importantForAutofill="no"
|
||||||
android:inputType="numberSigned" />
|
android:inputType="numberSigned" />
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|||||||
@@ -3,8 +3,9 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
tools:context="me.zobrist.tichucounter.MainActivity">
|
tools:context="me.zobrist.tichucounter.MainActivity">
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_settings"
|
android:id="@+id/action_clear"
|
||||||
|
android:checkable="false"
|
||||||
android:orderInCategory="100"
|
android:orderInCategory="100"
|
||||||
android:title="@string/action_settings"
|
android:title="@string/clear"
|
||||||
app:showAsAction="never" />
|
app:showAsAction="never" />
|
||||||
</menu>
|
</menu>
|
||||||
@@ -1,15 +1,9 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">Tichu Counter</string>
|
<string name="app_name">Tichu Counter</string>
|
||||||
<string name="action_settings">Settings</string>
|
|
||||||
<!-- Strings used for fragments for navigation -->
|
<!-- Strings used for fragments for navigation -->
|
||||||
<string name="first_fragment_label">First Fragment</string>
|
|
||||||
<string name="second_fragment_label">Second Fragment</string>
|
|
||||||
<string name="next">Next</string>
|
|
||||||
<string name="previous">Previous</string>
|
|
||||||
|
|
||||||
<string name="hello_first_fragment">Hello first fragment</string>
|
<string name="team_a">Team A</string>
|
||||||
<string name="hello_second_fragment">Hello second fragment. Arg: %1$s</string>
|
|
||||||
<string name="teama">TeamA</string>
|
|
||||||
<string name="team_b">Team B</string>
|
<string name="team_b">Team B</string>
|
||||||
<string name="add">Add</string>
|
<string name="add">Add</string>
|
||||||
|
<string name="clear">Clear</string>
|
||||||
</resources>
|
</resources>
|
||||||
Reference in New Issue
Block a user