- 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 androidx.appcompat.app.AppCompatActivity
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import androidx.core.widget.doOnTextChanged
|
||||
import kotlinx.android.synthetic.main.content_main.*
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
@@ -60,8 +61,6 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
inputTeamB.setText(temp.toString())
|
||||
}
|
||||
|
||||
updateTemp()
|
||||
}
|
||||
|
||||
sub100.setOnClickListener {
|
||||
@@ -85,8 +84,6 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
inputTeamB.setText(temp.toString())
|
||||
}
|
||||
|
||||
updateTemp()
|
||||
}
|
||||
|
||||
add.setOnClickListener {
|
||||
@@ -107,7 +104,6 @@ class MainActivity : AppCompatActivity() {
|
||||
inputTeamA.setText("")
|
||||
inputTeamB.setText("")
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,6 +113,26 @@ class MainActivity : AppCompatActivity() {
|
||||
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 {
|
||||
var toSet: Int = 0
|
||||
|
||||
@@ -131,11 +147,4 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
return "$toSet"
|
||||
}
|
||||
|
||||
private fun updateTemp() {
|
||||
nameTeamA.text = tempCounterTeamA.toString()
|
||||
nameTeamB.text = tempCounterTeamB.toString()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -22,7 +22,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.5"
|
||||
android:text="@string/teama"
|
||||
android:text="@string/team_a"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Display1" />
|
||||
|
||||
<TextView
|
||||
@@ -61,7 +61,6 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.5"
|
||||
android:text="0"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
||||
android:textSize="18sp" />
|
||||
|
||||
@@ -70,7 +69,6 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.5"
|
||||
android:text="0"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
||||
android:textSize="18sp" />
|
||||
</TableRow>
|
||||
@@ -85,6 +83,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.5"
|
||||
android:ems="10"
|
||||
android:hint="0"
|
||||
android:importantForAutofill="no"
|
||||
android:inputType="numberSigned" />
|
||||
|
||||
@@ -94,6 +93,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.5"
|
||||
android:ems="10"
|
||||
android:hint="0"
|
||||
android:importantForAutofill="no"
|
||||
android:inputType="numberSigned" />
|
||||
</TableRow>
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context="me.zobrist.tichucounter.MainActivity">
|
||||
<item
|
||||
android:id="@+id/action_settings"
|
||||
android:id="@+id/action_clear"
|
||||
android:checkable="false"
|
||||
android:orderInCategory="100"
|
||||
android:title="@string/action_settings"
|
||||
android:title="@string/clear"
|
||||
app:showAsAction="never" />
|
||||
</menu>
|
||||
@@ -1,15 +1,9 @@
|
||||
<resources>
|
||||
<string name="app_name">Tichu Counter</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
<!-- 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="hello_second_fragment">Hello second fragment. Arg: %1$s</string>
|
||||
<string name="teama">TeamA</string>
|
||||
<string name="team_a">Team A</string>
|
||||
<string name="team_b">Team B</string>
|
||||
<string name="add">Add</string>
|
||||
<string name="clear">Clear</string>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user