Split layout in Fragments.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package me.zobrist.tichucounter.viewModel
|
||||
package me.zobrist.tichucounter
|
||||
|
||||
import android.app.AlertDialog
|
||||
import android.content.Intent
|
||||
@@ -15,7 +15,6 @@ import androidx.core.os.LocaleListCompat
|
||||
import androidx.core.widget.doOnTextChanged
|
||||
import com.google.gson.Gson
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import me.zobrist.tichucounter.R
|
||||
import me.zobrist.tichucounter.databinding.ActivityMainBinding
|
||||
import me.zobrist.tichucounter.domain.History
|
||||
import me.zobrist.tichucounter.domain.Round
|
||||
@@ -44,9 +43,9 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
setSupportActionBar(binding.toolbar)
|
||||
|
||||
binding.contentMain.inputTeamA.setRawInputType(InputType.TYPE_NULL)
|
||||
binding.contentMain.inputTeamB.setRawInputType(InputType.TYPE_NULL)
|
||||
binding.contentMain.inputTeamA.requestFocus()
|
||||
binding.contentMain.keyboard.inputTeamA.setRawInputType(InputType.TYPE_NULL)
|
||||
binding.contentMain.keyboard.inputTeamB.setRawInputType(InputType.TYPE_NULL)
|
||||
binding.contentMain.keyboard.inputTeamA.requestFocus()
|
||||
disableSubmitButton()
|
||||
updateTheme(this.getSharedPreferences("Settings", MODE_PRIVATE).getInt("Theme", 2))
|
||||
keepScreenOn(
|
||||
@@ -67,258 +66,6 @@ class MainActivity : AppCompatActivity() {
|
||||
updateView()
|
||||
|
||||
this.setListeners()
|
||||
|
||||
|
||||
}
|
||||
|
||||
private fun setListeners() {
|
||||
binding.contentMain.inputTeamA.setOnFocusChangeListener { _, b ->
|
||||
if (b) {
|
||||
hideKeyboard()
|
||||
}
|
||||
}
|
||||
|
||||
binding.contentMain.inputTeamB.setOnFocusChangeListener { _, b ->
|
||||
if (b) {
|
||||
hideKeyboard()
|
||||
}
|
||||
}
|
||||
|
||||
binding.contentMain.inputTeamA.doOnTextChanged { text, _, _, _ ->
|
||||
if (binding.contentMain.inputTeamA.isFocused) {
|
||||
if (binding.contentMain.inputTeamA.text.isNotEmpty()) {
|
||||
if (updateOnChange) {
|
||||
currentRound = try {
|
||||
Round(text.toString().toInt(), true)
|
||||
|
||||
} catch (e: java.lang.Exception) {
|
||||
Round(1, 1)
|
||||
}
|
||||
binding.contentMain.inputTeamB.setText(currentRound.scoreB.toString())
|
||||
} else {
|
||||
updateOnChange = true
|
||||
}
|
||||
} else {
|
||||
binding.contentMain.inputTeamA.text.clear()
|
||||
binding.contentMain.inputTeamB.text.clear()
|
||||
}
|
||||
}
|
||||
|
||||
if (currentRound.isValidRound() && binding.contentMain.inputTeamA.text.isNotEmpty() && binding.contentMain.inputTeamB.text.isNotEmpty()) {
|
||||
enableSubmitButton()
|
||||
} else {
|
||||
disableSubmitButton()
|
||||
}
|
||||
}
|
||||
|
||||
binding.contentMain.inputTeamB.doOnTextChanged { text, _, _, _ ->
|
||||
if (binding.contentMain.inputTeamB.isFocused) {
|
||||
if (binding.contentMain.inputTeamB.text.isNotEmpty()) {
|
||||
if (updateOnChange) {
|
||||
currentRound = try {
|
||||
Round(text.toString().toInt(), false)
|
||||
|
||||
} catch (e: java.lang.Exception) {
|
||||
Round(1, 1)
|
||||
}
|
||||
binding.contentMain.inputTeamA.setText(currentRound.scoreA.toString())
|
||||
|
||||
} else {
|
||||
updateOnChange = true
|
||||
}
|
||||
|
||||
} else {
|
||||
binding.contentMain.inputTeamA.text.clear()
|
||||
binding.contentMain.inputTeamB.text.clear()
|
||||
}
|
||||
}
|
||||
|
||||
if (currentRound.isValidRound() && binding.contentMain.inputTeamA.text.isNotEmpty() && binding.contentMain.inputTeamB.text.isNotEmpty()) {
|
||||
enableSubmitButton()
|
||||
} else {
|
||||
disableSubmitButton()
|
||||
}
|
||||
}
|
||||
|
||||
binding.contentMain.buttonAdd100.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
|
||||
if (binding.contentMain.inputTeamA.isFocused) {
|
||||
|
||||
currentRound.scoreA = try {
|
||||
binding.contentMain.inputTeamA.text.toString().toInt() + 100
|
||||
} catch (e: Exception) {
|
||||
currentRound.scoreB = 0
|
||||
binding.contentMain.inputTeamB.setText(currentRound.scoreB.toString())
|
||||
100
|
||||
}
|
||||
updateOnChange = false
|
||||
binding.contentMain.inputTeamA.setText(currentRound.scoreA.toString())
|
||||
}
|
||||
|
||||
if (binding.contentMain.inputTeamB.isFocused) {
|
||||
currentRound.scoreB = try {
|
||||
binding.contentMain.inputTeamB.text.toString().toInt() + 100
|
||||
} catch (e: Exception) {
|
||||
currentRound.scoreA = 0
|
||||
binding.contentMain.inputTeamA.setText(currentRound.scoreA.toString())
|
||||
100
|
||||
|
||||
}
|
||||
updateOnChange = false
|
||||
binding.contentMain.inputTeamB.setText(currentRound.scoreB.toString())
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
binding.contentMain.buttonSub100.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
|
||||
if (binding.contentMain.inputTeamA.isFocused) {
|
||||
currentRound.scoreA = try {
|
||||
binding.contentMain.inputTeamA.text.toString().toInt() - 100
|
||||
} catch (e: Exception) {
|
||||
currentRound.scoreB = 0
|
||||
binding.contentMain.inputTeamB.setText(currentRound.scoreB.toString())
|
||||
-100
|
||||
}
|
||||
updateOnChange = false
|
||||
binding.contentMain.inputTeamA.setText(currentRound.scoreA.toString())
|
||||
}
|
||||
|
||||
if (binding.contentMain.inputTeamB.isFocused) {
|
||||
currentRound.scoreB = try {
|
||||
binding.contentMain.inputTeamB.text.toString().toInt() - 100
|
||||
} catch (e: Exception) {
|
||||
currentRound.scoreA = 0
|
||||
binding.contentMain.inputTeamA.setText(currentRound.scoreA.toString())
|
||||
-100
|
||||
}
|
||||
updateOnChange = false
|
||||
binding.contentMain.inputTeamB.setText(currentRound.scoreB.toString())
|
||||
}
|
||||
}
|
||||
|
||||
binding.contentMain.button0.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
appendToFocusedInput('0')
|
||||
}
|
||||
|
||||
binding.contentMain.button1.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
appendToFocusedInput('1')
|
||||
}
|
||||
|
||||
binding.contentMain.button2.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
appendToFocusedInput('2')
|
||||
}
|
||||
|
||||
binding.contentMain.button3.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
appendToFocusedInput('3')
|
||||
}
|
||||
|
||||
binding.contentMain.button4.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
appendToFocusedInput('4')
|
||||
}
|
||||
|
||||
binding.contentMain.button5.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
appendToFocusedInput('5')
|
||||
}
|
||||
|
||||
binding.contentMain.button6.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
appendToFocusedInput('6')
|
||||
}
|
||||
|
||||
binding.contentMain.button7.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
appendToFocusedInput('7')
|
||||
}
|
||||
|
||||
binding.contentMain.button8.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
appendToFocusedInput('8')
|
||||
}
|
||||
|
||||
binding.contentMain.button9.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
appendToFocusedInput('9')
|
||||
}
|
||||
|
||||
binding.contentMain.buttonInv.setOnClickListener {
|
||||
val tempInt: Int
|
||||
|
||||
giveFocusToAIfNone()
|
||||
|
||||
if (binding.contentMain.inputTeamA.isFocused) {
|
||||
if (binding.contentMain.inputTeamA.text.toString() == "-") {
|
||||
binding.contentMain.inputTeamA.text.clear()
|
||||
} else if (binding.contentMain.inputTeamA.text.isNotEmpty()) {
|
||||
tempInt = binding.contentMain.inputTeamA.text.toString().toInt() * -1
|
||||
binding.contentMain.inputTeamA.setText(tempInt.toString())
|
||||
} else {
|
||||
updateOnChange = false
|
||||
appendToFocusedInput('-')
|
||||
currentRound = Round(1, 1)
|
||||
}
|
||||
|
||||
|
||||
} else if (binding.contentMain.inputTeamB.isFocused) {
|
||||
if (binding.contentMain.inputTeamB.text.toString() == "-") {
|
||||
binding.contentMain.inputTeamB.text.clear()
|
||||
} else if (binding.contentMain.inputTeamB.text.isNotEmpty()) {
|
||||
tempInt = binding.contentMain.inputTeamB.text.toString().toInt() * -1
|
||||
binding.contentMain.inputTeamB.setText(tempInt.toString())
|
||||
} else {
|
||||
updateOnChange = false
|
||||
appendToFocusedInput('-')
|
||||
currentRound = Round(1, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
binding.contentMain.buttonBack.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
|
||||
if (binding.contentMain.inputTeamA.isFocused) {
|
||||
if (binding.contentMain.inputTeamA.text.isNotEmpty()) {
|
||||
val string = binding.contentMain.inputTeamA.text.toString()
|
||||
binding.contentMain.inputTeamA.setText(string.substring(0, string.length - 1))
|
||||
}
|
||||
|
||||
} else if (binding.contentMain.inputTeamB.isFocused) {
|
||||
if (binding.contentMain.inputTeamB.text.isNotEmpty()) {
|
||||
val string = binding.contentMain.inputTeamB.text.toString()
|
||||
binding.contentMain.inputTeamB.setText(string.substring(0, string.length - 1))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
binding.contentMain.submit.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
|
||||
if (binding.contentMain.inputTeamA.text.isNotEmpty() && binding.contentMain.inputTeamB.text.isNotEmpty()) {
|
||||
|
||||
history.logRound(
|
||||
Round(
|
||||
binding.contentMain.inputTeamA.text.toString().toInt(),
|
||||
binding.contentMain.inputTeamB.text.toString().toInt()
|
||||
)
|
||||
)
|
||||
|
||||
updateView()
|
||||
|
||||
binding.contentMain.inputTeamA.text.clear()
|
||||
binding.contentMain.inputTeamB.text.clear()
|
||||
disableSubmitButton()
|
||||
|
||||
binding.contentMain.scrollViewHistory.fullScroll(ScrollView.FOCUS_DOWN)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
@@ -332,6 +79,257 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
}
|
||||
|
||||
private fun setListeners() {
|
||||
binding.contentMain.keyboard.inputTeamA.setOnFocusChangeListener { _, b ->
|
||||
if (b) {
|
||||
hideKeyboard()
|
||||
}
|
||||
}
|
||||
|
||||
binding.contentMain.keyboard.inputTeamB.setOnFocusChangeListener { _, b ->
|
||||
if (b) {
|
||||
hideKeyboard()
|
||||
}
|
||||
}
|
||||
|
||||
binding.contentMain.keyboard.inputTeamA.doOnTextChanged { text, _, _, _ ->
|
||||
if (binding.contentMain.keyboard.inputTeamA.isFocused) {
|
||||
if (binding.contentMain.keyboard.inputTeamA.text.isNotEmpty()) {
|
||||
if (updateOnChange) {
|
||||
currentRound = try {
|
||||
Round(text.toString().toInt(), true)
|
||||
|
||||
} catch (e: java.lang.Exception) {
|
||||
Round(1, 1)
|
||||
}
|
||||
binding.contentMain.keyboard.inputTeamB.setText(currentRound.scoreB.toString())
|
||||
} else {
|
||||
updateOnChange = true
|
||||
}
|
||||
} else {
|
||||
binding.contentMain.keyboard.inputTeamA.text.clear()
|
||||
binding.contentMain.keyboard.inputTeamB.text.clear()
|
||||
}
|
||||
}
|
||||
|
||||
if (currentRound.isValidRound() && binding.contentMain.keyboard.inputTeamA.text.isNotEmpty() && binding.contentMain.keyboard.inputTeamB.text.isNotEmpty()) {
|
||||
enableSubmitButton()
|
||||
} else {
|
||||
disableSubmitButton()
|
||||
}
|
||||
}
|
||||
|
||||
binding.contentMain.keyboard.inputTeamB.doOnTextChanged { text, _, _, _ ->
|
||||
if (binding.contentMain.keyboard.inputTeamB.isFocused) {
|
||||
if (binding.contentMain.keyboard.inputTeamB.text.isNotEmpty()) {
|
||||
if (updateOnChange) {
|
||||
currentRound = try {
|
||||
Round(text.toString().toInt(), false)
|
||||
|
||||
} catch (e: java.lang.Exception) {
|
||||
Round(1, 1)
|
||||
}
|
||||
binding.contentMain.keyboard.inputTeamA.setText(currentRound.scoreA.toString())
|
||||
|
||||
} else {
|
||||
updateOnChange = true
|
||||
}
|
||||
|
||||
} else {
|
||||
binding.contentMain.keyboard.inputTeamA.text.clear()
|
||||
binding.contentMain.keyboard.inputTeamB.text.clear()
|
||||
}
|
||||
}
|
||||
|
||||
if (currentRound.isValidRound() && binding.contentMain.keyboard.inputTeamA.text.isNotEmpty() && binding.contentMain.keyboard.inputTeamB.text.isNotEmpty()) {
|
||||
enableSubmitButton()
|
||||
} else {
|
||||
disableSubmitButton()
|
||||
}
|
||||
}
|
||||
|
||||
binding.contentMain.keyboard.buttonAdd100.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
|
||||
if (binding.contentMain.keyboard.inputTeamA.isFocused) {
|
||||
|
||||
currentRound.scoreA = try {
|
||||
binding.contentMain.keyboard.inputTeamA.text.toString().toInt() + 100
|
||||
} catch (e: Exception) {
|
||||
currentRound.scoreB = 0
|
||||
binding.contentMain.keyboard.inputTeamB.setText(currentRound.scoreB.toString())
|
||||
100
|
||||
}
|
||||
updateOnChange = false
|
||||
binding.contentMain.keyboard.inputTeamA.setText(currentRound.scoreA.toString())
|
||||
}
|
||||
|
||||
if (binding.contentMain.keyboard.inputTeamB.isFocused) {
|
||||
currentRound.scoreB = try {
|
||||
binding.contentMain.keyboard.inputTeamB.text.toString().toInt() + 100
|
||||
} catch (e: Exception) {
|
||||
currentRound.scoreA = 0
|
||||
binding.contentMain.keyboard.inputTeamA.setText(currentRound.scoreA.toString())
|
||||
100
|
||||
|
||||
}
|
||||
updateOnChange = false
|
||||
binding.contentMain.keyboard.inputTeamB.setText(currentRound.scoreB.toString())
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
binding.contentMain.keyboard.buttonSub100.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
|
||||
if (binding.contentMain.keyboard.inputTeamA.isFocused) {
|
||||
currentRound.scoreA = try {
|
||||
binding.contentMain.keyboard.inputTeamA.text.toString().toInt() - 100
|
||||
} catch (e: Exception) {
|
||||
currentRound.scoreB = 0
|
||||
binding.contentMain.keyboard.inputTeamB.setText(currentRound.scoreB.toString())
|
||||
-100
|
||||
}
|
||||
updateOnChange = false
|
||||
binding.contentMain.keyboard.inputTeamA.setText(currentRound.scoreA.toString())
|
||||
}
|
||||
|
||||
if (binding.contentMain.keyboard.inputTeamB.isFocused) {
|
||||
currentRound.scoreB = try {
|
||||
binding.contentMain.keyboard.inputTeamB.text.toString().toInt() - 100
|
||||
} catch (e: Exception) {
|
||||
currentRound.scoreA = 0
|
||||
binding.contentMain.keyboard.inputTeamA.setText(currentRound.scoreA.toString())
|
||||
-100
|
||||
}
|
||||
updateOnChange = false
|
||||
binding.contentMain.keyboard.inputTeamB.setText(currentRound.scoreB.toString())
|
||||
}
|
||||
}
|
||||
|
||||
binding.contentMain.keyboard.button0.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
appendToFocusedInput('0')
|
||||
}
|
||||
|
||||
binding.contentMain.keyboard.button1.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
appendToFocusedInput('1')
|
||||
}
|
||||
|
||||
binding.contentMain.keyboard.button2.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
appendToFocusedInput('2')
|
||||
}
|
||||
|
||||
binding.contentMain.keyboard.button3.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
appendToFocusedInput('3')
|
||||
}
|
||||
|
||||
binding.contentMain.keyboard.button4.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
appendToFocusedInput('4')
|
||||
}
|
||||
|
||||
binding.contentMain.keyboard.button5.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
appendToFocusedInput('5')
|
||||
}
|
||||
|
||||
binding.contentMain.keyboard.button6.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
appendToFocusedInput('6')
|
||||
}
|
||||
|
||||
binding.contentMain.keyboard.button7.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
appendToFocusedInput('7')
|
||||
}
|
||||
|
||||
binding.contentMain.keyboard.button8.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
appendToFocusedInput('8')
|
||||
}
|
||||
|
||||
binding.contentMain.keyboard.button9.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
appendToFocusedInput('9')
|
||||
}
|
||||
|
||||
binding.contentMain.keyboard.buttonInv.setOnClickListener {
|
||||
val tempInt: Int
|
||||
|
||||
giveFocusToAIfNone()
|
||||
|
||||
if (binding.contentMain.keyboard.inputTeamA.isFocused) {
|
||||
if (binding.contentMain.keyboard.inputTeamA.text.toString() == "-") {
|
||||
binding.contentMain.keyboard.inputTeamA.text.clear()
|
||||
} else if (binding.contentMain.keyboard.inputTeamA.text.isNotEmpty()) {
|
||||
tempInt = binding.contentMain.keyboard.inputTeamA.text.toString().toInt() * -1
|
||||
binding.contentMain.keyboard.inputTeamA.setText(tempInt.toString())
|
||||
} else {
|
||||
updateOnChange = false
|
||||
appendToFocusedInput('-')
|
||||
currentRound = Round(1, 1)
|
||||
}
|
||||
|
||||
|
||||
} else if (binding.contentMain.keyboard.inputTeamB.isFocused) {
|
||||
if (binding.contentMain.keyboard.inputTeamB.text.toString() == "-") {
|
||||
binding.contentMain.keyboard.inputTeamB.text.clear()
|
||||
} else if (binding.contentMain.keyboard.inputTeamB.text.isNotEmpty()) {
|
||||
tempInt = binding.contentMain.keyboard.inputTeamB.text.toString().toInt() * -1
|
||||
binding.contentMain.keyboard.inputTeamB.setText(tempInt.toString())
|
||||
} else {
|
||||
updateOnChange = false
|
||||
appendToFocusedInput('-')
|
||||
currentRound = Round(1, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
binding.contentMain.keyboard.buttonBack.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
|
||||
if (binding.contentMain.keyboard.inputTeamA.isFocused) {
|
||||
if (binding.contentMain.keyboard.inputTeamA.text.isNotEmpty()) {
|
||||
val string = binding.contentMain.keyboard.inputTeamA.text.toString()
|
||||
binding.contentMain.keyboard.inputTeamA.setText(string.substring(0, string.length - 1))
|
||||
}
|
||||
|
||||
} else if (binding.contentMain.keyboard.inputTeamB.isFocused) {
|
||||
if (binding.contentMain.keyboard.inputTeamB.text.isNotEmpty()) {
|
||||
val string = binding.contentMain.keyboard.inputTeamB.text.toString()
|
||||
binding.contentMain.keyboard.inputTeamB.setText(string.substring(0, string.length - 1))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
binding.contentMain.keyboard.submit.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
|
||||
if (binding.contentMain.keyboard.inputTeamA.text.isNotEmpty() && binding.contentMain.keyboard.inputTeamB.text.isNotEmpty()) {
|
||||
|
||||
history.logRound(
|
||||
Round(
|
||||
binding.contentMain.keyboard.inputTeamA.text.toString().toInt(),
|
||||
binding.contentMain.keyboard.inputTeamB.text.toString().toInt()
|
||||
)
|
||||
)
|
||||
|
||||
updateView()
|
||||
|
||||
binding.contentMain.keyboard.inputTeamA.text.clear()
|
||||
binding.contentMain.keyboard.inputTeamB.text.clear()
|
||||
disableSubmitButton()
|
||||
|
||||
binding.contentMain.scrollHistory.scrollViewHistory.fullScroll(ScrollView.FOCUS_DOWN)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
menuInflater.inflate(R.menu.menu_main, menu)
|
||||
@@ -389,8 +387,8 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
private fun giveFocusToAIfNone() {
|
||||
if (!binding.contentMain.inputTeamA.isFocused && !binding.contentMain.inputTeamB.isFocused) {
|
||||
binding.contentMain.inputTeamA.requestFocus()
|
||||
if (!binding.contentMain.keyboard.inputTeamA.isFocused && !binding.contentMain.keyboard.inputTeamB.isFocused) {
|
||||
binding.contentMain.keyboard.inputTeamA.requestFocus()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -403,15 +401,15 @@ class MainActivity : AppCompatActivity() {
|
||||
binding.contentMain.scoreA.text = history.getScoreA().toString()
|
||||
binding.contentMain.scoreB.text = history.getScoreB().toString()
|
||||
|
||||
binding.contentMain.historyA.text = history.getHistoryA()
|
||||
binding.contentMain.historyB.text = history.getHistoryB()
|
||||
binding.contentMain.scrollHistory.historyA?.text = history.getHistoryA()
|
||||
binding.contentMain.scrollHistory.historyB?.text = history.getHistoryB()
|
||||
}
|
||||
|
||||
private fun clearAll() {
|
||||
binding.contentMain.historyA.text = ""
|
||||
binding.contentMain.historyB.text = ""
|
||||
binding.contentMain.inputTeamA.text.clear()
|
||||
binding.contentMain.inputTeamB.text.clear()
|
||||
binding.contentMain.scrollHistory.historyA?.text = ""
|
||||
binding.contentMain.scrollHistory.historyB?.text = ""
|
||||
binding.contentMain.keyboard.inputTeamA.text.clear()
|
||||
binding.contentMain.keyboard.inputTeamB.text.clear()
|
||||
binding.contentMain.scoreA.text = "0"
|
||||
binding.contentMain.scoreB.text = "0"
|
||||
|
||||
@@ -419,21 +417,21 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
private fun appendToFocusedInput(toAppend: Char) {
|
||||
if (binding.contentMain.inputTeamA.isFocused) {
|
||||
binding.contentMain.inputTeamA.text.append(toAppend)
|
||||
} else if (binding.contentMain.inputTeamB.isFocused) {
|
||||
binding.contentMain.inputTeamB.text.append(toAppend)
|
||||
if (binding.contentMain.keyboard.inputTeamA.isFocused) {
|
||||
binding.contentMain.keyboard.inputTeamA.text.append(toAppend)
|
||||
} else if (binding.contentMain.keyboard.inputTeamB.isFocused) {
|
||||
binding.contentMain.keyboard.inputTeamB.text.append(toAppend)
|
||||
}
|
||||
}
|
||||
|
||||
private fun enableSubmitButton() {
|
||||
binding.contentMain.submit.imageAlpha = 255 // 0 being transparent and 255 being opaque
|
||||
binding.contentMain.submit.isEnabled = true
|
||||
binding.contentMain.keyboard.submit?.imageAlpha = 255 // 0 being transparent and 255 being opaque
|
||||
binding.contentMain.keyboard.submit?.isEnabled = true
|
||||
}
|
||||
|
||||
private fun disableSubmitButton() {
|
||||
binding.contentMain.submit.imageAlpha = 60 // 0 being transparent and 255 being opaque
|
||||
binding.contentMain.submit.isEnabled = false
|
||||
binding.contentMain.keyboard.submit?.imageAlpha = 60 // 0 being transparent and 255 being opaque
|
||||
binding.contentMain.keyboard.submit?.isEnabled = false
|
||||
}
|
||||
|
||||
private fun chooseThemeDialog() {
|
||||
@@ -0,0 +1,32 @@
|
||||
package me.zobrist.tichucounter.fragments
|
||||
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.Fragment
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import me.zobrist.tichucounter.R
|
||||
|
||||
class HistoryList : Fragment() {
|
||||
|
||||
companion object {
|
||||
fun newInstance() = HistoryList()
|
||||
}
|
||||
|
||||
private lateinit var viewModel: HistoryListViewModel
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
return inflater.inflate(R.layout.fragment_history_list, container, false)
|
||||
}
|
||||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
viewModel = ViewModelProvider(this).get(HistoryListViewModel::class.java)
|
||||
// TODO: Use the ViewModel
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package me.zobrist.tichucounter.fragments
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
|
||||
class HistoryListViewModel : ViewModel() {
|
||||
// TODO: Implement the ViewModel
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package me.zobrist.tichucounter.fragments
|
||||
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.Fragment
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ScrollView
|
||||
import androidx.core.widget.doOnTextChanged
|
||||
import me.zobrist.tichucounter.R
|
||||
import me.zobrist.tichucounter.domain.Round
|
||||
|
||||
class Keyboard : Fragment() {
|
||||
|
||||
companion object {
|
||||
fun newInstance() = Keyboard()
|
||||
}
|
||||
|
||||
private lateinit var viewModel: KeyboardViewModel
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
return inflater.inflate(R.layout.fragment_keyboard, container, false)
|
||||
}
|
||||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
viewModel = ViewModelProvider(this).get(KeyboardViewModel::class.java)
|
||||
// TODO: Use the ViewModel
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package me.zobrist.tichucounter.fragments
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
|
||||
class KeyboardViewModel : ViewModel() {
|
||||
// TODO: Implement the ViewModel
|
||||
}
|
||||
Reference in New Issue
Block a user