Update deprecated extensions.
This commit is contained in:
@@ -1,14 +1,13 @@
|
|||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
apply plugin: 'kotlin-android'
|
apply plugin: 'kotlin-android'
|
||||||
apply plugin: 'kotlin-android-extensions'
|
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 30
|
compileSdkVersion 32
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "me.zobrist.tichucounter"
|
applicationId "me.zobrist.tichucounter"
|
||||||
minSdkVersion 16
|
minSdkVersion 16
|
||||||
targetSdkVersion 30
|
targetSdkVersion 32
|
||||||
versionCode 7
|
versionCode 7
|
||||||
versionName "1.0.0"
|
versionName "1.0.0"
|
||||||
|
|
||||||
@@ -22,6 +21,11 @@ android {
|
|||||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buildFeatures {
|
||||||
|
viewBinding = true
|
||||||
|
}
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
@@ -34,17 +38,17 @@ android {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||||
implementation 'androidx.core:core-ktx:1.3.1'
|
implementation 'androidx.core:core-ktx:1.8.0'
|
||||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
implementation 'androidx.appcompat:appcompat:1.4.2'
|
||||||
implementation 'com.google.android.material:material:1.2.0'
|
implementation 'com.google.android.material:material:1.6.1'
|
||||||
implementation 'com.google.android.play:core:1.8.0'
|
|
||||||
implementation 'com.google.android.play:core-ktx:1.8.1'
|
implementation 'com.google.android.play:core-ktx:1.8.1'
|
||||||
implementation 'com.google.code.gson:gson:2.8.5'
|
implementation 'com.google.android.play:core-ktx:1.8.1'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
|
implementation 'com.google.code.gson:gson:2.8.9'
|
||||||
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.0'
|
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||||
implementation 'androidx.navigation:navigation-ui-ktx:2.3.0'
|
implementation 'androidx.navigation:navigation-fragment-ktx:2.4.2'
|
||||||
|
implementation 'androidx.navigation:navigation-ui-ktx:2.4.2'
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.12'
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -15,7 +15,7 @@ import androidx.appcompat.app.AppCompatActivity
|
|||||||
import androidx.appcompat.app.AppCompatDelegate
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
import androidx.core.widget.doOnTextChanged
|
import androidx.core.widget.doOnTextChanged
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import kotlinx.android.synthetic.main.content_main.*
|
import me.zobrist.tichucounter.databinding.ContentMainBinding
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class MainActivity : AppCompatActivity() {
|
class MainActivity : AppCompatActivity() {
|
||||||
@@ -26,21 +26,31 @@ class MainActivity : AppCompatActivity() {
|
|||||||
private var currentRound = Round()
|
private var currentRound = Round()
|
||||||
private var systemLocale = Locale.getDefault()
|
private var systemLocale = Locale.getDefault()
|
||||||
|
|
||||||
|
private lateinit var binding: ContentMainBinding
|
||||||
|
|
||||||
|
|
||||||
override fun attachBaseContext(newBase: Context) {
|
override fun attachBaseContext(newBase: Context) {
|
||||||
// get chosen language from shread preference
|
// get chosen language from shread preference
|
||||||
val localeString = newBase.getSharedPreferences("Settings", Context.MODE_PRIVATE).getString("Language", systemLocale.toString())
|
val localeString = newBase.getSharedPreferences("Settings", Context.MODE_PRIVATE).getString("Language", systemLocale.toString())
|
||||||
val localeToSwitchTo = Locale(localeString)
|
|
||||||
val localeUpdatedContext: ContextWrapper = ContextUtils.updateLocale(newBase, localeToSwitchTo)
|
if(localeString != null)
|
||||||
super.attachBaseContext(localeUpdatedContext)
|
{
|
||||||
|
val localeToSwitchTo = Locale(localeString)
|
||||||
|
val localeUpdatedContext: ContextWrapper = ContextUtils.updateLocale(newBase, localeToSwitchTo)
|
||||||
|
super.attachBaseContext(localeUpdatedContext)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
binding = ContentMainBinding.inflate(layoutInflater)
|
||||||
|
|
||||||
setContentView(R.layout.activity_main)
|
setContentView(R.layout.activity_main)
|
||||||
setSupportActionBar(findViewById(R.id.toolbar))
|
setSupportActionBar(findViewById(R.id.toolbar))
|
||||||
inputTeamA.setRawInputType(InputType.TYPE_NULL)
|
|
||||||
inputTeamB.setRawInputType(InputType.TYPE_NULL)
|
binding.inputTeamA.setRawInputType(InputType.TYPE_NULL)
|
||||||
inputTeamA.requestFocus()
|
binding.inputTeamB.setRawInputType(InputType.TYPE_NULL)
|
||||||
|
binding.inputTeamA.requestFocus()
|
||||||
disableSubmitButton()
|
disableSubmitButton()
|
||||||
updateTheme(this.getSharedPreferences("Settings", Context.MODE_PRIVATE).getInt("Theme", 2))
|
updateTheme(this.getSharedPreferences("Settings", Context.MODE_PRIVATE).getInt("Theme", 2))
|
||||||
keepScreenOn(
|
keepScreenOn(
|
||||||
@@ -51,31 +61,32 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
val json = this.getSharedPreferences("Settings", Context.MODE_PRIVATE).getString("history", "{\"scores\":[]}")
|
val json = this.getSharedPreferences("Settings", Context.MODE_PRIVATE).getString("history", "{\"scores\":[]}")
|
||||||
history = Gson().fromJson(json, History::class.java)
|
history = Gson().fromJson(json, History::class.java)
|
||||||
nameTeamA.setText(this.getSharedPreferences("Settings", Context.MODE_PRIVATE).getString("nameTeamA", "TeamA"))
|
binding.nameTeamA.setText(this.getSharedPreferences("Settings", Context.MODE_PRIVATE).getString("nameTeamA", "TeamA"))
|
||||||
nameTeamB.setText(this.getSharedPreferences("Settings", Context.MODE_PRIVATE).getString("nameTeamB", "TeamB"))
|
binding.nameTeamB.setText(this.getSharedPreferences("Settings", Context.MODE_PRIVATE).getString("nameTeamB", "TeamB"))
|
||||||
updateView()
|
updateView()
|
||||||
|
|
||||||
this.setListenes()
|
this.setListenes()
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setListenes()
|
private fun setListenes()
|
||||||
{
|
{
|
||||||
inputTeamA.setOnFocusChangeListener { _, b ->
|
binding.inputTeamA.setOnFocusChangeListener { _, b ->
|
||||||
if (b) {
|
if (b) {
|
||||||
hideKeyboard()
|
hideKeyboard()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inputTeamB.setOnFocusChangeListener { _, b ->
|
binding.inputTeamB.setOnFocusChangeListener { _, b ->
|
||||||
if (b) {
|
if (b) {
|
||||||
hideKeyboard()
|
hideKeyboard()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inputTeamA.doOnTextChanged { text, _, _, _ ->
|
binding.inputTeamA.doOnTextChanged { text, _, _, _ ->
|
||||||
if (inputTeamA.isFocused) {
|
if (binding.inputTeamA.isFocused) {
|
||||||
if (inputTeamA.text.isNotEmpty()) {
|
if (binding.inputTeamA.text.isNotEmpty()) {
|
||||||
if (updateOnChange) {
|
if (updateOnChange) {
|
||||||
currentRound = try {
|
currentRound = try {
|
||||||
Round(text.toString().toInt(), true)
|
Round(text.toString().toInt(), true)
|
||||||
@@ -83,26 +94,26 @@ class MainActivity : AppCompatActivity() {
|
|||||||
} catch (e: java.lang.Exception) {
|
} catch (e: java.lang.Exception) {
|
||||||
Round(1, 1)
|
Round(1, 1)
|
||||||
}
|
}
|
||||||
inputTeamB.setText(currentRound.scoreB.toString())
|
binding.inputTeamB.setText(currentRound.scoreB.toString())
|
||||||
} else {
|
} else {
|
||||||
updateOnChange = true
|
updateOnChange = true
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
inputTeamA.text.clear()
|
binding.inputTeamA.text.clear()
|
||||||
inputTeamB.text.clear()
|
binding.inputTeamB.text.clear()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentRound.isValidRound() && inputTeamA.text.isNotEmpty() && inputTeamB.text.isNotEmpty()) {
|
if (currentRound.isValidRound() && binding.inputTeamA.text.isNotEmpty() && binding.inputTeamB.text.isNotEmpty()) {
|
||||||
enableSubmitButton()
|
enableSubmitButton()
|
||||||
} else {
|
} else {
|
||||||
disableSubmitButton()
|
disableSubmitButton()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inputTeamB.doOnTextChanged { text, _, _, _ ->
|
binding.inputTeamB.doOnTextChanged { text, _, _, _ ->
|
||||||
if (inputTeamB.isFocused) {
|
if (binding.inputTeamB.isFocused) {
|
||||||
if (inputTeamB.text.isNotEmpty()) {
|
if (binding.inputTeamB.text.isNotEmpty()) {
|
||||||
if (updateOnChange) {
|
if (updateOnChange) {
|
||||||
currentRound = try {
|
currentRound = try {
|
||||||
Round(text.toString().toInt(), false)
|
Round(text.toString().toInt(), false)
|
||||||
@@ -110,145 +121,145 @@ class MainActivity : AppCompatActivity() {
|
|||||||
} catch (e: java.lang.Exception) {
|
} catch (e: java.lang.Exception) {
|
||||||
Round(1, 1)
|
Round(1, 1)
|
||||||
}
|
}
|
||||||
inputTeamA.setText(currentRound.scoreA.toString())
|
binding.inputTeamA.setText(currentRound.scoreA.toString())
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
updateOnChange = true
|
updateOnChange = true
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
inputTeamA.text.clear()
|
binding.inputTeamA.text.clear()
|
||||||
inputTeamB.text.clear()
|
binding.inputTeamB.text.clear()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentRound.isValidRound() && inputTeamA.text.isNotEmpty() && inputTeamB.text.isNotEmpty()) {
|
if (currentRound.isValidRound() && binding.inputTeamA.text.isNotEmpty() && binding.inputTeamB.text.isNotEmpty()) {
|
||||||
enableSubmitButton()
|
enableSubmitButton()
|
||||||
} else {
|
} else {
|
||||||
disableSubmitButton()
|
disableSubmitButton()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buttonAdd100.setOnClickListener {
|
binding.buttonAdd100.setOnClickListener {
|
||||||
giveFocusToAIfNone()
|
giveFocusToAIfNone()
|
||||||
|
|
||||||
if (inputTeamA.isFocused) {
|
if (binding.inputTeamA.isFocused) {
|
||||||
|
|
||||||
currentRound.scoreA = try {
|
currentRound.scoreA = try {
|
||||||
inputTeamA.text.toString().toInt() + 100
|
binding.inputTeamA.text.toString().toInt() + 100
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
currentRound.scoreB = 0
|
currentRound.scoreB = 0
|
||||||
inputTeamB.setText(currentRound.scoreB.toString())
|
binding.inputTeamB.setText(currentRound.scoreB.toString())
|
||||||
100
|
100
|
||||||
}
|
}
|
||||||
updateOnChange = false
|
updateOnChange = false
|
||||||
inputTeamA.setText(currentRound.scoreA.toString())
|
binding.inputTeamA.setText(currentRound.scoreA.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inputTeamB.isFocused) {
|
if (binding.inputTeamB.isFocused) {
|
||||||
currentRound.scoreB = try {
|
currentRound.scoreB = try {
|
||||||
inputTeamB.text.toString().toInt() + 100
|
binding.inputTeamB.text.toString().toInt() + 100
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
currentRound.scoreA = 0
|
currentRound.scoreA = 0
|
||||||
inputTeamA.setText(currentRound.scoreA.toString())
|
binding.inputTeamA.setText(currentRound.scoreA.toString())
|
||||||
100
|
100
|
||||||
|
|
||||||
}
|
}
|
||||||
updateOnChange = false
|
updateOnChange = false
|
||||||
inputTeamB.setText(currentRound.scoreB.toString())
|
binding.inputTeamB.setText(currentRound.scoreB.toString())
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buttonSub100.setOnClickListener {
|
binding.buttonSub100.setOnClickListener {
|
||||||
giveFocusToAIfNone()
|
giveFocusToAIfNone()
|
||||||
|
|
||||||
if (inputTeamA.isFocused) {
|
if (binding.inputTeamA.isFocused) {
|
||||||
currentRound.scoreA = try {
|
currentRound.scoreA = try {
|
||||||
inputTeamA.text.toString().toInt() - 100
|
binding.inputTeamA.text.toString().toInt() - 100
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
currentRound.scoreB = 0
|
currentRound.scoreB = 0
|
||||||
inputTeamB.setText(currentRound.scoreB.toString())
|
binding.inputTeamB.setText(currentRound.scoreB.toString())
|
||||||
-100
|
-100
|
||||||
}
|
}
|
||||||
updateOnChange = false
|
updateOnChange = false
|
||||||
inputTeamA.setText(currentRound.scoreA.toString())
|
binding.inputTeamA.setText(currentRound.scoreA.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inputTeamB.isFocused) {
|
if (binding.inputTeamB.isFocused) {
|
||||||
currentRound.scoreB = try {
|
currentRound.scoreB = try {
|
||||||
inputTeamB.text.toString().toInt() - 100
|
binding.inputTeamB.text.toString().toInt() - 100
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
currentRound.scoreA = 0
|
currentRound.scoreA = 0
|
||||||
inputTeamA.setText(currentRound.scoreA.toString())
|
binding.inputTeamA.setText(currentRound.scoreA.toString())
|
||||||
-100
|
-100
|
||||||
}
|
}
|
||||||
updateOnChange = false
|
updateOnChange = false
|
||||||
inputTeamB.setText(currentRound.scoreB.toString())
|
binding.inputTeamB.setText(currentRound.scoreB.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
button0.setOnClickListener {
|
binding.button0.setOnClickListener {
|
||||||
giveFocusToAIfNone()
|
giveFocusToAIfNone()
|
||||||
appendToFocusedInput('0')
|
appendToFocusedInput('0')
|
||||||
}
|
}
|
||||||
|
|
||||||
button1.setOnClickListener {
|
binding.button1.setOnClickListener {
|
||||||
giveFocusToAIfNone()
|
giveFocusToAIfNone()
|
||||||
appendToFocusedInput('1')
|
appendToFocusedInput('1')
|
||||||
}
|
}
|
||||||
|
|
||||||
button2.setOnClickListener {
|
binding.button2.setOnClickListener {
|
||||||
giveFocusToAIfNone()
|
giveFocusToAIfNone()
|
||||||
appendToFocusedInput('2')
|
appendToFocusedInput('2')
|
||||||
}
|
}
|
||||||
|
|
||||||
button3.setOnClickListener {
|
binding.button3.setOnClickListener {
|
||||||
giveFocusToAIfNone()
|
giveFocusToAIfNone()
|
||||||
appendToFocusedInput('3')
|
appendToFocusedInput('3')
|
||||||
}
|
}
|
||||||
|
|
||||||
button4.setOnClickListener {
|
binding.button4.setOnClickListener {
|
||||||
giveFocusToAIfNone()
|
giveFocusToAIfNone()
|
||||||
appendToFocusedInput('4')
|
appendToFocusedInput('4')
|
||||||
}
|
}
|
||||||
|
|
||||||
button5.setOnClickListener {
|
binding.button5.setOnClickListener {
|
||||||
giveFocusToAIfNone()
|
giveFocusToAIfNone()
|
||||||
appendToFocusedInput('5')
|
appendToFocusedInput('5')
|
||||||
}
|
}
|
||||||
|
|
||||||
button6.setOnClickListener {
|
binding.button6.setOnClickListener {
|
||||||
giveFocusToAIfNone()
|
giveFocusToAIfNone()
|
||||||
appendToFocusedInput('6')
|
appendToFocusedInput('6')
|
||||||
}
|
}
|
||||||
|
|
||||||
button7.setOnClickListener {
|
binding.button7.setOnClickListener {
|
||||||
giveFocusToAIfNone()
|
giveFocusToAIfNone()
|
||||||
appendToFocusedInput('7')
|
appendToFocusedInput('7')
|
||||||
}
|
}
|
||||||
|
|
||||||
button8.setOnClickListener {
|
binding.button8.setOnClickListener {
|
||||||
giveFocusToAIfNone()
|
giveFocusToAIfNone()
|
||||||
appendToFocusedInput('8')
|
appendToFocusedInput('8')
|
||||||
}
|
}
|
||||||
|
|
||||||
button9.setOnClickListener {
|
binding.button9.setOnClickListener {
|
||||||
giveFocusToAIfNone()
|
giveFocusToAIfNone()
|
||||||
appendToFocusedInput('9')
|
appendToFocusedInput('9')
|
||||||
}
|
}
|
||||||
|
|
||||||
buttonInv.setOnClickListener {
|
binding.buttonInv.setOnClickListener {
|
||||||
val tempInt: Int
|
val tempInt: Int
|
||||||
|
|
||||||
giveFocusToAIfNone()
|
giveFocusToAIfNone()
|
||||||
|
|
||||||
if (inputTeamA.isFocused) {
|
if (binding.inputTeamA.isFocused) {
|
||||||
if (inputTeamA.text.toString().equals("-")) {
|
if (binding.inputTeamA.text.toString().equals("-")) {
|
||||||
inputTeamA.text.clear()
|
binding.inputTeamA.text.clear()
|
||||||
} else if (inputTeamA.text.isNotEmpty()) {
|
} else if (binding.inputTeamA.text.isNotEmpty()) {
|
||||||
tempInt = inputTeamA.text.toString().toInt() * -1
|
tempInt = binding.inputTeamA.text.toString().toInt() * -1
|
||||||
inputTeamA.setText(tempInt.toString())
|
binding.inputTeamA.setText(tempInt.toString())
|
||||||
} else {
|
} else {
|
||||||
updateOnChange = false
|
updateOnChange = false
|
||||||
appendToFocusedInput('-')
|
appendToFocusedInput('-')
|
||||||
@@ -256,12 +267,12 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else if (inputTeamB.isFocused) {
|
} else if (binding.inputTeamB.isFocused) {
|
||||||
if (inputTeamB.text.toString().equals("-")) {
|
if (binding.inputTeamB.text.toString().equals("-")) {
|
||||||
inputTeamB.text.clear()
|
binding.inputTeamB.text.clear()
|
||||||
} else if (inputTeamB.text.isNotEmpty()) {
|
} else if (binding.inputTeamB.text.isNotEmpty()) {
|
||||||
tempInt = inputTeamB.text.toString().toInt() * -1
|
tempInt = binding.inputTeamB.text.toString().toInt() * -1
|
||||||
inputTeamB.setText(tempInt.toString())
|
binding.inputTeamB.setText(tempInt.toString())
|
||||||
} else {
|
} else {
|
||||||
updateOnChange = false
|
updateOnChange = false
|
||||||
appendToFocusedInput('-')
|
appendToFocusedInput('-')
|
||||||
@@ -270,42 +281,42 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buttonBack.setOnClickListener {
|
binding.buttonBack.setOnClickListener {
|
||||||
giveFocusToAIfNone()
|
giveFocusToAIfNone()
|
||||||
|
|
||||||
if (inputTeamA.isFocused) {
|
if (binding.inputTeamA.isFocused) {
|
||||||
if (inputTeamA.text.isNotEmpty()) {
|
if (binding.inputTeamA.text.isNotEmpty()) {
|
||||||
val string = inputTeamA.text.toString()
|
val string = binding.inputTeamA.text.toString()
|
||||||
inputTeamA.setText(string.substring(0, string.length - 1))
|
binding.inputTeamA.setText(string.substring(0, string.length - 1))
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (inputTeamB.isFocused) {
|
} else if (binding.inputTeamB.isFocused) {
|
||||||
if (inputTeamB.text.isNotEmpty()) {
|
if (binding.inputTeamB.text.isNotEmpty()) {
|
||||||
val string = inputTeamB.text.toString()
|
val string = binding.inputTeamB.text.toString()
|
||||||
inputTeamB.setText(string.substring(0, string.length - 1))
|
binding.inputTeamB.setText(string.substring(0, string.length - 1))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
submit.setOnClickListener {
|
binding.submit.setOnClickListener {
|
||||||
giveFocusToAIfNone()
|
giveFocusToAIfNone()
|
||||||
|
|
||||||
if (inputTeamA.text.isNotEmpty() && inputTeamB.text.isNotEmpty()) {
|
if (binding.inputTeamA.text.isNotEmpty() && binding.inputTeamB.text.isNotEmpty()) {
|
||||||
|
|
||||||
history.logRound(
|
history.logRound(
|
||||||
Round(
|
Round(
|
||||||
inputTeamA.text.toString().toInt(),
|
binding.inputTeamA.text.toString().toInt(),
|
||||||
inputTeamB.text.toString().toInt()
|
binding.inputTeamB.text.toString().toInt()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
updateView()
|
updateView()
|
||||||
|
|
||||||
inputTeamA.text.clear()
|
binding.inputTeamA.text.clear()
|
||||||
inputTeamB.text.clear()
|
binding.inputTeamB.text.clear()
|
||||||
disableSubmitButton()
|
disableSubmitButton()
|
||||||
|
|
||||||
scrollViewHistory.fullScroll(ScrollView.FOCUS_DOWN)
|
binding.scrollViewHistory.fullScroll(ScrollView.FOCUS_DOWN)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -315,8 +326,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
val prefs = this.getSharedPreferences("Settings", Context.MODE_PRIVATE).edit()
|
val prefs = this.getSharedPreferences("Settings", Context.MODE_PRIVATE).edit()
|
||||||
prefs.putString("history", Gson().toJson(history))
|
prefs.putString("history", Gson().toJson(history))
|
||||||
prefs.putString("nameTeamA", nameTeamA.text.toString())
|
prefs.putString("nameTeamA", binding.nameTeamA.text.toString())
|
||||||
prefs.putString("nameTeamB", nameTeamB.text.toString())
|
prefs.putString("nameTeamB", binding.nameTeamB.text.toString())
|
||||||
prefs.apply()
|
prefs.apply()
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -378,8 +389,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun giveFocusToAIfNone() {
|
private fun giveFocusToAIfNone() {
|
||||||
if (!inputTeamA.isFocused && !inputTeamB.isFocused) {
|
if (!binding.inputTeamA.isFocused && !binding.inputTeamB.isFocused) {
|
||||||
inputTeamA.requestFocus()
|
binding.inputTeamA.requestFocus()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -389,40 +400,40 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updateView() {
|
private fun updateView() {
|
||||||
scoreA.text = history.getScoreA().toString()
|
binding.scoreA.text = history.getScoreA().toString()
|
||||||
scoreB.text = history.getScoreB().toString()
|
binding.scoreB.text = history.getScoreB().toString()
|
||||||
|
|
||||||
historyA.text = history.getHistoryA()
|
binding.historyA.text = history.getHistoryA()
|
||||||
historyB.text = history.getHistoryB()
|
binding.historyB.text = history.getHistoryB()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun clearAll() {
|
private fun clearAll() {
|
||||||
historyA.text = ""
|
binding.historyA.text = ""
|
||||||
historyB.text = ""
|
binding.historyB.text = ""
|
||||||
inputTeamA.text.clear()
|
binding.inputTeamA.text.clear()
|
||||||
inputTeamB.text.clear()
|
binding.inputTeamB.text.clear()
|
||||||
scoreA.text = "0"
|
binding.scoreA.text = "0"
|
||||||
scoreB.text = "0"
|
binding.scoreB.text = "0"
|
||||||
|
|
||||||
history.clearAll()
|
history.clearAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun appendToFocusedInput(toAppend: Char) {
|
private fun appendToFocusedInput(toAppend: Char) {
|
||||||
if (inputTeamA.isFocused) {
|
if (binding.inputTeamA.isFocused) {
|
||||||
inputTeamA.text.append(toAppend)
|
binding.inputTeamA.text.append(toAppend)
|
||||||
} else if (inputTeamB.isFocused) {
|
} else if (binding.inputTeamB.isFocused) {
|
||||||
inputTeamB.text.append(toAppend)
|
binding.inputTeamB.text.append(toAppend)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun enableSubmitButton() {
|
private fun enableSubmitButton() {
|
||||||
submit.imageAlpha = 255 // 0 being transparent and 255 being opaque
|
binding.submit.imageAlpha = 255 // 0 being transparent and 255 being opaque
|
||||||
submit.isEnabled = true
|
binding.submit.isEnabled = true
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun disableSubmitButton() {
|
private fun disableSubmitButton() {
|
||||||
submit.imageAlpha = 60 // 0 being transparent and 255 being opaque
|
binding.submit.imageAlpha = 60 // 0 being transparent and 255 being opaque
|
||||||
submit.isEnabled = false
|
binding.submit.isEnabled = false
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun chooseThemeDialog() {
|
private fun chooseThemeDialog() {
|
||||||
|
|||||||
Reference in New Issue
Block a user